From 026e8d23a5539a107357a008a08eb8c2174bfe1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E9=92=8A?= Date: Fri, 8 Aug 2025 11:25:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4thinkPHP?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .htaccess | 0 addons/.htaccess | 1 + application/.htaccess | 1 + extend/.htaccess | 1 + nginx.htaccess | 6 + public/.htaccess | 0 public/nginx.htaccess | 6 + thinkphp/.gitignore | 5 + thinkphp/.htaccess | 1 + thinkphp/.travis.yml | 47 + thinkphp/CONTRIBUTING.md | 119 + thinkphp/LICENSE.txt | 32 + thinkphp/README.md | 69 + thinkphp/base.php | 65 + thinkphp/codecov.yml | 12 + thinkphp/composer.json | 35 + thinkphp/console.php | 20 + thinkphp/convention.php | 298 + thinkphp/helper.php | 589 ++ thinkphp/lang/zh-cn.php | 136 + thinkphp/library/think/App.php | 677 ++ thinkphp/library/think/Build.php | 235 + thinkphp/library/think/Cache.php | 247 + thinkphp/library/think/Collection.php | 474 + thinkphp/library/think/Config.php | 214 + thinkphp/library/think/Console.php | 863 ++ thinkphp/library/think/Controller.php | 229 + thinkphp/library/think/Cookie.php | 280 + thinkphp/library/think/Db.php | 180 + thinkphp/library/think/Debug.php | 252 + thinkphp/library/think/Env.php | 39 + thinkphp/library/think/Error.php | 136 + thinkphp/library/think/Exception.php | 55 + thinkphp/library/think/File.php | 478 + thinkphp/library/think/Hook.php | 148 + thinkphp/library/think/Lang.php | 271 + thinkphp/library/think/Loader.php | 677 ++ thinkphp/library/think/Log.php | 237 + thinkphp/library/think/Model.php | 2363 +++++ thinkphp/library/think/Paginator.php | 416 + thinkphp/library/think/Process.php | 1205 +++ thinkphp/library/think/Request.php | 1690 ++++ thinkphp/library/think/Response.php | 332 + thinkphp/library/think/Route.php | 1645 ++++ thinkphp/library/think/Session.php | 366 + thinkphp/library/think/Template.php | 1139 +++ thinkphp/library/think/Url.php | 333 + thinkphp/library/think/Validate.php | 1393 +++ thinkphp/library/think/View.php | 239 + thinkphp/library/think/cache/Driver.php | 231 + thinkphp/library/think/cache/driver/File.php | 268 + thinkphp/library/think/cache/driver/Lite.php | 187 + .../library/think/cache/driver/Memcache.php | 177 + .../library/think/cache/driver/Memcached.php | 187 + thinkphp/library/think/cache/driver/Redis.php | 188 + .../library/think/cache/driver/Sqlite.php | 199 + .../library/think/cache/driver/Wincache.php | 152 + .../library/think/cache/driver/Xcache.php | 155 + thinkphp/library/think/config/driver/Ini.php | 24 + thinkphp/library/think/config/driver/Json.php | 24 + thinkphp/library/think/config/driver/Xml.php | 31 + thinkphp/library/think/console/Command.php | 470 + thinkphp/library/think/console/Input.php | 464 + thinkphp/library/think/console/LICENSE | 19 + thinkphp/library/think/console/Output.php | 222 + thinkphp/library/think/console/bin/README.md | 1 + .../library/think/console/bin/hiddeninput.exe | Bin 0 -> 9216 bytes .../library/think/console/command/Build.php | 56 + .../library/think/console/command/Clear.php | 63 + .../library/think/console/command/Help.php | 69 + .../library/think/console/command/Lists.php | 74 + .../library/think/console/command/Make.php | 110 + .../think/console/command/make/Controller.php | 50 + .../think/console/command/make/Model.php | 36 + .../command/make/stubs/controller.plain.stub | 10 + .../command/make/stubs/controller.stub | 85 + .../console/command/make/stubs/model.stub | 10 + .../console/command/optimize/Autoload.php | 294 + .../think/console/command/optimize/Config.php | 93 + .../think/console/command/optimize/Route.php | 75 + .../think/console/command/optimize/Schema.php | 118 + .../library/think/console/input/Argument.php | 115 + .../think/console/input/Definition.php | 375 + .../library/think/console/input/Option.php | 190 + thinkphp/library/think/console/output/Ask.php | 340 + .../think/console/output/Descriptor.php | 319 + .../think/console/output/Formatter.php | 198 + .../library/think/console/output/Question.php | 211 + .../console/output/descriptor/Console.php | 149 + .../think/console/output/driver/Buffer.php | 52 + .../think/console/output/driver/Console.php | 373 + .../think/console/output/driver/Nothing.php | 33 + .../think/console/output/formatter/Stack.php | 116 + .../think/console/output/formatter/Style.php | 189 + .../think/console/output/question/Choice.php | 163 + .../console/output/question/Confirmation.php | 57 + thinkphp/library/think/controller/Rest.php | 99 + thinkphp/library/think/controller/Yar.php | 51 + thinkphp/library/think/db/Builder.php | 905 ++ thinkphp/library/think/db/Connection.php | 1059 +++ thinkphp/library/think/db/Expression.php | 48 + thinkphp/library/think/db/Query.php | 3046 +++++++ thinkphp/library/think/db/builder/Mysql.php | 137 + thinkphp/library/think/db/builder/Pgsql.php | 89 + thinkphp/library/think/db/builder/Sqlite.php | 82 + thinkphp/library/think/db/builder/Sqlsrv.php | 137 + thinkphp/library/think/db/connector/Mysql.php | 126 + thinkphp/library/think/db/connector/Pgsql.php | 103 + .../library/think/db/connector/Sqlite.php | 104 + .../library/think/db/connector/Sqlsrv.php | 125 + thinkphp/library/think/db/connector/pgsql.sql | 117 + .../think/db/exception/BindParamException.php | 35 + .../db/exception/DataNotFoundException.php | 43 + .../db/exception/ModelNotFoundException.php | 43 + thinkphp/library/think/debug/Console.php | 160 + thinkphp/library/think/debug/Html.php | 111 + .../exception/ClassNotFoundException.php | 32 + .../library/think/exception/DbException.php | 43 + .../think/exception/ErrorException.php | 57 + thinkphp/library/think/exception/Handle.php | 282 + .../library/think/exception/HttpException.php | 36 + .../think/exception/HttpResponseException.php | 33 + .../library/think/exception/PDOException.php | 39 + .../exception/RouteNotFoundException.php | 22 + .../exception/TemplateNotFoundException.php | 33 + .../think/exception/ThrowableError.php | 47 + .../think/exception/ValidateException.php | 33 + thinkphp/library/think/log/driver/File.php | 272 + thinkphp/library/think/log/driver/Socket.php | 250 + thinkphp/library/think/log/driver/Test.php | 30 + thinkphp/library/think/model/Collection.php | 79 + thinkphp/library/think/model/Merge.php | 322 + thinkphp/library/think/model/Pivot.php | 42 + thinkphp/library/think/model/Relation.php | 155 + .../think/model/relation/BelongsTo.php | 243 + .../think/model/relation/BelongsToMany.php | 644 ++ .../library/think/model/relation/HasMany.php | 318 + .../think/model/relation/HasManyThrough.php | 157 + .../library/think/model/relation/HasOne.php | 215 + .../think/model/relation/MorphMany.php | 314 + .../library/think/model/relation/MorphOne.php | 263 + .../library/think/model/relation/MorphTo.php | 299 + .../library/think/model/relation/OneToOne.php | 337 + .../think/paginator/driver/Bootstrap.php | 205 + thinkphp/library/think/process/Builder.php | 233 + thinkphp/library/think/process/Utils.php | 75 + .../think/process/exception/Failed.php | 42 + .../think/process/exception/Timeout.php | 61 + .../library/think/process/pipes/Pipes.php | 93 + thinkphp/library/think/process/pipes/Unix.php | 196 + .../library/think/process/pipes/Windows.php | 228 + thinkphp/library/think/response/Json.php | 51 + thinkphp/library/think/response/Jsonp.php | 58 + thinkphp/library/think/response/Redirect.php | 105 + thinkphp/library/think/response/View.php | 89 + thinkphp/library/think/response/Xml.php | 102 + .../library/think/session/driver/Memcache.php | 118 + .../think/session/driver/Memcached.php | 126 + .../library/think/session/driver/Redis.php | 134 + thinkphp/library/think/template/TagLib.php | 334 + .../library/think/template/driver/File.php | 74 + thinkphp/library/think/template/taglib/Cx.php | 673 ++ thinkphp/library/think/view/driver/Php.php | 160 + thinkphp/library/think/view/driver/Think.php | 167 + thinkphp/library/traits/controller/Jump.php | 167 + thinkphp/library/traits/model/SoftDelete.php | 200 + thinkphp/library/traits/think/Instance.php | 54 + thinkphp/logo.png | Bin 0 -> 6995 bytes thinkphp/phpunit.xml | 35 + thinkphp/start.php | 19 + thinkphp/tests/.gitignore | 4 + thinkphp/tests/README.md | 132 + thinkphp/tests/application/config.php | 33 + thinkphp/tests/application/database.php | 44 + .../application/index/controller/Index.php | 10 + thinkphp/tests/application/route.php | 22 + thinkphp/tests/application/views/display.html | 1 + .../tests/application/views/display.phtml | 1 + thinkphp/tests/application/views/extend.html | 2 + thinkphp/tests/application/views/extend2.html | 17 + thinkphp/tests/application/views/include.html | 2 + .../tests/application/views/include2.html | 1 + thinkphp/tests/application/views/layout.html | 2 + thinkphp/tests/application/views/layout2.html | 2 + thinkphp/tests/conf/memcached.ini | 1 + thinkphp/tests/conf/redis.ini | 1 + thinkphp/tests/conf/timezone.ini | 1 + thinkphp/tests/mock.php | 20 + thinkphp/tests/script/install.sh | 13 + thinkphp/tests/thinkphp/baseTest.php | 39 + .../tests/thinkphp/library/think/appTest.php | 90 + .../thinkphp/library/think/behavior/One.php | 15 + .../thinkphp/library/think/behavior/Three.php | 9 + .../thinkphp/library/think/behavior/Two.php | 9 + .../thinkphp/library/think/buildTest.php | 73 + .../think/cache/driver/cacheTestCase.php | 207 + .../library/think/cache/driver/fileTest.php | 46 + .../library/think/cache/driver/liteTest.php | 69 + .../think/cache/driver/memcacheTest.php | 49 + .../think/cache/driver/memcachedTest.php | 72 + .../library/think/cache/driver/redisTest.php | 66 + .../thinkphp/library/think/cacheTest.php | 315 + .../library/think/config/ConfigInitTrait.php | 52 + .../think/config/driver/fixtures/config.ini | 1 + .../think/config/driver/fixtures/config.json | 1 + .../think/config/driver/fixtures/config.xml | 6 + .../library/think/config/driver/iniTest.php | 36 + .../library/think/config/driver/jsonTest.php | 36 + .../library/think/config/driver/xmlTest.php | 36 + .../thinkphp/library/think/configTest.php | 149 + .../library/think/controller/.gitignore | 2 + .../thinkphp/library/think/controllerTest.php | 194 + .../thinkphp/library/think/cookieTest.php | 150 + .../library/think/db/driver/.gitignore | 2 + .../tests/thinkphp/library/think/dbTest.php | 352 + .../thinkphp/library/think/debugTest.php | 220 + .../thinkphp/library/think/exceptionTest.php | 52 + .../tests/thinkphp/library/think/hookTest.php | 67 + .../thinkphp/library/think/lang/lang.php | 4 + .../tests/thinkphp/library/think/langTest.php | 76 + .../library/think/loader/test/Hello.php | 7 + .../thinkphp/library/think/loaderTest.php | 71 + .../library/think/log/driver/fileTest.php | 34 + .../tests/thinkphp/library/think/logTest.php | 39 + .../thinkphp/library/think/model/.gitignore | 2 + .../thinkphp/library/think/paginateTest.php | 40 + .../thinkphp/library/think/requestTest.php | 203 + .../thinkphp/library/think/responseTest.php | 95 + .../thinkphp/library/think/routeTest.php | 287 + .../thinkphp/library/think/session/.gitignore | 2 + .../thinkphp/library/think/sessionTest.php | 319 + .../library/think/template/driver/.gitignore | 2 + .../library/think/template/taglib/cxTest.php | 575 ++ .../thinkphp/library/think/templateTest.php | 415 + .../tests/thinkphp/library/think/urlTest.php | 129 + .../thinkphp/library/think/validateTest.php | 200 + .../library/think/view/driver/.gitignore | 2 + .../think/view/theme/index/template.html | 14 + .../tests/thinkphp/library/think/viewTest.php | 76 + .../library/traits/controller/jumpTest.php | 339 + .../library/traits/model/softDeleteTest.php | 179 + .../library/traits/think/instanceTest.php | 60 + thinkphp/tpl/default_index.tpl | 10 + thinkphp/tpl/dispatch_jump.tpl | 49 + thinkphp/tpl/page_trace.tpl | 71 + thinkphp/tpl/think_exception.tpl | 537 ++ .../adbario/php-dot-notation/LICENSE.md | 21 + .../adbario/php-dot-notation/composer.json | 29 + .../adbario/php-dot-notation/src/Dot.php | 623 ++ .../adbario/php-dot-notation/src/helpers.php | 24 + .../alibabacloud/credentials/CHANGELOG.md | 18 + .../alibabacloud/credentials/CONTRIBUTING.md | 30 + .../alibabacloud/credentials/LICENSE.md | 13 + .../vendor/alibabacloud/credentials/NOTICE.md | 88 + .../alibabacloud/credentials/README-zh-CN.md | 423 + .../vendor/alibabacloud/credentials/README.md | 422 + .../alibabacloud/credentials/SECURITY.md | 21 + .../alibabacloud/credentials/UPGRADING.md | 6 + .../alibabacloud/credentials/composer.json | 107 + .../credentials/src/AccessKeyCredential.php | 86 + .../credentials/src/BearerTokenCredential.php | 67 + .../credentials/src/Credential.php | 268 + .../credentials/src/Credential/Config.php | 270 + .../src/Credential/CredentialModel.php | 143 + .../src/Credential/RefreshResult.php | 97 + .../credentials/src/Credentials.php | 104 + .../credentials/src/CredentialsInterface.php | 32 + .../src/CredentialsProviderWrap.php | 76 + .../credentials/src/EcsRamRoleCredential.php | 199 + .../CLIProfileCredentialsProvider.php | 193 + .../src/Providers/ChainProvider.php | 188 + .../credentials/src/Providers/Credentials.php | 87 + .../src/Providers/CredentialsProvider.php | 24 + .../Providers/DefaultCredentialsProvider.php | 175 + .../EcsRamRoleCredentialsProvider.php | 276 + ...EnvironmentVariableCredentialsProvider.php | 65 + .../OIDCRoleArnCredentialsProvider.php | 268 + .../Providers/ProfileCredentialsProvider.php | 188 + .../RamRoleArnCredentialsProvider.php | 321 + .../RsaKeyPairCredentialsProvider.php | 200 + .../Providers/SessionCredentialsProvider.php | 161 + .../Providers/StaticAKCredentialsProvider.php | 78 + .../StaticSTSCredentialsProvider.php | 92 + .../src/Providers/URLCredentialsProvider.php | 126 + .../credentials/src/RamRoleArnCredential.php | 242 + .../credentials/src/Request/Request.php | 167 + .../credentials/src/RsaKeyPairCredential.php | 185 + .../src/Signature/BearerTokenSignature.php | 47 + .../src/Signature/ShaHmac1Signature.php | 47 + .../src/Signature/ShaHmac256Signature.php | 47 + .../Signature/ShaHmac256WithRsaSignature.php | 64 + .../src/Signature/SignatureInterface.php | 34 + .../credentials/src/StsCredential.php | 115 + .../credentials/src/Utils/Filter.php | 233 + .../credentials/src/Utils/Helper.php | 251 + .../credentials/src/Utils/MockTrait.php | 120 + .../alibabacloud/darabonba-openapi/.gitignore | 15 + .../darabonba-openapi/.php_cs.dist | 65 + .../darabonba-openapi/README-CN.md | 31 + .../alibabacloud/darabonba-openapi/README.md | 31 + .../darabonba-openapi/autoload.php | 15 + .../darabonba-openapi/composer.json | 34 + .../darabonba-openapi/phpunit.xml | 31 + .../darabonba-openapi/src/Models/Config.php | 463 + .../src/Models/GlobalParameters.php | 40 + .../src/Models/OpenApiRequest.php | 72 + .../darabonba-openapi/src/Models/Params.php | 130 + .../darabonba-openapi/src/OpenApiClient.php | 1345 +++ .../tests/OpenApiClientTest.php | 329 + .../darabonba-openapi/tests/bootstrap.php | 3 + .../alibabacloud/dypnsapi-20170525/.gitignore | 15 + .../dypnsapi-20170525/.php_cs.dist | 65 + .../dypnsapi-20170525/ChangeLog.md | 59 + .../alibabacloud/dypnsapi-20170525/LICENSE | 201 + .../dypnsapi-20170525/README-CN.md | 35 + .../alibabacloud/dypnsapi-20170525/README.md | 35 + .../dypnsapi-20170525/autoload.php | 17 + .../dypnsapi-20170525/composer.json | 33 + .../dypnsapi-20170525/src/Dypnsapi.php | 1658 ++++ .../src/Models/CheckSmsVerifyCodeRequest.php | 172 + .../src/Models/CheckSmsVerifyCodeResponse.php | 71 + .../Models/CheckSmsVerifyCodeResponseBody.php | 120 + .../CheckSmsVerifyCodeResponseBody/model_.php | 70 + .../src/Models/CreateSchemeConfigRequest.php | 206 + .../src/Models/CreateSchemeConfigResponse.php | 71 + .../Models/CreateSchemeConfigResponseBody.php | 120 + .../CreateSchemeConfigResponseBody/model_.php | 51 + .../src/Models/CreateVerifySchemeRequest.php | 369 + .../src/Models/CreateVerifySchemeResponse.php | 71 + .../Models/CreateVerifySchemeResponseBody.php | 136 + .../gateVerifySchemeDTO.php | 51 + .../src/Models/DeleteVerifySchemeRequest.php | 104 + .../src/Models/DeleteVerifySchemeResponse.php | 71 + .../Models/DeleteVerifySchemeResponseBody.php | 102 + .../Models/DescribeVerifySchemeRequest.php | 104 + .../Models/DescribeVerifySchemeResponse.php | 71 + .../DescribeVerifySchemeResponseBody.php | 98 + .../schemeQueryResultDTO.php | 51 + .../src/Models/GetAuthTokenRequest.php | 177 + .../src/Models/GetAuthTokenResponse.php | 71 + .../src/Models/GetAuthTokenResponseBody.php | 101 + .../GetAuthTokenResponseBody/tokenInfo.php | 69 + .../src/Models/GetAuthorizationUrlRequest.php | 121 + .../Models/GetAuthorizationUrlResponse.php | 71 + .../GetAuthorizationUrlResponseBody.php | 101 + .../GetAuthorizationUrlResponseBody/data.php | 51 + .../src/Models/GetFusionAuthTokenRequest.php | 170 + .../src/Models/GetFusionAuthTokenResponse.php | 71 + .../Models/GetFusionAuthTokenResponseBody.php | 115 + .../src/Models/GetMobileRequest.php | 104 + .../src/Models/GetMobileResponse.php | 71 + .../src/Models/GetMobileResponseBody.php | 101 + .../getMobileResultDTO.php | 51 + .../src/Models/GetPhoneWithTokenRequest.php | 88 + .../src/Models/GetPhoneWithTokenResponse.php | 71 + .../Models/GetPhoneWithTokenResponseBody.php | 101 + .../GetPhoneWithTokenResponseBody/data.php | 51 + .../src/Models/GetSmsAuthTokensRequest.php | 203 + .../src/Models/GetSmsAuthTokensResponse.php | 71 + .../Models/GetSmsAuthTokensResponseBody.php | 101 + .../GetSmsAuthTokensResponseBody/data.php | 115 + .../Models/JyCreateVerifySchemeRequest.php | 191 + .../Models/JyCreateVerifySchemeResponse.php | 71 + .../JyCreateVerifySchemeResponseBody.php | 84 + .../gateVerifySchemeData.php | 47 + .../JyQueryAppInfoBySceneCodeRequest.php | 85 + .../JyQueryAppInfoBySceneCodeResponse.php | 71 + .../JyQueryAppInfoBySceneCodeResponseBody.php | 84 + .../data.php | 83 + .../QueryGateVerifyBillingPublicRequest.php | 99 + .../QueryGateVerifyBillingPublicResponse.php | 71 + ...eryGateVerifyBillingPublicResponseBody.php | 101 + .../data.php | 78 + .../data/sceneBillingList.php | 147 + .../QueryGateVerifyStatisticPublicRequest.php | 150 + ...QueryGateVerifyStatisticPublicResponse.php | 71 + ...yGateVerifyStatisticPublicResponseBody.php | 101 + .../data.php | 126 + .../data/dayStatistic.php | 99 + .../src/Models/QuerySendDetailsRequest.php | 155 + .../src/Models/QuerySendDetailsResponse.php | 71 + .../Models/QuerySendDetailsResponseBody.php | 146 + .../QuerySendDetailsResponseBody/model_.php | 174 + .../src/Models/SendSmsVerifyCodeRequest.php | 322 + .../src/Models/SendSmsVerifyCodeResponse.php | 71 + .../Models/SendSmsVerifyCodeResponseBody.php | 117 + .../SendSmsVerifyCodeResponseBody/model_.php | 99 + .../src/Models/VerifyMobileRequest.php | 121 + .../src/Models/VerifyMobileResponse.php | 71 + .../src/Models/VerifyMobileResponseBody.php | 101 + .../gateVerifyResultDTO.php | 71 + .../Models/VerifyPhoneWithTokenRequest.php | 105 + .../Models/VerifyPhoneWithTokenResponse.php | 71 + .../VerifyPhoneWithTokenResponseBody.php | 101 + .../gateVerify.php | 71 + .../src/Models/VerifySmsCodeRequest.php | 86 + .../src/Models/VerifySmsCodeResponse.php | 71 + .../src/Models/VerifySmsCodeResponseBody.php | 105 + .../VerifyWithFusionAuthTokenRequest.php | 88 + .../VerifyWithFusionAuthTokenResponse.php | 71 + .../VerifyWithFusionAuthTokenResponseBody.php | 114 + .../model_.php | 83 + .../alibabacloud/endpoint-util/.gitignore | 13 + .../alibabacloud/endpoint-util/.php_cs.dist | 65 + .../vendor/alibabacloud/endpoint-util/LICENSE | 13 + .../alibabacloud/endpoint-util/README-CN.md | 31 + .../alibabacloud/endpoint-util/README.md | 31 + .../alibabacloud/endpoint-util/composer.json | 42 + .../alibabacloud/endpoint-util/phpunit.xml | 32 + .../endpoint-util/src/Endpoint.php | 61 + .../endpoint-util/tests/EndpointTest.php | 58 + .../endpoint-util/tests/bootstrap.php | 3 + .../alibabacloud/gateway-spi/.gitignore | 15 + .../alibabacloud/gateway-spi/.php_cs.dist | 65 + .../alibabacloud/gateway-spi/autoload.php | 15 + .../alibabacloud/gateway-spi/composer.json | 30 + .../alibabacloud/gateway-spi/src/Client.php | 35 + .../gateway-spi/src/Models/AttributeMap.php | 47 + .../src/Models/InterceptorContext.php | 63 + .../InterceptorContext/configuration.php | 83 + .../src/Models/InterceptorContext/request.php | 220 + .../Models/InterceptorContext/response.php | 54 + .../alibabacloud/openapi-util/.gitignore | 15 + .../alibabacloud/openapi-util/.php_cs.dist | 65 + .../alibabacloud/openapi-util/README-CN.md | 31 + .../alibabacloud/openapi-util/README.md | 31 + .../alibabacloud/openapi-util/autoload.php | 17 + .../alibabacloud/openapi-util/composer.json | 45 + .../alibabacloud/openapi-util/phpunit.xml | 31 + .../openapi-util/src/OpenApiUtilClient.php | 573 ++ .../openapi-util/tests/Models/SourceModel.php | 126 + .../openapi-util/tests/Models/TargetModel.php | 125 + .../tests/OpenApiUtilClientTest.php | 501 + .../openapi-util/tests/bootstrap.php | 3 + .../vendor/alibabacloud/tea-utils/.gitignore | 3 + .../alibabacloud/tea-utils/.php_cs.dist | 65 + .../alibabacloud/tea-utils/README-CN.md | 31 + .../vendor/alibabacloud/tea-utils/README.md | 31 + .../alibabacloud/tea-utils/composer.json | 38 + .../vendor/alibabacloud/tea-utils/phpunit.xml | 18 + .../alibabacloud/tea-utils/src/Utils.php | 600 ++ .../tea-utils/src/Utils/ExtendsParameters.php | 38 + .../tea-utils/src/Utils/RuntimeOptions.php | 273 + .../tea-utils/tests/UtilsTest.php | 550 ++ .../tea-utils/tests/bootstrap.php | 3 + vendor/vendor/alibabacloud/tea-xml/.gitignore | 12 + .../vendor/alibabacloud/tea-xml/.php_cs.dist | 65 + .../vendor/alibabacloud/tea-xml/README-CN.md | 31 + vendor/vendor/alibabacloud/tea-xml/README.md | 31 + .../vendor/alibabacloud/tea-xml/composer.json | 44 + .../vendor/alibabacloud/tea-xml/phpunit.xml | 32 + .../alibabacloud/tea-xml/src/ArrayToXml.php | 151 + .../vendor/alibabacloud/tea-xml/src/XML.php | 59 + .../alibabacloud/tea-xml/tests/XMLTest.php | 59 + .../alibabacloud/tea-xml/tests/bootstrap.php | 3 + vendor/vendor/alibabacloud/tea/.php_cs.dist | 65 + vendor/vendor/alibabacloud/tea/CHANGELOG.md | 148 + vendor/vendor/alibabacloud/tea/LICENSE.md | 13 + vendor/vendor/alibabacloud/tea/README.md | 16 + vendor/vendor/alibabacloud/tea/composer.json | 80 + .../tea/src/Exception/TeaError.php | 53 + .../tea/src/Exception/TeaRetryError.php | 21 + .../tea/src/Exception/TeaUnableRetryError.php | 41 + vendor/vendor/alibabacloud/tea/src/Helper.php | 112 + vendor/vendor/alibabacloud/tea/src/Model.php | 114 + .../vendor/alibabacloud/tea/src/Parameter.php | 50 + .../vendor/alibabacloud/tea/src/Request.php | 123 + .../vendor/alibabacloud/tea/src/Response.php | 372 + vendor/vendor/alibabacloud/tea/src/Tea.php | 287 + .../aliyuncs/oss-sdk-php/.coveralls.yml | 2 + vendor/vendor/aliyuncs/oss-sdk-php/.gitignore | 8 + .../vendor/aliyuncs/oss-sdk-php/.travis.yml | 21 + .../vendor/aliyuncs/oss-sdk-php/CHANGELOG.md | 159 + vendor/vendor/aliyuncs/oss-sdk-php/LICENSE.md | 21 + .../vendor/aliyuncs/oss-sdk-php/README-CN.md | 149 + vendor/vendor/aliyuncs/oss-sdk-php/README.md | 150 + .../vendor/aliyuncs/oss-sdk-php/autoload.php | 11 + .../vendor/aliyuncs/oss-sdk-php/build-phar.sh | 13 + .../vendor/aliyuncs/oss-sdk-php/composer.json | 24 + .../vendor/aliyuncs/oss-sdk-php/example.jpg | Bin 0 -> 21839 bytes vendor/vendor/aliyuncs/oss-sdk-php/index.php | 3 + .../vendor/aliyuncs/oss-sdk-php/phpunit.xml | 19 + .../aliyuncs/oss-sdk-php/samples/Bucket.php | 254 + .../oss-sdk-php/samples/BucketCname.php | 91 + .../oss-sdk-php/samples/BucketCors.php | 171 + .../oss-sdk-php/samples/BucketEncryption.php | 98 + .../oss-sdk-php/samples/BucketLifecycle.php | 109 + .../oss-sdk-php/samples/BucketLogging.php | 95 + .../oss-sdk-php/samples/BucketPayment.php | 116 + .../oss-sdk-php/samples/BucketPolicy.php | 123 + .../oss-sdk-php/samples/BucketReferer.php | 101 + .../oss-sdk-php/samples/BucketStat.php | 65 + .../oss-sdk-php/samples/BucketTags.php | 112 + .../samples/BucketTransferAcceleration.php | 61 + .../oss-sdk-php/samples/BucketVersion.php | 235 + .../oss-sdk-php/samples/BucketWebsite.php | 92 + .../oss-sdk-php/samples/BucketWorm.php | 145 + .../aliyuncs/oss-sdk-php/samples/Callback.php | 83 + .../aliyuncs/oss-sdk-php/samples/Common.php | 84 + .../aliyuncs/oss-sdk-php/samples/Config.php | 15 + .../oss-sdk-php/samples/CredentialsPhp.php | 76 + .../samples/CredentialsProvider.php | 63 + .../aliyuncs/oss-sdk-php/samples/Image.php | 87 + .../oss-sdk-php/samples/LiveChannel.php | 131 + .../oss-sdk-php/samples/MultipartUpload.php | 182 + .../aliyuncs/oss-sdk-php/samples/Object.php | 765 ++ .../oss-sdk-php/samples/ObjectTagging.php | 366 + .../aliyuncs/oss-sdk-php/samples/RunAll.php | 13 + .../oss-sdk-php/samples/Signature.php | 142 + .../oss-sdk-php/src/OSS/Core/MimeTypes.php | 263 + .../oss-sdk-php/src/OSS/Core/OssException.php | 54 + .../oss-sdk-php/src/OSS/Core/OssUtil.php | 543 ++ .../src/OSS/Credentials/Credentials.php | 63 + .../OSS/Credentials/CredentialsProvider.php | 11 + ...EnvironmentVariableCredentialsProvider.php | 20 + .../Credentials/StaticCredentialsProvider.php | 35 + .../aliyuncs/oss-sdk-php/src/OSS/Http/LICENSE | 25 + .../oss-sdk-php/src/OSS/Http/RequestCore.php | 898 ++ .../src/OSS/Http/RequestCore_Exception.php | 8 + .../oss-sdk-php/src/OSS/Http/ResponseCore.php | 56 + .../oss-sdk-php/src/OSS/Model/BucketInfo.php | 181 + .../src/OSS/Model/BucketListInfo.php | 39 + .../oss-sdk-php/src/OSS/Model/BucketStat.php | 331 + .../oss-sdk-php/src/OSS/Model/CnameConfig.php | 99 + .../src/OSS/Model/CnameTokenInfo.php | 105 + .../oss-sdk-php/src/OSS/Model/CorsConfig.php | 140 + .../oss-sdk-php/src/OSS/Model/CorsRule.php | 150 + .../src/OSS/Model/DeleteMarkerInfo.php | 65 + .../src/OSS/Model/DeleteObjectInfo.php | 41 + .../src/OSS/Model/DeletedObjectInfo.php | 63 + .../src/OSS/Model/ExtendWormConfig.php | 64 + .../src/OSS/Model/GetLiveChannelHistory.php | 37 + .../src/OSS/Model/GetLiveChannelInfo.php | 68 + .../src/OSS/Model/GetLiveChannelStatus.php | 107 + .../src/OSS/Model/InitiateWormConfig.php | 64 + .../src/OSS/Model/LifecycleAction.php | 88 + .../src/OSS/Model/LifecycleConfig.php | 107 + .../src/OSS/Model/LifecycleRule.php | 126 + .../src/OSS/Model/ListMultipartUploadInfo.php | 134 + .../src/OSS/Model/ListPartsInfo.php | 97 + .../src/OSS/Model/LiveChannelConfig.php | 121 + .../src/OSS/Model/LiveChannelHistory.php | 59 + .../src/OSS/Model/LiveChannelInfo.php | 107 + .../src/OSS/Model/LiveChannelListInfo.php | 107 + .../src/OSS/Model/LoggingConfig.php | 86 + .../oss-sdk-php/src/OSS/Model/ObjectInfo.php | 129 + .../src/OSS/Model/ObjectListInfo.php | 126 + .../src/OSS/Model/ObjectListInfoV2.php | 147 + .../src/OSS/Model/ObjectVersionInfo.php | 125 + .../src/OSS/Model/ObjectVersionListInfo.php | 162 + .../oss-sdk-php/src/OSS/Model/Owner.php | 46 + .../oss-sdk-php/src/OSS/Model/PartInfo.php | 74 + .../oss-sdk-php/src/OSS/Model/PrefixInfo.php | 36 + .../src/OSS/Model/RefererConfig.php | 93 + .../src/OSS/Model/RequestPaymentConfig.php | 68 + .../src/OSS/Model/RestoreConfig.php | 77 + .../OSS/Model/ServerSideEncryptionConfig.php | 91 + .../src/OSS/Model/StorageCapacityConfig.php | 76 + .../oss-sdk-php/src/OSS/Model/Tag.php | 41 + .../src/OSS/Model/TaggingConfig.php | 89 + .../OSS/Model/TransferAccelerationConfig.php | 73 + .../oss-sdk-php/src/OSS/Model/UploadInfo.php | 55 + .../src/OSS/Model/VersioningConfig.php | 67 + .../src/OSS/Model/WebsiteConfig.php | 76 + .../oss-sdk-php/src/OSS/Model/WormConfig.php | 90 + .../oss-sdk-php/src/OSS/Model/XmlConfig.php | 27 + .../oss-sdk-php/src/OSS/OssClient.php | 3802 ++++++++ .../oss-sdk-php/src/OSS/Result/AclResult.php | 31 + .../src/OSS/Result/AppendResult.php | 27 + .../oss-sdk-php/src/OSS/Result/BodyResult.php | 19 + .../src/OSS/Result/CallbackResult.php | 21 + .../src/OSS/Result/CopyObjectResult.php | 30 + .../Result/CreateBucketCnameTokenResult.php | 19 + .../OSS/Result/DeleteObjectVersionsResult.php | 39 + .../src/OSS/Result/DeleteObjectsResult.php | 27 + .../src/OSS/Result/ExistResult.php | 34 + .../OSS/Result/GetBucketCnameTokenResult.php | 19 + .../OSS/Result/GetBucketEncryptionResult.php | 26 + .../src/OSS/Result/GetBucketInfoResult.php | 37 + .../Result/GetBucketRequestPaymentResult.php | 26 + .../src/OSS/Result/GetBucketStatResult.php | 26 + .../src/OSS/Result/GetBucketTagsResult.php | 26 + .../GetBucketTransferAccelerationResult.php | 22 + .../OSS/Result/GetBucketVersioningResult.php | 26 + .../src/OSS/Result/GetBucketWormResult.php | 26 + .../src/OSS/Result/GetCnameResult.php | 19 + .../src/OSS/Result/GetCorsResult.php | 34 + .../src/OSS/Result/GetLifecycleResult.php | 41 + .../Result/GetLiveChannelHistoryResult.php | 19 + .../OSS/Result/GetLiveChannelInfoResult.php | 19 + .../OSS/Result/GetLiveChannelStatusResult.php | 19 + .../src/OSS/Result/GetLocationResult.php | 30 + .../src/OSS/Result/GetLoggingResult.php | 41 + .../src/OSS/Result/GetRefererResult.php | 41 + .../OSS/Result/GetStorageCapacityResult.php | 34 + .../src/OSS/Result/GetWebsiteResult.php | 40 + .../src/OSS/Result/HeaderResult.php | 23 + .../OSS/Result/InitiateBucketWormResult.php | 27 + .../Result/InitiateMultipartUploadResult.php | 29 + .../src/OSS/Result/ListBucketsResult.php | 32 + .../src/OSS/Result/ListLiveChannelResult.php | 16 + .../OSS/Result/ListMultipartUploadResult.php | 55 + .../OSS/Result/ListObjectVersionsResult.php | 98 + .../src/OSS/Result/ListObjectsResult.php | 80 + .../src/OSS/Result/ListObjectsV2Result.php | 81 + .../src/OSS/Result/ListPartsResult.php | 42 + .../src/OSS/Result/PutLiveChannelResult.php | 16 + .../src/OSS/Result/PutSetDeleteResult.php | 20 + .../oss-sdk-php/src/OSS/Result/Result.php | 213 + .../src/OSS/Result/SymlinkResult.php | 24 + .../src/OSS/Result/UploadPartResult.php | 28 + .../src/OSS/Signer/SignerInterface.php | 12 + .../oss-sdk-php/src/OSS/Signer/SignerV1.php | 161 + .../oss-sdk-php/src/OSS/Signer/SignerV4.php | 244 + .../tests/OSS/Tests/AclResultTest.php | 59 + .../tests/OSS/Tests/AssumeRole.php | 32 + .../tests/OSS/Tests/BodyResultTest.php | 26 + .../tests/OSS/Tests/BucketCnameTest.php | 65 + .../tests/OSS/Tests/BucketInfoTest.php | 21 + .../tests/OSS/Tests/BucketLiveChannelTest.php | 320 + .../tests/OSS/Tests/CallbackTest.php | 297 + .../tests/OSS/Tests/CnameConfigTest.php | 77 + .../tests/OSS/Tests/CnameTokenInfoTest.php | 31 + .../oss-sdk-php/tests/OSS/Tests/Common.php | 169 + .../tests/OSS/Tests/ContentTypeTest.php | 123 + .../tests/OSS/Tests/CopyObjectResult.php | 52 + .../tests/OSS/Tests/CorsConfigTest.php | 211 + .../Tests/DeleteObjectVersionsResultTest.php | 187 + .../tests/OSS/Tests/ExistResultTest.php | 38 + .../Tests/GetBucketEncryptionResultTest.php | 95 + .../GetBucketRequestPaymentResultTest.php | 66 + .../OSS/Tests/GetBucketStatResultTest.php | 85 + .../OSS/Tests/GetBucketTagsResultTest.php | 77 + ...etBucketTransferAccelerationResultTest.php | 61 + .../OSS/Tests/GetBucketWormResultTest.php | 84 + .../tests/OSS/Tests/GetCorsResultTest.php | 67 + .../OSS/Tests/GetLifecycleResultTest.php | 59 + .../tests/OSS/Tests/GetLoggingResultTest.php | 51 + .../tests/OSS/Tests/GetRefererResultTest.php | 51 + .../tests/OSS/Tests/GetWebsiteResultTest.php | 50 + .../tests/OSS/Tests/HeaderResultTest.php | 23 + .../oss-sdk-php/tests/OSS/Tests/HttpTest.php | 77 + .../InitiateMultipartUploadResultTest.php | 47 + .../tests/OSS/Tests/LifecycleConfigTest.php | 130 + .../tests/OSS/Tests/ListBucketsResultTest.php | 168 + .../Tests/ListMultipartUploadResultTest.php | 114 + .../Tests/ListObjectVersionsResultTest.php | 215 + .../tests/OSS/Tests/ListObjectsResultTest.php | 208 + .../OSS/Tests/ListObjectsV2ResultTest.php | 215 + .../tests/OSS/Tests/ListPartsResultTest.php | 62 + .../tests/OSS/Tests/LiveChannelXmlTest.php | 277 + .../tests/OSS/Tests/LoggingConfigTest.php | 47 + .../tests/OSS/Tests/MimeTypesTest.php | 13 + .../tests/OSS/Tests/ObjectAclTest.php | 29 + .../Tests/OssClientAsyncProcessObjectTest.php | 68 + .../OSS/Tests/OssClientBucketCnameTest.php | 61 + .../OSS/Tests/OssClientBucketCorsTest.php | 125 + .../Tests/OssClientBucketEncryptionTest.php | 63 + .../OSS/Tests/OssClientBucketInfoTest.php | 20 + .../Tests/OssClientBucketLifecycleTest.php | 57 + .../OSS/Tests/OssClientBucketLoggingTest.php | 43 + .../OSS/Tests/OssClientBucketPolicyTest.php | 54 + .../OSS/Tests/OssClientBucketRefererTest.php | 48 + .../OssClientBucketRequestPaymentTest.php | 51 + .../OSS/Tests/OssClientBucketStatTestTest.php | 34 + .../OssClientBucketStorageCapacityTest.php | 56 + .../OSS/Tests/OssClientBucketTagsTest.php | 76 + .../tests/OSS/Tests/OssClientBucketTest.php | 140 + ...ssClientBucketTransferAccelerationTest.php | 40 + .../Tests/OssClientBucketVersioningTest.php | 40 + .../OSS/Tests/OssClientBucketWebsiteTest.php | 46 + .../OSS/Tests/OssClientBucketWormTest.php | 36 + .../OSS/Tests/OssClientForcePathStyleTest.php | 124 + .../tests/OSS/Tests/OssClientImageTest.php | 149 + .../OSS/Tests/OssClientListObjectsTest.php | 184 + .../OSS/Tests/OssClientListObjectsV2Test.php | 175 + .../Tests/OssClientMultipartUploadTest.php | 476 + .../OssClientObjectRequestPaymentTest.php | 472 + .../OSS/Tests/OssClientObjectTaggingTest.php | 160 + .../tests/OSS/Tests/OssClientObjectTest.php | 938 ++ .../Tests/OssClientObjectVersioningTest.php | 610 ++ .../tests/OSS/Tests/OssClientPresignTest.php | 70 + .../OSS/Tests/OssClientPresignV4Test.php | 369 + .../OSS/Tests/OssClientRestoreObjectTest.php | 174 + .../OSS/Tests/OssClientSignatureTest.php | 267 + .../OSS/Tests/OssClientSignatureV4Test.php | 1409 +++ .../tests/OSS/Tests/OssClientTest.php | 521 ++ .../tests/OSS/Tests/OssExceptionTest.php | 19 + .../tests/OSS/Tests/OssTrafficLimitTest.php | 96 + .../tests/OSS/Tests/OssUtilTest.php | 300 + .../OSS/Tests/PutSetDeleteResultTest.php | 66 + .../tests/OSS/Tests/RefererConfigTest.php | 54 + .../tests/OSS/Tests/SignerTest.php | 558 ++ .../OSS/Tests/StorageCapacityConfigTest.php | 58 + .../tests/OSS/Tests/StorageCapacityTest.php | 63 + .../oss-sdk-php/tests/OSS/Tests/StsBase.php | 33 + .../oss-sdk-php/tests/OSS/Tests/StsClient.php | 108 + .../tests/OSS/Tests/SymlinkTest.php | 77 + .../tests/OSS/Tests/TestOssClientBase.php | 51 + .../Tests/TransferAccelerationConfigTest.php | 56 + .../tests/OSS/Tests/UploadPartResultTest.php | 33 + .../tests/OSS/Tests/WebsiteConfigTest.php | 56 + vendor/vendor/autoload.php | 22 + vendor/vendor/composer/ClassLoader.php | 579 ++ vendor/vendor/composer/InstalledVersions.php | 396 + vendor/vendor/composer/LICENSE | 21 + vendor/vendor/composer/autoload_classmap.php | 16 + vendor/vendor/composer/autoload_files.php | 23 + .../vendor/composer/autoload_namespaces.php | 11 + vendor/vendor/composer/autoload_psr4.php | 61 + vendor/vendor/composer/autoload_real.php | 50 + vendor/vendor/composer/autoload_static.php | 371 + vendor/vendor/composer/installed.json | 3924 ++++++++ vendor/vendor/composer/installed.php | 601 ++ vendor/vendor/composer/pcre/LICENSE | 19 + vendor/vendor/composer/pcre/README.md | 189 + vendor/vendor/composer/pcre/composer.json | 54 + vendor/vendor/composer/pcre/extension.neon | 22 + .../composer/pcre/src/MatchAllResult.php | 46 + .../pcre/src/MatchAllStrictGroupsResult.php | 46 + .../pcre/src/MatchAllWithOffsetsResult.php | 48 + .../vendor/composer/pcre/src/MatchResult.php | 39 + .../pcre/src/MatchStrictGroupsResult.php | 39 + .../pcre/src/MatchWithOffsetsResult.php | 41 + .../src/PHPStan/InvalidRegexPatternRule.php | 142 + .../pcre/src/PHPStan/PregMatchFlags.php | 70 + .../PregMatchParameterOutTypeExtension.php | 65 + .../PregMatchTypeSpecifyingExtension.php | 119 + ...regReplaceCallbackClosureTypeExtension.php | 91 + .../PHPStan/UnsafeStrictGroupsCallRule.php | 112 + .../composer/pcre/src/PcreException.php | 55 + vendor/vendor/composer/pcre/src/Preg.php | 430 + vendor/vendor/composer/pcre/src/Regex.php | 176 + .../composer/pcre/src/ReplaceResult.php | 43 + .../pcre/src/UnexpectedNullMatchException.php | 20 + vendor/vendor/composer/platform_check.php | 26 + .../easywechat-composer/.gitignore | 5 + .../easywechat-composer/.php_cs | 29 + .../easywechat-composer/.travis.yml | 12 + .../easywechat-composer/LICENSE | 21 + .../easywechat-composer/README.md | 55 + .../easywechat-composer/composer.json | 35 + .../easywechat-composer/phpunit.xml | 20 + .../src/Commands/ExtensionsCommand.php | 63 + .../src/Commands/Provider.php | 31 + .../src/Contracts/Encrypter.php | 35 + .../src/Delegation/DelegationOptions.php | 80 + .../src/Delegation/DelegationTo.php | 83 + .../src/Delegation/Hydrate.php | 83 + .../easywechat-composer/src/EasyWeChat.php | 79 + .../src/Encryption/DefaultEncrypter.php | 89 + .../src/Exceptions/DecryptException.php | 21 + .../src/Exceptions/DelegationException.php | 42 + .../src/Exceptions/EncryptException.php | 21 + .../easywechat-composer/src/Extension.php | 143 + .../src/Http/DelegationResponse.php | 25 + .../easywechat-composer/src/Http/Response.php | 104 + .../Http/Controllers/DelegatesController.php | 49 + .../src/Laravel/ServiceProvider.php | 116 + .../src/Laravel/config.php | 29 + .../src/Laravel/routes.php | 16 + .../src/ManifestManager.php | 127 + .../easywechat-composer/src/Plugin.php | 107 + .../src/Traits/MakesHttpRequests.php | 110 + .../src/Traits/WithAggregator.php | 60 + .../tests/ManifestManagerTest.php | 37 + vendor/vendor/ezyang/htmlpurifier/CREDITS | 9 + vendor/vendor/ezyang/htmlpurifier/LICENSE | 504 + vendor/vendor/ezyang/htmlpurifier/README.md | 29 + vendor/vendor/ezyang/htmlpurifier/VERSION | 1 + .../vendor/ezyang/htmlpurifier/composer.json | 45 + .../library/HTMLPurifier.auto.php | 11 + .../library/HTMLPurifier.autoload-legacy.php | 14 + .../library/HTMLPurifier.autoload.php | 25 + .../library/HTMLPurifier.composer.php | 4 + .../library/HTMLPurifier.func.php | 25 + .../library/HTMLPurifier.includes.php | 236 + .../library/HTMLPurifier.kses.php | 30 + .../library/HTMLPurifier.path.php | 11 + .../htmlpurifier/library/HTMLPurifier.php | 297 + .../library/HTMLPurifier.safe-includes.php | 230 + .../library/HTMLPurifier/Arborize.php | 71 + .../library/HTMLPurifier/AttrCollections.php | 148 + .../library/HTMLPurifier/AttrDef.php | 144 + .../library/HTMLPurifier/AttrDef/CSS.php | 140 + .../HTMLPurifier/AttrDef/CSS/AlphaValue.php | 34 + .../HTMLPurifier/AttrDef/CSS/Background.php | 113 + .../AttrDef/CSS/BackgroundPosition.php | 157 + .../HTMLPurifier/AttrDef/CSS/Border.php | 56 + .../HTMLPurifier/AttrDef/CSS/Color.php | 161 + .../HTMLPurifier/AttrDef/CSS/Composite.php | 48 + .../AttrDef/CSS/DenyElementDecorator.php | 44 + .../HTMLPurifier/AttrDef/CSS/Filter.php | 77 + .../library/HTMLPurifier/AttrDef/CSS/Font.php | 176 + .../HTMLPurifier/AttrDef/CSS/FontFamily.php | 217 + .../HTMLPurifier/AttrDef/CSS/Ident.php | 32 + .../AttrDef/CSS/ImportantDecorator.php | 56 + .../HTMLPurifier/AttrDef/CSS/Length.php | 77 + .../HTMLPurifier/AttrDef/CSS/ListStyle.php | 112 + .../HTMLPurifier/AttrDef/CSS/Multiple.php | 71 + .../HTMLPurifier/AttrDef/CSS/Number.php | 90 + .../HTMLPurifier/AttrDef/CSS/Percentage.php | 54 + .../HTMLPurifier/AttrDef/CSS/Ratio.php | 46 + .../AttrDef/CSS/TextDecoration.php | 46 + .../library/HTMLPurifier/AttrDef/CSS/URI.php | 77 + .../library/HTMLPurifier/AttrDef/Clone.php | 44 + .../library/HTMLPurifier/AttrDef/Enum.php | 73 + .../HTMLPurifier/AttrDef/HTML/Bool.php | 48 + .../HTMLPurifier/AttrDef/HTML/Class.php | 48 + .../HTMLPurifier/AttrDef/HTML/Color.php | 51 + .../AttrDef/HTML/ContentEditable.php | 16 + .../HTMLPurifier/AttrDef/HTML/FrameTarget.php | 38 + .../library/HTMLPurifier/AttrDef/HTML/ID.php | 113 + .../HTMLPurifier/AttrDef/HTML/Length.php | 56 + .../HTMLPurifier/AttrDef/HTML/LinkTypes.php | 72 + .../HTMLPurifier/AttrDef/HTML/MultiLength.php | 60 + .../HTMLPurifier/AttrDef/HTML/Nmtokens.php | 70 + .../HTMLPurifier/AttrDef/HTML/Pixels.php | 76 + .../library/HTMLPurifier/AttrDef/Integer.php | 91 + .../library/HTMLPurifier/AttrDef/Lang.php | 86 + .../library/HTMLPurifier/AttrDef/Switch.php | 53 + .../library/HTMLPurifier/AttrDef/Text.php | 21 + .../library/HTMLPurifier/AttrDef/URI.php | 111 + .../HTMLPurifier/AttrDef/URI/Email.php | 20 + .../AttrDef/URI/Email/SimpleCheck.php | 29 + .../library/HTMLPurifier/AttrDef/URI/Host.php | 136 + .../library/HTMLPurifier/AttrDef/URI/IPv4.php | 45 + .../library/HTMLPurifier/AttrDef/URI/IPv6.php | 89 + .../library/HTMLPurifier/AttrTransform.php | 60 + .../HTMLPurifier/AttrTransform/Background.php | 28 + .../HTMLPurifier/AttrTransform/BdoDir.php | 27 + .../HTMLPurifier/AttrTransform/BgColor.php | 28 + .../HTMLPurifier/AttrTransform/BoolToCSS.php | 47 + .../HTMLPurifier/AttrTransform/Border.php | 26 + .../HTMLPurifier/AttrTransform/EnumToCSS.php | 68 + .../AttrTransform/ImgRequired.php | 47 + .../HTMLPurifier/AttrTransform/ImgSpace.php | 61 + .../HTMLPurifier/AttrTransform/Input.php | 56 + .../HTMLPurifier/AttrTransform/Lang.php | 31 + .../HTMLPurifier/AttrTransform/Length.php | 45 + .../HTMLPurifier/AttrTransform/Name.php | 33 + .../HTMLPurifier/AttrTransform/NameSync.php | 46 + .../HTMLPurifier/AttrTransform/Nofollow.php | 52 + .../HTMLPurifier/AttrTransform/SafeEmbed.php | 25 + .../HTMLPurifier/AttrTransform/SafeObject.php | 28 + .../HTMLPurifier/AttrTransform/SafeParam.php | 84 + .../AttrTransform/ScriptRequired.php | 23 + .../AttrTransform/TargetBlank.php | 49 + .../AttrTransform/TargetNoopener.php | 37 + .../AttrTransform/TargetNoreferrer.php | 37 + .../HTMLPurifier/AttrTransform/Textarea.php | 27 + .../library/HTMLPurifier/AttrTypes.php | 97 + .../library/HTMLPurifier/AttrValidator.php | 178 + .../library/HTMLPurifier/Bootstrap.php | 91 + .../library/HTMLPurifier/CSSDefinition.php | 565 ++ .../library/HTMLPurifier/ChildDef.php | 52 + .../HTMLPurifier/ChildDef/Chameleon.php | 67 + .../library/HTMLPurifier/ChildDef/Custom.php | 102 + .../library/HTMLPurifier/ChildDef/Empty.php | 38 + .../library/HTMLPurifier/ChildDef/List.php | 94 + .../HTMLPurifier/ChildDef/Optional.php | 45 + .../HTMLPurifier/ChildDef/Required.php | 118 + .../ChildDef/StrictBlockquote.php | 110 + .../library/HTMLPurifier/ChildDef/Table.php | 227 + .../library/HTMLPurifier/Config.php | 920 ++ .../library/HTMLPurifier/ConfigSchema.php | 176 + .../ConfigSchema/Builder/ConfigSchema.php | 48 + .../HTMLPurifier/ConfigSchema/Builder/Xml.php | 144 + .../HTMLPurifier/ConfigSchema/Exception.php | 11 + .../HTMLPurifier/ConfigSchema/Interchange.php | 47 + .../ConfigSchema/Interchange/Directive.php | 89 + .../ConfigSchema/Interchange/Id.php | 58 + .../ConfigSchema/InterchangeBuilder.php | 226 + .../HTMLPurifier/ConfigSchema/Validator.php | 248 + .../ConfigSchema/ValidatorAtom.php | 130 + .../HTMLPurifier/ConfigSchema/schema.ser | 1 + .../schema/Attr.AllowedClasses.txt | 8 + .../schema/Attr.AllowedFrameTargets.txt | 12 + .../ConfigSchema/schema/Attr.AllowedRel.txt | 9 + .../ConfigSchema/schema/Attr.AllowedRev.txt | 9 + .../schema/Attr.ClassUseCDATA.txt | 19 + .../schema/Attr.DefaultImageAlt.txt | 11 + .../schema/Attr.DefaultInvalidImage.txt | 9 + .../schema/Attr.DefaultInvalidImageAlt.txt | 8 + .../schema/Attr.DefaultTextDir.txt | 10 + .../ConfigSchema/schema/Attr.EnableID.txt | 16 + .../schema/Attr.ForbiddenClasses.txt | 8 + .../ConfigSchema/schema/Attr.ID.HTML5.txt | 10 + .../ConfigSchema/schema/Attr.IDBlacklist.txt | 5 + .../schema/Attr.IDBlacklistRegexp.txt | 9 + .../ConfigSchema/schema/Attr.IDPrefix.txt | 12 + .../schema/Attr.IDPrefixLocal.txt | 14 + .../schema/AutoFormat.AutoParagraph.txt | 31 + .../ConfigSchema/schema/AutoFormat.Custom.txt | 12 + .../schema/AutoFormat.DisplayLinkURI.txt | 11 + .../schema/AutoFormat.Linkify.txt | 12 + .../AutoFormat.PurifierLinkify.DocURL.txt | 12 + .../schema/AutoFormat.PurifierLinkify.txt | 12 + .../AutoFormat.RemoveEmpty.Predicate.txt | 14 + ...rmat.RemoveEmpty.RemoveNbsp.Exceptions.txt | 11 + .../AutoFormat.RemoveEmpty.RemoveNbsp.txt | 15 + .../schema/AutoFormat.RemoveEmpty.txt | 46 + ...utoFormat.RemoveSpansWithoutAttributes.txt | 11 + .../schema/CSS.AllowDuplicates.txt | 11 + .../schema/CSS.AllowImportant.txt | 8 + .../ConfigSchema/schema/CSS.AllowTricky.txt | 11 + .../ConfigSchema/schema/CSS.AllowedFonts.txt | 12 + .../schema/CSS.AllowedProperties.txt | 18 + .../ConfigSchema/schema/CSS.DefinitionRev.txt | 11 + .../schema/CSS.ForbiddenProperties.txt | 13 + .../ConfigSchema/schema/CSS.MaxImgLength.txt | 16 + .../ConfigSchema/schema/CSS.Proprietary.txt | 10 + .../ConfigSchema/schema/CSS.Trusted.txt | 9 + .../schema/Cache.DefinitionImpl.txt | 14 + .../schema/Cache.SerializerPath.txt | 13 + .../schema/Cache.SerializerPermissions.txt | 16 + .../schema/Core.AggressivelyFixLt.txt | 18 + .../schema/Core.AggressivelyRemoveScript.txt | 16 + .../schema/Core.AllowHostnameUnderscore.txt | 16 + .../schema/Core.AllowParseManyTags.txt | 12 + .../schema/Core.CollectErrors.txt | 12 + .../schema/Core.ColorKeywords.txt | 160 + .../schema/Core.ConvertDocumentToFragment.txt | 14 + .../Core.DirectLexLineNumberSyncInterval.txt | 17 + .../schema/Core.DisableExcludes.txt | 14 + .../ConfigSchema/schema/Core.EnableIDNA.txt | 9 + .../ConfigSchema/schema/Core.Encoding.txt | 15 + .../schema/Core.EscapeInvalidChildren.txt | 12 + .../schema/Core.EscapeInvalidTags.txt | 7 + .../schema/Core.EscapeNonASCIICharacters.txt | 13 + .../schema/Core.HiddenElements.txt | 19 + .../ConfigSchema/schema/Core.Language.txt | 10 + .../schema/Core.LegacyEntityDecoder.txt | 36 + .../ConfigSchema/schema/Core.LexerImpl.txt | 34 + .../schema/Core.MaintainLineNumbers.txt | 16 + .../schema/Core.NormalizeNewlines.txt | 11 + .../ConfigSchema/schema/Core.RemoveBlanks.txt | 10 + .../schema/Core.RemoveInvalidImg.txt | 12 + .../Core.RemoveProcessingInstructions.txt | 11 + .../schema/Core.RemoveScriptContents.txt | 12 + .../ConfigSchema/schema/Filter.Custom.txt | 11 + .../Filter.ExtractStyleBlocks.Escaping.txt | 14 + .../Filter.ExtractStyleBlocks.Scope.txt | 29 + .../Filter.ExtractStyleBlocks.TidyImpl.txt | 16 + .../schema/Filter.ExtractStyleBlocks.txt | 74 + .../ConfigSchema/schema/Filter.YouTube.txt | 16 + .../ConfigSchema/schema/HTML.Allowed.txt | 25 + .../schema/HTML.AllowedAttributes.txt | 19 + .../schema/HTML.AllowedComments.txt | 10 + .../schema/HTML.AllowedCommentsRegexp.txt | 15 + .../schema/HTML.AllowedElements.txt | 23 + .../schema/HTML.AllowedModules.txt | 20 + .../schema/HTML.Attr.Name.UseCDATA.txt | 11 + .../ConfigSchema/schema/HTML.BlockWrapper.txt | 18 + .../ConfigSchema/schema/HTML.CoreModules.txt | 23 + .../schema/HTML.CustomDoctype.txt | 9 + .../ConfigSchema/schema/HTML.DefinitionID.txt | 33 + .../schema/HTML.DefinitionRev.txt | 16 + .../ConfigSchema/schema/HTML.Doctype.txt | 11 + .../schema/HTML.FlashAllowFullScreen.txt | 11 + .../schema/HTML.ForbiddenAttributes.txt | 21 + .../schema/HTML.ForbiddenElements.txt | 20 + .../ConfigSchema/schema/HTML.Forms.txt | 11 + .../ConfigSchema/schema/HTML.MaxImgLength.txt | 14 + .../ConfigSchema/schema/HTML.Nofollow.txt | 7 + .../ConfigSchema/schema/HTML.Parent.txt | 12 + .../ConfigSchema/schema/HTML.Proprietary.txt | 12 + .../ConfigSchema/schema/HTML.SafeEmbed.txt | 13 + .../ConfigSchema/schema/HTML.SafeIframe.txt | 13 + .../ConfigSchema/schema/HTML.SafeObject.txt | 13 + .../schema/HTML.SafeScripting.txt | 10 + .../ConfigSchema/schema/HTML.Strict.txt | 9 + .../ConfigSchema/schema/HTML.TargetBlank.txt | 8 + .../schema/HTML.TargetNoopener.txt | 10 + .../schema/HTML.TargetNoreferrer.txt | 9 + .../ConfigSchema/schema/HTML.TidyAdd.txt | 8 + .../ConfigSchema/schema/HTML.TidyLevel.txt | 24 + .../ConfigSchema/schema/HTML.TidyRemove.txt | 8 + .../ConfigSchema/schema/HTML.Trusted.txt | 9 + .../ConfigSchema/schema/HTML.XHTML.txt | 11 + .../schema/Output.CommentScriptContents.txt | 10 + .../schema/Output.FixInnerHTML.txt | 15 + .../schema/Output.FlashCompat.txt | 11 + .../ConfigSchema/schema/Output.Newline.txt | 13 + .../ConfigSchema/schema/Output.SortAttr.txt | 14 + .../ConfigSchema/schema/Output.TidyFormat.txt | 25 + .../ConfigSchema/schema/Test.ForceNoIconv.txt | 7 + .../schema/URI.AllowedSchemes.txt | 18 + .../ConfigSchema/schema/URI.Base.txt | 17 + .../ConfigSchema/schema/URI.DefaultScheme.txt | 15 + .../ConfigSchema/schema/URI.DefinitionID.txt | 11 + .../ConfigSchema/schema/URI.DefinitionRev.txt | 11 + .../ConfigSchema/schema/URI.Disable.txt | 14 + .../schema/URI.DisableExternal.txt | 11 + .../schema/URI.DisableExternalResources.txt | 13 + .../schema/URI.DisableResources.txt | 15 + .../ConfigSchema/schema/URI.Host.txt | 19 + .../ConfigSchema/schema/URI.HostBlacklist.txt | 9 + .../ConfigSchema/schema/URI.MakeAbsolute.txt | 13 + .../ConfigSchema/schema/URI.Munge.txt | 83 + .../schema/URI.MungeResources.txt | 17 + .../schema/URI.MungeSecretKey.txt | 30 + .../schema/URI.OverrideAllowedSchemes.txt | 9 + .../schema/URI.SafeIframeRegexp.txt | 22 + .../HTMLPurifier/ConfigSchema/schema/info.ini | 3 + .../library/HTMLPurifier/ContentSets.php | 170 + .../library/HTMLPurifier/Context.php | 95 + .../library/HTMLPurifier/Definition.php | 55 + .../library/HTMLPurifier/DefinitionCache.php | 129 + .../DefinitionCache/Decorator.php | 112 + .../DefinitionCache/Decorator/Cleanup.php | 78 + .../DefinitionCache/Decorator/Memory.php | 85 + .../DefinitionCache/Decorator/Template.php.in | 82 + .../HTMLPurifier/DefinitionCache/Null.php | 76 + .../DefinitionCache/Serializer.php | 312 + ...c0a322b208e83d22d3aef33ecb184bc71d31,1.ser | Bin 0 -> 95522 bytes .../DefinitionCache/Serializer/README | 3 + .../HTMLPurifier/DefinitionCacheFactory.php | 106 + .../library/HTMLPurifier/Doctype.php | 73 + .../library/HTMLPurifier/DoctypeRegistry.php | 142 + .../library/HTMLPurifier/ElementDef.php | 216 + .../library/HTMLPurifier/Encoder.php | 617 ++ .../library/HTMLPurifier/EntityLookup.php | 48 + .../HTMLPurifier/EntityLookup/entities.ser | 1 + .../library/HTMLPurifier/EntityParser.php | 285 + .../library/HTMLPurifier/ErrorCollector.php | 244 + .../library/HTMLPurifier/ErrorStruct.php | 74 + .../library/HTMLPurifier/Exception.php | 12 + .../library/HTMLPurifier/Filter.php | 56 + .../Filter/ExtractStyleBlocks.php | 362 + .../library/HTMLPurifier/Filter/YouTube.php | 65 + .../library/HTMLPurifier/Generator.php | 286 + .../library/HTMLPurifier/HTMLDefinition.php | 493 + .../library/HTMLPurifier/HTMLModule.php | 285 + .../library/HTMLPurifier/HTMLModule/Bdo.php | 44 + .../HTMLModule/CommonAttributes.php | 32 + .../library/HTMLPurifier/HTMLModule/Edit.php | 55 + .../library/HTMLPurifier/HTMLModule/Forms.php | 194 + .../HTMLPurifier/HTMLModule/Hypertext.php | 40 + .../HTMLPurifier/HTMLModule/Iframe.php | 57 + .../library/HTMLPurifier/HTMLModule/Image.php | 49 + .../HTMLPurifier/HTMLModule/Legacy.php | 186 + .../library/HTMLPurifier/HTMLModule/List.php | 51 + .../library/HTMLPurifier/HTMLModule/Name.php | 26 + .../HTMLPurifier/HTMLModule/Nofollow.php | 25 + .../HTMLModule/NonXMLCommonAttributes.php | 20 + .../HTMLPurifier/HTMLModule/Object.php | 62 + .../HTMLPurifier/HTMLModule/Presentation.php | 42 + .../HTMLPurifier/HTMLModule/Proprietary.php | 40 + .../library/HTMLPurifier/HTMLModule/Ruby.php | 36 + .../HTMLPurifier/HTMLModule/SafeEmbed.php | 40 + .../HTMLPurifier/HTMLModule/SafeObject.php | 62 + .../HTMLPurifier/HTMLModule/SafeScripting.php | 40 + .../HTMLPurifier/HTMLModule/Scripting.php | 73 + .../HTMLModule/StyleAttribute.php | 33 + .../HTMLPurifier/HTMLModule/Tables.php | 75 + .../HTMLPurifier/HTMLModule/Target.php | 28 + .../HTMLPurifier/HTMLModule/TargetBlank.php | 24 + .../HTMLModule/TargetNoopener.php | 21 + .../HTMLModule/TargetNoreferrer.php | 21 + .../library/HTMLPurifier/HTMLModule/Text.php | 87 + .../library/HTMLPurifier/HTMLModule/Tidy.php | 228 + .../HTMLPurifier/HTMLModule/Tidy/Name.php | 33 + .../HTMLModule/Tidy/Proprietary.php | 34 + .../HTMLPurifier/HTMLModule/Tidy/Strict.php | 43 + .../HTMLModule/Tidy/Transitional.php | 16 + .../HTMLPurifier/HTMLModule/Tidy/XHTML.php | 26 + .../HTMLModule/Tidy/XHTMLAndHTML4.php | 182 + .../HTMLModule/XMLCommonAttributes.php | 20 + .../HTMLPurifier/HTMLModuleManager.php | 467 + .../library/HTMLPurifier/IDAccumulator.php | 57 + .../library/HTMLPurifier/Injector.php | 283 + .../HTMLPurifier/Injector/AutoParagraph.php | 356 + .../HTMLPurifier/Injector/DisplayLinkURI.php | 40 + .../library/HTMLPurifier/Injector/Linkify.php | 67 + .../HTMLPurifier/Injector/PurifierLinkify.php | 71 + .../HTMLPurifier/Injector/RemoveEmpty.php | 112 + .../Injector/RemoveSpansWithoutAttributes.php | 95 + .../HTMLPurifier/Injector/SafeObject.php | 124 + .../library/HTMLPurifier/Language.php | 204 + .../HTMLPurifier/Language/messages/en.php | 55 + .../library/HTMLPurifier/LanguageFactory.php | 209 + .../library/HTMLPurifier/Length.php | 162 + .../library/HTMLPurifier/Lexer.php | 371 + .../library/HTMLPurifier/Lexer/DOMLex.php | 340 + .../library/HTMLPurifier/Lexer/DirectLex.php | 539 ++ .../library/HTMLPurifier/Lexer/PH5P.php | 4788 ++++++++++ .../library/HTMLPurifier/Node.php | 49 + .../library/HTMLPurifier/Node/Comment.php | 36 + .../library/HTMLPurifier/Node/Element.php | 59 + .../library/HTMLPurifier/Node/Text.php | 54 + .../library/HTMLPurifier/PercentEncoder.php | 111 + .../library/HTMLPurifier/Printer.php | 218 + .../HTMLPurifier/Printer/CSSDefinition.php | 44 + .../HTMLPurifier/Printer/ConfigForm.css | 10 + .../HTMLPurifier/Printer/ConfigForm.js | 5 + .../HTMLPurifier/Printer/ConfigForm.php | 456 + .../HTMLPurifier/Printer/HTMLDefinition.php | 324 + .../library/HTMLPurifier/PropertyList.php | 122 + .../HTMLPurifier/PropertyListIterator.php | 43 + .../library/HTMLPurifier/Queue.php | 56 + .../library/HTMLPurifier/Strategy.php | 26 + .../HTMLPurifier/Strategy/Composite.php | 30 + .../library/HTMLPurifier/Strategy/Core.php | 17 + .../HTMLPurifier/Strategy/FixNesting.php | 181 + .../HTMLPurifier/Strategy/MakeWellFormed.php | 659 ++ .../Strategy/RemoveForeignElements.php | 207 + .../Strategy/ValidateAttributes.php | 45 + .../library/HTMLPurifier/StringHash.php | 48 + .../library/HTMLPurifier/StringHashParser.php | 136 + .../library/HTMLPurifier/TagTransform.php | 37 + .../HTMLPurifier/TagTransform/Font.php | 114 + .../HTMLPurifier/TagTransform/Simple.php | 44 + .../library/HTMLPurifier/Token.php | 100 + .../library/HTMLPurifier/Token/Comment.php | 38 + .../library/HTMLPurifier/Token/Empty.php | 15 + .../library/HTMLPurifier/Token/End.php | 24 + .../library/HTMLPurifier/Token/Start.php | 10 + .../library/HTMLPurifier/Token/Tag.php | 68 + .../library/HTMLPurifier/Token/Text.php | 53 + .../library/HTMLPurifier/TokenFactory.php | 118 + .../htmlpurifier/library/HTMLPurifier/URI.php | 316 + .../library/HTMLPurifier/URIDefinition.php | 112 + .../library/HTMLPurifier/URIFilter.php | 74 + .../URIFilter/DisableExternal.php | 54 + .../URIFilter/DisableExternalResources.php | 25 + .../URIFilter/DisableResources.php | 22 + .../HTMLPurifier/URIFilter/HostBlacklist.php | 46 + .../HTMLPurifier/URIFilter/MakeAbsolute.php | 158 + .../library/HTMLPurifier/URIFilter/Munge.php | 115 + .../HTMLPurifier/URIFilter/SafeIframe.php | 68 + .../library/HTMLPurifier/URIParser.php | 71 + .../library/HTMLPurifier/URIScheme.php | 102 + .../library/HTMLPurifier/URIScheme/data.php | 136 + .../library/HTMLPurifier/URIScheme/file.php | 44 + .../library/HTMLPurifier/URIScheme/ftp.php | 58 + .../library/HTMLPurifier/URIScheme/http.php | 36 + .../library/HTMLPurifier/URIScheme/https.php | 18 + .../library/HTMLPurifier/URIScheme/mailto.php | 40 + .../library/HTMLPurifier/URIScheme/news.php | 35 + .../library/HTMLPurifier/URIScheme/nntp.php | 32 + .../library/HTMLPurifier/URIScheme/tel.php | 46 + .../HTMLPurifier/URISchemeRegistry.php | 81 + .../library/HTMLPurifier/UnitConverter.php | 307 + .../library/HTMLPurifier/VarParser.php | 198 + .../HTMLPurifier/VarParser/Flexible.php | 130 + .../library/HTMLPurifier/VarParser/Native.php | 38 + .../HTMLPurifier/VarParserException.php | 11 + .../library/HTMLPurifier/Zipper.php | 157 + .../fastadminnet/fastadmin-addons/.gitignore | 2 + .../fastadminnet/fastadmin-addons/LICENSE.txt | 202 + .../fastadminnet/fastadmin-addons/README.md | 11 + .../fastadmin-addons/composer.json | 37 + .../licenses/think-addons.txt | 32 + .../fastadmin-addons/src/Addons.php | 296 + .../src/addons/AddonException.php | 21 + .../src/addons/Controller.php | 220 + .../fastadmin-addons/src/addons/Route.php | 94 + .../fastadmin-addons/src/addons/Service.php | 1146 +++ .../fastadmin-addons/src/common.php | 530 ++ .../fastadmin-addons/src/config.php | 15 + .../fastadminnet/fastadmin-mailer/LICENSE | 20 + .../fastadmin-mailer/composer.json | 38 + .../fastadmin-mailer/src/Mailer.php | 209 + .../src/Mailer/Exceptions/CodeException.php | 40 + .../src/Mailer/Exceptions/CryptoException.php | 32 + .../src/Mailer/Exceptions/SMTPException.php | 35 + .../src/Mailer/Exceptions/SendException.php | 31 + .../fastadmin-mailer/src/Mailer/Message.php | 456 + .../fastadmin-mailer/src/Mailer/SMTP.php | 492 + vendor/vendor/guzzlehttp/guzzle/CHANGELOG.md | 1664 ++++ vendor/vendor/guzzlehttp/guzzle/LICENSE | 27 + vendor/vendor/guzzlehttp/guzzle/README.md | 94 + vendor/vendor/guzzlehttp/guzzle/UPGRADING.md | 1253 +++ vendor/vendor/guzzlehttp/guzzle/composer.json | 131 + .../guzzlehttp/guzzle/src/BodySummarizer.php | 28 + .../guzzle/src/BodySummarizerInterface.php | 13 + .../vendor/guzzlehttp/guzzle/src/Client.php | 483 + .../guzzlehttp/guzzle/src/ClientInterface.php | 84 + .../guzzlehttp/guzzle/src/ClientTrait.php | 241 + .../guzzle/src/Cookie/CookieJar.php | 307 + .../guzzle/src/Cookie/CookieJarInterface.php | 80 + .../guzzle/src/Cookie/FileCookieJar.php | 101 + .../guzzle/src/Cookie/SessionCookieJar.php | 77 + .../guzzle/src/Cookie/SetCookie.php | 488 + .../src/Exception/BadResponseException.php | 39 + .../guzzle/src/Exception/ClientException.php | 10 + .../guzzle/src/Exception/ConnectException.php | 56 + .../guzzle/src/Exception/GuzzleException.php | 9 + .../Exception/InvalidArgumentException.php | 7 + .../guzzle/src/Exception/RequestException.php | 150 + .../guzzle/src/Exception/ServerException.php | 10 + .../Exception/TooManyRedirectsException.php | 7 + .../src/Exception/TransferException.php | 7 + .../guzzle/src/Handler/CurlFactory.php | 736 ++ .../src/Handler/CurlFactoryInterface.php | 25 + .../guzzle/src/Handler/CurlHandler.php | 49 + .../guzzle/src/Handler/CurlMultiHandler.php | 284 + .../guzzle/src/Handler/EasyHandle.php | 112 + .../guzzle/src/Handler/HeaderProcessor.php | 42 + .../guzzle/src/Handler/MockHandler.php | 212 + .../guzzlehttp/guzzle/src/Handler/Proxy.php | 51 + .../guzzle/src/Handler/StreamHandler.php | 621 ++ .../guzzlehttp/guzzle/src/HandlerStack.php | 275 + .../guzzle/src/MessageFormatter.php | 199 + .../guzzle/src/MessageFormatterInterface.php | 18 + .../guzzlehttp/guzzle/src/Middleware.php | 268 + vendor/vendor/guzzlehttp/guzzle/src/Pool.php | 125 + .../guzzle/src/PrepareBodyMiddleware.php | 105 + .../guzzle/src/RedirectMiddleware.php | 228 + .../guzzlehttp/guzzle/src/RequestOptions.php | 274 + .../guzzlehttp/guzzle/src/RetryMiddleware.php | 119 + .../guzzlehttp/guzzle/src/TransferStats.php | 133 + vendor/vendor/guzzlehttp/guzzle/src/Utils.php | 384 + .../guzzlehttp/guzzle/src/functions.php | 167 + .../guzzle/src/functions_include.php | 6 + .../vendor/guzzlehttp/promises/CHANGELOG.md | 180 + vendor/vendor/guzzlehttp/promises/LICENSE | 24 + vendor/vendor/guzzlehttp/promises/README.md | 559 ++ .../vendor/guzzlehttp/promises/composer.json | 58 + .../promises/src/AggregateException.php | 19 + .../promises/src/CancellationException.php | 12 + .../guzzlehttp/promises/src/Coroutine.php | 162 + .../vendor/guzzlehttp/promises/src/Create.php | 79 + .../vendor/guzzlehttp/promises/src/Each.php | 81 + .../guzzlehttp/promises/src/EachPromise.php | 248 + .../promises/src/FulfilledPromise.php | 89 + vendor/vendor/guzzlehttp/promises/src/Is.php | 40 + .../guzzlehttp/promises/src/Promise.php | 281 + .../promises/src/PromiseInterface.php | 91 + .../promises/src/PromisorInterface.php | 16 + .../promises/src/RejectedPromise.php | 95 + .../promises/src/RejectionException.php | 49 + .../guzzlehttp/promises/src/TaskQueue.php | 71 + .../promises/src/TaskQueueInterface.php | 24 + .../vendor/guzzlehttp/promises/src/Utils.php | 261 + vendor/vendor/guzzlehttp/psr7/CHANGELOG.md | 475 + vendor/vendor/guzzlehttp/psr7/LICENSE | 26 + vendor/vendor/guzzlehttp/psr7/README.md | 887 ++ vendor/vendor/guzzlehttp/psr7/composer.json | 93 + .../guzzlehttp/psr7/src/AppendStream.php | 248 + .../guzzlehttp/psr7/src/BufferStream.php | 147 + .../guzzlehttp/psr7/src/CachingStream.php | 153 + .../guzzlehttp/psr7/src/DroppingStream.php | 49 + .../src/Exception/MalformedUriException.php | 14 + .../vendor/guzzlehttp/psr7/src/FnStream.php | 180 + vendor/vendor/guzzlehttp/psr7/src/Header.php | 134 + .../guzzlehttp/psr7/src/HttpFactory.php | 94 + .../guzzlehttp/psr7/src/InflateStream.php | 37 + .../guzzlehttp/psr7/src/LazyOpenStream.php | 49 + .../guzzlehttp/psr7/src/LimitStream.php | 157 + vendor/vendor/guzzlehttp/psr7/src/Message.php | 246 + .../guzzlehttp/psr7/src/MessageTrait.php | 265 + .../vendor/guzzlehttp/psr7/src/MimeType.php | 1259 +++ .../guzzlehttp/psr7/src/MultipartStream.php | 165 + .../guzzlehttp/psr7/src/NoSeekStream.php | 28 + .../vendor/guzzlehttp/psr7/src/PumpStream.php | 179 + vendor/vendor/guzzlehttp/psr7/src/Query.php | 118 + vendor/vendor/guzzlehttp/psr7/src/Request.php | 159 + .../vendor/guzzlehttp/psr7/src/Response.php | 161 + vendor/vendor/guzzlehttp/psr7/src/Rfc7230.php | 23 + .../guzzlehttp/psr7/src/ServerRequest.php | 340 + vendor/vendor/guzzlehttp/psr7/src/Stream.php | 283 + .../psr7/src/StreamDecoratorTrait.php | 156 + .../guzzlehttp/psr7/src/StreamWrapper.php | 207 + .../guzzlehttp/psr7/src/UploadedFile.php | 211 + vendor/vendor/guzzlehttp/psr7/src/Uri.php | 743 ++ .../guzzlehttp/psr7/src/UriComparator.php | 52 + .../guzzlehttp/psr7/src/UriNormalizer.php | 220 + .../guzzlehttp/psr7/src/UriResolver.php | 211 + vendor/vendor/guzzlehttp/psr7/src/Utils.php | 477 + .../lizhichao/one-sm/.github/FUNDING.yml | 5 + .../lizhichao/one-sm/.github/workflows/sm.yml | 33 + vendor/vendor/lizhichao/one-sm/.gitignore | 7 + vendor/vendor/lizhichao/one-sm/.php_cs.dist | 65 + vendor/vendor/lizhichao/one-sm/README.md | 100 + vendor/vendor/lizhichao/one-sm/bench.php | 97 + vendor/vendor/lizhichao/one-sm/composer.json | 24 + vendor/vendor/lizhichao/one-sm/src/Sm3.php | 142 + vendor/vendor/lizhichao/one-sm/src/Sm4.php | 350 + vendor/vendor/lizhichao/one-sm/test.php | 3 + vendor/vendor/lizhichao/one-sm/tests/sm3.php | 41 + vendor/vendor/lizhichao/one-sm/tests/sm4.php | 79 + .../maennchen/zipstream-php/.phive/phars.xml | 4 + .../zipstream-php/.php-cs-fixer.dist.php | 71 + .../.phpdoc/template/base.html.twig | 15 + .../maennchen/zipstream-php/.tool-versions | 1 + vendor/vendor/maennchen/zipstream-php/LICENSE | 24 + .../vendor/maennchen/zipstream-php/README.md | 114 + .../maennchen/zipstream-php/composer.json | 76 + .../zipstream-php/guides/ContentLength.rst | 79 + .../zipstream-php/guides/FlySystem.rst | 33 + .../maennchen/zipstream-php/guides/Nginx.rst | 16 + .../zipstream-php/guides/Options.rst | 61 + .../zipstream-php/guides/PSR7Streams.rst | 18 + .../zipstream-php/guides/StreamOutput.rst | 33 + .../zipstream-php/guides/Symfony.rst | 126 + .../zipstream-php/guides/Varnish.rst | 22 + .../maennchen/zipstream-php/guides/index.rst | 85 + .../maennchen/zipstream-php/phpdoc.dist.xml | 39 + .../maennchen/zipstream-php/phpunit.xml.dist | 14 + .../vendor/maennchen/zipstream-php/psalm.xml | 53 + .../maennchen/zipstream-php/src/Bigint.php | 174 + .../zipstream-php/src/DeflateStream.php | 71 + .../maennchen/zipstream-php/src/Exception.php | 12 + .../src/Exception/EncodingException.php | 14 + .../src/Exception/FileNotFoundException.php | 23 + .../Exception/FileNotReadableException.php | 23 + .../IncompatibleOptionsException.php | 14 + .../src/Exception/OverflowException.php | 18 + .../Exception/StreamNotReadableException.php | 23 + .../maennchen/zipstream-php/src/File.php | 483 + .../zipstream-php/src/Option/Archive.php | 276 + .../zipstream-php/src/Option/File.php | 122 + .../zipstream-php/src/Option/Method.php | 21 + .../zipstream-php/src/Option/Version.php | 25 + .../maennchen/zipstream-php/src/Stream.php | 265 + .../maennchen/zipstream-php/src/ZipStream.php | 608 ++ .../zipstream-php/test/BigintTest.php | 66 + .../zipstream-php/test/ZipStreamTest.php | 650 ++ .../zipstream-php/test/bootstrap.php | 7 + .../test/bug/BugHonorFileTimeTest.php | 40 + .../complex/.github/workflows/main.yml | 153 + vendor/vendor/markbaker/complex/README.md | 173 + .../markbaker/complex/classes/src/Complex.php | 388 + .../complex/classes/src/Exception.php | 13 + .../complex/classes/src/Functions.php | 823 ++ .../complex/classes/src/Operations.php | 210 + vendor/vendor/markbaker/complex/composer.json | 40 + .../complex/examples/complexTest.php | 154 + .../complex/examples/testFunctions.php | 52 + .../complex/examples/testOperations.php | 35 + vendor/vendor/markbaker/complex/license.md | 25 + .../matrix/.github/workflows/main.yaml | 124 + vendor/vendor/markbaker/matrix/README.md | 215 + vendor/vendor/markbaker/matrix/buildPhar.php | 62 + .../markbaker/matrix/classes/src/Builder.php | 70 + .../src/Decomposition/Decomposition.php | 27 + .../matrix/classes/src/Decomposition/LU.php | 260 + .../matrix/classes/src/Decomposition/QR.php | 191 + .../matrix/classes/src/Div0Exception.php | 13 + .../matrix/classes/src/Exception.php | 13 + .../matrix/classes/src/Functions.php | 376 + .../markbaker/matrix/classes/src/Matrix.php | 423 + .../matrix/classes/src/Operations.php | 157 + .../matrix/classes/src/Operators/Addition.php | 68 + .../classes/src/Operators/DirectSum.php | 64 + .../matrix/classes/src/Operators/Division.php | 35 + .../classes/src/Operators/Multiplication.php | 86 + .../matrix/classes/src/Operators/Operator.php | 78 + .../classes/src/Operators/Subtraction.php | 68 + vendor/vendor/markbaker/matrix/composer.json | 52 + .../vendor/markbaker/matrix/examples/test.php | 33 + .../markbaker/matrix/infection.json.dist | 17 + vendor/vendor/markbaker/matrix/license.md | 25 + vendor/vendor/markbaker/matrix/phpstan.neon | 6 + vendor/vendor/monolog/monolog/CHANGELOG.md | 641 ++ vendor/vendor/monolog/monolog/LICENSE | 19 + vendor/vendor/monolog/monolog/README.md | 112 + vendor/vendor/monolog/monolog/UPGRADE.md | 72 + vendor/vendor/monolog/monolog/composer.json | 81 + .../Monolog/Attribute/AsMonologProcessor.php | 46 + .../monolog/src/Monolog/DateTimeImmutable.php | 51 + .../monolog/src/Monolog/ErrorHandler.php | 307 + .../Monolog/Formatter/ChromePHPFormatter.php | 83 + .../Monolog/Formatter/ElasticaFormatter.php | 89 + .../Formatter/ElasticsearchFormatter.php | 89 + .../Monolog/Formatter/FlowdockFormatter.php | 112 + .../Monolog/Formatter/FluentdFormatter.php | 88 + .../Monolog/Formatter/FormatterInterface.php | 42 + .../Formatter/GelfMessageFormatter.php | 175 + .../Formatter/GoogleCloudLoggingFormatter.php | 40 + .../src/Monolog/Formatter/HtmlFormatter.php | 142 + .../src/Monolog/Formatter/JsonFormatter.php | 228 + .../src/Monolog/Formatter/LineFormatter.php | 246 + .../src/Monolog/Formatter/LogglyFormatter.php | 45 + .../Monolog/Formatter/LogmaticFormatter.php | 66 + .../Monolog/Formatter/LogstashFormatter.php | 101 + .../Monolog/Formatter/MongoDBFormatter.php | 162 + .../Monolog/Formatter/NormalizerFormatter.php | 290 + .../src/Monolog/Formatter/ScalarFormatter.php | 51 + .../Monolog/Formatter/WildfireFormatter.php | 139 + .../src/Monolog/Handler/AbstractHandler.php | 112 + .../Handler/AbstractProcessingHandler.php | 69 + .../Monolog/Handler/AbstractSyslogHandler.php | 106 + .../src/Monolog/Handler/AmqpHandler.php | 171 + .../Monolog/Handler/BrowserConsoleHandler.php | 308 + .../src/Monolog/Handler/BufferHandler.php | 167 + .../src/Monolog/Handler/ChromePHPHandler.php | 196 + .../src/Monolog/Handler/CouchDBHandler.php | 77 + .../src/Monolog/Handler/CubeHandler.php | 167 + .../monolog/src/Monolog/Handler/Curl/Util.php | 71 + .../Monolog/Handler/DeduplicationHandler.php | 186 + .../Handler/DoctrineCouchDBHandler.php | 47 + .../src/Monolog/Handler/DynamoDbHandler.php | 104 + .../src/Monolog/Handler/ElasticaHandler.php | 129 + .../Monolog/Handler/ElasticsearchHandler.php | 219 + .../src/Monolog/Handler/ErrorLogHandler.php | 91 + .../Monolog/Handler/FallbackGroupHandler.php | 71 + .../src/Monolog/Handler/FilterHandler.php | 212 + .../ActivationStrategyInterface.php | 29 + .../ChannelLevelActivationStrategy.php | 77 + .../ErrorLevelActivationStrategy.php | 46 + .../Monolog/Handler/FingersCrossedHandler.php | 252 + .../src/Monolog/Handler/FirePHPHandler.php | 180 + .../src/Monolog/Handler/FleepHookHandler.php | 135 + .../src/Monolog/Handler/FlowdockHandler.php | 133 + .../Handler/FormattableHandlerInterface.php | 37 + .../Handler/FormattableHandlerTrait.php | 60 + .../src/Monolog/Handler/GelfHandler.php | 57 + .../src/Monolog/Handler/GroupHandler.php | 132 + .../monolog/src/Monolog/Handler/Handler.php | 62 + .../src/Monolog/Handler/HandlerInterface.php | 85 + .../src/Monolog/Handler/HandlerWrapper.php | 136 + .../src/Monolog/Handler/IFTTTHandler.php | 74 + .../src/Monolog/Handler/InsightOpsHandler.php | 76 + .../src/Monolog/Handler/LogEntriesHandler.php | 70 + .../src/Monolog/Handler/LogglyHandler.php | 160 + .../src/Monolog/Handler/LogmaticHandler.php | 106 + .../src/Monolog/Handler/MailHandler.php | 95 + .../src/Monolog/Handler/MandrillHandler.php | 83 + .../Handler/MissingExtensionException.php | 21 + .../src/Monolog/Handler/MongoDBHandler.php | 86 + .../Monolog/Handler/NativeMailerHandler.php | 174 + .../src/Monolog/Handler/NewRelicHandler.php | 199 + .../src/Monolog/Handler/NoopHandler.php | 40 + .../src/Monolog/Handler/NullHandler.php | 60 + .../src/Monolog/Handler/OverflowHandler.php | 149 + .../src/Monolog/Handler/PHPConsoleHandler.php | 263 + .../src/Monolog/Handler/ProcessHandler.php | 191 + .../Handler/ProcessableHandlerInterface.php | 44 + .../Handler/ProcessableHandlerTrait.php | 77 + .../src/Monolog/Handler/PsrHandler.php | 95 + .../src/Monolog/Handler/PushoverHandler.php | 246 + .../src/Monolog/Handler/RedisHandler.php | 101 + .../Monolog/Handler/RedisPubSubHandler.php | 67 + .../src/Monolog/Handler/RollbarHandler.php | 131 + .../Monolog/Handler/RotatingFileHandler.php | 212 + .../src/Monolog/Handler/SamplingHandler.php | 132 + .../src/Monolog/Handler/SendGridHandler.php | 102 + .../src/Monolog/Handler/Slack/SlackRecord.php | 387 + .../src/Monolog/Handler/SlackHandler.php | 256 + .../Monolog/Handler/SlackWebhookHandler.php | 130 + .../src/Monolog/Handler/SocketHandler.php | 448 + .../src/Monolog/Handler/SqsHandler.php | 62 + .../src/Monolog/Handler/StreamHandler.php | 256 + .../Monolog/Handler/SwiftMailerHandler.php | 115 + .../Monolog/Handler/SymfonyMailerHandler.php | 111 + .../src/Monolog/Handler/SyslogHandler.php | 68 + .../Monolog/Handler/SyslogUdp/UdpSocket.php | 88 + .../src/Monolog/Handler/SyslogUdpHandler.php | 150 + .../Monolog/Handler/TelegramBotHandler.php | 274 + .../src/Monolog/Handler/TestHandler.php | 231 + .../Handler/WebRequestRecognizerTrait.php | 24 + .../Handler/WhatFailureGroupHandler.php | 81 + .../Monolog/Handler/ZendMonitorHandler.php | 101 + .../monolog/monolog/src/Monolog/LogRecord.php | 34 + .../monolog/monolog/src/Monolog/Logger.php | 762 ++ .../src/Monolog/Processor/GitProcessor.php | 77 + .../Monolog/Processor/HostnameProcessor.php | 36 + .../Processor/IntrospectionProcessor.php | 123 + .../Processor/MemoryPeakUsageProcessor.php | 37 + .../src/Monolog/Processor/MemoryProcessor.php | 61 + .../Processor/MemoryUsageProcessor.php | 37 + .../Monolog/Processor/MercurialProcessor.php | 77 + .../Monolog/Processor/ProcessIdProcessor.php | 30 + .../Monolog/Processor/ProcessorInterface.php | 30 + .../Processor/PsrLogMessageProcessor.php | 88 + .../src/Monolog/Processor/TagProcessor.php | 61 + .../src/Monolog/Processor/UidProcessor.php | 59 + .../src/Monolog/Processor/WebProcessor.php | 111 + .../monolog/monolog/src/Monolog/Registry.php | 134 + .../src/Monolog/ResettableInterface.php | 34 + .../monolog/src/Monolog/SignalHandler.php | 120 + .../monolog/src/Monolog/Test/TestCase.php | 85 + .../monolog/monolog/src/Monolog/Utils.php | 284 + vendor/vendor/myclabs/php-enum/LICENSE | 18 + vendor/vendor/myclabs/php-enum/README.md | 196 + vendor/vendor/myclabs/php-enum/SECURITY.md | 11 + vendor/vendor/myclabs/php-enum/composer.json | 36 + vendor/vendor/myclabs/php-enum/src/Enum.php | 319 + .../php-enum/src/PHPUnit/Comparator.php | 54 + .../myclabs/php-enum/stubs/Stringable.php | 11 + vendor/vendor/nelexa/zip/.php-cs-fixer.php | 1766 ++++ vendor/vendor/nelexa/zip/.phpstorm.meta.php | 134 + vendor/vendor/nelexa/zip/LICENSE | 21 + vendor/vendor/nelexa/zip/README.RU.md | 884 ++ vendor/vendor/nelexa/zip/README.md | 915 ++ vendor/vendor/nelexa/zip/composer.json | 64 + .../nelexa/zip/src/Constants/DosAttrs.php | 39 + .../nelexa/zip/src/Constants/DosCodePage.php | 103 + .../src/Constants/GeneralPurposeBitFlag.php | 77 + .../nelexa/zip/src/Constants/UnixStat.php | 90 + .../zip/src/Constants/ZipCompressionLevel.php | 63 + .../src/Constants/ZipCompressionMethod.php | 97 + .../nelexa/zip/src/Constants/ZipConstants.php | 105 + .../zip/src/Constants/ZipEncryptionMethod.php | 76 + .../nelexa/zip/src/Constants/ZipOptions.php | 68 + .../nelexa/zip/src/Constants/ZipPlatform.php | 54 + .../nelexa/zip/src/Constants/ZipVersion.php | 87 + .../zip/src/Exception/Crc32Exception.php | 58 + .../Exception/InvalidArgumentException.php | 20 + .../zip/src/Exception/RuntimeException.php | 20 + .../Exception/ZipAuthenticationException.php | 19 + .../zip/src/Exception/ZipCryptoException.php | 20 + .../Exception/ZipEntryNotFoundException.php | 40 + .../nelexa/zip/src/Exception/ZipException.php | 21 + .../Exception/ZipUnsupportMethodException.php | 16 + .../Filter/Cipher/Pkware/PKCryptContext.php | 389 + .../Pkware/PKDecryptionStreamFilter.php | 116 + .../Pkware/PKEncryptionStreamFilter.php | 127 + .../Cipher/WinZipAes/WinZipAesContext.php | 141 + .../WinZipAesDecryptionStreamFilter.php | 184 + .../WinZipAesEncryptionStreamFilter.php | 149 + .../zip/src/IO/Stream/ResponseStream.php | 290 + .../src/IO/Stream/ZipEntryStreamWrapper.php | 309 + vendor/vendor/nelexa/zip/src/IO/ZipReader.php | 883 ++ vendor/vendor/nelexa/zip/src/IO/ZipWriter.php | 791 ++ .../nelexa/zip/src/Model/Data/ZipFileData.php | 78 + .../nelexa/zip/src/Model/Data/ZipNewData.php | 138 + .../zip/src/Model/Data/ZipSourceFileData.php | 146 + .../zip/src/Model/EndOfCentralDirectory.php | 71 + .../src/Model/Extra/ExtraFieldsCollection.php | 271 + .../Fields/AbstractUnicodeExtraField.php | 133 + .../Extra/Fields/ApkAlignmentExtraField.php | 156 + .../src/Model/Extra/Fields/AsiExtraField.php | 285 + .../Fields/ExtendedTimestampExtraField.php | 436 + .../Extra/Fields/JarMarkerExtraField.php | 117 + .../Model/Extra/Fields/NewUnixExtraField.php | 216 + .../src/Model/Extra/Fields/NtfsExtraField.php | 287 + .../Model/Extra/Fields/OldUnixExtraField.php | 295 + .../Extra/Fields/UnicodeCommentExtraField.php | 80 + .../Extra/Fields/UnicodePathExtraField.php | 81 + .../Extra/Fields/UnrecognizedExtraField.php | 108 + .../Extra/Fields/WinZipAesExtraField.php | 356 + .../Model/Extra/Fields/Zip64ExtraField.php | 277 + .../zip/src/Model/Extra/ZipExtraDriver.php | 103 + .../zip/src/Model/Extra/ZipExtraField.php | 67 + .../zip/src/Model/ImmutableZipContainer.php | 73 + .../nelexa/zip/src/Model/ZipContainer.php | 335 + .../vendor/nelexa/zip/src/Model/ZipData.php | 34 + .../vendor/nelexa/zip/src/Model/ZipEntry.php | 1172 +++ .../nelexa/zip/src/Model/ZipEntryMatcher.php | 194 + .../vendor/nelexa/zip/src/Util/CryptoUtil.php | 62 + .../nelexa/zip/src/Util/DateTimeConverter.php | 109 + .../nelexa/zip/src/Util/FileAttribUtil.php | 106 + .../vendor/nelexa/zip/src/Util/FilesUtil.php | 399 + .../Iterator/IgnoreFilesFilterIterator.php | 62 + .../IgnoreFilesRecursiveFilterIterator.php | 72 + .../vendor/nelexa/zip/src/Util/MathUtil.php | 36 + .../vendor/nelexa/zip/src/Util/StringUtil.php | 35 + vendor/vendor/nelexa/zip/src/ZipFile.php | 1944 ++++ vendor/vendor/overtrue/pinyin/LICENSE | 21 + vendor/vendor/overtrue/pinyin/README.md | 120 + vendor/vendor/overtrue/pinyin/composer.json | 33 + vendor/vendor/overtrue/pinyin/data/surnames | 84 + vendor/vendor/overtrue/pinyin/data/words_0 | 8003 ++++++++++++++++ vendor/vendor/overtrue/pinyin/data/words_1 | 8003 ++++++++++++++++ vendor/vendor/overtrue/pinyin/data/words_2 | 8003 ++++++++++++++++ vendor/vendor/overtrue/pinyin/data/words_3 | 8003 ++++++++++++++++ vendor/vendor/overtrue/pinyin/data/words_4 | 8003 ++++++++++++++++ vendor/vendor/overtrue/pinyin/data/words_5 | 2056 +++++ .../pinyin/src/DictLoaderInterface.php | 42 + .../overtrue/pinyin/src/FileDictLoader.php | 76 + .../pinyin/src/GeneratorFileDictLoader.php | 142 + .../pinyin/src/MemoryFileDictLoader.php | 96 + vendor/vendor/overtrue/pinyin/src/Pinyin.php | 309 + .../overtrue/socialite/.github/FUNDING.yml | 9 + vendor/vendor/overtrue/socialite/.gitignore | 9 + vendor/vendor/overtrue/socialite/.php_cs | 28 + vendor/vendor/overtrue/socialite/.travis.yml | 13 + vendor/vendor/overtrue/socialite/LICENSE.txt | 21 + vendor/vendor/overtrue/socialite/README.md | 267 + .../vendor/overtrue/socialite/composer.json | 34 + vendor/vendor/overtrue/socialite/phpunit.xml | 18 + .../overtrue/socialite/src/AccessToken.php | 84 + .../socialite/src/AccessTokenInterface.php | 25 + .../src/AuthorizeFailedException.php | 35 + .../vendor/overtrue/socialite/src/Config.php | 180 + .../socialite/src/FactoryInterface.php | 27 + .../overtrue/socialite/src/HasAttributes.php | 135 + .../src/InvalidArgumentException.php | 16 + .../socialite/src/InvalidStateException.php | 16 + .../socialite/src/ProviderInterface.php | 31 + .../src/Providers/AbstractProvider.php | 585 ++ .../socialite/src/Providers/BaiduProvider.php | 134 + .../src/Providers/DouYinProvider.php | 169 + .../src/Providers/DoubanProvider.php | 88 + .../src/Providers/FacebookProvider.php | 168 + .../src/Providers/FeiShuProvider.php | 192 + .../src/Providers/GitHubProvider.php | 126 + .../src/Providers/GoogleProvider.php | 119 + .../src/Providers/LinkedinProvider.php | 181 + .../src/Providers/OutlookProvider.php | 89 + .../socialite/src/Providers/QQProvider.php | 206 + .../src/Providers/TaobaoProvider.php | 242 + .../src/Providers/WeChatProvider.php | 234 + .../src/Providers/WeWorkProvider.php | 214 + .../socialite/src/Providers/WeiboProvider.php | 126 + .../socialite/src/SocialiteManager.php | 251 + vendor/vendor/overtrue/socialite/src/User.php | 204 + .../overtrue/socialite/src/UserInterface.php | 53 + .../src/WeChatComponentInterface.php | 32 + .../overtrue/socialite/tests/OAuthTest.php | 243 + .../tests/Providers/WeWorkProviderTest.php | 60 + .../overtrue/socialite/tests/UserTest.php | 45 + .../socialite/tests/WechatProviderTest.php | 137 + vendor/vendor/overtrue/wechat/CHANGELOG.md | 1401 +++ vendor/vendor/overtrue/wechat/CONTRIBUTING.md | 67 + vendor/vendor/overtrue/wechat/LICENSE | 22 + vendor/vendor/overtrue/wechat/README.md | 92 + vendor/vendor/overtrue/wechat/composer.json | 62 + .../wechat/src/BasicService/Application.php | 39 + .../BasicService/ContentSecurity/Client.php | 107 + .../ContentSecurity/ServiceProvider.php | 31 + .../wechat/src/BasicService/Jssdk/Client.php | 198 + .../BasicService/Jssdk/ServiceProvider.php | 33 + .../wechat/src/BasicService/Media/Client.php | 192 + .../BasicService/Media/ServiceProvider.php | 44 + .../wechat/src/BasicService/QrCode/Client.php | 115 + .../BasicService/QrCode/ServiceProvider.php | 31 + .../wechat/src/BasicService/Url/Client.php | 40 + .../src/BasicService/Url/ServiceProvider.php | 31 + vendor/vendor/overtrue/wechat/src/Factory.php | 53 + .../wechat/src/Kernel/AccessToken.php | 255 + .../overtrue/wechat/src/Kernel/BaseClient.php | 243 + .../wechat/src/Kernel/Clauses/Clause.php | 73 + .../overtrue/wechat/src/Kernel/Config.php | 23 + .../Kernel/Contracts/AccessTokenInterface.php | 31 + .../wechat/src/Kernel/Contracts/Arrayable.php | 29 + .../Contracts/EventHandlerInterface.php | 25 + .../src/Kernel/Contracts/MediaInterface.php | 22 + .../src/Kernel/Contracts/MessageInterface.php | 26 + .../src/Kernel/Decorators/FinallyResult.php | 35 + .../src/Kernel/Decorators/TerminateResult.php | 35 + .../overtrue/wechat/src/Kernel/Encryptor.php | 198 + .../Kernel/Events/AccessTokenRefreshed.php | 32 + .../Kernel/Events/ApplicationInitialized.php | 32 + .../src/Kernel/Events/HttpResponseCreated.php | 32 + .../Events/ServerGuardResponseCreated.php | 32 + .../Kernel/Exceptions/BadRequestException.php | 21 + .../Kernel/Exceptions/DecryptException.php | 16 + .../src/Kernel/Exceptions/Exception.php | 23 + .../src/Kernel/Exceptions/HttpException.php | 51 + .../Exceptions/InvalidArgumentException.php | 21 + .../Exceptions/InvalidConfigException.php | 21 + .../Kernel/Exceptions/RuntimeException.php | 21 + .../Exceptions/UnboundServiceException.php | 21 + .../overtrue/wechat/src/Kernel/Helpers.php | 57 + .../wechat/src/Kernel/Http/Response.php | 117 + .../wechat/src/Kernel/Http/StreamResponse.php | 78 + .../wechat/src/Kernel/Log/LogManager.php | 580 ++ .../wechat/src/Kernel/Messages/Article.php | 58 + .../wechat/src/Kernel/Messages/Card.php | 50 + .../src/Kernel/Messages/DeviceEvent.php | 40 + .../wechat/src/Kernel/Messages/DeviceText.php | 50 + .../wechat/src/Kernel/Messages/File.php | 25 + .../wechat/src/Kernel/Messages/Image.php | 27 + .../wechat/src/Kernel/Messages/Link.php | 36 + .../wechat/src/Kernel/Messages/Location.php | 38 + .../wechat/src/Kernel/Messages/Media.php | 66 + .../wechat/src/Kernel/Messages/Message.php | 187 + .../src/Kernel/Messages/MiniProgramPage.php | 31 + .../src/Kernel/Messages/MiniprogramNotice.php | 22 + .../wechat/src/Kernel/Messages/Music.php | 73 + .../wechat/src/Kernel/Messages/News.php | 65 + .../wechat/src/Kernel/Messages/NewsItem.php | 57 + .../wechat/src/Kernel/Messages/Raw.php | 51 + .../wechat/src/Kernel/Messages/ShortVideo.php | 30 + .../wechat/src/Kernel/Messages/TaskCard.php | 44 + .../wechat/src/Kernel/Messages/Text.php | 52 + .../wechat/src/Kernel/Messages/TextCard.php | 40 + .../wechat/src/Kernel/Messages/Transfer.php | 54 + .../wechat/src/Kernel/Messages/Video.php | 62 + .../wechat/src/Kernel/Messages/Voice.php | 37 + .../Providers/ConfigServiceProvider.php | 39 + .../EventDispatcherServiceProvider.php | 47 + .../Providers/ExtensionServiceProvider.php | 39 + .../Providers/HttpClientServiceProvider.php | 39 + .../Kernel/Providers/LogServiceProvider.php | 82 + .../Providers/RequestServiceProvider.php | 39 + .../wechat/src/Kernel/ServerGuard.php | 352 + .../wechat/src/Kernel/ServiceContainer.php | 164 + .../wechat/src/Kernel/Support/AES.php | 66 + .../wechat/src/Kernel/Support/Arr.php | 439 + .../src/Kernel/Support/ArrayAccessible.php | 66 + .../wechat/src/Kernel/Support/Collection.php | 417 + .../wechat/src/Kernel/Support/File.php | 135 + .../wechat/src/Kernel/Support/Helpers.php | 127 + .../wechat/src/Kernel/Support/Str.php | 193 + .../wechat/src/Kernel/Support/XML.php | 166 + .../src/Kernel/Traits/HasAttributes.php | 245 + .../src/Kernel/Traits/HasHttpRequests.php | 211 + .../src/Kernel/Traits/InteractsWithCache.php | 102 + .../wechat/src/Kernel/Traits/Observable.php | 278 + .../src/Kernel/Traits/ResponseCastable.php | 92 + .../wechat/src/MicroMerchant/Application.php | 168 + .../wechat/src/MicroMerchant/Base/Client.php | 117 + .../MicroMerchant/Base/ServiceProvider.php | 33 + .../src/MicroMerchant/Certficates/Client.php | 89 + .../Certficates/ServiceProvider.php | 33 + .../src/MicroMerchant/Kernel/BaseClient.php | 241 + .../Kernel/Exceptions/EncryptException.php | 23 + .../Exceptions/InvalidExtensionException.php | 23 + .../Exceptions/InvalidSignException.php | 23 + .../src/MicroMerchant/Material/Client.php | 69 + .../Material/ServiceProvider.php | 33 + .../wechat/src/MicroMerchant/Media/Client.php | 47 + .../MicroMerchant/Media/ServiceProvider.php | 44 + .../MicroMerchant/MerchantConfig/Client.php | 116 + .../MerchantConfig/ServiceProvider.php | 33 + .../src/MicroMerchant/Withdraw/Client.php | 67 + .../Withdraw/ServiceProvider.php | 33 + .../MiniProgram/ActivityMessage/Client.php | 79 + .../ActivityMessage/ServiceProvider.php | 28 + .../wechat/src/MiniProgram/AppCode/Client.php | 80 + .../MiniProgram/AppCode/ServiceProvider.php | 33 + .../wechat/src/MiniProgram/Application.php | 91 + .../src/MiniProgram/Auth/AccessToken.php | 39 + .../wechat/src/MiniProgram/Auth/Client.php | 41 + .../src/MiniProgram/Auth/ServiceProvider.php | 32 + .../wechat/src/MiniProgram/Base/Client.php | 53 + .../src/MiniProgram/Base/ServiceProvider.php | 33 + .../src/MiniProgram/Broadcast/Client.php | 206 + .../MiniProgram/Broadcast/ServiceProvider.php | 33 + .../CustomerService/ServiceProvider.php | 34 + .../src/MiniProgram/DataCube/Client.php | 140 + .../MiniProgram/DataCube/ServiceProvider.php | 28 + .../wechat/src/MiniProgram/Encryptor.php | 46 + .../wechat/src/MiniProgram/Express/Client.php | 129 + .../MiniProgram/Express/ServiceProvider.php | 33 + .../wechat/src/MiniProgram/Live/Client.php | 58 + .../src/MiniProgram/Live/ServiceProvider.php | 33 + .../src/MiniProgram/Mall/CartClient.php | 87 + .../src/MiniProgram/Mall/ForwardsMall.php | 48 + .../src/MiniProgram/Mall/MediaClient.php | 37 + .../src/MiniProgram/Mall/OrderClient.php | 75 + .../src/MiniProgram/Mall/ProductClient.php | 68 + .../src/MiniProgram/Mall/ServiceProvider.php | 44 + .../src/MiniProgram/NearbyPoi/Client.php | 110 + .../MiniProgram/NearbyPoi/ServiceProvider.php | 33 + .../src/MiniProgram/OCR/ServiceProvider.php | 34 + .../src/MiniProgram/OpenData/Client.php | 81 + .../MiniProgram/OpenData/ServiceProvider.php | 28 + .../wechat/src/MiniProgram/Plugin/Client.php | 67 + .../src/MiniProgram/Plugin/DevClient.php | 86 + .../MiniProgram/Plugin/ServiceProvider.php | 40 + .../src/MiniProgram/RealtimeLog/Client.php | 41 + .../RealtimeLog/ServiceProvider.php | 33 + .../wechat/src/MiniProgram/Search/Client.php | 35 + .../MiniProgram/Search/ServiceProvider.php | 33 + .../MiniProgram/Server/ServiceProvider.php | 42 + .../wechat/src/MiniProgram/Soter/Client.php | 37 + .../src/MiniProgram/Soter/ServiceProvider.php | 33 + .../MiniProgram/SubscribeMessage/Client.php | 192 + .../SubscribeMessage/ServiceProvider.php | 28 + .../MiniProgram/TemplateMessage/Client.php | 101 + .../TemplateMessage/ServiceProvider.php | 28 + .../src/MiniProgram/UniformMessage/Client.php | 140 + .../UniformMessage/ServiceProvider.php | 28 + .../src/OfficialAccount/Application.php | 93 + .../src/OfficialAccount/Auth/AccessToken.php | 36 + .../OfficialAccount/Auth/ServiceProvider.php | 33 + .../src/OfficialAccount/AutoReply/Client.php | 34 + .../AutoReply/ServiceProvider.php | 33 + .../src/OfficialAccount/Base/Client.php | 81 + .../OfficialAccount/Base/ServiceProvider.php | 33 + .../OfficialAccount/Broadcasting/Client.php | 359 + .../Broadcasting/MessageBuilder.php | 143 + .../Broadcasting/ServiceProvider.php | 33 + .../Card/BoardingPassClient.php | 31 + .../wechat/src/OfficialAccount/Card/Card.php | 52 + .../src/OfficialAccount/Card/Client.php | 422 + .../src/OfficialAccount/Card/CodeClient.php | 169 + .../src/OfficialAccount/Card/CoinClient.php | 106 + .../Card/GeneralCardClient.php | 64 + .../OfficialAccount/Card/GiftCardClient.php | 66 + .../Card/GiftCardOrderClient.php | 68 + .../Card/GiftCardPageClient.php | 92 + .../OfficialAccount/Card/InvoiceClient.php | 101 + .../src/OfficialAccount/Card/JssdkClient.php | 77 + .../Card/MeetingTicketClient.php | 31 + .../OfficialAccount/Card/MemberCardClient.php | 113 + .../Card/MovieTicketClient.php | 31 + .../OfficialAccount/Card/ServiceProvider.php | 89 + .../Card/SubMerchantClient.php | 112 + .../src/OfficialAccount/Comment/Client.php | 175 + .../Comment/ServiceProvider.php | 44 + .../CustomerService/Client.php | 208 + .../CustomerService/Messenger.php | 159 + .../CustomerService/ServiceProvider.php | 37 + .../CustomerService/SessionClient.php | 94 + .../src/OfficialAccount/DataCube/Client.php | 271 + .../DataCube/ServiceProvider.php | 33 + .../src/OfficialAccount/Device/Client.php | 217 + .../Device/ServiceProvider.php | 33 + .../src/OfficialAccount/Goods/Client.php | 101 + .../OfficialAccount/Goods/ServiceProvider.php | 33 + .../src/OfficialAccount/Guide/Client.php | 991 ++ .../OfficialAccount/Guide/ServiceProvider.php | 33 + .../src/OfficialAccount/Material/Client.php | 275 + .../Material/ServiceProvider.php | 44 + .../src/OfficialAccount/Menu/Client.php | 98 + .../OfficialAccount/Menu/ServiceProvider.php | 33 + .../OfficialAccount/OAuth/ServiceProvider.php | 66 + .../wechat/src/OfficialAccount/OCR/Client.php | 78 + .../OfficialAccount/OCR/ServiceProvider.php | 33 + .../wechat/src/OfficialAccount/POI/Client.php | 131 + .../OfficialAccount/POI/ServiceProvider.php | 33 + .../src/OfficialAccount/Semantic/Client.php | 41 + .../Semantic/ServiceProvider.php | 31 + .../src/OfficialAccount/Server/Guard.php | 27 + .../Server/Handlers/EchoStrHandler.php | 49 + .../Server/ServiceProvider.php | 46 + .../OfficialAccount/ShakeAround/Client.php | 76 + .../ShakeAround/DeviceClient.php | 165 + .../ShakeAround/GroupClient.php | 147 + .../ShakeAround/MaterialClient.php | 41 + .../ShakeAround/PageClient.php | 98 + .../ShakeAround/RelationClient.php | 78 + .../ShakeAround/ServiceProvider.php | 57 + .../ShakeAround/ShakeAround.php | 44 + .../ShakeAround/StatsClient.php | 102 + .../src/OfficialAccount/Store/Client.php | 188 + .../OfficialAccount/Store/ServiceProvider.php | 33 + .../SubscribeMessage/Client.php | 193 + .../SubscribeMessage/ServiceProvider.php | 28 + .../TemplateMessage/Client.php | 226 + .../TemplateMessage/ServiceProvider.php | 33 + .../OfficialAccount/User/ServiceProvider.php | 35 + .../src/OfficialAccount/User/TagClient.php | 157 + .../src/OfficialAccount/User/UserClient.php | 158 + .../src/OfficialAccount/WiFi/CardClient.php | 48 + .../src/OfficialAccount/WiFi/Client.php | 86 + .../src/OfficialAccount/WiFi/DeviceClient.php | 110 + .../OfficialAccount/WiFi/ServiceProvider.php | 45 + .../src/OfficialAccount/WiFi/ShopClient.php | 89 + .../wechat/src/OpenPlatform/Application.php | 199 + .../src/OpenPlatform/Auth/AccessToken.php | 46 + .../src/OpenPlatform/Auth/ServiceProvider.php | 37 + .../src/OpenPlatform/Auth/VerifyTicket.php | 83 + .../Authorizer/Aggregate/Account/Client.php | 96 + .../Aggregate/AggregateServiceProvider.php | 22 + .../Authorizer/Auth/AccessToken.php | 73 + .../Authorizer/MiniProgram/Account/Client.php | 79 + .../MiniProgram/Account/ServiceProvider.php | 25 + .../Authorizer/MiniProgram/Application.php | 50 + .../Authorizer/MiniProgram/Auth/Client.php | 59 + .../Authorizer/MiniProgram/Code/Client.php | 252 + .../MiniProgram/Code/ServiceProvider.php | 25 + .../Authorizer/MiniProgram/Domain/Client.php | 51 + .../MiniProgram/Domain/ServiceProvider.php | 25 + .../Authorizer/MiniProgram/Setting/Client.php | 247 + .../MiniProgram/Setting/ServiceProvider.php | 25 + .../Authorizer/MiniProgram/Tester/Client.php | 67 + .../MiniProgram/Tester/ServiceProvider.php | 25 + .../OfficialAccount/Account/Client.php | 71 + .../OfficialAccount/Application.php | 43 + .../OfficialAccount/MiniProgram/Client.php | 71 + .../MiniProgram/ServiceProvider.php | 25 + .../OAuth/ComponentDelegate.php | 52 + .../OpenPlatform/Authorizer/Server/Guard.php | 32 + .../wechat/src/OpenPlatform/Base/Client.php | 155 + .../src/OpenPlatform/Base/ServiceProvider.php | 33 + .../src/OpenPlatform/CodeTemplate/Client.php | 84 + .../CodeTemplate/ServiceProvider.php | 25 + .../src/OpenPlatform/Component/Client.php | 54 + .../Component/ServiceProvider.php | 25 + .../wechat/src/OpenPlatform/Server/Guard.php | 63 + .../Server/Handlers/Authorized.php | 30 + .../Server/Handlers/Unauthorized.php | 30 + .../Server/Handlers/UpdateAuthorized.php | 30 + .../Server/Handlers/VerifyTicketRefreshed.php | 50 + .../OpenPlatform/Server/ServiceProvider.php | 34 + .../wechat/src/OpenWork/Application.php | 81 + .../wechat/src/OpenWork/Auth/AccessToken.php | 50 + .../src/OpenWork/Auth/ServiceProvider.php | 33 + .../wechat/src/OpenWork/Corp/Client.php | 197 + .../src/OpenWork/Corp/ServiceProvider.php | 36 + .../src/OpenWork/MiniProgram/Client.php | 46 + .../OpenWork/MiniProgram/ServiceProvider.php | 31 + .../wechat/src/OpenWork/Provider/Client.php | 214 + .../src/OpenWork/Provider/ServiceProvider.php | 33 + .../wechat/src/OpenWork/Server/Guard.php | 63 + .../Server/Handlers/EchoStrHandler.php | 60 + .../src/OpenWork/Server/ServiceProvider.php | 56 + .../src/OpenWork/SuiteAuth/AccessToken.php | 54 + .../OpenWork/SuiteAuth/ServiceProvider.php | 37 + .../src/OpenWork/SuiteAuth/SuiteTicket.php | 76 + .../wechat/src/OpenWork/Work/Application.php | 36 + .../src/OpenWork/Work/Auth/AccessToken.php | 70 + .../wechat/src/Payment/Application.php | 190 + .../wechat/src/Payment/Base/Client.php | 50 + .../src/Payment/Base/ServiceProvider.php | 33 + .../wechat/src/Payment/Bill/Client.php | 44 + .../src/Payment/Bill/ServiceProvider.php | 33 + .../wechat/src/Payment/Contract/Client.php | 102 + .../src/Payment/Contract/ServiceProvider.php | 33 + .../wechat/src/Payment/Coupon/Client.php | 71 + .../src/Payment/Coupon/ServiceProvider.php | 33 + .../wechat/src/Payment/Fundflow/Client.php | 54 + .../src/Payment/Fundflow/ServiceProvider.php | 33 + .../wechat/src/Payment/Jssdk/Client.php | 136 + .../src/Payment/Jssdk/ServiceProvider.php | 33 + .../wechat/src/Payment/Kernel/BaseClient.php | 171 + .../Exceptions/InvalidSignException.php | 18 + .../Kernel/Exceptions/SandboxException.php | 18 + .../wechat/src/Payment/Merchant/Client.php | 85 + .../src/Payment/Merchant/ServiceProvider.php | 33 + .../wechat/src/Payment/Notify/Handler.php | 189 + .../wechat/src/Payment/Notify/Paid.php | 31 + .../wechat/src/Payment/Notify/Refunded.php | 46 + .../wechat/src/Payment/Notify/Scanned.php | 55 + .../wechat/src/Payment/Order/Client.php | 117 + .../src/Payment/Order/ServiceProvider.php | 33 + .../src/Payment/ProfitSharing/Client.php | 249 + .../Payment/ProfitSharing/ServiceProvider.php | 33 + .../wechat/src/Payment/Redpack/Client.php | 102 + .../src/Payment/Redpack/ServiceProvider.php | 33 + .../wechat/src/Payment/Refund/Client.php | 133 + .../src/Payment/Refund/ServiceProvider.php | 33 + .../wechat/src/Payment/Reverse/Client.php | 60 + .../src/Payment/Reverse/ServiceProvider.php | 33 + .../wechat/src/Payment/Sandbox/Client.php | 55 + .../src/Payment/Sandbox/ServiceProvider.php | 30 + .../wechat/src/Payment/Security/Client.php | 38 + .../src/Payment/Security/ServiceProvider.php | 33 + .../wechat/src/Payment/Transfer/Client.php | 114 + .../src/Payment/Transfer/ServiceProvider.php | 33 + .../overtrue/wechat/src/Work/Agent/Client.php | 63 + .../wechat/src/Work/Agent/ServiceProvider.php | 33 + .../overtrue/wechat/src/Work/Application.php | 105 + .../wechat/src/Work/Auth/AccessToken.php | 43 + .../wechat/src/Work/Auth/ServiceProvider.php | 33 + .../overtrue/wechat/src/Work/Base/Client.php | 34 + .../wechat/src/Work/Base/ServiceProvider.php | 30 + .../wechat/src/Work/Calendar/Client.php | 78 + .../src/Work/Calendar/ServiceProvider.php | 33 + .../overtrue/wechat/src/Work/Chat/Client.php | 73 + .../wechat/src/Work/Chat/ServiceProvider.php | 33 + .../wechat/src/Work/Department/Client.php | 76 + .../src/Work/Department/ServiceProvider.php | 33 + .../src/Work/ExternalContact/Client.php | 266 + .../Work/ExternalContact/ContactWayClient.php | 87 + .../Work/ExternalContact/MessageClient.php | 171 + .../src/Work/ExternalContact/SchoolClient.php | 454 + .../Work/ExternalContact/ServiceProvider.php | 49 + .../Work/ExternalContact/StatisticsClient.php | 43 + .../wechat/src/Work/GroupRobot/Client.php | 48 + .../src/Work/GroupRobot/Messages/Image.php | 38 + .../src/Work/GroupRobot/Messages/Markdown.php | 38 + .../src/Work/GroupRobot/Messages/Message.php | 23 + .../src/Work/GroupRobot/Messages/News.php | 47 + .../src/Work/GroupRobot/Messages/NewsItem.php | 45 + .../src/Work/GroupRobot/Messages/Text.php | 69 + .../wechat/src/Work/GroupRobot/Messenger.php | 125 + .../src/Work/GroupRobot/ServiceProvider.php | 37 + .../wechat/src/Work/Invoice/Client.php | 87 + .../src/Work/Invoice/ServiceProvider.php | 33 + .../overtrue/wechat/src/Work/Jssdk/Client.php | 186 + .../wechat/src/Work/Jssdk/ServiceProvider.php | 33 + .../overtrue/wechat/src/Work/Media/Client.php | 135 + .../wechat/src/Work/Media/ServiceProvider.php | 28 + .../overtrue/wechat/src/Work/Menu/Client.php | 59 + .../wechat/src/Work/Menu/ServiceProvider.php | 33 + .../wechat/src/Work/Message/Client.php | 59 + .../wechat/src/Work/Message/Messenger.php | 217 + .../src/Work/Message/ServiceProvider.php | 43 + .../src/Work/MiniProgram/Application.php | 41 + .../src/Work/MiniProgram/Auth/Client.php | 37 + .../wechat/src/Work/MsgAudit/Client.php | 82 + .../src/Work/MsgAudit/ServiceProvider.php | 33 + .../overtrue/wechat/src/Work/OA/Client.php | 149 + .../wechat/src/Work/OA/ServiceProvider.php | 33 + .../src/Work/OAuth/AccessTokenDelegate.php | 43 + .../wechat/src/Work/OAuth/ServiceProvider.php | 62 + .../wechat/src/Work/Schedule/Client.php | 93 + .../src/Work/Schedule/ServiceProvider.php | 33 + .../overtrue/wechat/src/Work/Server/Guard.php | 43 + .../Work/Server/Handlers/EchoStrHandler.php | 56 + .../src/Work/Server/ServiceProvider.php | 46 + .../overtrue/wechat/src/Work/User/Client.php | 223 + .../wechat/src/Work/User/ServiceProvider.php | 37 + .../wechat/src/Work/User/TagClient.php | 151 + .../phpspreadsheet/.readthedocs.yaml | 12 + .../phpoffice/phpspreadsheet/CHANGELOG.md | 1491 +++ .../phpoffice/phpspreadsheet/CONTRIBUTING.md | 45 + .../vendor/phpoffice/phpspreadsheet/LICENSE | 21 + .../vendor/phpoffice/phpspreadsheet/README.md | 144 + .../phpoffice/phpspreadsheet/composer.json | 118 + .../Calculation/ArrayEnabled.php | 133 + .../Calculation/BinaryComparison.php | 181 + .../Calculation/Calculation.php | 5799 ++++++++++++ .../PhpSpreadsheet/Calculation/Category.php | 21 + .../PhpSpreadsheet/Calculation/Database.php | 430 + .../Calculation/Database/DAverage.php | 46 + .../Calculation/Database/DCount.php | 47 + .../Calculation/Database/DCountA.php | 46 + .../Calculation/Database/DGet.php | 51 + .../Calculation/Database/DMax.php | 47 + .../Calculation/Database/DMin.php | 47 + .../Calculation/Database/DProduct.php | 46 + .../Calculation/Database/DStDev.php | 47 + .../Calculation/Database/DStDevP.php | 47 + .../Calculation/Database/DSum.php | 46 + .../Calculation/Database/DVar.php | 47 + .../Calculation/Database/DVarP.php | 47 + .../Calculation/Database/DatabaseAbstract.php | 192 + .../PhpSpreadsheet/Calculation/DateTime.php | 890 ++ .../Calculation/DateTimeExcel/Constants.php | 38 + .../Calculation/DateTimeExcel/Current.php | 59 + .../Calculation/DateTimeExcel/Date.php | 172 + .../Calculation/DateTimeExcel/DateParts.php | 151 + .../Calculation/DateTimeExcel/DateValue.php | 162 + .../Calculation/DateTimeExcel/Days.php | 62 + .../Calculation/DateTimeExcel/Days360.php | 118 + .../Calculation/DateTimeExcel/Difference.php | 158 + .../Calculation/DateTimeExcel/Helpers.php | 307 + .../Calculation/DateTimeExcel/Month.php | 103 + .../Calculation/DateTimeExcel/NetworkDays.php | 119 + .../Calculation/DateTimeExcel/Time.php | 130 + .../Calculation/DateTimeExcel/TimeParts.php | 132 + .../Calculation/DateTimeExcel/TimeValue.php | 83 + .../Calculation/DateTimeExcel/Week.php | 278 + .../Calculation/DateTimeExcel/WorkDay.php | 201 + .../Calculation/DateTimeExcel/YearFrac.php | 133 + .../Engine/ArrayArgumentHelper.php | 209 + .../Engine/ArrayArgumentProcessor.php | 175 + .../Calculation/Engine/BranchPruner.php | 223 + .../Engine/CyclicReferenceStack.php | 73 + .../Calculation/Engine/FormattedNumber.php | 147 + .../Calculation/Engine/Logger.php | 142 + .../Calculation/Engine/Operands/Operand.php | 10 + .../Engine/Operands/StructuredReference.php | 344 + .../Calculation/Engineering.php | 1425 +++ .../Calculation/Engineering/BesselI.php | 152 + .../Calculation/Engineering/BesselJ.php | 180 + .../Calculation/Engineering/BesselK.php | 135 + .../Calculation/Engineering/BesselY.php | 141 + .../Calculation/Engineering/BitWise.php | 277 + .../Calculation/Engineering/Compare.php | 82 + .../Calculation/Engineering/Complex.php | 121 + .../Engineering/ComplexFunctions.php | 611 ++ .../Engineering/ComplexOperations.php | 134 + .../Calculation/Engineering/Constants.php | 11 + .../Calculation/Engineering/ConvertBase.php | 71 + .../Calculation/Engineering/ConvertBinary.php | 163 + .../Engineering/ConvertDecimal.php | 213 + .../Calculation/Engineering/ConvertHex.php | 175 + .../Calculation/Engineering/ConvertOctal.php | 174 + .../Calculation/Engineering/ConvertUOM.php | 694 ++ .../Engineering/EngineeringValidations.php | 33 + .../Calculation/Engineering/Erf.php | 110 + .../Calculation/Engineering/ErfC.php | 82 + .../PhpSpreadsheet/Calculation/Exception.php | 28 + .../Calculation/ExceptionHandler.php | 24 + .../PhpSpreadsheet/Calculation/Financial.php | 1389 +++ .../Calculation/Financial/Amortization.php | 216 + .../CashFlow/CashFlowValidations.php | 53 + .../Financial/CashFlow/Constant/Periodic.php | 200 + .../CashFlow/Constant/Periodic/Cumulative.php | 142 + .../CashFlow/Constant/Periodic/Interest.php | 220 + .../Periodic/InterestAndPrincipal.php | 46 + .../CashFlow/Constant/Periodic/Payments.php | 116 + .../Calculation/Financial/CashFlow/Single.php | 109 + .../CashFlow/Variable/NonPeriodic.php | 325 + .../Financial/CashFlow/Variable/Periodic.php | 169 + .../Calculation/Financial/Constants.php | 19 + .../Calculation/Financial/Coupons.php | 426 + .../Calculation/Financial/Depreciation.php | 276 + .../Calculation/Financial/Dollar.php | 132 + .../Financial/FinancialValidations.php | 158 + .../Calculation/Financial/Helpers.php | 58 + .../Calculation/Financial/InterestRate.php | 73 + .../Financial/Securities/AccruedInterest.php | 159 + .../Financial/Securities/Price.php | 284 + .../Financial/Securities/Rates.php | 138 + .../Securities/SecurityValidations.php | 42 + .../Financial/Securities/Yields.php | 153 + .../Calculation/Financial/TreasuryBill.php | 148 + .../Calculation/FormulaParser.php | 630 ++ .../Calculation/FormulaToken.php | 150 + .../PhpSpreadsheet/Calculation/Functions.php | 677 ++ .../Calculation/Information/ErrorValue.php | 71 + .../Calculation/Information/ExcelError.php | 171 + .../Calculation/Information/Value.php | 328 + .../Calculation/Internal/MakeMatrix.php | 12 + .../Calculation/Internal/WildcardMatch.php | 39 + .../PhpSpreadsheet/Calculation/Logical.php | 303 + .../Calculation/Logical/Boolean.php | 36 + .../Calculation/Logical/Conditional.php | 211 + .../Calculation/Logical/Operations.php | 172 + .../PhpSpreadsheet/Calculation/LookupRef.php | 402 + .../Calculation/LookupRef/Address.php | 124 + .../Calculation/LookupRef/ExcelMatch.php | 282 + .../Calculation/LookupRef/Filter.php | 81 + .../Calculation/LookupRef/Formula.php | 43 + .../Calculation/LookupRef/HLookup.php | 121 + .../Calculation/LookupRef/Helpers.php | 74 + .../Calculation/LookupRef/Hyperlink.php | 41 + .../Calculation/LookupRef/Indirect.php | 130 + .../Calculation/LookupRef/Lookup.php | 106 + .../Calculation/LookupRef/LookupBase.php | 67 + .../LookupRef/LookupRefValidations.php | 40 + .../Calculation/LookupRef/Matrix.php | 143 + .../Calculation/LookupRef/Offset.php | 158 + .../LookupRef/RowColumnInformation.php | 209 + .../Calculation/LookupRef/Selection.php | 51 + .../Calculation/LookupRef/Sort.php | 342 + .../Calculation/LookupRef/Unique.php | 141 + .../Calculation/LookupRef/VLookup.php | 117 + .../PhpSpreadsheet/Calculation/MathTrig.php | 1446 +++ .../Calculation/MathTrig/Absolute.php | 37 + .../Calculation/MathTrig/Angle.php | 63 + .../Calculation/MathTrig/Arabic.php | 112 + .../Calculation/MathTrig/Base.php | 68 + .../Calculation/MathTrig/Ceiling.php | 167 + .../Calculation/MathTrig/Combinations.php | 91 + .../Calculation/MathTrig/Exp.php | 37 + .../Calculation/MathTrig/Factorial.php | 126 + .../Calculation/MathTrig/Floor.php | 195 + .../Calculation/MathTrig/Gcd.php | 70 + .../Calculation/MathTrig/Helpers.php | 130 + .../Calculation/MathTrig/IntClass.php | 40 + .../Calculation/MathTrig/Lcm.php | 111 + .../Calculation/MathTrig/Logarithms.php | 102 + .../Calculation/MathTrig/MatrixFunctions.php | 179 + .../Calculation/MathTrig/Operations.php | 162 + .../Calculation/MathTrig/Random.php | 99 + .../Calculation/MathTrig/Roman.php | 846 ++ .../Calculation/MathTrig/Round.php | 236 + .../Calculation/MathTrig/SeriesSum.php | 53 + .../Calculation/MathTrig/Sign.php | 38 + .../Calculation/MathTrig/Sqrt.php | 64 + .../Calculation/MathTrig/Subtotal.php | 135 + .../Calculation/MathTrig/Sum.php | 118 + .../Calculation/MathTrig/SumSquares.php | 143 + .../Calculation/MathTrig/Trig/Cosecant.php | 64 + .../Calculation/MathTrig/Trig/Cosine.php | 116 + .../Calculation/MathTrig/Trig/Cotangent.php | 118 + .../Calculation/MathTrig/Trig/Secant.php | 64 + .../Calculation/MathTrig/Trig/Sine.php | 116 + .../Calculation/MathTrig/Trig/Tangent.php | 161 + .../Calculation/MathTrig/Trunc.php | 36 + .../Calculation/Statistical.php | 1739 ++++ .../Calculation/Statistical/AggregateBase.php | 70 + .../Calculation/Statistical/Averages.php | 261 + .../Calculation/Statistical/Averages/Mean.php | 132 + .../Calculation/Statistical/Conditional.php | 316 + .../Calculation/Statistical/Confidence.php | 52 + .../Calculation/Statistical/Counts.php | 102 + .../Calculation/Statistical/Deviations.php | 142 + .../Statistical/Distributions/Beta.php | 286 + .../Statistical/Distributions/Binomial.php | 237 + .../Statistical/Distributions/ChiSquared.php | 335 + .../Distributions/DistributionValidations.php | 24 + .../Statistical/Distributions/Exponential.php | 55 + .../Statistical/Distributions/F.php | 64 + .../Statistical/Distributions/Fisher.php | 74 + .../Statistical/Distributions/Gamma.php | 151 + .../Statistical/Distributions/GammaBase.php | 390 + .../Distributions/HyperGeometric.php | 76 + .../Statistical/Distributions/LogNormal.php | 139 + .../Distributions/NewtonRaphson.php | 65 + .../Statistical/Distributions/Normal.php | 180 + .../Statistical/Distributions/Poisson.php | 66 + .../Distributions/StandardNormal.php | 153 + .../Statistical/Distributions/StudentT.php | 137 + .../Statistical/Distributions/Weibull.php | 57 + .../Calculation/Statistical/MaxMinBase.php | 22 + .../Calculation/Statistical/Maximum.php | 89 + .../Calculation/Statistical/Minimum.php | 89 + .../Calculation/Statistical/Percentiles.php | 206 + .../Calculation/Statistical/Permutations.php | 99 + .../Calculation/Statistical/Size.php | 97 + .../Statistical/StandardDeviations.php | 95 + .../Calculation/Statistical/Standardize.php | 49 + .../Statistical/StatisticalValidations.php | 45 + .../Calculation/Statistical/Trends.php | 434 + .../Calculation/Statistical/VarianceBase.php | 38 + .../Calculation/Statistical/Variances.php | 186 + .../PhpSpreadsheet/Calculation/TextData.php | 450 + .../Calculation/TextData/CaseConvert.php | 80 + .../Calculation/TextData/CharacterConvert.php | 81 + .../Calculation/TextData/Concatenate.php | 137 + .../Calculation/TextData/Extract.php | 280 + .../Calculation/TextData/Format.php | 323 + .../Calculation/TextData/Helpers.php | 91 + .../Calculation/TextData/Replace.php | 118 + .../Calculation/TextData/Search.php | 97 + .../Calculation/TextData/Text.php | 255 + .../Calculation/TextData/Trim.php | 52 + .../Calculation/Token/Stack.php | 129 + .../src/PhpSpreadsheet/Calculation/Web.php | 30 + .../Calculation/Web/Service.php | 75 + .../Calculation/locale/Translations.xlsx | Bin 0 -> 108747 bytes .../Calculation/locale/bg/config | 27 + .../Calculation/locale/bg/functions | 417 + .../Calculation/locale/cs/config | 20 + .../Calculation/locale/cs/functions | 520 ++ .../Calculation/locale/da/config | 20 + .../Calculation/locale/da/functions | 538 ++ .../Calculation/locale/de/config | 20 + .../Calculation/locale/de/functions | 534 ++ .../Calculation/locale/en/uk/config | 8 + .../Calculation/locale/es/config | 20 + .../Calculation/locale/es/functions | 538 ++ .../Calculation/locale/fi/config | 20 + .../Calculation/locale/fi/functions | 538 ++ .../Calculation/locale/fr/config | 20 + .../Calculation/locale/fr/functions | 525 ++ .../Calculation/locale/hu/config | 20 + .../Calculation/locale/hu/functions | 538 ++ .../Calculation/locale/it/config | 20 + .../Calculation/locale/it/functions | 537 ++ .../Calculation/locale/nb/config | 20 + .../Calculation/locale/nb/functions | 539 ++ .../Calculation/locale/nl/config | 20 + .../Calculation/locale/nl/functions | 537 ++ .../Calculation/locale/pl/config | 20 + .../Calculation/locale/pl/functions | 536 ++ .../Calculation/locale/pt/br/config | 20 + .../Calculation/locale/pt/br/functions | 528 ++ .../Calculation/locale/pt/config | 20 + .../Calculation/locale/pt/functions | 538 ++ .../Calculation/locale/ru/config | 20 + .../Calculation/locale/ru/functions | 555 ++ .../Calculation/locale/sv/config | 20 + .../Calculation/locale/sv/functions | 533 ++ .../Calculation/locale/tr/config | 20 + .../Calculation/locale/tr/functions | 537 ++ .../src/PhpSpreadsheet/Cell/AddressHelper.php | 177 + .../src/PhpSpreadsheet/Cell/AddressRange.php | 24 + .../Cell/AdvancedValueBinder.php | 211 + .../src/PhpSpreadsheet/Cell/Cell.php | 808 ++ .../src/PhpSpreadsheet/Cell/CellAddress.php | 166 + .../src/PhpSpreadsheet/Cell/CellRange.php | 136 + .../src/PhpSpreadsheet/Cell/ColumnRange.php | 125 + .../src/PhpSpreadsheet/Cell/Coordinate.php | 604 ++ .../src/PhpSpreadsheet/Cell/DataType.php | 89 + .../PhpSpreadsheet/Cell/DataValidation.php | 497 + .../src/PhpSpreadsheet/Cell/DataValidator.php | 122 + .../Cell/DefaultValueBinder.php | 83 + .../src/PhpSpreadsheet/Cell/Hyperlink.php | 113 + .../src/PhpSpreadsheet/Cell/IValueBinder.php | 16 + .../src/PhpSpreadsheet/Cell/IgnoredErrors.php | 66 + .../src/PhpSpreadsheet/Cell/RowRange.php | 93 + .../PhpSpreadsheet/Cell/StringValueBinder.php | 124 + .../PhpSpreadsheet/CellReferenceHelper.php | 131 + .../src/PhpSpreadsheet/Chart/Axis.php | 336 + .../src/PhpSpreadsheet/Chart/AxisText.php | 56 + .../src/PhpSpreadsheet/Chart/Chart.php | 814 ++ .../src/PhpSpreadsheet/Chart/ChartColor.php | 177 + .../src/PhpSpreadsheet/Chart/DataSeries.php | 419 + .../PhpSpreadsheet/Chart/DataSeriesValues.php | 595 ++ .../src/PhpSpreadsheet/Chart/Exception.php | 9 + .../src/PhpSpreadsheet/Chart/GridLines.php | 13 + .../src/PhpSpreadsheet/Chart/Layout.php | 577 ++ .../src/PhpSpreadsheet/Chart/Legend.php | 191 + .../src/PhpSpreadsheet/Chart/PlotArea.php | 211 + .../src/PhpSpreadsheet/Chart/Properties.php | 985 ++ .../Chart/Renderer/IRenderer.php | 22 + .../PhpSpreadsheet/Chart/Renderer/JpGraph.php | 40 + .../Chart/Renderer/JpGraphRendererBase.php | 873 ++ .../Chart/Renderer/MtJpGraphRenderer.php | 36 + .../Chart/Renderer/PHP Charting Libraries.txt | 23 + .../src/PhpSpreadsheet/Chart/Title.php | 115 + .../src/PhpSpreadsheet/Chart/TrendLine.php | 226 + .../src/PhpSpreadsheet/Collection/Cells.php | 478 + .../Collection/CellsFactory.php | 20 + .../Collection/Memory/SimpleCache1.php | 126 + .../Collection/Memory/SimpleCache3.php | 109 + .../src/PhpSpreadsheet/Comment.php | 362 + .../src/PhpSpreadsheet/DefinedName.php | 275 + .../PhpSpreadsheet/Document/Properties.php | 551 ++ .../src/PhpSpreadsheet/Document/Security.php | 152 + .../src/PhpSpreadsheet/Exception.php | 7 + .../src/PhpSpreadsheet/HashTable.php | 180 + .../src/PhpSpreadsheet/Helper/Dimension.php | 115 + .../src/PhpSpreadsheet/Helper/Downloader.php | 89 + .../src/PhpSpreadsheet/Helper/Handler.php | 46 + .../src/PhpSpreadsheet/Helper/Html.php | 859 ++ .../src/PhpSpreadsheet/Helper/Sample.php | 302 + .../src/PhpSpreadsheet/Helper/Size.php | 52 + .../src/PhpSpreadsheet/Helper/TextGrid.php | 139 + .../src/PhpSpreadsheet/IComparable.php | 13 + .../src/PhpSpreadsheet/IOFactory.php | 239 + .../src/PhpSpreadsheet/NamedFormula.php | 45 + .../src/PhpSpreadsheet/NamedRange.php | 55 + .../src/PhpSpreadsheet/Reader/BaseReader.php | 206 + .../src/PhpSpreadsheet/Reader/Csv.php | 735 ++ .../PhpSpreadsheet/Reader/Csv/Delimiter.php | 151 + .../Reader/DefaultReadFilter.php | 20 + .../src/PhpSpreadsheet/Reader/Exception.php | 9 + .../src/PhpSpreadsheet/Reader/Gnumeric.php | 604 ++ .../Reader/Gnumeric/PageSetup.php | 150 + .../Reader/Gnumeric/Properties.php | 164 + .../PhpSpreadsheet/Reader/Gnumeric/Styles.php | 281 + .../src/PhpSpreadsheet/Reader/Html.php | 1182 +++ .../src/PhpSpreadsheet/Reader/IReadFilter.php | 17 + .../src/PhpSpreadsheet/Reader/IReader.php | 143 + .../src/PhpSpreadsheet/Reader/Ods.php | 821 ++ .../PhpSpreadsheet/Reader/Ods/AutoFilter.php | 45 + .../PhpSpreadsheet/Reader/Ods/BaseLoader.php | 27 + .../Reader/Ods/DefinedNames.php | 66 + .../Reader/Ods/FormulaTranslator.php | 97 + .../Reader/Ods/PageSettings.php | 184 + .../PhpSpreadsheet/Reader/Ods/Properties.php | 136 + .../Reader/Security/XmlScanner.php | 202 + .../src/PhpSpreadsheet/Reader/Slk.php | 592 ++ .../src/PhpSpreadsheet/Reader/Xls.php | 8091 +++++++++++++++++ .../src/PhpSpreadsheet/Reader/Xls/Color.php | 36 + .../PhpSpreadsheet/Reader/Xls/Color/BIFF5.php | 77 + .../PhpSpreadsheet/Reader/Xls/Color/BIFF8.php | 77 + .../Reader/Xls/Color/BuiltIn.php | 31 + .../Reader/Xls/ConditionalFormatting.php | 49 + .../Reader/Xls/DataValidationHelper.php | 72 + .../PhpSpreadsheet/Reader/Xls/ErrorCode.php | 28 + .../src/PhpSpreadsheet/Reader/Xls/Escher.php | 624 ++ .../src/PhpSpreadsheet/Reader/Xls/MD5.php | 210 + .../src/PhpSpreadsheet/Reader/Xls/RC4.php | 63 + .../Reader/Xls/Style/Border.php | 37 + .../Reader/Xls/Style/CellAlignment.php | 50 + .../Reader/Xls/Style/CellFont.php | 39 + .../Reader/Xls/Style/FillPattern.php | 50 + .../src/PhpSpreadsheet/Reader/Xlsx.php | 2328 +++++ .../PhpSpreadsheet/Reader/Xlsx/AutoFilter.php | 159 + .../Reader/Xlsx/BaseParserClass.php | 22 + .../src/PhpSpreadsheet/Reader/Xlsx/Chart.php | 1565 ++++ .../Reader/Xlsx/ColumnAndRowAttributes.php | 223 + .../Reader/Xlsx/ConditionalStyles.php | 291 + .../Reader/Xlsx/DataValidations.php | 67 + .../PhpSpreadsheet/Reader/Xlsx/Hyperlinks.php | 66 + .../PhpSpreadsheet/Reader/Xlsx/Namespaces.php | 118 + .../PhpSpreadsheet/Reader/Xlsx/PageSetup.php | 172 + .../PhpSpreadsheet/Reader/Xlsx/Properties.php | 109 + .../Reader/Xlsx/SharedFormula.php | 26 + .../Reader/Xlsx/SheetViewOptions.php | 140 + .../PhpSpreadsheet/Reader/Xlsx/SheetViews.php | 156 + .../src/PhpSpreadsheet/Reader/Xlsx/Styles.php | 458 + .../Reader/Xlsx/TableReader.php | 113 + .../src/PhpSpreadsheet/Reader/Xlsx/Theme.php | 78 + .../Reader/Xlsx/WorkbookView.php | 153 + .../src/PhpSpreadsheet/Reader/Xml.php | 615 ++ .../Reader/Xml/DataValidations.php | 177 + .../Reader/Xml/PageSettings.php | 134 + .../PhpSpreadsheet/Reader/Xml/Properties.php | 158 + .../src/PhpSpreadsheet/Reader/Xml/Style.php | 107 + .../Reader/Xml/Style/Alignment.php | 58 + .../Reader/Xml/Style/Border.php | 98 + .../PhpSpreadsheet/Reader/Xml/Style/Fill.php | 63 + .../PhpSpreadsheet/Reader/Xml/Style/Font.php | 79 + .../Reader/Xml/Style/NumberFormat.php | 33 + .../Reader/Xml/Style/StyleBase.php | 30 + .../src/PhpSpreadsheet/ReferenceHelper.php | 1219 +++ .../PhpSpreadsheet/RichText/ITextElement.php | 36 + .../src/PhpSpreadsheet/RichText/RichText.php | 171 + .../src/PhpSpreadsheet/RichText/Run.php | 65 + .../PhpSpreadsheet/RichText/TextElement.php | 71 + .../src/PhpSpreadsheet/Settings.php | 223 + .../src/PhpSpreadsheet/Shared/CodePage.php | 114 + .../src/PhpSpreadsheet/Shared/Date.php | 556 ++ .../src/PhpSpreadsheet/Shared/Drawing.php | 177 + .../src/PhpSpreadsheet/Shared/Escher.php | 64 + .../Shared/Escher/DgContainer.php | 65 + .../Escher/DgContainer/SpgrContainer.php | 75 + .../DgContainer/SpgrContainer/SpContainer.php | 369 + .../Shared/Escher/DggContainer.php | 175 + .../Escher/DggContainer/BstoreContainer.php | 32 + .../DggContainer/BstoreContainer/BSE.php | 88 + .../DggContainer/BstoreContainer/BSE/Blip.php | 58 + .../src/PhpSpreadsheet/Shared/File.php | 197 + .../src/PhpSpreadsheet/Shared/Font.php | 675 ++ .../src/PhpSpreadsheet/Shared/IntOrFloat.php | 21 + .../src/PhpSpreadsheet/Shared/OLE.php | 568 ++ .../Shared/OLE/ChainedBlockStream.php | 200 + .../src/PhpSpreadsheet/Shared/OLE/PPS.php | 233 + .../PhpSpreadsheet/Shared/OLE/PPS/File.php | 64 + .../PhpSpreadsheet/Shared/OLE/PPS/Root.php | 425 + .../src/PhpSpreadsheet/Shared/OLERead.php | 350 + .../PhpSpreadsheet/Shared/PasswordHasher.php | 109 + .../PhpSpreadsheet/Shared/StringHelper.php | 684 ++ .../src/PhpSpreadsheet/Shared/TimeZone.php | 77 + .../PhpSpreadsheet/Shared/Trend/BestFit.php | 501 + .../Shared/Trend/ExponentialBestFit.php | 119 + .../Shared/Trend/LinearBestFit.php | 80 + .../Shared/Trend/LogarithmicBestFit.php | 87 + .../Shared/Trend/PolynomialBestFit.php | 219 + .../Shared/Trend/PowerBestFit.php | 109 + .../src/PhpSpreadsheet/Shared/Trend/Trend.php | 130 + .../src/PhpSpreadsheet/Shared/XMLWriter.php | 104 + .../src/PhpSpreadsheet/Shared/Xls.php | 277 + .../src/PhpSpreadsheet/Spreadsheet.php | 1705 ++++ .../src/PhpSpreadsheet/Style/Alignment.php | 545 ++ .../src/PhpSpreadsheet/Style/Border.php | 244 + .../src/PhpSpreadsheet/Style/Borders.php | 424 + .../src/PhpSpreadsheet/Style/Color.php | 427 + .../src/PhpSpreadsheet/Style/Conditional.php | 361 + .../ConditionalFormatting/CellMatcher.php | 313 + .../CellStyleAssessor.php | 45 + .../ConditionalDataBar.php | 93 + .../ConditionalDataBarExtension.php | 290 + .../ConditionalFormatValueObject.php | 83 + .../ConditionalFormattingRuleExtension.php | 226 + .../ConditionalFormatting/StyleMerger.php | 118 + .../Style/ConditionalFormatting/Wizard.php | 95 + .../ConditionalFormatting/Wizard/Blanks.php | 99 + .../Wizard/CellValue.php | 200 + .../Wizard/DateValue.php | 111 + .../Wizard/Duplicates.php | 78 + .../ConditionalFormatting/Wizard/Errors.php | 95 + .../Wizard/Expression.php | 75 + .../Wizard/TextValue.php | 164 + .../Wizard/WizardAbstract.php | 199 + .../Wizard/WizardInterface.php | 25 + .../src/PhpSpreadsheet/Style/Fill.php | 347 + .../src/PhpSpreadsheet/Style/Font.php | 854 ++ .../src/PhpSpreadsheet/Style/NumberFormat.php | 457 + .../Style/NumberFormat/BaseFormatter.php | 12 + .../Style/NumberFormat/DateFormatter.php | 182 + .../Style/NumberFormat/Formatter.php | 206 + .../Style/NumberFormat/FractionFormatter.php | 72 + .../Style/NumberFormat/NumberFormatter.php | 326 + .../NumberFormat/PercentageFormatter.php | 48 + .../Style/NumberFormat/Wizard/Accounting.php | 102 + .../Style/NumberFormat/Wizard/Currency.php | 112 + .../Style/NumberFormat/Wizard/Date.php | 125 + .../Style/NumberFormat/Wizard/DateTime.php | 50 + .../NumberFormat/Wizard/DateTimeWizard.php | 44 + .../Style/NumberFormat/Wizard/Duration.php | 153 + .../Style/NumberFormat/Wizard/Locale.php | 37 + .../Style/NumberFormat/Wizard/Number.php | 57 + .../Style/NumberFormat/Wizard/NumberBase.php | 80 + .../Style/NumberFormat/Wizard/Percentage.php | 40 + .../Style/NumberFormat/Wizard/Scientific.php | 33 + .../Style/NumberFormat/Wizard/Time.php | 105 + .../Style/NumberFormat/Wizard/Wizard.php | 8 + .../src/PhpSpreadsheet/Style/Protection.php | 198 + .../src/PhpSpreadsheet/Style/RgbTint.php | 175 + .../src/PhpSpreadsheet/Style/Style.php | 745 ++ .../src/PhpSpreadsheet/Style/Supervisor.php | 175 + .../src/PhpSpreadsheet/Theme.php | 269 + .../PhpSpreadsheet/Worksheet/AutoFilter.php | 1118 +++ .../Worksheet/AutoFilter/Column.php | 404 + .../Worksheet/AutoFilter/Column/Rule.php | 426 + .../src/PhpSpreadsheet/Worksheet/AutoFit.php | 51 + .../PhpSpreadsheet/Worksheet/BaseDrawing.php | 543 ++ .../PhpSpreadsheet/Worksheet/CellIterator.php | 94 + .../src/PhpSpreadsheet/Worksheet/Column.php | 121 + .../Worksheet/ColumnCellIterator.php | 205 + .../Worksheet/ColumnDimension.php | 137 + .../Worksheet/ColumnIterator.php | 174 + .../PhpSpreadsheet/Worksheet/Dimension.php | 134 + .../src/PhpSpreadsheet/Worksheet/Drawing.php | 272 + .../Worksheet/Drawing/Shadow.php | 287 + .../PhpSpreadsheet/Worksheet/HeaderFooter.php | 490 + .../Worksheet/HeaderFooterDrawing.php | 24 + .../src/PhpSpreadsheet/Worksheet/Iterator.php | 74 + .../Worksheet/MemoryDrawing.php | 356 + .../PhpSpreadsheet/Worksheet/PageBreak.php | 58 + .../PhpSpreadsheet/Worksheet/PageMargins.php | 229 + .../PhpSpreadsheet/Worksheet/PageSetup.php | 888 ++ .../PhpSpreadsheet/Worksheet/Protection.php | 517 ++ .../src/PhpSpreadsheet/Worksheet/Row.php | 120 + .../Worksheet/RowCellIterator.php | 195 + .../PhpSpreadsheet/Worksheet/RowDimension.php | 118 + .../PhpSpreadsheet/Worksheet/RowIterator.php | 163 + .../PhpSpreadsheet/Worksheet/SheetView.php | 178 + .../src/PhpSpreadsheet/Worksheet/Table.php | 585 ++ .../PhpSpreadsheet/Worksheet/Table/Column.php | 254 + .../Worksheet/Table/TableStyle.php | 230 + .../PhpSpreadsheet/Worksheet/Validations.php | 118 + .../PhpSpreadsheet/Worksheet/Worksheet.php | 3708 ++++++++ .../src/PhpSpreadsheet/Writer/BaseWriter.php | 148 + .../src/PhpSpreadsheet/Writer/Csv.php | 326 + .../src/PhpSpreadsheet/Writer/Exception.php | 9 + .../src/PhpSpreadsheet/Writer/Html.php | 1935 ++++ .../src/PhpSpreadsheet/Writer/IWriter.php | 98 + .../src/PhpSpreadsheet/Writer/Ods.php | 186 + .../PhpSpreadsheet/Writer/Ods/AutoFilters.php | 66 + .../Writer/Ods/Cell/Comment.php | 30 + .../PhpSpreadsheet/Writer/Ods/Cell/Style.php | 259 + .../src/PhpSpreadsheet/Writer/Ods/Content.php | 345 + .../src/PhpSpreadsheet/Writer/Ods/Formula.php | 120 + .../src/PhpSpreadsheet/Writer/Ods/Meta.php | 122 + .../src/PhpSpreadsheet/Writer/Ods/MetaInf.php | 60 + .../PhpSpreadsheet/Writer/Ods/Mimetype.php | 16 + .../Writer/Ods/NamedExpressions.php | 140 + .../PhpSpreadsheet/Writer/Ods/Settings.php | 152 + .../src/PhpSpreadsheet/Writer/Ods/Styles.php | 65 + .../PhpSpreadsheet/Writer/Ods/Thumbnails.php | 16 + .../PhpSpreadsheet/Writer/Ods/WriterPart.php | 35 + .../src/PhpSpreadsheet/Writer/Pdf.php | 251 + .../src/PhpSpreadsheet/Writer/Pdf/Dompdf.php | 60 + .../src/PhpSpreadsheet/Writer/Pdf/Mpdf.php | 93 + .../src/PhpSpreadsheet/Writer/Pdf/Tcpdf.php | 84 + .../src/PhpSpreadsheet/Writer/Xls.php | 924 ++ .../PhpSpreadsheet/Writer/Xls/BIFFwriter.php | 224 + .../Writer/Xls/CellDataValidation.php | 78 + .../Writer/Xls/ConditionalHelper.php | 76 + .../PhpSpreadsheet/Writer/Xls/ErrorCode.php | 28 + .../src/PhpSpreadsheet/Writer/Xls/Escher.php | 524 ++ .../src/PhpSpreadsheet/Writer/Xls/Font.php | 146 + .../src/PhpSpreadsheet/Writer/Xls/Parser.php | 1664 ++++ .../Writer/Xls/Style/CellAlignment.php | 59 + .../Writer/Xls/Style/CellBorder.php | 40 + .../Writer/Xls/Style/CellFill.php | 46 + .../Writer/Xls/Style/ColorMap.php | 90 + .../PhpSpreadsheet/Writer/Xls/Workbook.php | 1190 +++ .../PhpSpreadsheet/Writer/Xls/Worksheet.php | 3218 +++++++ .../src/PhpSpreadsheet/Writer/Xls/Xf.php | 415 + .../src/PhpSpreadsheet/Writer/Xlsx.php | 763 ++ .../PhpSpreadsheet/Writer/Xlsx/AutoFilter.php | 125 + .../src/PhpSpreadsheet/Writer/Xlsx/Chart.php | 1842 ++++ .../PhpSpreadsheet/Writer/Xlsx/Comments.php | 236 + .../Writer/Xlsx/ContentTypes.php | 272 + .../Writer/Xlsx/DefinedNames.php | 244 + .../PhpSpreadsheet/Writer/Xlsx/DocProps.php | 250 + .../PhpSpreadsheet/Writer/Xlsx/Drawing.php | 571 ++ .../Writer/Xlsx/FunctionPrefix.php | 194 + .../src/PhpSpreadsheet/Writer/Xlsx/Rels.php | 498 + .../PhpSpreadsheet/Writer/Xlsx/RelsRibbon.php | 46 + .../PhpSpreadsheet/Writer/Xlsx/RelsVBA.php | 40 + .../Writer/Xlsx/StringTable.php | 346 + .../src/PhpSpreadsheet/Writer/Xlsx/Style.php | 734 ++ .../src/PhpSpreadsheet/Writer/Xlsx/Table.php | 115 + .../src/PhpSpreadsheet/Writer/Xlsx/Theme.php | 744 ++ .../PhpSpreadsheet/Writer/Xlsx/Workbook.php | 214 + .../PhpSpreadsheet/Writer/Xlsx/Worksheet.php | 1462 +++ .../PhpSpreadsheet/Writer/Xlsx/WriterPart.php | 33 + .../src/PhpSpreadsheet/Writer/ZipStream0.php | 17 + .../src/PhpSpreadsheet/Writer/ZipStream2.php | 21 + .../src/PhpSpreadsheet/Writer/ZipStream3.php | 22 + .../pimple/pimple/.github/workflows/tests.yml | 47 + vendor/vendor/pimple/pimple/.gitignore | 4 + vendor/vendor/pimple/pimple/.php_cs.dist | 20 + vendor/vendor/pimple/pimple/CHANGELOG | 72 + vendor/vendor/pimple/pimple/LICENSE | 19 + vendor/vendor/pimple/pimple/README.rst | 332 + vendor/vendor/pimple/pimple/composer.json | 29 + vendor/vendor/pimple/pimple/phpunit.xml.dist | 18 + .../pimple/pimple/src/Pimple/Container.php | 305 + .../Exception/ExpectedInvokableException.php | 38 + .../Exception/FrozenServiceException.php | 45 + .../InvalidServiceIdentifierException.php | 45 + .../Exception/UnknownIdentifierException.php | 45 + .../pimple/src/Pimple/Psr11/Container.php | 55 + .../src/Pimple/Psr11/ServiceLocator.php | 75 + .../pimple/src/Pimple/ServiceIterator.php | 89 + .../src/Pimple/ServiceProviderInterface.php | 44 + .../src/Pimple/Tests/Fixtures/Invokable.php | 38 + .../Pimple/Tests/Fixtures/NonInvokable.php | 34 + .../Tests/Fixtures/PimpleServiceProvider.php | 52 + .../src/Pimple/Tests/Fixtures/Service.php | 35 + .../PimpleServiceProviderInterfaceTest.php | 77 + .../pimple/src/Pimple/Tests/PimpleTest.php | 610 ++ .../src/Pimple/Tests/Psr11/ContainerTest.php | 76 + .../Pimple/Tests/Psr11/ServiceLocatorTest.php | 131 + .../src/Pimple/Tests/ServiceIteratorTest.php | 52 + vendor/vendor/psr/cache/CHANGELOG.md | 16 + vendor/vendor/psr/cache/LICENSE.txt | 19 + vendor/vendor/psr/cache/README.md | 9 + vendor/vendor/psr/cache/composer.json | 25 + .../vendor/psr/cache/src/CacheException.php | 10 + .../psr/cache/src/CacheItemInterface.php | 105 + .../psr/cache/src/CacheItemPoolInterface.php | 138 + .../cache/src/InvalidArgumentException.php | 13 + vendor/vendor/psr/container/.gitignore | 3 + vendor/vendor/psr/container/LICENSE | 21 + vendor/vendor/psr/container/README.md | 13 + vendor/vendor/psr/container/composer.json | 27 + .../src/ContainerExceptionInterface.php | 12 + .../psr/container/src/ContainerInterface.php | 36 + .../src/NotFoundExceptionInterface.php | 10 + .../vendor/psr/event-dispatcher/.editorconfig | 15 + vendor/vendor/psr/event-dispatcher/.gitignore | 2 + vendor/vendor/psr/event-dispatcher/LICENSE | 21 + vendor/vendor/psr/event-dispatcher/README.md | 6 + .../vendor/psr/event-dispatcher/composer.json | 26 + .../src/EventDispatcherInterface.php | 21 + .../src/ListenerProviderInterface.php | 19 + .../src/StoppableEventInterface.php | 26 + vendor/vendor/psr/http-client/CHANGELOG.md | 31 + vendor/vendor/psr/http-client/LICENSE | 19 + vendor/vendor/psr/http-client/README.md | 12 + vendor/vendor/psr/http-client/composer.json | 30 + .../src/ClientExceptionInterface.php | 10 + .../psr/http-client/src/ClientInterface.php | 20 + .../src/NetworkExceptionInterface.php | 24 + .../src/RequestExceptionInterface.php | 24 + vendor/vendor/psr/http-factory/LICENSE | 21 + vendor/vendor/psr/http-factory/README.md | 12 + vendor/vendor/psr/http-factory/composer.json | 35 + .../src/RequestFactoryInterface.php | 18 + .../src/ResponseFactoryInterface.php | 18 + .../src/ServerRequestFactoryInterface.php | 24 + .../src/StreamFactoryInterface.php | 45 + .../src/UploadedFileFactoryInterface.php | 34 + .../http-factory/src/UriFactoryInterface.php | 17 + vendor/vendor/psr/http-message/CHANGELOG.md | 36 + vendor/vendor/psr/http-message/LICENSE | 19 + vendor/vendor/psr/http-message/README.md | 16 + vendor/vendor/psr/http-message/composer.json | 26 + .../psr/http-message/docs/PSR7-Interfaces.md | 130 + .../psr/http-message/docs/PSR7-Usage.md | 159 + .../psr/http-message/src/MessageInterface.php | 189 + .../psr/http-message/src/RequestInterface.php | 131 + .../http-message/src/ResponseInterface.php | 70 + .../src/ServerRequestInterface.php | 263 + .../psr/http-message/src/StreamInterface.php | 160 + .../src/UploadedFileInterface.php | 125 + .../psr/http-message/src/UriInterface.php | 326 + vendor/vendor/psr/log/LICENSE | 19 + .../vendor/psr/log/Psr/Log/AbstractLogger.php | 128 + .../log/Psr/Log/InvalidArgumentException.php | 7 + vendor/vendor/psr/log/Psr/Log/LogLevel.php | 18 + .../psr/log/Psr/Log/LoggerAwareInterface.php | 18 + .../psr/log/Psr/Log/LoggerAwareTrait.php | 26 + .../psr/log/Psr/Log/LoggerInterface.php | 125 + vendor/vendor/psr/log/Psr/Log/LoggerTrait.php | 142 + vendor/vendor/psr/log/Psr/Log/NullLogger.php | 30 + .../vendor/psr/log/Psr/Log/Test/DummyTest.php | 18 + .../log/Psr/Log/Test/LoggerInterfaceTest.php | 138 + .../psr/log/Psr/Log/Test/TestLogger.php | 147 + vendor/vendor/psr/log/README.md | 58 + vendor/vendor/psr/log/composer.json | 26 + vendor/vendor/psr/simple-cache/.editorconfig | 12 + vendor/vendor/psr/simple-cache/LICENSE.md | 21 + vendor/vendor/psr/simple-cache/README.md | 8 + vendor/vendor/psr/simple-cache/composer.json | 25 + .../psr/simple-cache/src/CacheException.php | 10 + .../psr/simple-cache/src/CacheInterface.php | 114 + .../src/InvalidArgumentException.php | 13 + vendor/vendor/ralouphie/getallheaders/LICENSE | 21 + .../vendor/ralouphie/getallheaders/README.md | 27 + .../ralouphie/getallheaders/composer.json | 26 + .../getallheaders/src/getallheaders.php | 46 + .../symfony/cache-contracts/CHANGELOG.md | 5 + .../cache-contracts/CacheInterface.php | 57 + .../symfony/cache-contracts/CacheTrait.php | 80 + .../cache-contracts/CallbackInterface.php | 30 + .../symfony/cache-contracts/ItemInterface.php | 65 + vendor/vendor/symfony/cache-contracts/LICENSE | 19 + .../vendor/symfony/cache-contracts/README.md | 9 + .../TagAwareCacheInterface.php | 38 + .../symfony/cache-contracts/composer.json | 38 + .../symfony/cache/Adapter/AbstractAdapter.php | 208 + .../cache/Adapter/AbstractTagAwareAdapter.php | 330 + .../cache/Adapter/AdapterInterface.php | 47 + .../symfony/cache/Adapter/ApcuAdapter.php | 138 + .../symfony/cache/Adapter/ArrayAdapter.php | 407 + .../symfony/cache/Adapter/ChainAdapter.php | 342 + .../cache/Adapter/CouchbaseBucketAdapter.php | 252 + .../Adapter/CouchbaseCollectionAdapter.php | 222 + .../symfony/cache/Adapter/DoctrineAdapter.php | 110 + .../cache/Adapter/DoctrineDbalAdapter.php | 448 + .../cache/Adapter/FilesystemAdapter.php | 29 + .../Adapter/FilesystemTagAwareAdapter.php | 239 + .../cache/Adapter/MemcachedAdapter.php | 347 + .../symfony/cache/Adapter/NullAdapter.php | 152 + .../cache/Adapter/ParameterNormalizer.php | 35 + .../symfony/cache/Adapter/PdoAdapter.php | 616 ++ .../symfony/cache/Adapter/PhpArrayAdapter.php | 435 + .../symfony/cache/Adapter/PhpFilesAdapter.php | 330 + .../symfony/cache/Adapter/ProxyAdapter.php | 268 + .../symfony/cache/Adapter/Psr16Adapter.php | 86 + .../symfony/cache/Adapter/RedisAdapter.php | 32 + .../cache/Adapter/RedisTagAwareAdapter.php | 325 + .../symfony/cache/Adapter/TagAwareAdapter.php | 428 + .../Adapter/TagAwareAdapterInterface.php | 33 + .../cache/Adapter/TraceableAdapter.php | 295 + .../Adapter/TraceableTagAwareAdapter.php | 38 + vendor/vendor/symfony/cache/CHANGELOG.md | 108 + vendor/vendor/symfony/cache/CacheItem.php | 192 + .../DataCollector/CacheDataCollector.php | 183 + .../CacheCollectorPass.php | 94 + .../CachePoolClearerPass.php | 52 + .../DependencyInjection/CachePoolPass.php | 274 + .../CachePoolPrunerPass.php | 64 + .../vendor/symfony/cache/DoctrineProvider.php | 124 + .../cache/Exception/CacheException.php | 25 + .../Exception/InvalidArgumentException.php | 25 + .../cache/Exception/LogicException.php | 25 + vendor/vendor/symfony/cache/LICENSE | 19 + vendor/vendor/symfony/cache/LockRegistry.php | 165 + .../cache/Marshaller/DefaultMarshaller.php | 104 + .../cache/Marshaller/DeflateMarshaller.php | 53 + .../cache/Marshaller/MarshallerInterface.php | 40 + .../cache/Marshaller/SodiumMarshaller.php | 80 + .../cache/Marshaller/TagAwareMarshaller.php | 89 + .../Messenger/EarlyExpirationDispatcher.php | 61 + .../Messenger/EarlyExpirationHandler.php | 81 + .../Messenger/EarlyExpirationMessage.php | 97 + .../symfony/cache/PruneableInterface.php | 23 + vendor/vendor/symfony/cache/Psr16Cache.php | 289 + vendor/vendor/symfony/cache/README.md | 19 + .../symfony/cache/ResettableInterface.php | 21 + .../cache/Traits/AbstractAdapterTrait.php | 427 + .../symfony/cache/Traits/ContractsTrait.php | 109 + .../cache/Traits/FilesystemCommonTrait.php | 210 + .../symfony/cache/Traits/FilesystemTrait.php | 124 + .../symfony/cache/Traits/ProxyTrait.php | 43 + .../cache/Traits/RedisClusterNodeProxy.php | 53 + .../cache/Traits/RedisClusterProxy.php | 63 + .../symfony/cache/Traits/RedisProxy.php | 65 + .../symfony/cache/Traits/RedisTrait.php | 660 ++ vendor/vendor/symfony/cache/composer.json | 60 + .../deprecation-contracts/CHANGELOG.md | 5 + .../symfony/deprecation-contracts/LICENSE | 19 + .../symfony/deprecation-contracts/README.md | 26 + .../deprecation-contracts/composer.json | 35 + .../deprecation-contracts/function.php | 27 + .../event-dispatcher-contracts/CHANGELOG.md | 5 + .../event-dispatcher-contracts/Event.php | 54 + .../EventDispatcherInterface.php | 31 + .../event-dispatcher-contracts/LICENSE | 19 + .../event-dispatcher-contracts/README.md | 9 + .../event-dispatcher-contracts/composer.json | 38 + .../Attribute/AsEventListener.php | 29 + .../symfony/event-dispatcher/CHANGELOG.md | 91 + .../Debug/TraceableEventDispatcher.php | 366 + .../Debug/WrappedListener.php | 129 + .../AddEventAliasesPass.php | 46 + .../RegisterListenersPass.php | 242 + .../event-dispatcher/EventDispatcher.php | 280 + .../EventDispatcherInterface.php | 70 + .../EventSubscriberInterface.php | 49 + .../symfony/event-dispatcher/GenericEvent.php | 182 + .../ImmutableEventDispatcher.php | 91 + .../vendor/symfony/event-dispatcher/LICENSE | 19 + .../LegacyEventDispatcherProxy.php | 31 + .../vendor/symfony/event-dispatcher/README.md | 15 + .../symfony/event-dispatcher/composer.json | 52 + vendor/vendor/symfony/finder/CHANGELOG.md | 87 + .../symfony/finder/Comparator/Comparator.php | 117 + .../finder/Comparator/DateComparator.php | 50 + .../finder/Comparator/NumberComparator.php | 78 + .../Exception/AccessDeniedException.php | 19 + .../Exception/DirectoryNotFoundException.php | 19 + vendor/vendor/symfony/finder/Finder.php | 806 ++ vendor/vendor/symfony/finder/Gitignore.php | 93 + vendor/vendor/symfony/finder/Glob.php | 111 + .../finder/Iterator/CustomFilterIterator.php | 64 + .../Iterator/DateRangeFilterIterator.php | 61 + .../Iterator/DepthRangeFilterIterator.php | 51 + .../ExcludeDirectoryFilterIterator.php | 97 + .../Iterator/FileTypeFilterIterator.php | 56 + .../Iterator/FilecontentFilterIterator.php | 61 + .../Iterator/FilenameFilterIterator.php | 50 + .../symfony/finder/Iterator/LazyIterator.php | 32 + .../Iterator/MultiplePcreFilterIterator.php | 117 + .../finder/Iterator/PathFilterIterator.php | 59 + .../Iterator/RecursiveDirectoryIterator.php | 158 + .../Iterator/SizeRangeFilterIterator.php | 60 + .../finder/Iterator/SortableIterator.php | 104 + .../Iterator/VcsIgnoredFilterIterator.php | 151 + vendor/vendor/symfony/finder/LICENSE | 19 + vendor/vendor/symfony/finder/README.md | 14 + vendor/vendor/symfony/finder/SplFileInfo.php | 88 + vendor/vendor/symfony/finder/composer.json | 30 + .../symfony/http-foundation/AcceptHeader.php | 168 + .../http-foundation/AcceptHeaderItem.php | 177 + .../http-foundation/BinaryFileResponse.php | 418 + .../symfony/http-foundation/CHANGELOG.md | 296 + .../vendor/symfony/http-foundation/Cookie.php | 422 + .../Exception/BadRequestException.php | 19 + .../Exception/ConflictingHeadersException.php | 21 + .../Exception/JsonException.php | 21 + .../Exception/RequestExceptionInterface.php | 21 + .../Exception/SessionNotFoundException.php | 27 + .../SuspiciousOperationException.php | 20 + .../ExpressionRequestMatcher.php | 47 + .../File/Exception/AccessDeniedException.php | 25 + .../Exception/CannotWriteFileException.php | 21 + .../File/Exception/ExtensionFileException.php | 21 + .../File/Exception/FileException.php | 21 + .../File/Exception/FileNotFoundException.php | 25 + .../File/Exception/FormSizeFileException.php | 21 + .../File/Exception/IniSizeFileException.php | 21 + .../File/Exception/NoFileException.php | 21 + .../File/Exception/NoTmpDirFileException.php | 21 + .../File/Exception/PartialFileException.php | 21 + .../Exception/UnexpectedTypeException.php | 20 + .../File/Exception/UploadException.php | 21 + .../symfony/http-foundation/File/File.php | 152 + .../symfony/http-foundation/File/Stream.php | 31 + .../http-foundation/File/UploadedFile.php | 290 + .../symfony/http-foundation/FileBag.php | 140 + .../symfony/http-foundation/HeaderBag.php | 295 + .../symfony/http-foundation/HeaderUtils.php | 298 + .../symfony/http-foundation/InputBag.php | 113 + .../symfony/http-foundation/IpUtils.php | 216 + .../symfony/http-foundation/JsonResponse.php | 221 + vendor/vendor/symfony/http-foundation/LICENSE | 19 + .../symfony/http-foundation/ParameterBag.php | 228 + .../vendor/symfony/http-foundation/README.md | 28 + .../AbstractRequestRateLimiter.php | 71 + .../RequestRateLimiterInterface.php | 30 + .../http-foundation/RedirectResponse.php | 110 + .../symfony/http-foundation/Request.php | 2188 +++++ .../http-foundation/RequestMatcher.php | 196 + .../RequestMatcherInterface.php | 27 + .../symfony/http-foundation/RequestStack.php | 128 + .../symfony/http-foundation/Response.php | 1288 +++ .../http-foundation/ResponseHeaderBag.php | 291 + .../symfony/http-foundation/ServerBag.php | 99 + .../Session/Attribute/AttributeBag.php | 152 + .../Attribute/AttributeBagInterface.php | 61 + .../Attribute/NamespacedAttributeBag.php | 161 + .../Session/Flash/AutoExpireFlashBag.php | 161 + .../Session/Flash/FlashBag.php | 152 + .../Session/Flash/FlashBagInterface.php | 88 + .../http-foundation/Session/Session.php | 285 + .../Session/SessionBagInterface.php | 46 + .../Session/SessionBagProxy.php | 95 + .../Session/SessionFactory.php | 40 + .../Session/SessionFactoryInterface.php | 20 + .../Session/SessionInterface.php | 166 + .../http-foundation/Session/SessionUtils.php | 59 + .../Handler/AbstractSessionHandler.php | 155 + .../Storage/Handler/IdentityMarshaller.php | 42 + .../Handler/MarshallingSessionHandler.php | 108 + .../Handler/MemcachedSessionHandler.php | 135 + .../Handler/MigratingSessionHandler.php | 139 + .../Storage/Handler/MongoDbSessionHandler.php | 193 + .../Handler/NativeFileSessionHandler.php | 59 + .../Storage/Handler/NullSessionHandler.php | 80 + .../Storage/Handler/PdoSessionHandler.php | 943 ++ .../Storage/Handler/RedisSessionHandler.php | 137 + .../Storage/Handler/SessionHandlerFactory.php | 103 + .../Storage/Handler/StrictSessionHandler.php | 118 + .../Session/Storage/MetadataBag.php | 167 + .../Storage/MockArraySessionStorage.php | 249 + .../Storage/MockFileSessionStorage.php | 160 + .../Storage/MockFileSessionStorageFactory.php | 42 + .../Session/Storage/NativeSessionStorage.php | 507 ++ .../Storage/NativeSessionStorageFactory.php | 49 + .../Storage/PhpBridgeSessionStorage.php | 64 + .../PhpBridgeSessionStorageFactory.php | 47 + .../Session/Storage/Proxy/AbstractProxy.php | 118 + .../Storage/Proxy/SessionHandlerProxy.php | 111 + .../Session/Storage/ServiceSessionFactory.php | 38 + .../SessionStorageFactoryInterface.php | 25 + .../Storage/SessionStorageInterface.php | 131 + .../http-foundation/StreamedResponse.php | 139 + .../Constraint/RequestAttributeValueSame.php | 55 + .../Constraint/ResponseCookieValueSame.php | 85 + .../Test/Constraint/ResponseFormatSame.php | 71 + .../Test/Constraint/ResponseHasCookie.php | 77 + .../Test/Constraint/ResponseHasHeader.php | 53 + .../Test/Constraint/ResponseHeaderSame.php | 55 + .../Test/Constraint/ResponseIsRedirected.php | 56 + .../Test/Constraint/ResponseIsSuccessful.php | 56 + .../Constraint/ResponseIsUnprocessable.php | 56 + .../Constraint/ResponseStatusCodeSame.php | 63 + .../symfony/http-foundation/UrlHelper.php | 118 + .../symfony/http-foundation/composer.json | 43 + .../vendor/symfony/polyfill-mbstring/LICENSE | 19 + .../symfony/polyfill-mbstring/Mbstring.php | 1045 +++ .../symfony/polyfill-mbstring/README.md | 13 + .../Resources/unidata/caseFolding.php | 119 + .../Resources/unidata/lowerCase.php | 1397 +++ .../Resources/unidata/titleCaseRegexp.php | 5 + .../Resources/unidata/upperCase.php | 1489 +++ .../symfony/polyfill-mbstring/bootstrap.php | 172 + .../symfony/polyfill-mbstring/bootstrap80.php | 167 + .../symfony/polyfill-mbstring/composer.json | 38 + vendor/vendor/symfony/polyfill-php73/LICENSE | 19 + .../vendor/symfony/polyfill-php73/Php73.php | 43 + .../vendor/symfony/polyfill-php73/README.md | 18 + .../Resources/stubs/JsonException.php | 16 + .../symfony/polyfill-php73/bootstrap.php | 31 + .../symfony/polyfill-php73/composer.json | 33 + vendor/vendor/symfony/polyfill-php80/LICENSE | 19 + .../vendor/symfony/polyfill-php80/Php80.php | 115 + .../symfony/polyfill-php80/PhpToken.php | 106 + .../vendor/symfony/polyfill-php80/README.md | 25 + .../Resources/stubs/Attribute.php | 31 + .../Resources/stubs/PhpToken.php | 16 + .../Resources/stubs/Stringable.php | 20 + .../Resources/stubs/UnhandledMatchError.php | 16 + .../Resources/stubs/ValueError.php | 16 + .../symfony/polyfill-php80/bootstrap.php | 42 + .../symfony/polyfill-php80/composer.json | 37 + .../.php-cs-fixer.dist.php | 25 + .../PsrServerRequestResolver.php | 67 + .../ValueResolverInterface.php | 26 + .../psr-http-message-bridge/CHANGELOG.md | 85 + .../EventListener/PsrResponseListener.php | 50 + .../Factory/HttpFoundationFactory.php | 252 + .../Factory/PsrHttpFactory.php | 198 + .../Factory/UploadedFile.php | 73 + .../HttpFoundationFactoryInterface.php | 39 + .../HttpMessageFactoryInterface.php | 39 + .../symfony/psr-http-message-bridge/LICENSE | 19 + .../symfony/psr-http-message-bridge/README.md | 19 + .../psr-http-message-bridge/composer.json | 48 + .../vendor/symfony/service-contracts/LICENSE | 19 + .../symfony/service-contracts/README.md | 9 + .../service-contracts/ResetInterface.php | 30 + .../service-contracts/ServiceLocatorTrait.php | 120 + .../ServiceProviderInterface.php | 36 + .../ServiceSubscriberInterface.php | 53 + .../ServiceSubscriberTrait.php | 61 + .../Test/ServiceLocatorTest.php | 94 + .../symfony/service-contracts/composer.json | 34 + .../vendor/symfony/var-exporter/CHANGELOG.md | 12 + .../Exception/ClassNotFoundException.php | 20 + .../Exception/ExceptionInterface.php | 16 + .../NotInstantiableTypeException.php | 20 + .../symfony/var-exporter/Instantiator.php | 92 + .../var-exporter/Internal/Exporter.php | 417 + .../var-exporter/Internal/Hydrator.php | 152 + .../var-exporter/Internal/Reference.php | 30 + .../var-exporter/Internal/Registry.php | 146 + .../symfony/var-exporter/Internal/Values.php | 27 + vendor/vendor/symfony/var-exporter/LICENSE | 19 + vendor/vendor/symfony/var-exporter/README.md | 38 + .../symfony/var-exporter/VarExporter.php | 115 + .../vendor/symfony/var-exporter/composer.json | 32 + .../vendor/topthink/think-captcha/.gitignore | 3 + vendor/vendor/topthink/think-captcha/LICENSE | 32 + .../vendor/topthink/think-captcha/README.md | 33 + .../topthink/think-captcha/assets/bgs/1.jpg | Bin 0 -> 30428 bytes .../topthink/think-captcha/assets/bgs/2.jpg | Bin 0 -> 29677 bytes .../topthink/think-captcha/assets/bgs/3.jpg | Bin 0 -> 32109 bytes .../topthink/think-captcha/assets/bgs/4.jpg | Bin 0 -> 29081 bytes .../topthink/think-captcha/assets/bgs/5.jpg | Bin 0 -> 27940 bytes .../topthink/think-captcha/assets/bgs/6.jpg | Bin 0 -> 31381 bytes .../topthink/think-captcha/assets/bgs/7.jpg | Bin 0 -> 30234 bytes .../topthink/think-captcha/assets/bgs/8.jpg | Bin 0 -> 30188 bytes .../topthink/think-captcha/assets/ttfs/1.ttf | Bin 0 -> 57520 bytes .../topthink/think-captcha/assets/ttfs/2.ttf | Bin 0 -> 28328 bytes .../topthink/think-captcha/assets/ttfs/3.ttf | Bin 0 -> 39308 bytes .../topthink/think-captcha/assets/ttfs/4.ttf | Bin 0 -> 34852 bytes .../topthink/think-captcha/assets/ttfs/5.ttf | Bin 0 -> 32664 bytes .../topthink/think-captcha/assets/ttfs/6.ttf | Bin 0 -> 28036 bytes .../think-captcha/assets/zhttfs/1.ttf | Bin 0 -> 2183628 bytes .../topthink/think-captcha/composer.json | 23 + .../topthink/think-captcha/src/Captcha.php | 351 + .../think-captcha/src/CaptchaController.php | 23 + .../topthink/think-captcha/src/helper.php | 75 + .../vendor/topthink/think-helper/.gitignore | 2 + vendor/vendor/topthink/think-helper/LICENSE | 201 + vendor/vendor/topthink/think-helper/README.md | 92 + .../topthink/think-helper/composer.json | 19 + .../vendor/topthink/think-helper/src/Arr.php | 41 + .../vendor/topthink/think-helper/src/Hash.php | 48 + .../vendor/topthink/think-helper/src/Str.php | 202 + .../vendor/topthink/think-helper/src/Time.php | 203 + .../topthink/think-helper/src/hash/Bcrypt.php | 51 + .../topthink/think-helper/src/hash/Md5.php | 42 + .../topthink/think-helper/src/helper.php | 93 + .../topthink/think-installer/.gitignore | 3 + .../topthink/think-installer/composer.json | 25 + .../think-installer/src/LibraryInstaller.php | 28 + .../topthink/think-installer/src/Plugin.php | 34 + .../topthink/think-installer/src/Promise.php | 11 + .../think-installer/src/ThinkExtend.php | 77 + .../think-installer/src/ThinkFramework.php | 62 + .../think-installer/src/ThinkTesting.php | 64 + vendor/vendor/topthink/think-queue/.gitignore | 4 + vendor/vendor/topthink/think-queue/LICENSE | 201 + vendor/vendor/topthink/think-queue/README.md | 132 + .../vendor/topthink/think-queue/composer.json | 32 + .../vendor/topthink/think-queue/src/Queue.php | 49 + .../topthink/think-queue/src/common.php | 36 + .../topthink/think-queue/src/config.php | 14 + .../src/queue/CallQueuedHandler.php | 36 + .../think-queue/src/queue/Connector.php | 69 + .../topthink/think-queue/src/queue/Job.php | 213 + .../think-queue/src/queue/Listener.php | 164 + .../think-queue/src/queue/Queueable.php | 46 + .../think-queue/src/queue/ShouldQueue.php | 17 + .../topthink/think-queue/src/queue/Worker.php | 119 + .../think-queue/src/queue/command/Listen.php | 65 + .../think-queue/src/queue/command/Restart.php | 31 + .../src/queue/command/Subscribe.php | 46 + .../think-queue/src/queue/command/Work.php | 210 + .../src/queue/connector/Database.php | 171 + .../think-queue/src/queue/connector/Redis.php | 236 + .../think-queue/src/queue/connector/Sync.php | 57 + .../src/queue/connector/Topthink.php | 225 + .../think-queue/src/queue/job/Database.php | 88 + .../think-queue/src/queue/job/Redis.php | 92 + .../think-queue/src/queue/job/Sync.php | 56 + .../think-queue/src/queue/job/Topthink.php | 85 + 2987 files changed, 484280 insertions(+) create mode 100644 .htaccess create mode 100644 addons/.htaccess create mode 100644 application/.htaccess create mode 100644 extend/.htaccess create mode 100644 nginx.htaccess create mode 100644 public/.htaccess create mode 100644 public/nginx.htaccess create mode 100644 thinkphp/.gitignore create mode 100644 thinkphp/.htaccess create mode 100644 thinkphp/.travis.yml create mode 100644 thinkphp/CONTRIBUTING.md create mode 100644 thinkphp/LICENSE.txt create mode 100644 thinkphp/README.md create mode 100644 thinkphp/base.php create mode 100644 thinkphp/codecov.yml create mode 100644 thinkphp/composer.json create mode 100644 thinkphp/console.php create mode 100644 thinkphp/convention.php create mode 100644 thinkphp/helper.php create mode 100644 thinkphp/lang/zh-cn.php create mode 100644 thinkphp/library/think/App.php create mode 100644 thinkphp/library/think/Build.php create mode 100644 thinkphp/library/think/Cache.php create mode 100644 thinkphp/library/think/Collection.php create mode 100644 thinkphp/library/think/Config.php create mode 100644 thinkphp/library/think/Console.php create mode 100644 thinkphp/library/think/Controller.php create mode 100644 thinkphp/library/think/Cookie.php create mode 100644 thinkphp/library/think/Db.php create mode 100644 thinkphp/library/think/Debug.php create mode 100644 thinkphp/library/think/Env.php create mode 100644 thinkphp/library/think/Error.php create mode 100644 thinkphp/library/think/Exception.php create mode 100644 thinkphp/library/think/File.php create mode 100644 thinkphp/library/think/Hook.php create mode 100644 thinkphp/library/think/Lang.php create mode 100644 thinkphp/library/think/Loader.php create mode 100644 thinkphp/library/think/Log.php create mode 100644 thinkphp/library/think/Model.php create mode 100644 thinkphp/library/think/Paginator.php create mode 100644 thinkphp/library/think/Process.php create mode 100644 thinkphp/library/think/Request.php create mode 100644 thinkphp/library/think/Response.php create mode 100644 thinkphp/library/think/Route.php create mode 100644 thinkphp/library/think/Session.php create mode 100644 thinkphp/library/think/Template.php create mode 100644 thinkphp/library/think/Url.php create mode 100644 thinkphp/library/think/Validate.php create mode 100644 thinkphp/library/think/View.php create mode 100644 thinkphp/library/think/cache/Driver.php create mode 100644 thinkphp/library/think/cache/driver/File.php create mode 100644 thinkphp/library/think/cache/driver/Lite.php create mode 100644 thinkphp/library/think/cache/driver/Memcache.php create mode 100644 thinkphp/library/think/cache/driver/Memcached.php create mode 100644 thinkphp/library/think/cache/driver/Redis.php create mode 100644 thinkphp/library/think/cache/driver/Sqlite.php create mode 100644 thinkphp/library/think/cache/driver/Wincache.php create mode 100644 thinkphp/library/think/cache/driver/Xcache.php create mode 100644 thinkphp/library/think/config/driver/Ini.php create mode 100644 thinkphp/library/think/config/driver/Json.php create mode 100644 thinkphp/library/think/config/driver/Xml.php create mode 100644 thinkphp/library/think/console/Command.php create mode 100644 thinkphp/library/think/console/Input.php create mode 100644 thinkphp/library/think/console/LICENSE create mode 100644 thinkphp/library/think/console/Output.php create mode 100644 thinkphp/library/think/console/bin/README.md create mode 100644 thinkphp/library/think/console/bin/hiddeninput.exe create mode 100644 thinkphp/library/think/console/command/Build.php create mode 100644 thinkphp/library/think/console/command/Clear.php create mode 100644 thinkphp/library/think/console/command/Help.php create mode 100644 thinkphp/library/think/console/command/Lists.php create mode 100644 thinkphp/library/think/console/command/Make.php create mode 100644 thinkphp/library/think/console/command/make/Controller.php create mode 100644 thinkphp/library/think/console/command/make/Model.php create mode 100644 thinkphp/library/think/console/command/make/stubs/controller.plain.stub create mode 100644 thinkphp/library/think/console/command/make/stubs/controller.stub create mode 100644 thinkphp/library/think/console/command/make/stubs/model.stub create mode 100644 thinkphp/library/think/console/command/optimize/Autoload.php create mode 100644 thinkphp/library/think/console/command/optimize/Config.php create mode 100644 thinkphp/library/think/console/command/optimize/Route.php create mode 100644 thinkphp/library/think/console/command/optimize/Schema.php create mode 100644 thinkphp/library/think/console/input/Argument.php create mode 100644 thinkphp/library/think/console/input/Definition.php create mode 100644 thinkphp/library/think/console/input/Option.php create mode 100644 thinkphp/library/think/console/output/Ask.php create mode 100644 thinkphp/library/think/console/output/Descriptor.php create mode 100644 thinkphp/library/think/console/output/Formatter.php create mode 100644 thinkphp/library/think/console/output/Question.php create mode 100644 thinkphp/library/think/console/output/descriptor/Console.php create mode 100644 thinkphp/library/think/console/output/driver/Buffer.php create mode 100644 thinkphp/library/think/console/output/driver/Console.php create mode 100644 thinkphp/library/think/console/output/driver/Nothing.php create mode 100644 thinkphp/library/think/console/output/formatter/Stack.php create mode 100644 thinkphp/library/think/console/output/formatter/Style.php create mode 100644 thinkphp/library/think/console/output/question/Choice.php create mode 100644 thinkphp/library/think/console/output/question/Confirmation.php create mode 100644 thinkphp/library/think/controller/Rest.php create mode 100644 thinkphp/library/think/controller/Yar.php create mode 100644 thinkphp/library/think/db/Builder.php create mode 100644 thinkphp/library/think/db/Connection.php create mode 100644 thinkphp/library/think/db/Expression.php create mode 100644 thinkphp/library/think/db/Query.php create mode 100644 thinkphp/library/think/db/builder/Mysql.php create mode 100644 thinkphp/library/think/db/builder/Pgsql.php create mode 100644 thinkphp/library/think/db/builder/Sqlite.php create mode 100644 thinkphp/library/think/db/builder/Sqlsrv.php create mode 100644 thinkphp/library/think/db/connector/Mysql.php create mode 100644 thinkphp/library/think/db/connector/Pgsql.php create mode 100644 thinkphp/library/think/db/connector/Sqlite.php create mode 100644 thinkphp/library/think/db/connector/Sqlsrv.php create mode 100644 thinkphp/library/think/db/connector/pgsql.sql create mode 100644 thinkphp/library/think/db/exception/BindParamException.php create mode 100644 thinkphp/library/think/db/exception/DataNotFoundException.php create mode 100644 thinkphp/library/think/db/exception/ModelNotFoundException.php create mode 100644 thinkphp/library/think/debug/Console.php create mode 100644 thinkphp/library/think/debug/Html.php create mode 100644 thinkphp/library/think/exception/ClassNotFoundException.php create mode 100644 thinkphp/library/think/exception/DbException.php create mode 100644 thinkphp/library/think/exception/ErrorException.php create mode 100644 thinkphp/library/think/exception/Handle.php create mode 100644 thinkphp/library/think/exception/HttpException.php create mode 100644 thinkphp/library/think/exception/HttpResponseException.php create mode 100644 thinkphp/library/think/exception/PDOException.php create mode 100644 thinkphp/library/think/exception/RouteNotFoundException.php create mode 100644 thinkphp/library/think/exception/TemplateNotFoundException.php create mode 100644 thinkphp/library/think/exception/ThrowableError.php create mode 100644 thinkphp/library/think/exception/ValidateException.php create mode 100644 thinkphp/library/think/log/driver/File.php create mode 100644 thinkphp/library/think/log/driver/Socket.php create mode 100644 thinkphp/library/think/log/driver/Test.php create mode 100644 thinkphp/library/think/model/Collection.php create mode 100644 thinkphp/library/think/model/Merge.php create mode 100644 thinkphp/library/think/model/Pivot.php create mode 100644 thinkphp/library/think/model/Relation.php create mode 100644 thinkphp/library/think/model/relation/BelongsTo.php create mode 100644 thinkphp/library/think/model/relation/BelongsToMany.php create mode 100644 thinkphp/library/think/model/relation/HasMany.php create mode 100644 thinkphp/library/think/model/relation/HasManyThrough.php create mode 100644 thinkphp/library/think/model/relation/HasOne.php create mode 100644 thinkphp/library/think/model/relation/MorphMany.php create mode 100644 thinkphp/library/think/model/relation/MorphOne.php create mode 100644 thinkphp/library/think/model/relation/MorphTo.php create mode 100644 thinkphp/library/think/model/relation/OneToOne.php create mode 100644 thinkphp/library/think/paginator/driver/Bootstrap.php create mode 100644 thinkphp/library/think/process/Builder.php create mode 100644 thinkphp/library/think/process/Utils.php create mode 100644 thinkphp/library/think/process/exception/Failed.php create mode 100644 thinkphp/library/think/process/exception/Timeout.php create mode 100644 thinkphp/library/think/process/pipes/Pipes.php create mode 100644 thinkphp/library/think/process/pipes/Unix.php create mode 100644 thinkphp/library/think/process/pipes/Windows.php create mode 100644 thinkphp/library/think/response/Json.php create mode 100644 thinkphp/library/think/response/Jsonp.php create mode 100644 thinkphp/library/think/response/Redirect.php create mode 100644 thinkphp/library/think/response/View.php create mode 100644 thinkphp/library/think/response/Xml.php create mode 100644 thinkphp/library/think/session/driver/Memcache.php create mode 100644 thinkphp/library/think/session/driver/Memcached.php create mode 100644 thinkphp/library/think/session/driver/Redis.php create mode 100644 thinkphp/library/think/template/TagLib.php create mode 100644 thinkphp/library/think/template/driver/File.php create mode 100644 thinkphp/library/think/template/taglib/Cx.php create mode 100644 thinkphp/library/think/view/driver/Php.php create mode 100644 thinkphp/library/think/view/driver/Think.php create mode 100644 thinkphp/library/traits/controller/Jump.php create mode 100644 thinkphp/library/traits/model/SoftDelete.php create mode 100644 thinkphp/library/traits/think/Instance.php create mode 100644 thinkphp/logo.png create mode 100644 thinkphp/phpunit.xml create mode 100644 thinkphp/start.php create mode 100644 thinkphp/tests/.gitignore create mode 100644 thinkphp/tests/README.md create mode 100644 thinkphp/tests/application/config.php create mode 100644 thinkphp/tests/application/database.php create mode 100644 thinkphp/tests/application/index/controller/Index.php create mode 100644 thinkphp/tests/application/route.php create mode 100644 thinkphp/tests/application/views/display.html create mode 100644 thinkphp/tests/application/views/display.phtml create mode 100644 thinkphp/tests/application/views/extend.html create mode 100644 thinkphp/tests/application/views/extend2.html create mode 100644 thinkphp/tests/application/views/include.html create mode 100644 thinkphp/tests/application/views/include2.html create mode 100644 thinkphp/tests/application/views/layout.html create mode 100644 thinkphp/tests/application/views/layout2.html create mode 100644 thinkphp/tests/conf/memcached.ini create mode 100644 thinkphp/tests/conf/redis.ini create mode 100644 thinkphp/tests/conf/timezone.ini create mode 100644 thinkphp/tests/mock.php create mode 100644 thinkphp/tests/script/install.sh create mode 100644 thinkphp/tests/thinkphp/baseTest.php create mode 100644 thinkphp/tests/thinkphp/library/think/appTest.php create mode 100644 thinkphp/tests/thinkphp/library/think/behavior/One.php create mode 100644 thinkphp/tests/thinkphp/library/think/behavior/Three.php create mode 100644 thinkphp/tests/thinkphp/library/think/behavior/Two.php create mode 100644 thinkphp/tests/thinkphp/library/think/buildTest.php create mode 100644 thinkphp/tests/thinkphp/library/think/cache/driver/cacheTestCase.php create mode 100644 thinkphp/tests/thinkphp/library/think/cache/driver/fileTest.php create mode 100644 thinkphp/tests/thinkphp/library/think/cache/driver/liteTest.php create mode 100644 thinkphp/tests/thinkphp/library/think/cache/driver/memcacheTest.php create mode 100644 thinkphp/tests/thinkphp/library/think/cache/driver/memcachedTest.php create mode 100644 thinkphp/tests/thinkphp/library/think/cache/driver/redisTest.php create mode 100644 thinkphp/tests/thinkphp/library/think/cacheTest.php create mode 100644 thinkphp/tests/thinkphp/library/think/config/ConfigInitTrait.php create mode 100644 thinkphp/tests/thinkphp/library/think/config/driver/fixtures/config.ini create mode 100644 thinkphp/tests/thinkphp/library/think/config/driver/fixtures/config.json create mode 100644 thinkphp/tests/thinkphp/library/think/config/driver/fixtures/config.xml create mode 100644 thinkphp/tests/thinkphp/library/think/config/driver/iniTest.php create mode 100644 thinkphp/tests/thinkphp/library/think/config/driver/jsonTest.php create mode 100644 thinkphp/tests/thinkphp/library/think/config/driver/xmlTest.php create mode 100644 thinkphp/tests/thinkphp/library/think/configTest.php create mode 100644 thinkphp/tests/thinkphp/library/think/controller/.gitignore create mode 100644 thinkphp/tests/thinkphp/library/think/controllerTest.php create mode 100644 thinkphp/tests/thinkphp/library/think/cookieTest.php create mode 100644 thinkphp/tests/thinkphp/library/think/db/driver/.gitignore create mode 100644 thinkphp/tests/thinkphp/library/think/dbTest.php create mode 100644 thinkphp/tests/thinkphp/library/think/debugTest.php create mode 100644 thinkphp/tests/thinkphp/library/think/exceptionTest.php create mode 100644 thinkphp/tests/thinkphp/library/think/hookTest.php create mode 100644 thinkphp/tests/thinkphp/library/think/lang/lang.php create mode 100644 thinkphp/tests/thinkphp/library/think/langTest.php create mode 100644 thinkphp/tests/thinkphp/library/think/loader/test/Hello.php create mode 100644 thinkphp/tests/thinkphp/library/think/loaderTest.php create mode 100644 thinkphp/tests/thinkphp/library/think/log/driver/fileTest.php create mode 100644 thinkphp/tests/thinkphp/library/think/logTest.php create mode 100644 thinkphp/tests/thinkphp/library/think/model/.gitignore create mode 100644 thinkphp/tests/thinkphp/library/think/paginateTest.php create mode 100644 thinkphp/tests/thinkphp/library/think/requestTest.php create mode 100644 thinkphp/tests/thinkphp/library/think/responseTest.php create mode 100644 thinkphp/tests/thinkphp/library/think/routeTest.php create mode 100644 thinkphp/tests/thinkphp/library/think/session/.gitignore create mode 100644 thinkphp/tests/thinkphp/library/think/sessionTest.php create mode 100644 thinkphp/tests/thinkphp/library/think/template/driver/.gitignore create mode 100644 thinkphp/tests/thinkphp/library/think/template/taglib/cxTest.php create mode 100644 thinkphp/tests/thinkphp/library/think/templateTest.php create mode 100644 thinkphp/tests/thinkphp/library/think/urlTest.php create mode 100644 thinkphp/tests/thinkphp/library/think/validateTest.php create mode 100644 thinkphp/tests/thinkphp/library/think/view/driver/.gitignore create mode 100644 thinkphp/tests/thinkphp/library/think/view/theme/index/template.html create mode 100644 thinkphp/tests/thinkphp/library/think/viewTest.php create mode 100644 thinkphp/tests/thinkphp/library/traits/controller/jumpTest.php create mode 100644 thinkphp/tests/thinkphp/library/traits/model/softDeleteTest.php create mode 100644 thinkphp/tests/thinkphp/library/traits/think/instanceTest.php create mode 100644 thinkphp/tpl/default_index.tpl create mode 100644 thinkphp/tpl/dispatch_jump.tpl create mode 100644 thinkphp/tpl/page_trace.tpl create mode 100644 thinkphp/tpl/think_exception.tpl create mode 100644 vendor/vendor/adbario/php-dot-notation/LICENSE.md create mode 100644 vendor/vendor/adbario/php-dot-notation/composer.json create mode 100644 vendor/vendor/adbario/php-dot-notation/src/Dot.php create mode 100644 vendor/vendor/adbario/php-dot-notation/src/helpers.php create mode 100644 vendor/vendor/alibabacloud/credentials/CHANGELOG.md create mode 100644 vendor/vendor/alibabacloud/credentials/CONTRIBUTING.md create mode 100644 vendor/vendor/alibabacloud/credentials/LICENSE.md create mode 100644 vendor/vendor/alibabacloud/credentials/NOTICE.md create mode 100644 vendor/vendor/alibabacloud/credentials/README-zh-CN.md create mode 100644 vendor/vendor/alibabacloud/credentials/README.md create mode 100644 vendor/vendor/alibabacloud/credentials/SECURITY.md create mode 100644 vendor/vendor/alibabacloud/credentials/UPGRADING.md create mode 100644 vendor/vendor/alibabacloud/credentials/composer.json create mode 100644 vendor/vendor/alibabacloud/credentials/src/AccessKeyCredential.php create mode 100644 vendor/vendor/alibabacloud/credentials/src/BearerTokenCredential.php create mode 100644 vendor/vendor/alibabacloud/credentials/src/Credential.php create mode 100644 vendor/vendor/alibabacloud/credentials/src/Credential/Config.php create mode 100644 vendor/vendor/alibabacloud/credentials/src/Credential/CredentialModel.php create mode 100644 vendor/vendor/alibabacloud/credentials/src/Credential/RefreshResult.php create mode 100644 vendor/vendor/alibabacloud/credentials/src/Credentials.php create mode 100644 vendor/vendor/alibabacloud/credentials/src/CredentialsInterface.php create mode 100644 vendor/vendor/alibabacloud/credentials/src/CredentialsProviderWrap.php create mode 100644 vendor/vendor/alibabacloud/credentials/src/EcsRamRoleCredential.php create mode 100644 vendor/vendor/alibabacloud/credentials/src/Providers/CLIProfileCredentialsProvider.php create mode 100644 vendor/vendor/alibabacloud/credentials/src/Providers/ChainProvider.php create mode 100644 vendor/vendor/alibabacloud/credentials/src/Providers/Credentials.php create mode 100644 vendor/vendor/alibabacloud/credentials/src/Providers/CredentialsProvider.php create mode 100644 vendor/vendor/alibabacloud/credentials/src/Providers/DefaultCredentialsProvider.php create mode 100644 vendor/vendor/alibabacloud/credentials/src/Providers/EcsRamRoleCredentialsProvider.php create mode 100644 vendor/vendor/alibabacloud/credentials/src/Providers/EnvironmentVariableCredentialsProvider.php create mode 100644 vendor/vendor/alibabacloud/credentials/src/Providers/OIDCRoleArnCredentialsProvider.php create mode 100644 vendor/vendor/alibabacloud/credentials/src/Providers/ProfileCredentialsProvider.php create mode 100644 vendor/vendor/alibabacloud/credentials/src/Providers/RamRoleArnCredentialsProvider.php create mode 100644 vendor/vendor/alibabacloud/credentials/src/Providers/RsaKeyPairCredentialsProvider.php create mode 100644 vendor/vendor/alibabacloud/credentials/src/Providers/SessionCredentialsProvider.php create mode 100644 vendor/vendor/alibabacloud/credentials/src/Providers/StaticAKCredentialsProvider.php create mode 100644 vendor/vendor/alibabacloud/credentials/src/Providers/StaticSTSCredentialsProvider.php create mode 100644 vendor/vendor/alibabacloud/credentials/src/Providers/URLCredentialsProvider.php create mode 100644 vendor/vendor/alibabacloud/credentials/src/RamRoleArnCredential.php create mode 100644 vendor/vendor/alibabacloud/credentials/src/Request/Request.php create mode 100644 vendor/vendor/alibabacloud/credentials/src/RsaKeyPairCredential.php create mode 100644 vendor/vendor/alibabacloud/credentials/src/Signature/BearerTokenSignature.php create mode 100644 vendor/vendor/alibabacloud/credentials/src/Signature/ShaHmac1Signature.php create mode 100644 vendor/vendor/alibabacloud/credentials/src/Signature/ShaHmac256Signature.php create mode 100644 vendor/vendor/alibabacloud/credentials/src/Signature/ShaHmac256WithRsaSignature.php create mode 100644 vendor/vendor/alibabacloud/credentials/src/Signature/SignatureInterface.php create mode 100644 vendor/vendor/alibabacloud/credentials/src/StsCredential.php create mode 100644 vendor/vendor/alibabacloud/credentials/src/Utils/Filter.php create mode 100644 vendor/vendor/alibabacloud/credentials/src/Utils/Helper.php create mode 100644 vendor/vendor/alibabacloud/credentials/src/Utils/MockTrait.php create mode 100644 vendor/vendor/alibabacloud/darabonba-openapi/.gitignore create mode 100644 vendor/vendor/alibabacloud/darabonba-openapi/.php_cs.dist create mode 100644 vendor/vendor/alibabacloud/darabonba-openapi/README-CN.md create mode 100644 vendor/vendor/alibabacloud/darabonba-openapi/README.md create mode 100644 vendor/vendor/alibabacloud/darabonba-openapi/autoload.php create mode 100644 vendor/vendor/alibabacloud/darabonba-openapi/composer.json create mode 100644 vendor/vendor/alibabacloud/darabonba-openapi/phpunit.xml create mode 100644 vendor/vendor/alibabacloud/darabonba-openapi/src/Models/Config.php create mode 100644 vendor/vendor/alibabacloud/darabonba-openapi/src/Models/GlobalParameters.php create mode 100644 vendor/vendor/alibabacloud/darabonba-openapi/src/Models/OpenApiRequest.php create mode 100644 vendor/vendor/alibabacloud/darabonba-openapi/src/Models/Params.php create mode 100644 vendor/vendor/alibabacloud/darabonba-openapi/src/OpenApiClient.php create mode 100644 vendor/vendor/alibabacloud/darabonba-openapi/tests/OpenApiClientTest.php create mode 100644 vendor/vendor/alibabacloud/darabonba-openapi/tests/bootstrap.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/.gitignore create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/.php_cs.dist create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/ChangeLog.md create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/LICENSE create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/README-CN.md create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/README.md create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/autoload.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/composer.json create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Dypnsapi.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/CheckSmsVerifyCodeRequest.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/CheckSmsVerifyCodeResponse.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/CheckSmsVerifyCodeResponseBody.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/CheckSmsVerifyCodeResponseBody/model_.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/CreateSchemeConfigRequest.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/CreateSchemeConfigResponse.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/CreateSchemeConfigResponseBody.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/CreateSchemeConfigResponseBody/model_.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/CreateVerifySchemeRequest.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/CreateVerifySchemeResponse.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/CreateVerifySchemeResponseBody.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/CreateVerifySchemeResponseBody/gateVerifySchemeDTO.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/DeleteVerifySchemeRequest.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/DeleteVerifySchemeResponse.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/DeleteVerifySchemeResponseBody.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/DescribeVerifySchemeRequest.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/DescribeVerifySchemeResponse.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/DescribeVerifySchemeResponseBody.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/DescribeVerifySchemeResponseBody/schemeQueryResultDTO.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetAuthTokenRequest.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetAuthTokenResponse.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetAuthTokenResponseBody.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetAuthTokenResponseBody/tokenInfo.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetAuthorizationUrlRequest.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetAuthorizationUrlResponse.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetAuthorizationUrlResponseBody.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetAuthorizationUrlResponseBody/data.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetFusionAuthTokenRequest.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetFusionAuthTokenResponse.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetFusionAuthTokenResponseBody.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetMobileRequest.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetMobileResponse.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetMobileResponseBody.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetMobileResponseBody/getMobileResultDTO.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetPhoneWithTokenRequest.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetPhoneWithTokenResponse.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetPhoneWithTokenResponseBody.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetPhoneWithTokenResponseBody/data.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetSmsAuthTokensRequest.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetSmsAuthTokensResponse.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetSmsAuthTokensResponseBody.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetSmsAuthTokensResponseBody/data.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/JyCreateVerifySchemeRequest.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/JyCreateVerifySchemeResponse.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/JyCreateVerifySchemeResponseBody.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/JyCreateVerifySchemeResponseBody/gateVerifySchemeData.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/JyQueryAppInfoBySceneCodeRequest.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/JyQueryAppInfoBySceneCodeResponse.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/JyQueryAppInfoBySceneCodeResponseBody.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/JyQueryAppInfoBySceneCodeResponseBody/data.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/QueryGateVerifyBillingPublicRequest.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/QueryGateVerifyBillingPublicResponse.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/QueryGateVerifyBillingPublicResponseBody.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/QueryGateVerifyBillingPublicResponseBody/data.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/QueryGateVerifyBillingPublicResponseBody/data/sceneBillingList.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/QueryGateVerifyStatisticPublicRequest.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/QueryGateVerifyStatisticPublicResponse.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/QueryGateVerifyStatisticPublicResponseBody.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/QueryGateVerifyStatisticPublicResponseBody/data.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/QueryGateVerifyStatisticPublicResponseBody/data/dayStatistic.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/QuerySendDetailsRequest.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/QuerySendDetailsResponse.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/QuerySendDetailsResponseBody.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/QuerySendDetailsResponseBody/model_.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/SendSmsVerifyCodeRequest.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/SendSmsVerifyCodeResponse.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/SendSmsVerifyCodeResponseBody.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/SendSmsVerifyCodeResponseBody/model_.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyMobileRequest.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyMobileResponse.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyMobileResponseBody.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyMobileResponseBody/gateVerifyResultDTO.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyPhoneWithTokenRequest.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyPhoneWithTokenResponse.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyPhoneWithTokenResponseBody.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyPhoneWithTokenResponseBody/gateVerify.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifySmsCodeRequest.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifySmsCodeResponse.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifySmsCodeResponseBody.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyWithFusionAuthTokenRequest.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyWithFusionAuthTokenResponse.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyWithFusionAuthTokenResponseBody.php create mode 100644 vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyWithFusionAuthTokenResponseBody/model_.php create mode 100644 vendor/vendor/alibabacloud/endpoint-util/.gitignore create mode 100644 vendor/vendor/alibabacloud/endpoint-util/.php_cs.dist create mode 100644 vendor/vendor/alibabacloud/endpoint-util/LICENSE create mode 100644 vendor/vendor/alibabacloud/endpoint-util/README-CN.md create mode 100644 vendor/vendor/alibabacloud/endpoint-util/README.md create mode 100644 vendor/vendor/alibabacloud/endpoint-util/composer.json create mode 100644 vendor/vendor/alibabacloud/endpoint-util/phpunit.xml create mode 100644 vendor/vendor/alibabacloud/endpoint-util/src/Endpoint.php create mode 100644 vendor/vendor/alibabacloud/endpoint-util/tests/EndpointTest.php create mode 100644 vendor/vendor/alibabacloud/endpoint-util/tests/bootstrap.php create mode 100644 vendor/vendor/alibabacloud/gateway-spi/.gitignore create mode 100644 vendor/vendor/alibabacloud/gateway-spi/.php_cs.dist create mode 100644 vendor/vendor/alibabacloud/gateway-spi/autoload.php create mode 100644 vendor/vendor/alibabacloud/gateway-spi/composer.json create mode 100644 vendor/vendor/alibabacloud/gateway-spi/src/Client.php create mode 100644 vendor/vendor/alibabacloud/gateway-spi/src/Models/AttributeMap.php create mode 100644 vendor/vendor/alibabacloud/gateway-spi/src/Models/InterceptorContext.php create mode 100644 vendor/vendor/alibabacloud/gateway-spi/src/Models/InterceptorContext/configuration.php create mode 100644 vendor/vendor/alibabacloud/gateway-spi/src/Models/InterceptorContext/request.php create mode 100644 vendor/vendor/alibabacloud/gateway-spi/src/Models/InterceptorContext/response.php create mode 100644 vendor/vendor/alibabacloud/openapi-util/.gitignore create mode 100644 vendor/vendor/alibabacloud/openapi-util/.php_cs.dist create mode 100644 vendor/vendor/alibabacloud/openapi-util/README-CN.md create mode 100644 vendor/vendor/alibabacloud/openapi-util/README.md create mode 100644 vendor/vendor/alibabacloud/openapi-util/autoload.php create mode 100644 vendor/vendor/alibabacloud/openapi-util/composer.json create mode 100644 vendor/vendor/alibabacloud/openapi-util/phpunit.xml create mode 100644 vendor/vendor/alibabacloud/openapi-util/src/OpenApiUtilClient.php create mode 100644 vendor/vendor/alibabacloud/openapi-util/tests/Models/SourceModel.php create mode 100644 vendor/vendor/alibabacloud/openapi-util/tests/Models/TargetModel.php create mode 100644 vendor/vendor/alibabacloud/openapi-util/tests/OpenApiUtilClientTest.php create mode 100644 vendor/vendor/alibabacloud/openapi-util/tests/bootstrap.php create mode 100644 vendor/vendor/alibabacloud/tea-utils/.gitignore create mode 100644 vendor/vendor/alibabacloud/tea-utils/.php_cs.dist create mode 100644 vendor/vendor/alibabacloud/tea-utils/README-CN.md create mode 100644 vendor/vendor/alibabacloud/tea-utils/README.md create mode 100644 vendor/vendor/alibabacloud/tea-utils/composer.json create mode 100644 vendor/vendor/alibabacloud/tea-utils/phpunit.xml create mode 100644 vendor/vendor/alibabacloud/tea-utils/src/Utils.php create mode 100644 vendor/vendor/alibabacloud/tea-utils/src/Utils/ExtendsParameters.php create mode 100644 vendor/vendor/alibabacloud/tea-utils/src/Utils/RuntimeOptions.php create mode 100644 vendor/vendor/alibabacloud/tea-utils/tests/UtilsTest.php create mode 100644 vendor/vendor/alibabacloud/tea-utils/tests/bootstrap.php create mode 100644 vendor/vendor/alibabacloud/tea-xml/.gitignore create mode 100644 vendor/vendor/alibabacloud/tea-xml/.php_cs.dist create mode 100644 vendor/vendor/alibabacloud/tea-xml/README-CN.md create mode 100644 vendor/vendor/alibabacloud/tea-xml/README.md create mode 100644 vendor/vendor/alibabacloud/tea-xml/composer.json create mode 100644 vendor/vendor/alibabacloud/tea-xml/phpunit.xml create mode 100644 vendor/vendor/alibabacloud/tea-xml/src/ArrayToXml.php create mode 100644 vendor/vendor/alibabacloud/tea-xml/src/XML.php create mode 100644 vendor/vendor/alibabacloud/tea-xml/tests/XMLTest.php create mode 100644 vendor/vendor/alibabacloud/tea-xml/tests/bootstrap.php create mode 100644 vendor/vendor/alibabacloud/tea/.php_cs.dist create mode 100644 vendor/vendor/alibabacloud/tea/CHANGELOG.md create mode 100644 vendor/vendor/alibabacloud/tea/LICENSE.md create mode 100644 vendor/vendor/alibabacloud/tea/README.md create mode 100644 vendor/vendor/alibabacloud/tea/composer.json create mode 100644 vendor/vendor/alibabacloud/tea/src/Exception/TeaError.php create mode 100644 vendor/vendor/alibabacloud/tea/src/Exception/TeaRetryError.php create mode 100644 vendor/vendor/alibabacloud/tea/src/Exception/TeaUnableRetryError.php create mode 100644 vendor/vendor/alibabacloud/tea/src/Helper.php create mode 100644 vendor/vendor/alibabacloud/tea/src/Model.php create mode 100644 vendor/vendor/alibabacloud/tea/src/Parameter.php create mode 100644 vendor/vendor/alibabacloud/tea/src/Request.php create mode 100644 vendor/vendor/alibabacloud/tea/src/Response.php create mode 100644 vendor/vendor/alibabacloud/tea/src/Tea.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/.coveralls.yml create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/.gitignore create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/.travis.yml create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/CHANGELOG.md create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/LICENSE.md create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/README-CN.md create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/README.md create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/autoload.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/build-phar.sh create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/composer.json create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/example.jpg create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/index.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/phpunit.xml create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/samples/Bucket.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/samples/BucketCname.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/samples/BucketCors.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/samples/BucketEncryption.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/samples/BucketLifecycle.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/samples/BucketLogging.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/samples/BucketPayment.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/samples/BucketPolicy.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/samples/BucketReferer.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/samples/BucketStat.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/samples/BucketTags.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/samples/BucketTransferAcceleration.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/samples/BucketVersion.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/samples/BucketWebsite.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/samples/BucketWorm.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/samples/Callback.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/samples/Common.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/samples/Config.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/samples/CredentialsPhp.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/samples/CredentialsProvider.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/samples/Image.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/samples/LiveChannel.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/samples/MultipartUpload.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/samples/Object.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/samples/ObjectTagging.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/samples/RunAll.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/samples/Signature.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Core/MimeTypes.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Core/OssException.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Core/OssUtil.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Credentials/Credentials.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Credentials/CredentialsProvider.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Credentials/EnvironmentVariableCredentialsProvider.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Credentials/StaticCredentialsProvider.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Http/LICENSE create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Http/RequestCore.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Http/RequestCore_Exception.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Http/ResponseCore.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/BucketInfo.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/BucketListInfo.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/BucketStat.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/CnameConfig.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/CnameTokenInfo.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/CorsConfig.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/CorsRule.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/DeleteMarkerInfo.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/DeleteObjectInfo.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/DeletedObjectInfo.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/ExtendWormConfig.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/GetLiveChannelHistory.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/GetLiveChannelInfo.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/GetLiveChannelStatus.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/InitiateWormConfig.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LifecycleAction.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LifecycleConfig.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LifecycleRule.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/ListMultipartUploadInfo.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/ListPartsInfo.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LiveChannelConfig.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LiveChannelHistory.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LiveChannelInfo.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LiveChannelListInfo.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LoggingConfig.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/ObjectInfo.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/ObjectListInfo.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/ObjectListInfoV2.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/ObjectVersionInfo.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/ObjectVersionListInfo.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/Owner.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/PartInfo.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/PrefixInfo.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/RefererConfig.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/RequestPaymentConfig.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/RestoreConfig.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/ServerSideEncryptionConfig.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/StorageCapacityConfig.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/Tag.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/TaggingConfig.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/TransferAccelerationConfig.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/UploadInfo.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/VersioningConfig.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/WebsiteConfig.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/WormConfig.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/XmlConfig.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/OssClient.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/AclResult.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/AppendResult.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/BodyResult.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/CallbackResult.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/CopyObjectResult.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/CreateBucketCnameTokenResult.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/DeleteObjectVersionsResult.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/DeleteObjectsResult.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/ExistResult.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketCnameTokenResult.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketEncryptionResult.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketInfoResult.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketRequestPaymentResult.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketStatResult.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketTagsResult.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketTransferAccelerationResult.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketVersioningResult.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketWormResult.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetCnameResult.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetCorsResult.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetLifecycleResult.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetLiveChannelHistoryResult.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetLiveChannelInfoResult.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetLiveChannelStatusResult.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetLocationResult.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetLoggingResult.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetRefererResult.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetStorageCapacityResult.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetWebsiteResult.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/HeaderResult.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/InitiateBucketWormResult.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/InitiateMultipartUploadResult.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/ListBucketsResult.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/ListLiveChannelResult.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/ListMultipartUploadResult.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/ListObjectVersionsResult.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/ListObjectsResult.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/ListObjectsV2Result.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/ListPartsResult.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/PutLiveChannelResult.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/PutSetDeleteResult.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/Result.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/SymlinkResult.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/UploadPartResult.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Signer/SignerInterface.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Signer/SignerV1.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Signer/SignerV4.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/AclResultTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/AssumeRole.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/BodyResultTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/BucketCnameTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/BucketInfoTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/BucketLiveChannelTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/CallbackTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/CnameConfigTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/CnameTokenInfoTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/Common.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/ContentTypeTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/CopyObjectResult.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/CorsConfigTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/DeleteObjectVersionsResultTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/ExistResultTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetBucketEncryptionResultTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetBucketRequestPaymentResultTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetBucketStatResultTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetBucketTagsResultTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetBucketTransferAccelerationResultTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetBucketWormResultTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetCorsResultTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetLifecycleResultTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetLoggingResultTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetRefererResultTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetWebsiteResultTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/HeaderResultTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/HttpTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/InitiateMultipartUploadResultTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/LifecycleConfigTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/ListBucketsResultTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/ListMultipartUploadResultTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/ListObjectVersionsResultTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/ListObjectsResultTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/ListObjectsV2ResultTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/ListPartsResultTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/LiveChannelXmlTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/LoggingConfigTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/MimeTypesTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/ObjectAclTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientAsyncProcessObjectTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketCnameTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketCorsTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketEncryptionTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketInfoTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketLifecycleTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketLoggingTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketPolicyTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketRefererTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketRequestPaymentTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketStatTestTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketStorageCapacityTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketTagsTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketTransferAccelerationTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketVersioningTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketWebsiteTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketWormTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientForcePathStyleTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientImageTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientListObjectsTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientListObjectsV2Test.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientMultipartUploadTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientObjectRequestPaymentTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientObjectTaggingTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientObjectTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientObjectVersioningTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientPresignTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientPresignV4Test.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientRestoreObjectTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientSignatureTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientSignatureV4Test.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssExceptionTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssTrafficLimitTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssUtilTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/PutSetDeleteResultTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/RefererConfigTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/SignerTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/StorageCapacityConfigTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/StorageCapacityTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/StsBase.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/StsClient.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/SymlinkTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/TestOssClientBase.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/TransferAccelerationConfigTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/UploadPartResultTest.php create mode 100644 vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/WebsiteConfigTest.php create mode 100644 vendor/vendor/autoload.php create mode 100644 vendor/vendor/composer/ClassLoader.php create mode 100644 vendor/vendor/composer/InstalledVersions.php create mode 100644 vendor/vendor/composer/LICENSE create mode 100644 vendor/vendor/composer/autoload_classmap.php create mode 100644 vendor/vendor/composer/autoload_files.php create mode 100644 vendor/vendor/composer/autoload_namespaces.php create mode 100644 vendor/vendor/composer/autoload_psr4.php create mode 100644 vendor/vendor/composer/autoload_real.php create mode 100644 vendor/vendor/composer/autoload_static.php create mode 100644 vendor/vendor/composer/installed.json create mode 100644 vendor/vendor/composer/installed.php create mode 100644 vendor/vendor/composer/pcre/LICENSE create mode 100644 vendor/vendor/composer/pcre/README.md create mode 100644 vendor/vendor/composer/pcre/composer.json create mode 100644 vendor/vendor/composer/pcre/extension.neon create mode 100644 vendor/vendor/composer/pcre/src/MatchAllResult.php create mode 100644 vendor/vendor/composer/pcre/src/MatchAllStrictGroupsResult.php create mode 100644 vendor/vendor/composer/pcre/src/MatchAllWithOffsetsResult.php create mode 100644 vendor/vendor/composer/pcre/src/MatchResult.php create mode 100644 vendor/vendor/composer/pcre/src/MatchStrictGroupsResult.php create mode 100644 vendor/vendor/composer/pcre/src/MatchWithOffsetsResult.php create mode 100644 vendor/vendor/composer/pcre/src/PHPStan/InvalidRegexPatternRule.php create mode 100644 vendor/vendor/composer/pcre/src/PHPStan/PregMatchFlags.php create mode 100644 vendor/vendor/composer/pcre/src/PHPStan/PregMatchParameterOutTypeExtension.php create mode 100644 vendor/vendor/composer/pcre/src/PHPStan/PregMatchTypeSpecifyingExtension.php create mode 100644 vendor/vendor/composer/pcre/src/PHPStan/PregReplaceCallbackClosureTypeExtension.php create mode 100644 vendor/vendor/composer/pcre/src/PHPStan/UnsafeStrictGroupsCallRule.php create mode 100644 vendor/vendor/composer/pcre/src/PcreException.php create mode 100644 vendor/vendor/composer/pcre/src/Preg.php create mode 100644 vendor/vendor/composer/pcre/src/Regex.php create mode 100644 vendor/vendor/composer/pcre/src/ReplaceResult.php create mode 100644 vendor/vendor/composer/pcre/src/UnexpectedNullMatchException.php create mode 100644 vendor/vendor/composer/platform_check.php create mode 100644 vendor/vendor/easywechat-composer/easywechat-composer/.gitignore create mode 100644 vendor/vendor/easywechat-composer/easywechat-composer/.php_cs create mode 100644 vendor/vendor/easywechat-composer/easywechat-composer/.travis.yml create mode 100644 vendor/vendor/easywechat-composer/easywechat-composer/LICENSE create mode 100644 vendor/vendor/easywechat-composer/easywechat-composer/README.md create mode 100644 vendor/vendor/easywechat-composer/easywechat-composer/composer.json create mode 100644 vendor/vendor/easywechat-composer/easywechat-composer/phpunit.xml create mode 100644 vendor/vendor/easywechat-composer/easywechat-composer/src/Commands/ExtensionsCommand.php create mode 100644 vendor/vendor/easywechat-composer/easywechat-composer/src/Commands/Provider.php create mode 100644 vendor/vendor/easywechat-composer/easywechat-composer/src/Contracts/Encrypter.php create mode 100644 vendor/vendor/easywechat-composer/easywechat-composer/src/Delegation/DelegationOptions.php create mode 100644 vendor/vendor/easywechat-composer/easywechat-composer/src/Delegation/DelegationTo.php create mode 100644 vendor/vendor/easywechat-composer/easywechat-composer/src/Delegation/Hydrate.php create mode 100644 vendor/vendor/easywechat-composer/easywechat-composer/src/EasyWeChat.php create mode 100644 vendor/vendor/easywechat-composer/easywechat-composer/src/Encryption/DefaultEncrypter.php create mode 100644 vendor/vendor/easywechat-composer/easywechat-composer/src/Exceptions/DecryptException.php create mode 100644 vendor/vendor/easywechat-composer/easywechat-composer/src/Exceptions/DelegationException.php create mode 100644 vendor/vendor/easywechat-composer/easywechat-composer/src/Exceptions/EncryptException.php create mode 100644 vendor/vendor/easywechat-composer/easywechat-composer/src/Extension.php create mode 100644 vendor/vendor/easywechat-composer/easywechat-composer/src/Http/DelegationResponse.php create mode 100644 vendor/vendor/easywechat-composer/easywechat-composer/src/Http/Response.php create mode 100644 vendor/vendor/easywechat-composer/easywechat-composer/src/Laravel/Http/Controllers/DelegatesController.php create mode 100644 vendor/vendor/easywechat-composer/easywechat-composer/src/Laravel/ServiceProvider.php create mode 100644 vendor/vendor/easywechat-composer/easywechat-composer/src/Laravel/config.php create mode 100644 vendor/vendor/easywechat-composer/easywechat-composer/src/Laravel/routes.php create mode 100644 vendor/vendor/easywechat-composer/easywechat-composer/src/ManifestManager.php create mode 100644 vendor/vendor/easywechat-composer/easywechat-composer/src/Plugin.php create mode 100644 vendor/vendor/easywechat-composer/easywechat-composer/src/Traits/MakesHttpRequests.php create mode 100644 vendor/vendor/easywechat-composer/easywechat-composer/src/Traits/WithAggregator.php create mode 100644 vendor/vendor/easywechat-composer/easywechat-composer/tests/ManifestManagerTest.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/CREDITS create mode 100644 vendor/vendor/ezyang/htmlpurifier/LICENSE create mode 100644 vendor/vendor/ezyang/htmlpurifier/README.md create mode 100644 vendor/vendor/ezyang/htmlpurifier/VERSION create mode 100644 vendor/vendor/ezyang/htmlpurifier/composer.json create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier.auto.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier.autoload-legacy.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier.autoload.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier.composer.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier.func.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier.includes.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier.kses.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier.path.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier.safe-includes.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Arborize.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrCollections.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/AlphaValue.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Background.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/BackgroundPosition.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Border.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Color.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Composite.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/DenyElementDecorator.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Filter.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Font.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/FontFamily.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Ident.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/ImportantDecorator.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Length.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/ListStyle.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Multiple.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Number.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Percentage.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Ratio.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/TextDecoration.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/URI.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/Clone.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/Enum.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/Bool.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/Class.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/Color.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/ContentEditable.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/FrameTarget.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/ID.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/Length.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/LinkTypes.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/MultiLength.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/Nmtokens.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/Pixels.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/Integer.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/Lang.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/Switch.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/Text.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/URI.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/URI/Email.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/URI/Email/SimpleCheck.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/URI/Host.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/URI/IPv4.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/URI/IPv6.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/Background.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/BdoDir.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/BgColor.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/BoolToCSS.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/Border.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/EnumToCSS.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/ImgRequired.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/ImgSpace.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/Input.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/Lang.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/Length.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/Name.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/NameSync.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/Nofollow.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/SafeEmbed.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/SafeObject.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/SafeParam.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/ScriptRequired.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/TargetBlank.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/TargetNoopener.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/TargetNoreferrer.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/Textarea.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTypes.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrValidator.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Bootstrap.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/CSSDefinition.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ChildDef.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ChildDef/Chameleon.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ChildDef/Custom.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ChildDef/Empty.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ChildDef/List.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ChildDef/Optional.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ChildDef/Required.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ChildDef/StrictBlockquote.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ChildDef/Table.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Config.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/Builder/ConfigSchema.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/Builder/Xml.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/Exception.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/Interchange.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/Interchange/Directive.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/Interchange/Id.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/InterchangeBuilder.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/Validator.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/ValidatorAtom.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema.ser create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.AllowedClasses.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.AllowedFrameTargets.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.AllowedRel.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.AllowedRev.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.ClassUseCDATA.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.DefaultImageAlt.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.DefaultInvalidImage.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.DefaultInvalidImageAlt.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.DefaultTextDir.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.EnableID.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.ForbiddenClasses.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.ID.HTML5.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.IDBlacklist.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.IDBlacklistRegexp.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.IDPrefix.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.IDPrefixLocal.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.AutoParagraph.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.Custom.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.DisplayLinkURI.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.Linkify.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.PurifierLinkify.DocURL.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.PurifierLinkify.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.RemoveEmpty.Predicate.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.RemoveEmpty.RemoveNbsp.Exceptions.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.RemoveEmpty.RemoveNbsp.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.RemoveEmpty.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.RemoveSpansWithoutAttributes.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/CSS.AllowDuplicates.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/CSS.AllowImportant.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/CSS.AllowTricky.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/CSS.AllowedFonts.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/CSS.AllowedProperties.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/CSS.DefinitionRev.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/CSS.ForbiddenProperties.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/CSS.MaxImgLength.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/CSS.Proprietary.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/CSS.Trusted.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Cache.DefinitionImpl.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Cache.SerializerPath.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Cache.SerializerPermissions.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.AggressivelyFixLt.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.AggressivelyRemoveScript.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.AllowHostnameUnderscore.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.AllowParseManyTags.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.CollectErrors.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.ColorKeywords.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.ConvertDocumentToFragment.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.DirectLexLineNumberSyncInterval.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.DisableExcludes.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.EnableIDNA.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.Encoding.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.EscapeInvalidChildren.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.EscapeInvalidTags.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.EscapeNonASCIICharacters.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.HiddenElements.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.Language.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.LegacyEntityDecoder.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.LexerImpl.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.MaintainLineNumbers.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.NormalizeNewlines.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.RemoveBlanks.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.RemoveInvalidImg.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.RemoveProcessingInstructions.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.RemoveScriptContents.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Filter.Custom.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Filter.ExtractStyleBlocks.Escaping.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Filter.ExtractStyleBlocks.Scope.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Filter.ExtractStyleBlocks.TidyImpl.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Filter.ExtractStyleBlocks.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Filter.YouTube.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.Allowed.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.AllowedAttributes.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.AllowedComments.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.AllowedCommentsRegexp.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.AllowedElements.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.AllowedModules.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.Attr.Name.UseCDATA.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.BlockWrapper.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.CoreModules.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.CustomDoctype.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.DefinitionID.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.DefinitionRev.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.Doctype.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.FlashAllowFullScreen.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.ForbiddenAttributes.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.ForbiddenElements.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.Forms.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.MaxImgLength.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.Nofollow.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.Parent.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.Proprietary.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.SafeEmbed.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.SafeIframe.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.SafeObject.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.SafeScripting.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.Strict.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.TargetBlank.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.TargetNoopener.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.TargetNoreferrer.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.TidyAdd.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.TidyLevel.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.TidyRemove.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.Trusted.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.XHTML.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Output.CommentScriptContents.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Output.FixInnerHTML.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Output.FlashCompat.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Output.Newline.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Output.SortAttr.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Output.TidyFormat.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Test.ForceNoIconv.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.AllowedSchemes.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.Base.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.DefaultScheme.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.DefinitionID.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.DefinitionRev.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.Disable.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.DisableExternal.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.DisableExternalResources.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.DisableResources.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.Host.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.HostBlacklist.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.MakeAbsolute.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.Munge.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.MungeResources.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.MungeSecretKey.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.OverrideAllowedSchemes.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.SafeIframeRegexp.txt create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/info.ini create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ContentSets.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Context.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Definition.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/Decorator.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/Decorator/Cleanup.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/Decorator/Memory.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/Decorator/Template.php.in create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/Null.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/Serializer.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/Serializer/HTML/4.18.0,f474c0a322b208e83d22d3aef33ecb184bc71d31,1.ser create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/Serializer/README create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCacheFactory.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Doctype.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DoctypeRegistry.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ElementDef.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Encoder.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/EntityLookup.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/EntityLookup/entities.ser create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/EntityParser.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ErrorCollector.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ErrorStruct.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Exception.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Filter.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Filter/ExtractStyleBlocks.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Filter/YouTube.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Generator.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLDefinition.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Bdo.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/CommonAttributes.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Edit.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Forms.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Hypertext.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Iframe.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Image.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Legacy.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/List.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Name.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Nofollow.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/NonXMLCommonAttributes.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Object.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Presentation.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Proprietary.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Ruby.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/SafeEmbed.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/SafeObject.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/SafeScripting.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Scripting.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/StyleAttribute.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Tables.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Target.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/TargetBlank.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/TargetNoopener.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/TargetNoreferrer.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Text.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Tidy.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Tidy/Name.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Tidy/Proprietary.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Tidy/Strict.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Tidy/Transitional.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Tidy/XHTML.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Tidy/XHTMLAndHTML4.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/XMLCommonAttributes.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModuleManager.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/IDAccumulator.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Injector.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Injector/AutoParagraph.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Injector/DisplayLinkURI.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Injector/Linkify.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Injector/PurifierLinkify.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Injector/RemoveEmpty.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Injector/RemoveSpansWithoutAttributes.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Injector/SafeObject.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Language.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Language/messages/en.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/LanguageFactory.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Length.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Lexer.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Lexer/DOMLex.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Lexer/DirectLex.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Lexer/PH5P.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Node.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Node/Comment.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Node/Element.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Node/Text.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/PercentEncoder.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Printer.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Printer/CSSDefinition.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Printer/ConfigForm.css create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Printer/ConfigForm.js create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Printer/ConfigForm.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Printer/HTMLDefinition.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/PropertyList.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/PropertyListIterator.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Queue.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Strategy.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Strategy/Composite.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Strategy/Core.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Strategy/FixNesting.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Strategy/MakeWellFormed.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Strategy/RemoveForeignElements.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Strategy/ValidateAttributes.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/StringHash.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/StringHashParser.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/TagTransform.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/TagTransform/Font.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/TagTransform/Simple.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Token.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Token/Comment.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Token/Empty.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Token/End.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Token/Start.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Token/Tag.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Token/Text.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/TokenFactory.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/URI.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/URIDefinition.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/URIFilter.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/URIFilter/DisableExternal.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/URIFilter/DisableExternalResources.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/URIFilter/DisableResources.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/URIFilter/HostBlacklist.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/URIFilter/MakeAbsolute.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/URIFilter/Munge.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/URIFilter/SafeIframe.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/URIParser.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/URIScheme.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/URIScheme/data.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/URIScheme/file.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/URIScheme/ftp.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/URIScheme/http.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/URIScheme/https.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/URIScheme/mailto.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/URIScheme/news.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/URIScheme/nntp.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/URIScheme/tel.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/URISchemeRegistry.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/UnitConverter.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/VarParser.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/VarParser/Flexible.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/VarParser/Native.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/VarParserException.php create mode 100644 vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Zipper.php create mode 100644 vendor/vendor/fastadminnet/fastadmin-addons/.gitignore create mode 100644 vendor/vendor/fastadminnet/fastadmin-addons/LICENSE.txt create mode 100644 vendor/vendor/fastadminnet/fastadmin-addons/README.md create mode 100644 vendor/vendor/fastadminnet/fastadmin-addons/composer.json create mode 100644 vendor/vendor/fastadminnet/fastadmin-addons/licenses/think-addons.txt create mode 100644 vendor/vendor/fastadminnet/fastadmin-addons/src/Addons.php create mode 100644 vendor/vendor/fastadminnet/fastadmin-addons/src/addons/AddonException.php create mode 100644 vendor/vendor/fastadminnet/fastadmin-addons/src/addons/Controller.php create mode 100644 vendor/vendor/fastadminnet/fastadmin-addons/src/addons/Route.php create mode 100644 vendor/vendor/fastadminnet/fastadmin-addons/src/addons/Service.php create mode 100644 vendor/vendor/fastadminnet/fastadmin-addons/src/common.php create mode 100644 vendor/vendor/fastadminnet/fastadmin-addons/src/config.php create mode 100644 vendor/vendor/fastadminnet/fastadmin-mailer/LICENSE create mode 100644 vendor/vendor/fastadminnet/fastadmin-mailer/composer.json create mode 100644 vendor/vendor/fastadminnet/fastadmin-mailer/src/Mailer.php create mode 100644 vendor/vendor/fastadminnet/fastadmin-mailer/src/Mailer/Exceptions/CodeException.php create mode 100644 vendor/vendor/fastadminnet/fastadmin-mailer/src/Mailer/Exceptions/CryptoException.php create mode 100644 vendor/vendor/fastadminnet/fastadmin-mailer/src/Mailer/Exceptions/SMTPException.php create mode 100644 vendor/vendor/fastadminnet/fastadmin-mailer/src/Mailer/Exceptions/SendException.php create mode 100644 vendor/vendor/fastadminnet/fastadmin-mailer/src/Mailer/Message.php create mode 100644 vendor/vendor/fastadminnet/fastadmin-mailer/src/Mailer/SMTP.php create mode 100644 vendor/vendor/guzzlehttp/guzzle/CHANGELOG.md create mode 100644 vendor/vendor/guzzlehttp/guzzle/LICENSE create mode 100644 vendor/vendor/guzzlehttp/guzzle/README.md create mode 100644 vendor/vendor/guzzlehttp/guzzle/UPGRADING.md create mode 100644 vendor/vendor/guzzlehttp/guzzle/composer.json create mode 100644 vendor/vendor/guzzlehttp/guzzle/src/BodySummarizer.php create mode 100644 vendor/vendor/guzzlehttp/guzzle/src/BodySummarizerInterface.php create mode 100644 vendor/vendor/guzzlehttp/guzzle/src/Client.php create mode 100644 vendor/vendor/guzzlehttp/guzzle/src/ClientInterface.php create mode 100644 vendor/vendor/guzzlehttp/guzzle/src/ClientTrait.php create mode 100644 vendor/vendor/guzzlehttp/guzzle/src/Cookie/CookieJar.php create mode 100644 vendor/vendor/guzzlehttp/guzzle/src/Cookie/CookieJarInterface.php create mode 100644 vendor/vendor/guzzlehttp/guzzle/src/Cookie/FileCookieJar.php create mode 100644 vendor/vendor/guzzlehttp/guzzle/src/Cookie/SessionCookieJar.php create mode 100644 vendor/vendor/guzzlehttp/guzzle/src/Cookie/SetCookie.php create mode 100644 vendor/vendor/guzzlehttp/guzzle/src/Exception/BadResponseException.php create mode 100644 vendor/vendor/guzzlehttp/guzzle/src/Exception/ClientException.php create mode 100644 vendor/vendor/guzzlehttp/guzzle/src/Exception/ConnectException.php create mode 100644 vendor/vendor/guzzlehttp/guzzle/src/Exception/GuzzleException.php create mode 100644 vendor/vendor/guzzlehttp/guzzle/src/Exception/InvalidArgumentException.php create mode 100644 vendor/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php create mode 100644 vendor/vendor/guzzlehttp/guzzle/src/Exception/ServerException.php create mode 100644 vendor/vendor/guzzlehttp/guzzle/src/Exception/TooManyRedirectsException.php create mode 100644 vendor/vendor/guzzlehttp/guzzle/src/Exception/TransferException.php create mode 100644 vendor/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php create mode 100644 vendor/vendor/guzzlehttp/guzzle/src/Handler/CurlFactoryInterface.php create mode 100644 vendor/vendor/guzzlehttp/guzzle/src/Handler/CurlHandler.php create mode 100644 vendor/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php create mode 100644 vendor/vendor/guzzlehttp/guzzle/src/Handler/EasyHandle.php create mode 100644 vendor/vendor/guzzlehttp/guzzle/src/Handler/HeaderProcessor.php create mode 100644 vendor/vendor/guzzlehttp/guzzle/src/Handler/MockHandler.php create mode 100644 vendor/vendor/guzzlehttp/guzzle/src/Handler/Proxy.php create mode 100644 vendor/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php create mode 100644 vendor/vendor/guzzlehttp/guzzle/src/HandlerStack.php create mode 100644 vendor/vendor/guzzlehttp/guzzle/src/MessageFormatter.php create mode 100644 vendor/vendor/guzzlehttp/guzzle/src/MessageFormatterInterface.php create mode 100644 vendor/vendor/guzzlehttp/guzzle/src/Middleware.php create mode 100644 vendor/vendor/guzzlehttp/guzzle/src/Pool.php create mode 100644 vendor/vendor/guzzlehttp/guzzle/src/PrepareBodyMiddleware.php create mode 100644 vendor/vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php create mode 100644 vendor/vendor/guzzlehttp/guzzle/src/RequestOptions.php create mode 100644 vendor/vendor/guzzlehttp/guzzle/src/RetryMiddleware.php create mode 100644 vendor/vendor/guzzlehttp/guzzle/src/TransferStats.php create mode 100644 vendor/vendor/guzzlehttp/guzzle/src/Utils.php create mode 100644 vendor/vendor/guzzlehttp/guzzle/src/functions.php create mode 100644 vendor/vendor/guzzlehttp/guzzle/src/functions_include.php create mode 100644 vendor/vendor/guzzlehttp/promises/CHANGELOG.md create mode 100644 vendor/vendor/guzzlehttp/promises/LICENSE create mode 100644 vendor/vendor/guzzlehttp/promises/README.md create mode 100644 vendor/vendor/guzzlehttp/promises/composer.json create mode 100644 vendor/vendor/guzzlehttp/promises/src/AggregateException.php create mode 100644 vendor/vendor/guzzlehttp/promises/src/CancellationException.php create mode 100644 vendor/vendor/guzzlehttp/promises/src/Coroutine.php create mode 100644 vendor/vendor/guzzlehttp/promises/src/Create.php create mode 100644 vendor/vendor/guzzlehttp/promises/src/Each.php create mode 100644 vendor/vendor/guzzlehttp/promises/src/EachPromise.php create mode 100644 vendor/vendor/guzzlehttp/promises/src/FulfilledPromise.php create mode 100644 vendor/vendor/guzzlehttp/promises/src/Is.php create mode 100644 vendor/vendor/guzzlehttp/promises/src/Promise.php create mode 100644 vendor/vendor/guzzlehttp/promises/src/PromiseInterface.php create mode 100644 vendor/vendor/guzzlehttp/promises/src/PromisorInterface.php create mode 100644 vendor/vendor/guzzlehttp/promises/src/RejectedPromise.php create mode 100644 vendor/vendor/guzzlehttp/promises/src/RejectionException.php create mode 100644 vendor/vendor/guzzlehttp/promises/src/TaskQueue.php create mode 100644 vendor/vendor/guzzlehttp/promises/src/TaskQueueInterface.php create mode 100644 vendor/vendor/guzzlehttp/promises/src/Utils.php create mode 100644 vendor/vendor/guzzlehttp/psr7/CHANGELOG.md create mode 100644 vendor/vendor/guzzlehttp/psr7/LICENSE create mode 100644 vendor/vendor/guzzlehttp/psr7/README.md create mode 100644 vendor/vendor/guzzlehttp/psr7/composer.json create mode 100644 vendor/vendor/guzzlehttp/psr7/src/AppendStream.php create mode 100644 vendor/vendor/guzzlehttp/psr7/src/BufferStream.php create mode 100644 vendor/vendor/guzzlehttp/psr7/src/CachingStream.php create mode 100644 vendor/vendor/guzzlehttp/psr7/src/DroppingStream.php create mode 100644 vendor/vendor/guzzlehttp/psr7/src/Exception/MalformedUriException.php create mode 100644 vendor/vendor/guzzlehttp/psr7/src/FnStream.php create mode 100644 vendor/vendor/guzzlehttp/psr7/src/Header.php create mode 100644 vendor/vendor/guzzlehttp/psr7/src/HttpFactory.php create mode 100644 vendor/vendor/guzzlehttp/psr7/src/InflateStream.php create mode 100644 vendor/vendor/guzzlehttp/psr7/src/LazyOpenStream.php create mode 100644 vendor/vendor/guzzlehttp/psr7/src/LimitStream.php create mode 100644 vendor/vendor/guzzlehttp/psr7/src/Message.php create mode 100644 vendor/vendor/guzzlehttp/psr7/src/MessageTrait.php create mode 100644 vendor/vendor/guzzlehttp/psr7/src/MimeType.php create mode 100644 vendor/vendor/guzzlehttp/psr7/src/MultipartStream.php create mode 100644 vendor/vendor/guzzlehttp/psr7/src/NoSeekStream.php create mode 100644 vendor/vendor/guzzlehttp/psr7/src/PumpStream.php create mode 100644 vendor/vendor/guzzlehttp/psr7/src/Query.php create mode 100644 vendor/vendor/guzzlehttp/psr7/src/Request.php create mode 100644 vendor/vendor/guzzlehttp/psr7/src/Response.php create mode 100644 vendor/vendor/guzzlehttp/psr7/src/Rfc7230.php create mode 100644 vendor/vendor/guzzlehttp/psr7/src/ServerRequest.php create mode 100644 vendor/vendor/guzzlehttp/psr7/src/Stream.php create mode 100644 vendor/vendor/guzzlehttp/psr7/src/StreamDecoratorTrait.php create mode 100644 vendor/vendor/guzzlehttp/psr7/src/StreamWrapper.php create mode 100644 vendor/vendor/guzzlehttp/psr7/src/UploadedFile.php create mode 100644 vendor/vendor/guzzlehttp/psr7/src/Uri.php create mode 100644 vendor/vendor/guzzlehttp/psr7/src/UriComparator.php create mode 100644 vendor/vendor/guzzlehttp/psr7/src/UriNormalizer.php create mode 100644 vendor/vendor/guzzlehttp/psr7/src/UriResolver.php create mode 100644 vendor/vendor/guzzlehttp/psr7/src/Utils.php create mode 100644 vendor/vendor/lizhichao/one-sm/.github/FUNDING.yml create mode 100644 vendor/vendor/lizhichao/one-sm/.github/workflows/sm.yml create mode 100644 vendor/vendor/lizhichao/one-sm/.gitignore create mode 100644 vendor/vendor/lizhichao/one-sm/.php_cs.dist create mode 100644 vendor/vendor/lizhichao/one-sm/README.md create mode 100644 vendor/vendor/lizhichao/one-sm/bench.php create mode 100644 vendor/vendor/lizhichao/one-sm/composer.json create mode 100644 vendor/vendor/lizhichao/one-sm/src/Sm3.php create mode 100644 vendor/vendor/lizhichao/one-sm/src/Sm4.php create mode 100644 vendor/vendor/lizhichao/one-sm/test.php create mode 100644 vendor/vendor/lizhichao/one-sm/tests/sm3.php create mode 100644 vendor/vendor/lizhichao/one-sm/tests/sm4.php create mode 100644 vendor/vendor/maennchen/zipstream-php/.phive/phars.xml create mode 100644 vendor/vendor/maennchen/zipstream-php/.php-cs-fixer.dist.php create mode 100644 vendor/vendor/maennchen/zipstream-php/.phpdoc/template/base.html.twig create mode 100644 vendor/vendor/maennchen/zipstream-php/.tool-versions create mode 100644 vendor/vendor/maennchen/zipstream-php/LICENSE create mode 100644 vendor/vendor/maennchen/zipstream-php/README.md create mode 100644 vendor/vendor/maennchen/zipstream-php/composer.json create mode 100644 vendor/vendor/maennchen/zipstream-php/guides/ContentLength.rst create mode 100644 vendor/vendor/maennchen/zipstream-php/guides/FlySystem.rst create mode 100644 vendor/vendor/maennchen/zipstream-php/guides/Nginx.rst create mode 100644 vendor/vendor/maennchen/zipstream-php/guides/Options.rst create mode 100644 vendor/vendor/maennchen/zipstream-php/guides/PSR7Streams.rst create mode 100644 vendor/vendor/maennchen/zipstream-php/guides/StreamOutput.rst create mode 100644 vendor/vendor/maennchen/zipstream-php/guides/Symfony.rst create mode 100644 vendor/vendor/maennchen/zipstream-php/guides/Varnish.rst create mode 100644 vendor/vendor/maennchen/zipstream-php/guides/index.rst create mode 100644 vendor/vendor/maennchen/zipstream-php/phpdoc.dist.xml create mode 100644 vendor/vendor/maennchen/zipstream-php/phpunit.xml.dist create mode 100644 vendor/vendor/maennchen/zipstream-php/psalm.xml create mode 100644 vendor/vendor/maennchen/zipstream-php/src/Bigint.php create mode 100644 vendor/vendor/maennchen/zipstream-php/src/DeflateStream.php create mode 100644 vendor/vendor/maennchen/zipstream-php/src/Exception.php create mode 100644 vendor/vendor/maennchen/zipstream-php/src/Exception/EncodingException.php create mode 100644 vendor/vendor/maennchen/zipstream-php/src/Exception/FileNotFoundException.php create mode 100644 vendor/vendor/maennchen/zipstream-php/src/Exception/FileNotReadableException.php create mode 100644 vendor/vendor/maennchen/zipstream-php/src/Exception/IncompatibleOptionsException.php create mode 100644 vendor/vendor/maennchen/zipstream-php/src/Exception/OverflowException.php create mode 100644 vendor/vendor/maennchen/zipstream-php/src/Exception/StreamNotReadableException.php create mode 100644 vendor/vendor/maennchen/zipstream-php/src/File.php create mode 100644 vendor/vendor/maennchen/zipstream-php/src/Option/Archive.php create mode 100644 vendor/vendor/maennchen/zipstream-php/src/Option/File.php create mode 100644 vendor/vendor/maennchen/zipstream-php/src/Option/Method.php create mode 100644 vendor/vendor/maennchen/zipstream-php/src/Option/Version.php create mode 100644 vendor/vendor/maennchen/zipstream-php/src/Stream.php create mode 100644 vendor/vendor/maennchen/zipstream-php/src/ZipStream.php create mode 100644 vendor/vendor/maennchen/zipstream-php/test/BigintTest.php create mode 100644 vendor/vendor/maennchen/zipstream-php/test/ZipStreamTest.php create mode 100644 vendor/vendor/maennchen/zipstream-php/test/bootstrap.php create mode 100644 vendor/vendor/maennchen/zipstream-php/test/bug/BugHonorFileTimeTest.php create mode 100644 vendor/vendor/markbaker/complex/.github/workflows/main.yml create mode 100644 vendor/vendor/markbaker/complex/README.md create mode 100644 vendor/vendor/markbaker/complex/classes/src/Complex.php create mode 100644 vendor/vendor/markbaker/complex/classes/src/Exception.php create mode 100644 vendor/vendor/markbaker/complex/classes/src/Functions.php create mode 100644 vendor/vendor/markbaker/complex/classes/src/Operations.php create mode 100644 vendor/vendor/markbaker/complex/composer.json create mode 100644 vendor/vendor/markbaker/complex/examples/complexTest.php create mode 100644 vendor/vendor/markbaker/complex/examples/testFunctions.php create mode 100644 vendor/vendor/markbaker/complex/examples/testOperations.php create mode 100644 vendor/vendor/markbaker/complex/license.md create mode 100644 vendor/vendor/markbaker/matrix/.github/workflows/main.yaml create mode 100644 vendor/vendor/markbaker/matrix/README.md create mode 100644 vendor/vendor/markbaker/matrix/buildPhar.php create mode 100644 vendor/vendor/markbaker/matrix/classes/src/Builder.php create mode 100644 vendor/vendor/markbaker/matrix/classes/src/Decomposition/Decomposition.php create mode 100644 vendor/vendor/markbaker/matrix/classes/src/Decomposition/LU.php create mode 100644 vendor/vendor/markbaker/matrix/classes/src/Decomposition/QR.php create mode 100644 vendor/vendor/markbaker/matrix/classes/src/Div0Exception.php create mode 100644 vendor/vendor/markbaker/matrix/classes/src/Exception.php create mode 100644 vendor/vendor/markbaker/matrix/classes/src/Functions.php create mode 100644 vendor/vendor/markbaker/matrix/classes/src/Matrix.php create mode 100644 vendor/vendor/markbaker/matrix/classes/src/Operations.php create mode 100644 vendor/vendor/markbaker/matrix/classes/src/Operators/Addition.php create mode 100644 vendor/vendor/markbaker/matrix/classes/src/Operators/DirectSum.php create mode 100644 vendor/vendor/markbaker/matrix/classes/src/Operators/Division.php create mode 100644 vendor/vendor/markbaker/matrix/classes/src/Operators/Multiplication.php create mode 100644 vendor/vendor/markbaker/matrix/classes/src/Operators/Operator.php create mode 100644 vendor/vendor/markbaker/matrix/classes/src/Operators/Subtraction.php create mode 100644 vendor/vendor/markbaker/matrix/composer.json create mode 100644 vendor/vendor/markbaker/matrix/examples/test.php create mode 100644 vendor/vendor/markbaker/matrix/infection.json.dist create mode 100644 vendor/vendor/markbaker/matrix/license.md create mode 100644 vendor/vendor/markbaker/matrix/phpstan.neon create mode 100644 vendor/vendor/monolog/monolog/CHANGELOG.md create mode 100644 vendor/vendor/monolog/monolog/LICENSE create mode 100644 vendor/vendor/monolog/monolog/README.md create mode 100644 vendor/vendor/monolog/monolog/UPGRADE.md create mode 100644 vendor/vendor/monolog/monolog/composer.json create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Attribute/AsMonologProcessor.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/DateTimeImmutable.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/ErrorHandler.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Formatter/ChromePHPFormatter.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Formatter/ElasticaFormatter.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Formatter/ElasticsearchFormatter.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Formatter/FlowdockFormatter.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Formatter/FluentdFormatter.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Formatter/FormatterInterface.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Formatter/GelfMessageFormatter.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Formatter/GoogleCloudLoggingFormatter.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Formatter/HtmlFormatter.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Formatter/JsonFormatter.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Formatter/LineFormatter.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Formatter/LogglyFormatter.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Formatter/LogmaticFormatter.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Formatter/LogstashFormatter.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Formatter/MongoDBFormatter.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Formatter/NormalizerFormatter.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Formatter/ScalarFormatter.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Formatter/WildfireFormatter.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Handler/AbstractHandler.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Handler/AbstractSyslogHandler.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Handler/AmqpHandler.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Handler/BrowserConsoleHandler.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Handler/BufferHandler.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Handler/ChromePHPHandler.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Handler/CouchDBHandler.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Handler/CubeHandler.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Handler/Curl/Util.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Handler/DeduplicationHandler.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Handler/DoctrineCouchDBHandler.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Handler/DynamoDbHandler.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Handler/ElasticaHandler.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Handler/ElasticsearchHandler.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Handler/ErrorLogHandler.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Handler/FallbackGroupHandler.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Handler/FilterHandler.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossed/ActivationStrategyInterface.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossed/ChannelLevelActivationStrategy.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossed/ErrorLevelActivationStrategy.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossedHandler.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Handler/FirePHPHandler.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Handler/FleepHookHandler.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Handler/FlowdockHandler.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Handler/FormattableHandlerInterface.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Handler/FormattableHandlerTrait.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Handler/GelfHandler.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Handler/GroupHandler.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Handler/Handler.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Handler/HandlerInterface.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Handler/HandlerWrapper.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Handler/IFTTTHandler.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Handler/InsightOpsHandler.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Handler/LogEntriesHandler.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Handler/LogglyHandler.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Handler/LogmaticHandler.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Handler/MailHandler.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Handler/MandrillHandler.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Handler/MissingExtensionException.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Handler/MongoDBHandler.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Handler/NativeMailerHandler.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Handler/NewRelicHandler.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Handler/NoopHandler.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Handler/NullHandler.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Handler/OverflowHandler.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Handler/PHPConsoleHandler.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Handler/ProcessHandler.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Handler/ProcessableHandlerInterface.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Handler/ProcessableHandlerTrait.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Handler/PsrHandler.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Handler/PushoverHandler.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Handler/RedisHandler.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Handler/RedisPubSubHandler.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Handler/RollbarHandler.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Handler/RotatingFileHandler.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Handler/SamplingHandler.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Handler/SendGridHandler.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Handler/Slack/SlackRecord.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Handler/SlackHandler.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Handler/SlackWebhookHandler.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Handler/SocketHandler.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Handler/SqsHandler.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Handler/SwiftMailerHandler.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Handler/SymfonyMailerHandler.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Handler/SyslogHandler.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Handler/SyslogUdp/UdpSocket.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Handler/SyslogUdpHandler.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Handler/TelegramBotHandler.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Handler/TestHandler.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Handler/WebRequestRecognizerTrait.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Handler/WhatFailureGroupHandler.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Handler/ZendMonitorHandler.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/LogRecord.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Logger.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Processor/GitProcessor.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Processor/HostnameProcessor.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Processor/IntrospectionProcessor.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Processor/MemoryPeakUsageProcessor.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Processor/MemoryProcessor.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Processor/MemoryUsageProcessor.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Processor/MercurialProcessor.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Processor/ProcessIdProcessor.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Processor/ProcessorInterface.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Processor/PsrLogMessageProcessor.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Processor/TagProcessor.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Processor/UidProcessor.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Processor/WebProcessor.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Registry.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/ResettableInterface.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/SignalHandler.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Test/TestCase.php create mode 100644 vendor/vendor/monolog/monolog/src/Monolog/Utils.php create mode 100644 vendor/vendor/myclabs/php-enum/LICENSE create mode 100644 vendor/vendor/myclabs/php-enum/README.md create mode 100644 vendor/vendor/myclabs/php-enum/SECURITY.md create mode 100644 vendor/vendor/myclabs/php-enum/composer.json create mode 100644 vendor/vendor/myclabs/php-enum/src/Enum.php create mode 100644 vendor/vendor/myclabs/php-enum/src/PHPUnit/Comparator.php create mode 100644 vendor/vendor/myclabs/php-enum/stubs/Stringable.php create mode 100644 vendor/vendor/nelexa/zip/.php-cs-fixer.php create mode 100644 vendor/vendor/nelexa/zip/.phpstorm.meta.php create mode 100644 vendor/vendor/nelexa/zip/LICENSE create mode 100644 vendor/vendor/nelexa/zip/README.RU.md create mode 100644 vendor/vendor/nelexa/zip/README.md create mode 100644 vendor/vendor/nelexa/zip/composer.json create mode 100644 vendor/vendor/nelexa/zip/src/Constants/DosAttrs.php create mode 100644 vendor/vendor/nelexa/zip/src/Constants/DosCodePage.php create mode 100644 vendor/vendor/nelexa/zip/src/Constants/GeneralPurposeBitFlag.php create mode 100644 vendor/vendor/nelexa/zip/src/Constants/UnixStat.php create mode 100644 vendor/vendor/nelexa/zip/src/Constants/ZipCompressionLevel.php create mode 100644 vendor/vendor/nelexa/zip/src/Constants/ZipCompressionMethod.php create mode 100644 vendor/vendor/nelexa/zip/src/Constants/ZipConstants.php create mode 100644 vendor/vendor/nelexa/zip/src/Constants/ZipEncryptionMethod.php create mode 100644 vendor/vendor/nelexa/zip/src/Constants/ZipOptions.php create mode 100644 vendor/vendor/nelexa/zip/src/Constants/ZipPlatform.php create mode 100644 vendor/vendor/nelexa/zip/src/Constants/ZipVersion.php create mode 100644 vendor/vendor/nelexa/zip/src/Exception/Crc32Exception.php create mode 100644 vendor/vendor/nelexa/zip/src/Exception/InvalidArgumentException.php create mode 100644 vendor/vendor/nelexa/zip/src/Exception/RuntimeException.php create mode 100644 vendor/vendor/nelexa/zip/src/Exception/ZipAuthenticationException.php create mode 100644 vendor/vendor/nelexa/zip/src/Exception/ZipCryptoException.php create mode 100644 vendor/vendor/nelexa/zip/src/Exception/ZipEntryNotFoundException.php create mode 100644 vendor/vendor/nelexa/zip/src/Exception/ZipException.php create mode 100644 vendor/vendor/nelexa/zip/src/Exception/ZipUnsupportMethodException.php create mode 100644 vendor/vendor/nelexa/zip/src/IO/Filter/Cipher/Pkware/PKCryptContext.php create mode 100644 vendor/vendor/nelexa/zip/src/IO/Filter/Cipher/Pkware/PKDecryptionStreamFilter.php create mode 100644 vendor/vendor/nelexa/zip/src/IO/Filter/Cipher/Pkware/PKEncryptionStreamFilter.php create mode 100644 vendor/vendor/nelexa/zip/src/IO/Filter/Cipher/WinZipAes/WinZipAesContext.php create mode 100644 vendor/vendor/nelexa/zip/src/IO/Filter/Cipher/WinZipAes/WinZipAesDecryptionStreamFilter.php create mode 100644 vendor/vendor/nelexa/zip/src/IO/Filter/Cipher/WinZipAes/WinZipAesEncryptionStreamFilter.php create mode 100644 vendor/vendor/nelexa/zip/src/IO/Stream/ResponseStream.php create mode 100644 vendor/vendor/nelexa/zip/src/IO/Stream/ZipEntryStreamWrapper.php create mode 100644 vendor/vendor/nelexa/zip/src/IO/ZipReader.php create mode 100644 vendor/vendor/nelexa/zip/src/IO/ZipWriter.php create mode 100644 vendor/vendor/nelexa/zip/src/Model/Data/ZipFileData.php create mode 100644 vendor/vendor/nelexa/zip/src/Model/Data/ZipNewData.php create mode 100644 vendor/vendor/nelexa/zip/src/Model/Data/ZipSourceFileData.php create mode 100644 vendor/vendor/nelexa/zip/src/Model/EndOfCentralDirectory.php create mode 100644 vendor/vendor/nelexa/zip/src/Model/Extra/ExtraFieldsCollection.php create mode 100644 vendor/vendor/nelexa/zip/src/Model/Extra/Fields/AbstractUnicodeExtraField.php create mode 100644 vendor/vendor/nelexa/zip/src/Model/Extra/Fields/ApkAlignmentExtraField.php create mode 100644 vendor/vendor/nelexa/zip/src/Model/Extra/Fields/AsiExtraField.php create mode 100644 vendor/vendor/nelexa/zip/src/Model/Extra/Fields/ExtendedTimestampExtraField.php create mode 100644 vendor/vendor/nelexa/zip/src/Model/Extra/Fields/JarMarkerExtraField.php create mode 100644 vendor/vendor/nelexa/zip/src/Model/Extra/Fields/NewUnixExtraField.php create mode 100644 vendor/vendor/nelexa/zip/src/Model/Extra/Fields/NtfsExtraField.php create mode 100644 vendor/vendor/nelexa/zip/src/Model/Extra/Fields/OldUnixExtraField.php create mode 100644 vendor/vendor/nelexa/zip/src/Model/Extra/Fields/UnicodeCommentExtraField.php create mode 100644 vendor/vendor/nelexa/zip/src/Model/Extra/Fields/UnicodePathExtraField.php create mode 100644 vendor/vendor/nelexa/zip/src/Model/Extra/Fields/UnrecognizedExtraField.php create mode 100644 vendor/vendor/nelexa/zip/src/Model/Extra/Fields/WinZipAesExtraField.php create mode 100644 vendor/vendor/nelexa/zip/src/Model/Extra/Fields/Zip64ExtraField.php create mode 100644 vendor/vendor/nelexa/zip/src/Model/Extra/ZipExtraDriver.php create mode 100644 vendor/vendor/nelexa/zip/src/Model/Extra/ZipExtraField.php create mode 100644 vendor/vendor/nelexa/zip/src/Model/ImmutableZipContainer.php create mode 100644 vendor/vendor/nelexa/zip/src/Model/ZipContainer.php create mode 100644 vendor/vendor/nelexa/zip/src/Model/ZipData.php create mode 100644 vendor/vendor/nelexa/zip/src/Model/ZipEntry.php create mode 100644 vendor/vendor/nelexa/zip/src/Model/ZipEntryMatcher.php create mode 100644 vendor/vendor/nelexa/zip/src/Util/CryptoUtil.php create mode 100644 vendor/vendor/nelexa/zip/src/Util/DateTimeConverter.php create mode 100644 vendor/vendor/nelexa/zip/src/Util/FileAttribUtil.php create mode 100644 vendor/vendor/nelexa/zip/src/Util/FilesUtil.php create mode 100644 vendor/vendor/nelexa/zip/src/Util/Iterator/IgnoreFilesFilterIterator.php create mode 100644 vendor/vendor/nelexa/zip/src/Util/Iterator/IgnoreFilesRecursiveFilterIterator.php create mode 100644 vendor/vendor/nelexa/zip/src/Util/MathUtil.php create mode 100644 vendor/vendor/nelexa/zip/src/Util/StringUtil.php create mode 100644 vendor/vendor/nelexa/zip/src/ZipFile.php create mode 100644 vendor/vendor/overtrue/pinyin/LICENSE create mode 100644 vendor/vendor/overtrue/pinyin/README.md create mode 100644 vendor/vendor/overtrue/pinyin/composer.json create mode 100644 vendor/vendor/overtrue/pinyin/data/surnames create mode 100644 vendor/vendor/overtrue/pinyin/data/words_0 create mode 100644 vendor/vendor/overtrue/pinyin/data/words_1 create mode 100644 vendor/vendor/overtrue/pinyin/data/words_2 create mode 100644 vendor/vendor/overtrue/pinyin/data/words_3 create mode 100644 vendor/vendor/overtrue/pinyin/data/words_4 create mode 100644 vendor/vendor/overtrue/pinyin/data/words_5 create mode 100644 vendor/vendor/overtrue/pinyin/src/DictLoaderInterface.php create mode 100644 vendor/vendor/overtrue/pinyin/src/FileDictLoader.php create mode 100644 vendor/vendor/overtrue/pinyin/src/GeneratorFileDictLoader.php create mode 100644 vendor/vendor/overtrue/pinyin/src/MemoryFileDictLoader.php create mode 100644 vendor/vendor/overtrue/pinyin/src/Pinyin.php create mode 100644 vendor/vendor/overtrue/socialite/.github/FUNDING.yml create mode 100644 vendor/vendor/overtrue/socialite/.gitignore create mode 100644 vendor/vendor/overtrue/socialite/.php_cs create mode 100644 vendor/vendor/overtrue/socialite/.travis.yml create mode 100644 vendor/vendor/overtrue/socialite/LICENSE.txt create mode 100644 vendor/vendor/overtrue/socialite/README.md create mode 100644 vendor/vendor/overtrue/socialite/composer.json create mode 100644 vendor/vendor/overtrue/socialite/phpunit.xml create mode 100644 vendor/vendor/overtrue/socialite/src/AccessToken.php create mode 100644 vendor/vendor/overtrue/socialite/src/AccessTokenInterface.php create mode 100644 vendor/vendor/overtrue/socialite/src/AuthorizeFailedException.php create mode 100644 vendor/vendor/overtrue/socialite/src/Config.php create mode 100644 vendor/vendor/overtrue/socialite/src/FactoryInterface.php create mode 100644 vendor/vendor/overtrue/socialite/src/HasAttributes.php create mode 100644 vendor/vendor/overtrue/socialite/src/InvalidArgumentException.php create mode 100644 vendor/vendor/overtrue/socialite/src/InvalidStateException.php create mode 100644 vendor/vendor/overtrue/socialite/src/ProviderInterface.php create mode 100644 vendor/vendor/overtrue/socialite/src/Providers/AbstractProvider.php create mode 100644 vendor/vendor/overtrue/socialite/src/Providers/BaiduProvider.php create mode 100644 vendor/vendor/overtrue/socialite/src/Providers/DouYinProvider.php create mode 100644 vendor/vendor/overtrue/socialite/src/Providers/DoubanProvider.php create mode 100644 vendor/vendor/overtrue/socialite/src/Providers/FacebookProvider.php create mode 100644 vendor/vendor/overtrue/socialite/src/Providers/FeiShuProvider.php create mode 100644 vendor/vendor/overtrue/socialite/src/Providers/GitHubProvider.php create mode 100644 vendor/vendor/overtrue/socialite/src/Providers/GoogleProvider.php create mode 100644 vendor/vendor/overtrue/socialite/src/Providers/LinkedinProvider.php create mode 100644 vendor/vendor/overtrue/socialite/src/Providers/OutlookProvider.php create mode 100644 vendor/vendor/overtrue/socialite/src/Providers/QQProvider.php create mode 100644 vendor/vendor/overtrue/socialite/src/Providers/TaobaoProvider.php create mode 100644 vendor/vendor/overtrue/socialite/src/Providers/WeChatProvider.php create mode 100644 vendor/vendor/overtrue/socialite/src/Providers/WeWorkProvider.php create mode 100644 vendor/vendor/overtrue/socialite/src/Providers/WeiboProvider.php create mode 100644 vendor/vendor/overtrue/socialite/src/SocialiteManager.php create mode 100644 vendor/vendor/overtrue/socialite/src/User.php create mode 100644 vendor/vendor/overtrue/socialite/src/UserInterface.php create mode 100644 vendor/vendor/overtrue/socialite/src/WeChatComponentInterface.php create mode 100644 vendor/vendor/overtrue/socialite/tests/OAuthTest.php create mode 100644 vendor/vendor/overtrue/socialite/tests/Providers/WeWorkProviderTest.php create mode 100644 vendor/vendor/overtrue/socialite/tests/UserTest.php create mode 100644 vendor/vendor/overtrue/socialite/tests/WechatProviderTest.php create mode 100644 vendor/vendor/overtrue/wechat/CHANGELOG.md create mode 100644 vendor/vendor/overtrue/wechat/CONTRIBUTING.md create mode 100644 vendor/vendor/overtrue/wechat/LICENSE create mode 100644 vendor/vendor/overtrue/wechat/README.md create mode 100644 vendor/vendor/overtrue/wechat/composer.json create mode 100644 vendor/vendor/overtrue/wechat/src/BasicService/Application.php create mode 100644 vendor/vendor/overtrue/wechat/src/BasicService/ContentSecurity/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/BasicService/ContentSecurity/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/BasicService/Jssdk/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/BasicService/Jssdk/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/BasicService/Media/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/BasicService/Media/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/BasicService/QrCode/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/BasicService/QrCode/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/BasicService/Url/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/BasicService/Url/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/Factory.php create mode 100644 vendor/vendor/overtrue/wechat/src/Kernel/AccessToken.php create mode 100644 vendor/vendor/overtrue/wechat/src/Kernel/BaseClient.php create mode 100644 vendor/vendor/overtrue/wechat/src/Kernel/Clauses/Clause.php create mode 100644 vendor/vendor/overtrue/wechat/src/Kernel/Config.php create mode 100644 vendor/vendor/overtrue/wechat/src/Kernel/Contracts/AccessTokenInterface.php create mode 100644 vendor/vendor/overtrue/wechat/src/Kernel/Contracts/Arrayable.php create mode 100644 vendor/vendor/overtrue/wechat/src/Kernel/Contracts/EventHandlerInterface.php create mode 100644 vendor/vendor/overtrue/wechat/src/Kernel/Contracts/MediaInterface.php create mode 100644 vendor/vendor/overtrue/wechat/src/Kernel/Contracts/MessageInterface.php create mode 100644 vendor/vendor/overtrue/wechat/src/Kernel/Decorators/FinallyResult.php create mode 100644 vendor/vendor/overtrue/wechat/src/Kernel/Decorators/TerminateResult.php create mode 100644 vendor/vendor/overtrue/wechat/src/Kernel/Encryptor.php create mode 100644 vendor/vendor/overtrue/wechat/src/Kernel/Events/AccessTokenRefreshed.php create mode 100644 vendor/vendor/overtrue/wechat/src/Kernel/Events/ApplicationInitialized.php create mode 100644 vendor/vendor/overtrue/wechat/src/Kernel/Events/HttpResponseCreated.php create mode 100644 vendor/vendor/overtrue/wechat/src/Kernel/Events/ServerGuardResponseCreated.php create mode 100644 vendor/vendor/overtrue/wechat/src/Kernel/Exceptions/BadRequestException.php create mode 100644 vendor/vendor/overtrue/wechat/src/Kernel/Exceptions/DecryptException.php create mode 100644 vendor/vendor/overtrue/wechat/src/Kernel/Exceptions/Exception.php create mode 100644 vendor/vendor/overtrue/wechat/src/Kernel/Exceptions/HttpException.php create mode 100644 vendor/vendor/overtrue/wechat/src/Kernel/Exceptions/InvalidArgumentException.php create mode 100644 vendor/vendor/overtrue/wechat/src/Kernel/Exceptions/InvalidConfigException.php create mode 100644 vendor/vendor/overtrue/wechat/src/Kernel/Exceptions/RuntimeException.php create mode 100644 vendor/vendor/overtrue/wechat/src/Kernel/Exceptions/UnboundServiceException.php create mode 100644 vendor/vendor/overtrue/wechat/src/Kernel/Helpers.php create mode 100644 vendor/vendor/overtrue/wechat/src/Kernel/Http/Response.php create mode 100644 vendor/vendor/overtrue/wechat/src/Kernel/Http/StreamResponse.php create mode 100644 vendor/vendor/overtrue/wechat/src/Kernel/Log/LogManager.php create mode 100644 vendor/vendor/overtrue/wechat/src/Kernel/Messages/Article.php create mode 100644 vendor/vendor/overtrue/wechat/src/Kernel/Messages/Card.php create mode 100644 vendor/vendor/overtrue/wechat/src/Kernel/Messages/DeviceEvent.php create mode 100644 vendor/vendor/overtrue/wechat/src/Kernel/Messages/DeviceText.php create mode 100644 vendor/vendor/overtrue/wechat/src/Kernel/Messages/File.php create mode 100644 vendor/vendor/overtrue/wechat/src/Kernel/Messages/Image.php create mode 100644 vendor/vendor/overtrue/wechat/src/Kernel/Messages/Link.php create mode 100644 vendor/vendor/overtrue/wechat/src/Kernel/Messages/Location.php create mode 100644 vendor/vendor/overtrue/wechat/src/Kernel/Messages/Media.php create mode 100644 vendor/vendor/overtrue/wechat/src/Kernel/Messages/Message.php create mode 100644 vendor/vendor/overtrue/wechat/src/Kernel/Messages/MiniProgramPage.php create mode 100644 vendor/vendor/overtrue/wechat/src/Kernel/Messages/MiniprogramNotice.php create mode 100644 vendor/vendor/overtrue/wechat/src/Kernel/Messages/Music.php create mode 100644 vendor/vendor/overtrue/wechat/src/Kernel/Messages/News.php create mode 100644 vendor/vendor/overtrue/wechat/src/Kernel/Messages/NewsItem.php create mode 100644 vendor/vendor/overtrue/wechat/src/Kernel/Messages/Raw.php create mode 100644 vendor/vendor/overtrue/wechat/src/Kernel/Messages/ShortVideo.php create mode 100644 vendor/vendor/overtrue/wechat/src/Kernel/Messages/TaskCard.php create mode 100644 vendor/vendor/overtrue/wechat/src/Kernel/Messages/Text.php create mode 100644 vendor/vendor/overtrue/wechat/src/Kernel/Messages/TextCard.php create mode 100644 vendor/vendor/overtrue/wechat/src/Kernel/Messages/Transfer.php create mode 100644 vendor/vendor/overtrue/wechat/src/Kernel/Messages/Video.php create mode 100644 vendor/vendor/overtrue/wechat/src/Kernel/Messages/Voice.php create mode 100644 vendor/vendor/overtrue/wechat/src/Kernel/Providers/ConfigServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/Kernel/Providers/EventDispatcherServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/Kernel/Providers/ExtensionServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/Kernel/Providers/HttpClientServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/Kernel/Providers/LogServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/Kernel/Providers/RequestServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/Kernel/ServerGuard.php create mode 100644 vendor/vendor/overtrue/wechat/src/Kernel/ServiceContainer.php create mode 100644 vendor/vendor/overtrue/wechat/src/Kernel/Support/AES.php create mode 100644 vendor/vendor/overtrue/wechat/src/Kernel/Support/Arr.php create mode 100644 vendor/vendor/overtrue/wechat/src/Kernel/Support/ArrayAccessible.php create mode 100644 vendor/vendor/overtrue/wechat/src/Kernel/Support/Collection.php create mode 100644 vendor/vendor/overtrue/wechat/src/Kernel/Support/File.php create mode 100644 vendor/vendor/overtrue/wechat/src/Kernel/Support/Helpers.php create mode 100644 vendor/vendor/overtrue/wechat/src/Kernel/Support/Str.php create mode 100644 vendor/vendor/overtrue/wechat/src/Kernel/Support/XML.php create mode 100644 vendor/vendor/overtrue/wechat/src/Kernel/Traits/HasAttributes.php create mode 100644 vendor/vendor/overtrue/wechat/src/Kernel/Traits/HasHttpRequests.php create mode 100644 vendor/vendor/overtrue/wechat/src/Kernel/Traits/InteractsWithCache.php create mode 100644 vendor/vendor/overtrue/wechat/src/Kernel/Traits/Observable.php create mode 100644 vendor/vendor/overtrue/wechat/src/Kernel/Traits/ResponseCastable.php create mode 100644 vendor/vendor/overtrue/wechat/src/MicroMerchant/Application.php create mode 100644 vendor/vendor/overtrue/wechat/src/MicroMerchant/Base/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/MicroMerchant/Base/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/MicroMerchant/Certficates/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/MicroMerchant/Certficates/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/MicroMerchant/Kernel/BaseClient.php create mode 100644 vendor/vendor/overtrue/wechat/src/MicroMerchant/Kernel/Exceptions/EncryptException.php create mode 100644 vendor/vendor/overtrue/wechat/src/MicroMerchant/Kernel/Exceptions/InvalidExtensionException.php create mode 100644 vendor/vendor/overtrue/wechat/src/MicroMerchant/Kernel/Exceptions/InvalidSignException.php create mode 100644 vendor/vendor/overtrue/wechat/src/MicroMerchant/Material/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/MicroMerchant/Material/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/MicroMerchant/Media/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/MicroMerchant/Media/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/MicroMerchant/MerchantConfig/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/MicroMerchant/MerchantConfig/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/MicroMerchant/Withdraw/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/MicroMerchant/Withdraw/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/MiniProgram/ActivityMessage/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/MiniProgram/ActivityMessage/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/MiniProgram/AppCode/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/MiniProgram/AppCode/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/MiniProgram/Application.php create mode 100644 vendor/vendor/overtrue/wechat/src/MiniProgram/Auth/AccessToken.php create mode 100644 vendor/vendor/overtrue/wechat/src/MiniProgram/Auth/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/MiniProgram/Auth/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/MiniProgram/Base/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/MiniProgram/Base/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/MiniProgram/Broadcast/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/MiniProgram/Broadcast/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/MiniProgram/CustomerService/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/MiniProgram/DataCube/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/MiniProgram/DataCube/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/MiniProgram/Encryptor.php create mode 100644 vendor/vendor/overtrue/wechat/src/MiniProgram/Express/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/MiniProgram/Express/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/MiniProgram/Live/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/MiniProgram/Live/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/MiniProgram/Mall/CartClient.php create mode 100644 vendor/vendor/overtrue/wechat/src/MiniProgram/Mall/ForwardsMall.php create mode 100644 vendor/vendor/overtrue/wechat/src/MiniProgram/Mall/MediaClient.php create mode 100644 vendor/vendor/overtrue/wechat/src/MiniProgram/Mall/OrderClient.php create mode 100644 vendor/vendor/overtrue/wechat/src/MiniProgram/Mall/ProductClient.php create mode 100644 vendor/vendor/overtrue/wechat/src/MiniProgram/Mall/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/MiniProgram/NearbyPoi/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/MiniProgram/NearbyPoi/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/MiniProgram/OCR/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/MiniProgram/OpenData/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/MiniProgram/OpenData/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/MiniProgram/Plugin/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/MiniProgram/Plugin/DevClient.php create mode 100644 vendor/vendor/overtrue/wechat/src/MiniProgram/Plugin/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/MiniProgram/RealtimeLog/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/MiniProgram/RealtimeLog/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/MiniProgram/Search/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/MiniProgram/Search/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/MiniProgram/Server/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/MiniProgram/Soter/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/MiniProgram/Soter/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/MiniProgram/SubscribeMessage/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/MiniProgram/SubscribeMessage/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/MiniProgram/TemplateMessage/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/MiniProgram/TemplateMessage/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/MiniProgram/UniformMessage/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/MiniProgram/UniformMessage/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/Application.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/Auth/AccessToken.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/Auth/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/AutoReply/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/AutoReply/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/Base/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/Base/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/Broadcasting/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/Broadcasting/MessageBuilder.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/Broadcasting/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/Card/BoardingPassClient.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/Card/Card.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/Card/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/Card/CodeClient.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/Card/CoinClient.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/Card/GeneralCardClient.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/Card/GiftCardClient.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/Card/GiftCardOrderClient.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/Card/GiftCardPageClient.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/Card/InvoiceClient.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/Card/JssdkClient.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/Card/MeetingTicketClient.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/Card/MemberCardClient.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/Card/MovieTicketClient.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/Card/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/Card/SubMerchantClient.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/Comment/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/Comment/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/CustomerService/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/CustomerService/Messenger.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/CustomerService/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/CustomerService/SessionClient.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/DataCube/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/DataCube/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/Device/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/Device/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/Goods/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/Goods/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/Guide/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/Guide/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/Material/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/Material/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/Menu/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/Menu/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/OAuth/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/OCR/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/OCR/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/POI/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/POI/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/Semantic/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/Semantic/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/Server/Guard.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/Server/Handlers/EchoStrHandler.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/Server/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/ShakeAround/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/ShakeAround/DeviceClient.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/ShakeAround/GroupClient.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/ShakeAround/MaterialClient.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/ShakeAround/PageClient.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/ShakeAround/RelationClient.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/ShakeAround/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/ShakeAround/ShakeAround.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/ShakeAround/StatsClient.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/Store/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/Store/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/SubscribeMessage/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/SubscribeMessage/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/TemplateMessage/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/TemplateMessage/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/User/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/User/TagClient.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/User/UserClient.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/WiFi/CardClient.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/WiFi/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/WiFi/DeviceClient.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/WiFi/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/OfficialAccount/WiFi/ShopClient.php create mode 100644 vendor/vendor/overtrue/wechat/src/OpenPlatform/Application.php create mode 100644 vendor/vendor/overtrue/wechat/src/OpenPlatform/Auth/AccessToken.php create mode 100644 vendor/vendor/overtrue/wechat/src/OpenPlatform/Auth/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/OpenPlatform/Auth/VerifyTicket.php create mode 100644 vendor/vendor/overtrue/wechat/src/OpenPlatform/Authorizer/Aggregate/Account/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/OpenPlatform/Authorizer/Aggregate/AggregateServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/OpenPlatform/Authorizer/Auth/AccessToken.php create mode 100644 vendor/vendor/overtrue/wechat/src/OpenPlatform/Authorizer/MiniProgram/Account/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/OpenPlatform/Authorizer/MiniProgram/Account/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/OpenPlatform/Authorizer/MiniProgram/Application.php create mode 100644 vendor/vendor/overtrue/wechat/src/OpenPlatform/Authorizer/MiniProgram/Auth/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/OpenPlatform/Authorizer/MiniProgram/Code/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/OpenPlatform/Authorizer/MiniProgram/Code/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/OpenPlatform/Authorizer/MiniProgram/Domain/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/OpenPlatform/Authorizer/MiniProgram/Domain/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/OpenPlatform/Authorizer/MiniProgram/Setting/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/OpenPlatform/Authorizer/MiniProgram/Setting/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/OpenPlatform/Authorizer/MiniProgram/Tester/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/OpenPlatform/Authorizer/MiniProgram/Tester/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/OpenPlatform/Authorizer/OfficialAccount/Account/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/OpenPlatform/Authorizer/OfficialAccount/Application.php create mode 100644 vendor/vendor/overtrue/wechat/src/OpenPlatform/Authorizer/OfficialAccount/MiniProgram/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/OpenPlatform/Authorizer/OfficialAccount/MiniProgram/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/OpenPlatform/Authorizer/OfficialAccount/OAuth/ComponentDelegate.php create mode 100644 vendor/vendor/overtrue/wechat/src/OpenPlatform/Authorizer/Server/Guard.php create mode 100644 vendor/vendor/overtrue/wechat/src/OpenPlatform/Base/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/OpenPlatform/Base/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/OpenPlatform/CodeTemplate/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/OpenPlatform/CodeTemplate/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/OpenPlatform/Component/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/OpenPlatform/Component/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/OpenPlatform/Server/Guard.php create mode 100644 vendor/vendor/overtrue/wechat/src/OpenPlatform/Server/Handlers/Authorized.php create mode 100644 vendor/vendor/overtrue/wechat/src/OpenPlatform/Server/Handlers/Unauthorized.php create mode 100644 vendor/vendor/overtrue/wechat/src/OpenPlatform/Server/Handlers/UpdateAuthorized.php create mode 100644 vendor/vendor/overtrue/wechat/src/OpenPlatform/Server/Handlers/VerifyTicketRefreshed.php create mode 100644 vendor/vendor/overtrue/wechat/src/OpenPlatform/Server/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/OpenWork/Application.php create mode 100644 vendor/vendor/overtrue/wechat/src/OpenWork/Auth/AccessToken.php create mode 100644 vendor/vendor/overtrue/wechat/src/OpenWork/Auth/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/OpenWork/Corp/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/OpenWork/Corp/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/OpenWork/MiniProgram/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/OpenWork/MiniProgram/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/OpenWork/Provider/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/OpenWork/Provider/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/OpenWork/Server/Guard.php create mode 100644 vendor/vendor/overtrue/wechat/src/OpenWork/Server/Handlers/EchoStrHandler.php create mode 100644 vendor/vendor/overtrue/wechat/src/OpenWork/Server/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/OpenWork/SuiteAuth/AccessToken.php create mode 100644 vendor/vendor/overtrue/wechat/src/OpenWork/SuiteAuth/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/OpenWork/SuiteAuth/SuiteTicket.php create mode 100644 vendor/vendor/overtrue/wechat/src/OpenWork/Work/Application.php create mode 100644 vendor/vendor/overtrue/wechat/src/OpenWork/Work/Auth/AccessToken.php create mode 100644 vendor/vendor/overtrue/wechat/src/Payment/Application.php create mode 100644 vendor/vendor/overtrue/wechat/src/Payment/Base/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/Payment/Base/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/Payment/Bill/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/Payment/Bill/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/Payment/Contract/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/Payment/Contract/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/Payment/Coupon/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/Payment/Coupon/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/Payment/Fundflow/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/Payment/Fundflow/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/Payment/Jssdk/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/Payment/Jssdk/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/Payment/Kernel/BaseClient.php create mode 100644 vendor/vendor/overtrue/wechat/src/Payment/Kernel/Exceptions/InvalidSignException.php create mode 100644 vendor/vendor/overtrue/wechat/src/Payment/Kernel/Exceptions/SandboxException.php create mode 100644 vendor/vendor/overtrue/wechat/src/Payment/Merchant/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/Payment/Merchant/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/Payment/Notify/Handler.php create mode 100644 vendor/vendor/overtrue/wechat/src/Payment/Notify/Paid.php create mode 100644 vendor/vendor/overtrue/wechat/src/Payment/Notify/Refunded.php create mode 100644 vendor/vendor/overtrue/wechat/src/Payment/Notify/Scanned.php create mode 100644 vendor/vendor/overtrue/wechat/src/Payment/Order/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/Payment/Order/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/Payment/ProfitSharing/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/Payment/ProfitSharing/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/Payment/Redpack/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/Payment/Redpack/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/Payment/Refund/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/Payment/Refund/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/Payment/Reverse/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/Payment/Reverse/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/Payment/Sandbox/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/Payment/Sandbox/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/Payment/Security/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/Payment/Security/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/Payment/Transfer/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/Payment/Transfer/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/Work/Agent/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/Work/Agent/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/Work/Application.php create mode 100644 vendor/vendor/overtrue/wechat/src/Work/Auth/AccessToken.php create mode 100644 vendor/vendor/overtrue/wechat/src/Work/Auth/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/Work/Base/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/Work/Base/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/Work/Calendar/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/Work/Calendar/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/Work/Chat/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/Work/Chat/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/Work/Department/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/Work/Department/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/Work/ExternalContact/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/Work/ExternalContact/ContactWayClient.php create mode 100644 vendor/vendor/overtrue/wechat/src/Work/ExternalContact/MessageClient.php create mode 100644 vendor/vendor/overtrue/wechat/src/Work/ExternalContact/SchoolClient.php create mode 100644 vendor/vendor/overtrue/wechat/src/Work/ExternalContact/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/Work/ExternalContact/StatisticsClient.php create mode 100644 vendor/vendor/overtrue/wechat/src/Work/GroupRobot/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/Work/GroupRobot/Messages/Image.php create mode 100644 vendor/vendor/overtrue/wechat/src/Work/GroupRobot/Messages/Markdown.php create mode 100644 vendor/vendor/overtrue/wechat/src/Work/GroupRobot/Messages/Message.php create mode 100644 vendor/vendor/overtrue/wechat/src/Work/GroupRobot/Messages/News.php create mode 100644 vendor/vendor/overtrue/wechat/src/Work/GroupRobot/Messages/NewsItem.php create mode 100644 vendor/vendor/overtrue/wechat/src/Work/GroupRobot/Messages/Text.php create mode 100644 vendor/vendor/overtrue/wechat/src/Work/GroupRobot/Messenger.php create mode 100644 vendor/vendor/overtrue/wechat/src/Work/GroupRobot/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/Work/Invoice/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/Work/Invoice/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/Work/Jssdk/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/Work/Jssdk/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/Work/Media/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/Work/Media/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/Work/Menu/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/Work/Menu/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/Work/Message/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/Work/Message/Messenger.php create mode 100644 vendor/vendor/overtrue/wechat/src/Work/Message/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/Work/MiniProgram/Application.php create mode 100644 vendor/vendor/overtrue/wechat/src/Work/MiniProgram/Auth/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/Work/MsgAudit/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/Work/MsgAudit/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/Work/OA/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/Work/OA/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/Work/OAuth/AccessTokenDelegate.php create mode 100644 vendor/vendor/overtrue/wechat/src/Work/OAuth/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/Work/Schedule/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/Work/Schedule/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/Work/Server/Guard.php create mode 100644 vendor/vendor/overtrue/wechat/src/Work/Server/Handlers/EchoStrHandler.php create mode 100644 vendor/vendor/overtrue/wechat/src/Work/Server/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/Work/User/Client.php create mode 100644 vendor/vendor/overtrue/wechat/src/Work/User/ServiceProvider.php create mode 100644 vendor/vendor/overtrue/wechat/src/Work/User/TagClient.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/.readthedocs.yaml create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/CHANGELOG.md create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/CONTRIBUTING.md create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/LICENSE create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/README.md create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/composer.json create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/ArrayEnabled.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/BinaryComparison.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Calculation.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Category.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Database.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Database/DAverage.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Database/DCount.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Database/DCountA.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Database/DGet.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Database/DMax.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Database/DMin.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Database/DProduct.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Database/DStDev.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Database/DStDevP.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Database/DSum.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Database/DVar.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Database/DVarP.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Database/DatabaseAbstract.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/DateTime.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/DateTimeExcel/Constants.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/DateTimeExcel/Current.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/DateTimeExcel/Date.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/DateTimeExcel/DateParts.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/DateTimeExcel/DateValue.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/DateTimeExcel/Days.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/DateTimeExcel/Days360.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/DateTimeExcel/Difference.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/DateTimeExcel/Helpers.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/DateTimeExcel/Month.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/DateTimeExcel/NetworkDays.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/DateTimeExcel/Time.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/DateTimeExcel/TimeParts.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/DateTimeExcel/TimeValue.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/DateTimeExcel/Week.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/DateTimeExcel/WorkDay.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/DateTimeExcel/YearFrac.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Engine/ArrayArgumentHelper.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Engine/ArrayArgumentProcessor.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Engine/BranchPruner.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Engine/CyclicReferenceStack.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Engine/FormattedNumber.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Engine/Logger.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Engine/Operands/Operand.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Engine/Operands/StructuredReference.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Engineering.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Engineering/BesselI.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Engineering/BesselJ.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Engineering/BesselK.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Engineering/BesselY.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Engineering/BitWise.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Engineering/Compare.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Engineering/Complex.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Engineering/ComplexFunctions.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Engineering/ComplexOperations.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Engineering/Constants.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Engineering/ConvertBase.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Engineering/ConvertBinary.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Engineering/ConvertDecimal.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Engineering/ConvertHex.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Engineering/ConvertOctal.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Engineering/ConvertUOM.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Engineering/EngineeringValidations.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Engineering/Erf.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Engineering/ErfC.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Exception.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/ExceptionHandler.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Financial.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Financial/Amortization.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Financial/CashFlow/CashFlowValidations.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Cumulative.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Interest.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/InterestAndPrincipal.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Payments.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Single.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Variable/NonPeriodic.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Variable/Periodic.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Financial/Constants.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Financial/Coupons.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Financial/Depreciation.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Financial/Dollar.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Financial/FinancialValidations.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Financial/Helpers.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Financial/InterestRate.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Financial/Securities/AccruedInterest.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Financial/Securities/Price.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Financial/Securities/Rates.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Financial/Securities/SecurityValidations.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Financial/Securities/Yields.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Financial/TreasuryBill.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/FormulaParser.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/FormulaToken.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Functions.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Information/ErrorValue.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Information/ExcelError.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Information/Value.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Internal/MakeMatrix.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Internal/WildcardMatch.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Logical.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Logical/Boolean.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Logical/Conditional.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Logical/Operations.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/LookupRef.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/LookupRef/Address.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/LookupRef/ExcelMatch.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/LookupRef/Filter.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/LookupRef/Formula.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/LookupRef/HLookup.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/LookupRef/Helpers.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/LookupRef/Hyperlink.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/LookupRef/Indirect.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/LookupRef/Lookup.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/LookupRef/LookupBase.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/LookupRef/LookupRefValidations.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/LookupRef/Matrix.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/LookupRef/Offset.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/LookupRef/RowColumnInformation.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/LookupRef/Selection.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/LookupRef/Sort.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/LookupRef/Unique.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/LookupRef/VLookup.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/MathTrig.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/MathTrig/Absolute.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/MathTrig/Angle.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/MathTrig/Arabic.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/MathTrig/Base.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/MathTrig/Ceiling.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/MathTrig/Combinations.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/MathTrig/Exp.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/MathTrig/Factorial.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/MathTrig/Floor.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/MathTrig/Gcd.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/MathTrig/Helpers.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/MathTrig/IntClass.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/MathTrig/Lcm.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/MathTrig/Logarithms.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/MathTrig/MatrixFunctions.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/MathTrig/Operations.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/MathTrig/Random.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/MathTrig/Roman.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/MathTrig/Round.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/MathTrig/SeriesSum.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/MathTrig/Sign.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/MathTrig/Sqrt.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/MathTrig/Subtotal.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/MathTrig/Sum.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/MathTrig/SumSquares.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/MathTrig/Trig/Cosecant.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/MathTrig/Trig/Cosine.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/MathTrig/Trig/Cotangent.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/MathTrig/Trig/Secant.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/MathTrig/Trig/Sine.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/MathTrig/Trig/Tangent.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/MathTrig/Trunc.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Statistical.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Statistical/AggregateBase.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Statistical/Averages.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Statistical/Averages/Mean.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Statistical/Conditional.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Statistical/Confidence.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Statistical/Counts.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Statistical/Deviations.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Beta.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Binomial.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Statistical/Distributions/ChiSquared.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Statistical/Distributions/DistributionValidations.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Exponential.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Statistical/Distributions/F.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Fisher.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Gamma.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Statistical/Distributions/GammaBase.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Statistical/Distributions/HyperGeometric.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Statistical/Distributions/LogNormal.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Statistical/Distributions/NewtonRaphson.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Normal.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Poisson.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Statistical/Distributions/StandardNormal.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Statistical/Distributions/StudentT.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Weibull.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Statistical/MaxMinBase.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Statistical/Maximum.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Statistical/Minimum.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Statistical/Percentiles.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Statistical/Permutations.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Statistical/Size.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Statistical/StandardDeviations.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Statistical/Standardize.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Statistical/StatisticalValidations.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Statistical/Trends.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Statistical/VarianceBase.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Statistical/Variances.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/TextData.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/TextData/CaseConvert.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/TextData/CharacterConvert.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/TextData/Concatenate.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/TextData/Extract.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/TextData/Format.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/TextData/Helpers.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/TextData/Replace.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/TextData/Search.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/TextData/Text.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/TextData/Trim.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Token/Stack.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Web.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Web/Service.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/Translations.xlsx create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/bg/config create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/bg/functions create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/cs/config create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/cs/functions create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/da/config create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/da/functions create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/de/config create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/de/functions create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/en/uk/config create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/es/config create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/es/functions create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/fi/config create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/fi/functions create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/fr/config create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/fr/functions create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/hu/config create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/hu/functions create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/it/config create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/it/functions create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/nb/config create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/nb/functions create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/nl/config create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/nl/functions create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/pl/config create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/pl/functions create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/pt/br/config create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/pt/br/functions create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/pt/config create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/pt/functions create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/ru/config create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/ru/functions create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/sv/config create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/sv/functions create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/tr/config create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/tr/functions create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/AddressHelper.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/AddressRange.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/AdvancedValueBinder.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/Cell.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/CellAddress.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/CellRange.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/ColumnRange.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/Coordinate.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/DataType.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/DataValidation.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/DataValidator.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/DefaultValueBinder.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/Hyperlink.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/IValueBinder.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/IgnoredErrors.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/RowRange.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/StringValueBinder.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/CellReferenceHelper.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Axis.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/AxisText.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Chart.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/ChartColor.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/DataSeries.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/DataSeriesValues.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Exception.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/GridLines.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Layout.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Legend.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/PlotArea.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Properties.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Renderer/IRenderer.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Renderer/JpGraph.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Renderer/JpGraphRendererBase.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Renderer/MtJpGraphRenderer.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Renderer/PHP Charting Libraries.txt create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Title.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/TrendLine.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Collection/Cells.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Collection/CellsFactory.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Collection/Memory/SimpleCache1.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Collection/Memory/SimpleCache3.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Comment.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/DefinedName.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Document/Properties.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Document/Security.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Exception.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/HashTable.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Helper/Dimension.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Helper/Downloader.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Helper/Handler.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Helper/Html.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Helper/Sample.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Helper/Size.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Helper/TextGrid.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/IComparable.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/IOFactory.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/NamedFormula.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/NamedRange.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/BaseReader.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Csv.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Csv/Delimiter.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/DefaultReadFilter.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Exception.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Gnumeric.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Gnumeric/PageSetup.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Gnumeric/Properties.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Gnumeric/Styles.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Html.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/IReadFilter.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/IReader.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Ods.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Ods/AutoFilter.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Ods/BaseLoader.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Ods/DefinedNames.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Ods/FormulaTranslator.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Ods/PageSettings.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Ods/Properties.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Security/XmlScanner.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Slk.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xls.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xls/Color.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xls/Color/BIFF5.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xls/Color/BIFF8.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xls/Color/BuiltIn.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xls/ConditionalFormatting.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xls/DataValidationHelper.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xls/ErrorCode.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xls/Escher.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xls/MD5.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xls/RC4.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xls/Style/Border.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xls/Style/CellAlignment.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xls/Style/CellFont.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xls/Style/FillPattern.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/AutoFilter.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/BaseParserClass.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/Chart.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/ColumnAndRowAttributes.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/ConditionalStyles.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/DataValidations.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/Hyperlinks.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/Namespaces.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/PageSetup.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/Properties.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/SharedFormula.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/SheetViewOptions.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/SheetViews.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/Styles.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/TableReader.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/Theme.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/WorkbookView.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xml.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xml/DataValidations.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xml/PageSettings.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xml/Properties.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xml/Style.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xml/Style/Alignment.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xml/Style/Border.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xml/Style/Fill.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xml/Style/Font.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xml/Style/NumberFormat.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xml/Style/StyleBase.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/ReferenceHelper.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/RichText/ITextElement.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/RichText/RichText.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/RichText/Run.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/RichText/TextElement.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Settings.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/CodePage.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Date.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Drawing.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Escher.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Escher/DgContainer.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Escher/DgContainer/SpgrContainer.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Escher/DgContainer/SpgrContainer/SpContainer.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Escher/DggContainer.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer/BSE.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer/BSE/Blip.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/File.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Font.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/IntOrFloat.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/OLE.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/OLE/ChainedBlockStream.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/OLE/PPS.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/OLE/PPS/File.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/OLE/PPS/Root.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/OLERead.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/PasswordHasher.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/StringHelper.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/TimeZone.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Trend/BestFit.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Trend/ExponentialBestFit.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Trend/LinearBestFit.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Trend/LogarithmicBestFit.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Trend/PolynomialBestFit.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Trend/PowerBestFit.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Trend/Trend.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/XMLWriter.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Xls.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Spreadsheet.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Alignment.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Border.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Borders.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Color.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Conditional.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/ConditionalFormatting/CellMatcher.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/ConditionalFormatting/CellStyleAssessor.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/ConditionalFormatting/ConditionalDataBar.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/ConditionalFormatting/ConditionalDataBarExtension.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/ConditionalFormatting/ConditionalFormatValueObject.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/ConditionalFormatting/ConditionalFormattingRuleExtension.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/ConditionalFormatting/StyleMerger.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/Blanks.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/CellValue.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/DateValue.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/Duplicates.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/Errors.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/Expression.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/TextValue.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/WizardAbstract.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/WizardInterface.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Fill.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Font.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/BaseFormatter.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/DateFormatter.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/Formatter.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/FractionFormatter.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/NumberFormatter.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/PercentageFormatter.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/Wizard/Accounting.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/Wizard/Currency.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/Wizard/Date.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/Wizard/DateTime.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/Wizard/DateTimeWizard.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/Wizard/Duration.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/Wizard/Locale.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/Wizard/Number.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/Wizard/NumberBase.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/Wizard/Percentage.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/Wizard/Scientific.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/Wizard/Time.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/Wizard/Wizard.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Protection.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/RgbTint.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Style.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Supervisor.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Theme.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/AutoFilter.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/AutoFilter/Column.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/AutoFilter/Column/Rule.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/AutoFit.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/BaseDrawing.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/CellIterator.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/Column.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/ColumnCellIterator.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/ColumnDimension.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/ColumnIterator.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/Dimension.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/Drawing.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/Drawing/Shadow.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/HeaderFooter.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/HeaderFooterDrawing.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/Iterator.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/MemoryDrawing.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/PageBreak.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/PageMargins.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/PageSetup.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/Protection.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/Row.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/RowCellIterator.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/RowDimension.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/RowIterator.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/SheetView.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/Table.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/Table/Column.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/Table/TableStyle.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/Validations.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/Worksheet.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/BaseWriter.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Csv.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Exception.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Html.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/IWriter.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Ods.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Ods/AutoFilters.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Ods/Cell/Comment.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Ods/Cell/Style.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Ods/Content.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Ods/Formula.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Ods/Meta.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Ods/MetaInf.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Ods/Mimetype.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Ods/NamedExpressions.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Ods/Settings.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Ods/Styles.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Ods/Thumbnails.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Ods/WriterPart.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Pdf.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Pdf/Dompdf.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Pdf/Mpdf.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Pdf/Tcpdf.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xls.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xls/BIFFwriter.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xls/CellDataValidation.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xls/ConditionalHelper.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xls/ErrorCode.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xls/Escher.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xls/Font.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xls/Parser.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xls/Style/CellAlignment.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xls/Style/CellBorder.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xls/Style/CellFill.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xls/Style/ColorMap.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xls/Workbook.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xls/Worksheet.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xls/Xf.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/AutoFilter.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/Chart.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/Comments.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/ContentTypes.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/DefinedNames.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/DocProps.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/Drawing.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/FunctionPrefix.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/Rels.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/RelsRibbon.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/RelsVBA.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/StringTable.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/Style.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/Table.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/Theme.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/Workbook.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/WriterPart.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/ZipStream0.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/ZipStream2.php create mode 100644 vendor/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/ZipStream3.php create mode 100644 vendor/vendor/pimple/pimple/.github/workflows/tests.yml create mode 100644 vendor/vendor/pimple/pimple/.gitignore create mode 100644 vendor/vendor/pimple/pimple/.php_cs.dist create mode 100644 vendor/vendor/pimple/pimple/CHANGELOG create mode 100644 vendor/vendor/pimple/pimple/LICENSE create mode 100644 vendor/vendor/pimple/pimple/README.rst create mode 100644 vendor/vendor/pimple/pimple/composer.json create mode 100644 vendor/vendor/pimple/pimple/phpunit.xml.dist create mode 100644 vendor/vendor/pimple/pimple/src/Pimple/Container.php create mode 100644 vendor/vendor/pimple/pimple/src/Pimple/Exception/ExpectedInvokableException.php create mode 100644 vendor/vendor/pimple/pimple/src/Pimple/Exception/FrozenServiceException.php create mode 100644 vendor/vendor/pimple/pimple/src/Pimple/Exception/InvalidServiceIdentifierException.php create mode 100644 vendor/vendor/pimple/pimple/src/Pimple/Exception/UnknownIdentifierException.php create mode 100644 vendor/vendor/pimple/pimple/src/Pimple/Psr11/Container.php create mode 100644 vendor/vendor/pimple/pimple/src/Pimple/Psr11/ServiceLocator.php create mode 100644 vendor/vendor/pimple/pimple/src/Pimple/ServiceIterator.php create mode 100644 vendor/vendor/pimple/pimple/src/Pimple/ServiceProviderInterface.php create mode 100644 vendor/vendor/pimple/pimple/src/Pimple/Tests/Fixtures/Invokable.php create mode 100644 vendor/vendor/pimple/pimple/src/Pimple/Tests/Fixtures/NonInvokable.php create mode 100644 vendor/vendor/pimple/pimple/src/Pimple/Tests/Fixtures/PimpleServiceProvider.php create mode 100644 vendor/vendor/pimple/pimple/src/Pimple/Tests/Fixtures/Service.php create mode 100644 vendor/vendor/pimple/pimple/src/Pimple/Tests/PimpleServiceProviderInterfaceTest.php create mode 100644 vendor/vendor/pimple/pimple/src/Pimple/Tests/PimpleTest.php create mode 100644 vendor/vendor/pimple/pimple/src/Pimple/Tests/Psr11/ContainerTest.php create mode 100644 vendor/vendor/pimple/pimple/src/Pimple/Tests/Psr11/ServiceLocatorTest.php create mode 100644 vendor/vendor/pimple/pimple/src/Pimple/Tests/ServiceIteratorTest.php create mode 100644 vendor/vendor/psr/cache/CHANGELOG.md create mode 100644 vendor/vendor/psr/cache/LICENSE.txt create mode 100644 vendor/vendor/psr/cache/README.md create mode 100644 vendor/vendor/psr/cache/composer.json create mode 100644 vendor/vendor/psr/cache/src/CacheException.php create mode 100644 vendor/vendor/psr/cache/src/CacheItemInterface.php create mode 100644 vendor/vendor/psr/cache/src/CacheItemPoolInterface.php create mode 100644 vendor/vendor/psr/cache/src/InvalidArgumentException.php create mode 100644 vendor/vendor/psr/container/.gitignore create mode 100644 vendor/vendor/psr/container/LICENSE create mode 100644 vendor/vendor/psr/container/README.md create mode 100644 vendor/vendor/psr/container/composer.json create mode 100644 vendor/vendor/psr/container/src/ContainerExceptionInterface.php create mode 100644 vendor/vendor/psr/container/src/ContainerInterface.php create mode 100644 vendor/vendor/psr/container/src/NotFoundExceptionInterface.php create mode 100644 vendor/vendor/psr/event-dispatcher/.editorconfig create mode 100644 vendor/vendor/psr/event-dispatcher/.gitignore create mode 100644 vendor/vendor/psr/event-dispatcher/LICENSE create mode 100644 vendor/vendor/psr/event-dispatcher/README.md create mode 100644 vendor/vendor/psr/event-dispatcher/composer.json create mode 100644 vendor/vendor/psr/event-dispatcher/src/EventDispatcherInterface.php create mode 100644 vendor/vendor/psr/event-dispatcher/src/ListenerProviderInterface.php create mode 100644 vendor/vendor/psr/event-dispatcher/src/StoppableEventInterface.php create mode 100644 vendor/vendor/psr/http-client/CHANGELOG.md create mode 100644 vendor/vendor/psr/http-client/LICENSE create mode 100644 vendor/vendor/psr/http-client/README.md create mode 100644 vendor/vendor/psr/http-client/composer.json create mode 100644 vendor/vendor/psr/http-client/src/ClientExceptionInterface.php create mode 100644 vendor/vendor/psr/http-client/src/ClientInterface.php create mode 100644 vendor/vendor/psr/http-client/src/NetworkExceptionInterface.php create mode 100644 vendor/vendor/psr/http-client/src/RequestExceptionInterface.php create mode 100644 vendor/vendor/psr/http-factory/LICENSE create mode 100644 vendor/vendor/psr/http-factory/README.md create mode 100644 vendor/vendor/psr/http-factory/composer.json create mode 100644 vendor/vendor/psr/http-factory/src/RequestFactoryInterface.php create mode 100644 vendor/vendor/psr/http-factory/src/ResponseFactoryInterface.php create mode 100644 vendor/vendor/psr/http-factory/src/ServerRequestFactoryInterface.php create mode 100644 vendor/vendor/psr/http-factory/src/StreamFactoryInterface.php create mode 100644 vendor/vendor/psr/http-factory/src/UploadedFileFactoryInterface.php create mode 100644 vendor/vendor/psr/http-factory/src/UriFactoryInterface.php create mode 100644 vendor/vendor/psr/http-message/CHANGELOG.md create mode 100644 vendor/vendor/psr/http-message/LICENSE create mode 100644 vendor/vendor/psr/http-message/README.md create mode 100644 vendor/vendor/psr/http-message/composer.json create mode 100644 vendor/vendor/psr/http-message/docs/PSR7-Interfaces.md create mode 100644 vendor/vendor/psr/http-message/docs/PSR7-Usage.md create mode 100644 vendor/vendor/psr/http-message/src/MessageInterface.php create mode 100644 vendor/vendor/psr/http-message/src/RequestInterface.php create mode 100644 vendor/vendor/psr/http-message/src/ResponseInterface.php create mode 100644 vendor/vendor/psr/http-message/src/ServerRequestInterface.php create mode 100644 vendor/vendor/psr/http-message/src/StreamInterface.php create mode 100644 vendor/vendor/psr/http-message/src/UploadedFileInterface.php create mode 100644 vendor/vendor/psr/http-message/src/UriInterface.php create mode 100644 vendor/vendor/psr/log/LICENSE create mode 100644 vendor/vendor/psr/log/Psr/Log/AbstractLogger.php create mode 100644 vendor/vendor/psr/log/Psr/Log/InvalidArgumentException.php create mode 100644 vendor/vendor/psr/log/Psr/Log/LogLevel.php create mode 100644 vendor/vendor/psr/log/Psr/Log/LoggerAwareInterface.php create mode 100644 vendor/vendor/psr/log/Psr/Log/LoggerAwareTrait.php create mode 100644 vendor/vendor/psr/log/Psr/Log/LoggerInterface.php create mode 100644 vendor/vendor/psr/log/Psr/Log/LoggerTrait.php create mode 100644 vendor/vendor/psr/log/Psr/Log/NullLogger.php create mode 100644 vendor/vendor/psr/log/Psr/Log/Test/DummyTest.php create mode 100644 vendor/vendor/psr/log/Psr/Log/Test/LoggerInterfaceTest.php create mode 100644 vendor/vendor/psr/log/Psr/Log/Test/TestLogger.php create mode 100644 vendor/vendor/psr/log/README.md create mode 100644 vendor/vendor/psr/log/composer.json create mode 100644 vendor/vendor/psr/simple-cache/.editorconfig create mode 100644 vendor/vendor/psr/simple-cache/LICENSE.md create mode 100644 vendor/vendor/psr/simple-cache/README.md create mode 100644 vendor/vendor/psr/simple-cache/composer.json create mode 100644 vendor/vendor/psr/simple-cache/src/CacheException.php create mode 100644 vendor/vendor/psr/simple-cache/src/CacheInterface.php create mode 100644 vendor/vendor/psr/simple-cache/src/InvalidArgumentException.php create mode 100644 vendor/vendor/ralouphie/getallheaders/LICENSE create mode 100644 vendor/vendor/ralouphie/getallheaders/README.md create mode 100644 vendor/vendor/ralouphie/getallheaders/composer.json create mode 100644 vendor/vendor/ralouphie/getallheaders/src/getallheaders.php create mode 100644 vendor/vendor/symfony/cache-contracts/CHANGELOG.md create mode 100644 vendor/vendor/symfony/cache-contracts/CacheInterface.php create mode 100644 vendor/vendor/symfony/cache-contracts/CacheTrait.php create mode 100644 vendor/vendor/symfony/cache-contracts/CallbackInterface.php create mode 100644 vendor/vendor/symfony/cache-contracts/ItemInterface.php create mode 100644 vendor/vendor/symfony/cache-contracts/LICENSE create mode 100644 vendor/vendor/symfony/cache-contracts/README.md create mode 100644 vendor/vendor/symfony/cache-contracts/TagAwareCacheInterface.php create mode 100644 vendor/vendor/symfony/cache-contracts/composer.json create mode 100644 vendor/vendor/symfony/cache/Adapter/AbstractAdapter.php create mode 100644 vendor/vendor/symfony/cache/Adapter/AbstractTagAwareAdapter.php create mode 100644 vendor/vendor/symfony/cache/Adapter/AdapterInterface.php create mode 100644 vendor/vendor/symfony/cache/Adapter/ApcuAdapter.php create mode 100644 vendor/vendor/symfony/cache/Adapter/ArrayAdapter.php create mode 100644 vendor/vendor/symfony/cache/Adapter/ChainAdapter.php create mode 100644 vendor/vendor/symfony/cache/Adapter/CouchbaseBucketAdapter.php create mode 100644 vendor/vendor/symfony/cache/Adapter/CouchbaseCollectionAdapter.php create mode 100644 vendor/vendor/symfony/cache/Adapter/DoctrineAdapter.php create mode 100644 vendor/vendor/symfony/cache/Adapter/DoctrineDbalAdapter.php create mode 100644 vendor/vendor/symfony/cache/Adapter/FilesystemAdapter.php create mode 100644 vendor/vendor/symfony/cache/Adapter/FilesystemTagAwareAdapter.php create mode 100644 vendor/vendor/symfony/cache/Adapter/MemcachedAdapter.php create mode 100644 vendor/vendor/symfony/cache/Adapter/NullAdapter.php create mode 100644 vendor/vendor/symfony/cache/Adapter/ParameterNormalizer.php create mode 100644 vendor/vendor/symfony/cache/Adapter/PdoAdapter.php create mode 100644 vendor/vendor/symfony/cache/Adapter/PhpArrayAdapter.php create mode 100644 vendor/vendor/symfony/cache/Adapter/PhpFilesAdapter.php create mode 100644 vendor/vendor/symfony/cache/Adapter/ProxyAdapter.php create mode 100644 vendor/vendor/symfony/cache/Adapter/Psr16Adapter.php create mode 100644 vendor/vendor/symfony/cache/Adapter/RedisAdapter.php create mode 100644 vendor/vendor/symfony/cache/Adapter/RedisTagAwareAdapter.php create mode 100644 vendor/vendor/symfony/cache/Adapter/TagAwareAdapter.php create mode 100644 vendor/vendor/symfony/cache/Adapter/TagAwareAdapterInterface.php create mode 100644 vendor/vendor/symfony/cache/Adapter/TraceableAdapter.php create mode 100644 vendor/vendor/symfony/cache/Adapter/TraceableTagAwareAdapter.php create mode 100644 vendor/vendor/symfony/cache/CHANGELOG.md create mode 100644 vendor/vendor/symfony/cache/CacheItem.php create mode 100644 vendor/vendor/symfony/cache/DataCollector/CacheDataCollector.php create mode 100644 vendor/vendor/symfony/cache/DependencyInjection/CacheCollectorPass.php create mode 100644 vendor/vendor/symfony/cache/DependencyInjection/CachePoolClearerPass.php create mode 100644 vendor/vendor/symfony/cache/DependencyInjection/CachePoolPass.php create mode 100644 vendor/vendor/symfony/cache/DependencyInjection/CachePoolPrunerPass.php create mode 100644 vendor/vendor/symfony/cache/DoctrineProvider.php create mode 100644 vendor/vendor/symfony/cache/Exception/CacheException.php create mode 100644 vendor/vendor/symfony/cache/Exception/InvalidArgumentException.php create mode 100644 vendor/vendor/symfony/cache/Exception/LogicException.php create mode 100644 vendor/vendor/symfony/cache/LICENSE create mode 100644 vendor/vendor/symfony/cache/LockRegistry.php create mode 100644 vendor/vendor/symfony/cache/Marshaller/DefaultMarshaller.php create mode 100644 vendor/vendor/symfony/cache/Marshaller/DeflateMarshaller.php create mode 100644 vendor/vendor/symfony/cache/Marshaller/MarshallerInterface.php create mode 100644 vendor/vendor/symfony/cache/Marshaller/SodiumMarshaller.php create mode 100644 vendor/vendor/symfony/cache/Marshaller/TagAwareMarshaller.php create mode 100644 vendor/vendor/symfony/cache/Messenger/EarlyExpirationDispatcher.php create mode 100644 vendor/vendor/symfony/cache/Messenger/EarlyExpirationHandler.php create mode 100644 vendor/vendor/symfony/cache/Messenger/EarlyExpirationMessage.php create mode 100644 vendor/vendor/symfony/cache/PruneableInterface.php create mode 100644 vendor/vendor/symfony/cache/Psr16Cache.php create mode 100644 vendor/vendor/symfony/cache/README.md create mode 100644 vendor/vendor/symfony/cache/ResettableInterface.php create mode 100644 vendor/vendor/symfony/cache/Traits/AbstractAdapterTrait.php create mode 100644 vendor/vendor/symfony/cache/Traits/ContractsTrait.php create mode 100644 vendor/vendor/symfony/cache/Traits/FilesystemCommonTrait.php create mode 100644 vendor/vendor/symfony/cache/Traits/FilesystemTrait.php create mode 100644 vendor/vendor/symfony/cache/Traits/ProxyTrait.php create mode 100644 vendor/vendor/symfony/cache/Traits/RedisClusterNodeProxy.php create mode 100644 vendor/vendor/symfony/cache/Traits/RedisClusterProxy.php create mode 100644 vendor/vendor/symfony/cache/Traits/RedisProxy.php create mode 100644 vendor/vendor/symfony/cache/Traits/RedisTrait.php create mode 100644 vendor/vendor/symfony/cache/composer.json create mode 100644 vendor/vendor/symfony/deprecation-contracts/CHANGELOG.md create mode 100644 vendor/vendor/symfony/deprecation-contracts/LICENSE create mode 100644 vendor/vendor/symfony/deprecation-contracts/README.md create mode 100644 vendor/vendor/symfony/deprecation-contracts/composer.json create mode 100644 vendor/vendor/symfony/deprecation-contracts/function.php create mode 100644 vendor/vendor/symfony/event-dispatcher-contracts/CHANGELOG.md create mode 100644 vendor/vendor/symfony/event-dispatcher-contracts/Event.php create mode 100644 vendor/vendor/symfony/event-dispatcher-contracts/EventDispatcherInterface.php create mode 100644 vendor/vendor/symfony/event-dispatcher-contracts/LICENSE create mode 100644 vendor/vendor/symfony/event-dispatcher-contracts/README.md create mode 100644 vendor/vendor/symfony/event-dispatcher-contracts/composer.json create mode 100644 vendor/vendor/symfony/event-dispatcher/Attribute/AsEventListener.php create mode 100644 vendor/vendor/symfony/event-dispatcher/CHANGELOG.md create mode 100644 vendor/vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php create mode 100644 vendor/vendor/symfony/event-dispatcher/Debug/WrappedListener.php create mode 100644 vendor/vendor/symfony/event-dispatcher/DependencyInjection/AddEventAliasesPass.php create mode 100644 vendor/vendor/symfony/event-dispatcher/DependencyInjection/RegisterListenersPass.php create mode 100644 vendor/vendor/symfony/event-dispatcher/EventDispatcher.php create mode 100644 vendor/vendor/symfony/event-dispatcher/EventDispatcherInterface.php create mode 100644 vendor/vendor/symfony/event-dispatcher/EventSubscriberInterface.php create mode 100644 vendor/vendor/symfony/event-dispatcher/GenericEvent.php create mode 100644 vendor/vendor/symfony/event-dispatcher/ImmutableEventDispatcher.php create mode 100644 vendor/vendor/symfony/event-dispatcher/LICENSE create mode 100644 vendor/vendor/symfony/event-dispatcher/LegacyEventDispatcherProxy.php create mode 100644 vendor/vendor/symfony/event-dispatcher/README.md create mode 100644 vendor/vendor/symfony/event-dispatcher/composer.json create mode 100644 vendor/vendor/symfony/finder/CHANGELOG.md create mode 100644 vendor/vendor/symfony/finder/Comparator/Comparator.php create mode 100644 vendor/vendor/symfony/finder/Comparator/DateComparator.php create mode 100644 vendor/vendor/symfony/finder/Comparator/NumberComparator.php create mode 100644 vendor/vendor/symfony/finder/Exception/AccessDeniedException.php create mode 100644 vendor/vendor/symfony/finder/Exception/DirectoryNotFoundException.php create mode 100644 vendor/vendor/symfony/finder/Finder.php create mode 100644 vendor/vendor/symfony/finder/Gitignore.php create mode 100644 vendor/vendor/symfony/finder/Glob.php create mode 100644 vendor/vendor/symfony/finder/Iterator/CustomFilterIterator.php create mode 100644 vendor/vendor/symfony/finder/Iterator/DateRangeFilterIterator.php create mode 100644 vendor/vendor/symfony/finder/Iterator/DepthRangeFilterIterator.php create mode 100644 vendor/vendor/symfony/finder/Iterator/ExcludeDirectoryFilterIterator.php create mode 100644 vendor/vendor/symfony/finder/Iterator/FileTypeFilterIterator.php create mode 100644 vendor/vendor/symfony/finder/Iterator/FilecontentFilterIterator.php create mode 100644 vendor/vendor/symfony/finder/Iterator/FilenameFilterIterator.php create mode 100644 vendor/vendor/symfony/finder/Iterator/LazyIterator.php create mode 100644 vendor/vendor/symfony/finder/Iterator/MultiplePcreFilterIterator.php create mode 100644 vendor/vendor/symfony/finder/Iterator/PathFilterIterator.php create mode 100644 vendor/vendor/symfony/finder/Iterator/RecursiveDirectoryIterator.php create mode 100644 vendor/vendor/symfony/finder/Iterator/SizeRangeFilterIterator.php create mode 100644 vendor/vendor/symfony/finder/Iterator/SortableIterator.php create mode 100644 vendor/vendor/symfony/finder/Iterator/VcsIgnoredFilterIterator.php create mode 100644 vendor/vendor/symfony/finder/LICENSE create mode 100644 vendor/vendor/symfony/finder/README.md create mode 100644 vendor/vendor/symfony/finder/SplFileInfo.php create mode 100644 vendor/vendor/symfony/finder/composer.json create mode 100644 vendor/vendor/symfony/http-foundation/AcceptHeader.php create mode 100644 vendor/vendor/symfony/http-foundation/AcceptHeaderItem.php create mode 100644 vendor/vendor/symfony/http-foundation/BinaryFileResponse.php create mode 100644 vendor/vendor/symfony/http-foundation/CHANGELOG.md create mode 100644 vendor/vendor/symfony/http-foundation/Cookie.php create mode 100644 vendor/vendor/symfony/http-foundation/Exception/BadRequestException.php create mode 100644 vendor/vendor/symfony/http-foundation/Exception/ConflictingHeadersException.php create mode 100644 vendor/vendor/symfony/http-foundation/Exception/JsonException.php create mode 100644 vendor/vendor/symfony/http-foundation/Exception/RequestExceptionInterface.php create mode 100644 vendor/vendor/symfony/http-foundation/Exception/SessionNotFoundException.php create mode 100644 vendor/vendor/symfony/http-foundation/Exception/SuspiciousOperationException.php create mode 100644 vendor/vendor/symfony/http-foundation/ExpressionRequestMatcher.php create mode 100644 vendor/vendor/symfony/http-foundation/File/Exception/AccessDeniedException.php create mode 100644 vendor/vendor/symfony/http-foundation/File/Exception/CannotWriteFileException.php create mode 100644 vendor/vendor/symfony/http-foundation/File/Exception/ExtensionFileException.php create mode 100644 vendor/vendor/symfony/http-foundation/File/Exception/FileException.php create mode 100644 vendor/vendor/symfony/http-foundation/File/Exception/FileNotFoundException.php create mode 100644 vendor/vendor/symfony/http-foundation/File/Exception/FormSizeFileException.php create mode 100644 vendor/vendor/symfony/http-foundation/File/Exception/IniSizeFileException.php create mode 100644 vendor/vendor/symfony/http-foundation/File/Exception/NoFileException.php create mode 100644 vendor/vendor/symfony/http-foundation/File/Exception/NoTmpDirFileException.php create mode 100644 vendor/vendor/symfony/http-foundation/File/Exception/PartialFileException.php create mode 100644 vendor/vendor/symfony/http-foundation/File/Exception/UnexpectedTypeException.php create mode 100644 vendor/vendor/symfony/http-foundation/File/Exception/UploadException.php create mode 100644 vendor/vendor/symfony/http-foundation/File/File.php create mode 100644 vendor/vendor/symfony/http-foundation/File/Stream.php create mode 100644 vendor/vendor/symfony/http-foundation/File/UploadedFile.php create mode 100644 vendor/vendor/symfony/http-foundation/FileBag.php create mode 100644 vendor/vendor/symfony/http-foundation/HeaderBag.php create mode 100644 vendor/vendor/symfony/http-foundation/HeaderUtils.php create mode 100644 vendor/vendor/symfony/http-foundation/InputBag.php create mode 100644 vendor/vendor/symfony/http-foundation/IpUtils.php create mode 100644 vendor/vendor/symfony/http-foundation/JsonResponse.php create mode 100644 vendor/vendor/symfony/http-foundation/LICENSE create mode 100644 vendor/vendor/symfony/http-foundation/ParameterBag.php create mode 100644 vendor/vendor/symfony/http-foundation/README.md create mode 100644 vendor/vendor/symfony/http-foundation/RateLimiter/AbstractRequestRateLimiter.php create mode 100644 vendor/vendor/symfony/http-foundation/RateLimiter/RequestRateLimiterInterface.php create mode 100644 vendor/vendor/symfony/http-foundation/RedirectResponse.php create mode 100644 vendor/vendor/symfony/http-foundation/Request.php create mode 100644 vendor/vendor/symfony/http-foundation/RequestMatcher.php create mode 100644 vendor/vendor/symfony/http-foundation/RequestMatcherInterface.php create mode 100644 vendor/vendor/symfony/http-foundation/RequestStack.php create mode 100644 vendor/vendor/symfony/http-foundation/Response.php create mode 100644 vendor/vendor/symfony/http-foundation/ResponseHeaderBag.php create mode 100644 vendor/vendor/symfony/http-foundation/ServerBag.php create mode 100644 vendor/vendor/symfony/http-foundation/Session/Attribute/AttributeBag.php create mode 100644 vendor/vendor/symfony/http-foundation/Session/Attribute/AttributeBagInterface.php create mode 100644 vendor/vendor/symfony/http-foundation/Session/Attribute/NamespacedAttributeBag.php create mode 100644 vendor/vendor/symfony/http-foundation/Session/Flash/AutoExpireFlashBag.php create mode 100644 vendor/vendor/symfony/http-foundation/Session/Flash/FlashBag.php create mode 100644 vendor/vendor/symfony/http-foundation/Session/Flash/FlashBagInterface.php create mode 100644 vendor/vendor/symfony/http-foundation/Session/Session.php create mode 100644 vendor/vendor/symfony/http-foundation/Session/SessionBagInterface.php create mode 100644 vendor/vendor/symfony/http-foundation/Session/SessionBagProxy.php create mode 100644 vendor/vendor/symfony/http-foundation/Session/SessionFactory.php create mode 100644 vendor/vendor/symfony/http-foundation/Session/SessionFactoryInterface.php create mode 100644 vendor/vendor/symfony/http-foundation/Session/SessionInterface.php create mode 100644 vendor/vendor/symfony/http-foundation/Session/SessionUtils.php create mode 100644 vendor/vendor/symfony/http-foundation/Session/Storage/Handler/AbstractSessionHandler.php create mode 100644 vendor/vendor/symfony/http-foundation/Session/Storage/Handler/IdentityMarshaller.php create mode 100644 vendor/vendor/symfony/http-foundation/Session/Storage/Handler/MarshallingSessionHandler.php create mode 100644 vendor/vendor/symfony/http-foundation/Session/Storage/Handler/MemcachedSessionHandler.php create mode 100644 vendor/vendor/symfony/http-foundation/Session/Storage/Handler/MigratingSessionHandler.php create mode 100644 vendor/vendor/symfony/http-foundation/Session/Storage/Handler/MongoDbSessionHandler.php create mode 100644 vendor/vendor/symfony/http-foundation/Session/Storage/Handler/NativeFileSessionHandler.php create mode 100644 vendor/vendor/symfony/http-foundation/Session/Storage/Handler/NullSessionHandler.php create mode 100644 vendor/vendor/symfony/http-foundation/Session/Storage/Handler/PdoSessionHandler.php create mode 100644 vendor/vendor/symfony/http-foundation/Session/Storage/Handler/RedisSessionHandler.php create mode 100644 vendor/vendor/symfony/http-foundation/Session/Storage/Handler/SessionHandlerFactory.php create mode 100644 vendor/vendor/symfony/http-foundation/Session/Storage/Handler/StrictSessionHandler.php create mode 100644 vendor/vendor/symfony/http-foundation/Session/Storage/MetadataBag.php create mode 100644 vendor/vendor/symfony/http-foundation/Session/Storage/MockArraySessionStorage.php create mode 100644 vendor/vendor/symfony/http-foundation/Session/Storage/MockFileSessionStorage.php create mode 100644 vendor/vendor/symfony/http-foundation/Session/Storage/MockFileSessionStorageFactory.php create mode 100644 vendor/vendor/symfony/http-foundation/Session/Storage/NativeSessionStorage.php create mode 100644 vendor/vendor/symfony/http-foundation/Session/Storage/NativeSessionStorageFactory.php create mode 100644 vendor/vendor/symfony/http-foundation/Session/Storage/PhpBridgeSessionStorage.php create mode 100644 vendor/vendor/symfony/http-foundation/Session/Storage/PhpBridgeSessionStorageFactory.php create mode 100644 vendor/vendor/symfony/http-foundation/Session/Storage/Proxy/AbstractProxy.php create mode 100644 vendor/vendor/symfony/http-foundation/Session/Storage/Proxy/SessionHandlerProxy.php create mode 100644 vendor/vendor/symfony/http-foundation/Session/Storage/ServiceSessionFactory.php create mode 100644 vendor/vendor/symfony/http-foundation/Session/Storage/SessionStorageFactoryInterface.php create mode 100644 vendor/vendor/symfony/http-foundation/Session/Storage/SessionStorageInterface.php create mode 100644 vendor/vendor/symfony/http-foundation/StreamedResponse.php create mode 100644 vendor/vendor/symfony/http-foundation/Test/Constraint/RequestAttributeValueSame.php create mode 100644 vendor/vendor/symfony/http-foundation/Test/Constraint/ResponseCookieValueSame.php create mode 100644 vendor/vendor/symfony/http-foundation/Test/Constraint/ResponseFormatSame.php create mode 100644 vendor/vendor/symfony/http-foundation/Test/Constraint/ResponseHasCookie.php create mode 100644 vendor/vendor/symfony/http-foundation/Test/Constraint/ResponseHasHeader.php create mode 100644 vendor/vendor/symfony/http-foundation/Test/Constraint/ResponseHeaderSame.php create mode 100644 vendor/vendor/symfony/http-foundation/Test/Constraint/ResponseIsRedirected.php create mode 100644 vendor/vendor/symfony/http-foundation/Test/Constraint/ResponseIsSuccessful.php create mode 100644 vendor/vendor/symfony/http-foundation/Test/Constraint/ResponseIsUnprocessable.php create mode 100644 vendor/vendor/symfony/http-foundation/Test/Constraint/ResponseStatusCodeSame.php create mode 100644 vendor/vendor/symfony/http-foundation/UrlHelper.php create mode 100644 vendor/vendor/symfony/http-foundation/composer.json create mode 100644 vendor/vendor/symfony/polyfill-mbstring/LICENSE create mode 100644 vendor/vendor/symfony/polyfill-mbstring/Mbstring.php create mode 100644 vendor/vendor/symfony/polyfill-mbstring/README.md create mode 100644 vendor/vendor/symfony/polyfill-mbstring/Resources/unidata/caseFolding.php create mode 100644 vendor/vendor/symfony/polyfill-mbstring/Resources/unidata/lowerCase.php create mode 100644 vendor/vendor/symfony/polyfill-mbstring/Resources/unidata/titleCaseRegexp.php create mode 100644 vendor/vendor/symfony/polyfill-mbstring/Resources/unidata/upperCase.php create mode 100644 vendor/vendor/symfony/polyfill-mbstring/bootstrap.php create mode 100644 vendor/vendor/symfony/polyfill-mbstring/bootstrap80.php create mode 100644 vendor/vendor/symfony/polyfill-mbstring/composer.json create mode 100644 vendor/vendor/symfony/polyfill-php73/LICENSE create mode 100644 vendor/vendor/symfony/polyfill-php73/Php73.php create mode 100644 vendor/vendor/symfony/polyfill-php73/README.md create mode 100644 vendor/vendor/symfony/polyfill-php73/Resources/stubs/JsonException.php create mode 100644 vendor/vendor/symfony/polyfill-php73/bootstrap.php create mode 100644 vendor/vendor/symfony/polyfill-php73/composer.json create mode 100644 vendor/vendor/symfony/polyfill-php80/LICENSE create mode 100644 vendor/vendor/symfony/polyfill-php80/Php80.php create mode 100644 vendor/vendor/symfony/polyfill-php80/PhpToken.php create mode 100644 vendor/vendor/symfony/polyfill-php80/README.md create mode 100644 vendor/vendor/symfony/polyfill-php80/Resources/stubs/Attribute.php create mode 100644 vendor/vendor/symfony/polyfill-php80/Resources/stubs/PhpToken.php create mode 100644 vendor/vendor/symfony/polyfill-php80/Resources/stubs/Stringable.php create mode 100644 vendor/vendor/symfony/polyfill-php80/Resources/stubs/UnhandledMatchError.php create mode 100644 vendor/vendor/symfony/polyfill-php80/Resources/stubs/ValueError.php create mode 100644 vendor/vendor/symfony/polyfill-php80/bootstrap.php create mode 100644 vendor/vendor/symfony/polyfill-php80/composer.json create mode 100644 vendor/vendor/symfony/psr-http-message-bridge/.php-cs-fixer.dist.php create mode 100644 vendor/vendor/symfony/psr-http-message-bridge/ArgumentValueResolver/PsrServerRequestResolver.php create mode 100644 vendor/vendor/symfony/psr-http-message-bridge/ArgumentValueResolver/ValueResolverInterface.php create mode 100644 vendor/vendor/symfony/psr-http-message-bridge/CHANGELOG.md create mode 100644 vendor/vendor/symfony/psr-http-message-bridge/EventListener/PsrResponseListener.php create mode 100644 vendor/vendor/symfony/psr-http-message-bridge/Factory/HttpFoundationFactory.php create mode 100644 vendor/vendor/symfony/psr-http-message-bridge/Factory/PsrHttpFactory.php create mode 100644 vendor/vendor/symfony/psr-http-message-bridge/Factory/UploadedFile.php create mode 100644 vendor/vendor/symfony/psr-http-message-bridge/HttpFoundationFactoryInterface.php create mode 100644 vendor/vendor/symfony/psr-http-message-bridge/HttpMessageFactoryInterface.php create mode 100644 vendor/vendor/symfony/psr-http-message-bridge/LICENSE create mode 100644 vendor/vendor/symfony/psr-http-message-bridge/README.md create mode 100644 vendor/vendor/symfony/psr-http-message-bridge/composer.json create mode 100644 vendor/vendor/symfony/service-contracts/LICENSE create mode 100644 vendor/vendor/symfony/service-contracts/README.md create mode 100644 vendor/vendor/symfony/service-contracts/ResetInterface.php create mode 100644 vendor/vendor/symfony/service-contracts/ServiceLocatorTrait.php create mode 100644 vendor/vendor/symfony/service-contracts/ServiceProviderInterface.php create mode 100644 vendor/vendor/symfony/service-contracts/ServiceSubscriberInterface.php create mode 100644 vendor/vendor/symfony/service-contracts/ServiceSubscriberTrait.php create mode 100644 vendor/vendor/symfony/service-contracts/Test/ServiceLocatorTest.php create mode 100644 vendor/vendor/symfony/service-contracts/composer.json create mode 100644 vendor/vendor/symfony/var-exporter/CHANGELOG.md create mode 100644 vendor/vendor/symfony/var-exporter/Exception/ClassNotFoundException.php create mode 100644 vendor/vendor/symfony/var-exporter/Exception/ExceptionInterface.php create mode 100644 vendor/vendor/symfony/var-exporter/Exception/NotInstantiableTypeException.php create mode 100644 vendor/vendor/symfony/var-exporter/Instantiator.php create mode 100644 vendor/vendor/symfony/var-exporter/Internal/Exporter.php create mode 100644 vendor/vendor/symfony/var-exporter/Internal/Hydrator.php create mode 100644 vendor/vendor/symfony/var-exporter/Internal/Reference.php create mode 100644 vendor/vendor/symfony/var-exporter/Internal/Registry.php create mode 100644 vendor/vendor/symfony/var-exporter/Internal/Values.php create mode 100644 vendor/vendor/symfony/var-exporter/LICENSE create mode 100644 vendor/vendor/symfony/var-exporter/README.md create mode 100644 vendor/vendor/symfony/var-exporter/VarExporter.php create mode 100644 vendor/vendor/symfony/var-exporter/composer.json create mode 100644 vendor/vendor/topthink/think-captcha/.gitignore create mode 100644 vendor/vendor/topthink/think-captcha/LICENSE create mode 100644 vendor/vendor/topthink/think-captcha/README.md create mode 100644 vendor/vendor/topthink/think-captcha/assets/bgs/1.jpg create mode 100644 vendor/vendor/topthink/think-captcha/assets/bgs/2.jpg create mode 100644 vendor/vendor/topthink/think-captcha/assets/bgs/3.jpg create mode 100644 vendor/vendor/topthink/think-captcha/assets/bgs/4.jpg create mode 100644 vendor/vendor/topthink/think-captcha/assets/bgs/5.jpg create mode 100644 vendor/vendor/topthink/think-captcha/assets/bgs/6.jpg create mode 100644 vendor/vendor/topthink/think-captcha/assets/bgs/7.jpg create mode 100644 vendor/vendor/topthink/think-captcha/assets/bgs/8.jpg create mode 100644 vendor/vendor/topthink/think-captcha/assets/ttfs/1.ttf create mode 100644 vendor/vendor/topthink/think-captcha/assets/ttfs/2.ttf create mode 100644 vendor/vendor/topthink/think-captcha/assets/ttfs/3.ttf create mode 100644 vendor/vendor/topthink/think-captcha/assets/ttfs/4.ttf create mode 100644 vendor/vendor/topthink/think-captcha/assets/ttfs/5.ttf create mode 100644 vendor/vendor/topthink/think-captcha/assets/ttfs/6.ttf create mode 100644 vendor/vendor/topthink/think-captcha/assets/zhttfs/1.ttf create mode 100644 vendor/vendor/topthink/think-captcha/composer.json create mode 100644 vendor/vendor/topthink/think-captcha/src/Captcha.php create mode 100644 vendor/vendor/topthink/think-captcha/src/CaptchaController.php create mode 100644 vendor/vendor/topthink/think-captcha/src/helper.php create mode 100644 vendor/vendor/topthink/think-helper/.gitignore create mode 100644 vendor/vendor/topthink/think-helper/LICENSE create mode 100644 vendor/vendor/topthink/think-helper/README.md create mode 100644 vendor/vendor/topthink/think-helper/composer.json create mode 100644 vendor/vendor/topthink/think-helper/src/Arr.php create mode 100644 vendor/vendor/topthink/think-helper/src/Hash.php create mode 100644 vendor/vendor/topthink/think-helper/src/Str.php create mode 100644 vendor/vendor/topthink/think-helper/src/Time.php create mode 100644 vendor/vendor/topthink/think-helper/src/hash/Bcrypt.php create mode 100644 vendor/vendor/topthink/think-helper/src/hash/Md5.php create mode 100644 vendor/vendor/topthink/think-helper/src/helper.php create mode 100644 vendor/vendor/topthink/think-installer/.gitignore create mode 100644 vendor/vendor/topthink/think-installer/composer.json create mode 100644 vendor/vendor/topthink/think-installer/src/LibraryInstaller.php create mode 100644 vendor/vendor/topthink/think-installer/src/Plugin.php create mode 100644 vendor/vendor/topthink/think-installer/src/Promise.php create mode 100644 vendor/vendor/topthink/think-installer/src/ThinkExtend.php create mode 100644 vendor/vendor/topthink/think-installer/src/ThinkFramework.php create mode 100644 vendor/vendor/topthink/think-installer/src/ThinkTesting.php create mode 100644 vendor/vendor/topthink/think-queue/.gitignore create mode 100644 vendor/vendor/topthink/think-queue/LICENSE create mode 100644 vendor/vendor/topthink/think-queue/README.md create mode 100644 vendor/vendor/topthink/think-queue/composer.json create mode 100644 vendor/vendor/topthink/think-queue/src/Queue.php create mode 100644 vendor/vendor/topthink/think-queue/src/common.php create mode 100644 vendor/vendor/topthink/think-queue/src/config.php create mode 100644 vendor/vendor/topthink/think-queue/src/queue/CallQueuedHandler.php create mode 100644 vendor/vendor/topthink/think-queue/src/queue/Connector.php create mode 100644 vendor/vendor/topthink/think-queue/src/queue/Job.php create mode 100644 vendor/vendor/topthink/think-queue/src/queue/Listener.php create mode 100644 vendor/vendor/topthink/think-queue/src/queue/Queueable.php create mode 100644 vendor/vendor/topthink/think-queue/src/queue/ShouldQueue.php create mode 100644 vendor/vendor/topthink/think-queue/src/queue/Worker.php create mode 100644 vendor/vendor/topthink/think-queue/src/queue/command/Listen.php create mode 100644 vendor/vendor/topthink/think-queue/src/queue/command/Restart.php create mode 100644 vendor/vendor/topthink/think-queue/src/queue/command/Subscribe.php create mode 100644 vendor/vendor/topthink/think-queue/src/queue/command/Work.php create mode 100644 vendor/vendor/topthink/think-queue/src/queue/connector/Database.php create mode 100644 vendor/vendor/topthink/think-queue/src/queue/connector/Redis.php create mode 100644 vendor/vendor/topthink/think-queue/src/queue/connector/Sync.php create mode 100644 vendor/vendor/topthink/think-queue/src/queue/connector/Topthink.php create mode 100644 vendor/vendor/topthink/think-queue/src/queue/job/Database.php create mode 100644 vendor/vendor/topthink/think-queue/src/queue/job/Redis.php create mode 100644 vendor/vendor/topthink/think-queue/src/queue/job/Sync.php create mode 100644 vendor/vendor/topthink/think-queue/src/queue/job/Topthink.php diff --git a/.htaccess b/.htaccess new file mode 100644 index 0000000..e69de29 diff --git a/addons/.htaccess b/addons/.htaccess new file mode 100644 index 0000000..3418e55 --- /dev/null +++ b/addons/.htaccess @@ -0,0 +1 @@ +deny from all \ No newline at end of file diff --git a/application/.htaccess b/application/.htaccess new file mode 100644 index 0000000..3418e55 --- /dev/null +++ b/application/.htaccess @@ -0,0 +1 @@ +deny from all \ No newline at end of file diff --git a/extend/.htaccess b/extend/.htaccess new file mode 100644 index 0000000..3418e55 --- /dev/null +++ b/extend/.htaccess @@ -0,0 +1 @@ +deny from all \ No newline at end of file diff --git a/nginx.htaccess b/nginx.htaccess new file mode 100644 index 0000000..5d6ebdf --- /dev/null +++ b/nginx.htaccess @@ -0,0 +1,6 @@ +location /{ + if (!-e $request_filename) { + rewrite ^(.*)$ /index.php/$1 last; + break; + } +} \ No newline at end of file diff --git a/public/.htaccess b/public/.htaccess new file mode 100644 index 0000000..e69de29 diff --git a/public/nginx.htaccess b/public/nginx.htaccess new file mode 100644 index 0000000..5d6ebdf --- /dev/null +++ b/public/nginx.htaccess @@ -0,0 +1,6 @@ +location /{ + if (!-e $request_filename) { + rewrite ^(.*)$ /index.php/$1 last; + break; + } +} \ No newline at end of file diff --git a/thinkphp/.gitignore b/thinkphp/.gitignore new file mode 100644 index 0000000..7884c74 --- /dev/null +++ b/thinkphp/.gitignore @@ -0,0 +1,5 @@ +/composer.lock +/vendor +.idea +.DS_Store +/.vscode diff --git a/thinkphp/.htaccess b/thinkphp/.htaccess new file mode 100644 index 0000000..3418e55 --- /dev/null +++ b/thinkphp/.htaccess @@ -0,0 +1 @@ +deny from all \ No newline at end of file diff --git a/thinkphp/.travis.yml b/thinkphp/.travis.yml new file mode 100644 index 0000000..f74ffca --- /dev/null +++ b/thinkphp/.travis.yml @@ -0,0 +1,47 @@ +sudo: false + +language: php + +services: + - memcached + - mongodb + - mysql + - postgresql + - redis-server + +matrix: + fast_finish: true + include: + - php: 5.4 + - php: 5.5 + - php: 5.6 + - php: 7.0 + - php: hhvm + allow_failures: + - php: hhvm + +cache: + directories: + - $HOME/.composer/cache + +before_install: + - composer self-update + - mysql -e "create database IF NOT EXISTS test;" -uroot + - psql -c 'DROP DATABASE IF EXISTS test;' -U postgres + - psql -c 'create database test;' -U postgres + +install: + - ./tests/script/install.sh + +script: + ## LINT + - find . -path ./vendor -prune -o -type f -name \*.php -exec php -l {} \; + ## PHP Copy/Paste Detector + - vendor/bin/phpcpd --verbose --exclude vendor ./ || true + ## PHPLOC + - vendor/bin/phploc --exclude vendor ./ + ## PHPUNIT + - vendor/bin/phpunit --coverage-clover=coverage.xml --configuration=phpunit.xml + +after_success: + - bash <(curl -s https://codecov.io/bash) diff --git a/thinkphp/CONTRIBUTING.md b/thinkphp/CONTRIBUTING.md new file mode 100644 index 0000000..dc8e91c --- /dev/null +++ b/thinkphp/CONTRIBUTING.md @@ -0,0 +1,119 @@ +如何贡献我的源代码 +=== + +此文档介绍了 ThinkPHP 团队的组成以及运转机制,您提交的代码将给 ThinkPHP 项目带来什么好处,以及如何才能加入我们的行列。 + +## 通过 Github 贡献代码 + +ThinkPHP 目前使用 Git 来控制程序版本,如果你想为 ThinkPHP 贡献源代码,请先大致了解 Git 的使用方法。我们目前把项目托管在 GitHub 上,任何 GitHub 用户都可以向我们贡献代码。 + +参与的方式很简单,`fork`一份 ThinkPHP 的代码到你的仓库中,修改后提交,并向我们发起`pull request`申请,我们会及时对代码进行审查并处理你的申请。审查通过后,你的代码将被`merge`进我们的仓库中,这样你就会自动出现在贡献者名单里了,非常方便。 + +我们希望你贡献的代码符合: + +* ThinkPHP 的编码规范 +* 适当的注释,能让其他人读懂 +* 遵循 Apache2 开源协议 + +**如果想要了解更多细节或有任何疑问,请继续阅读下面的内容** + +### 注意事项 + +* 本项目代码格式化标准选用 [**PSR-2**](http://www.kancloud.cn/thinkphp/php-fig-psr/3141); +* 类名和类文件名遵循 [**PSR-4**](http://www.kancloud.cn/thinkphp/php-fig-psr/3144); +* 对于 Issues 的处理,请使用诸如 `fix #xxx(Issue ID)` 的 commit title 直接关闭 issue。 +* 系统会自动在 PHP 5.4 5.5 5.6 7.0 和 HHVM 上测试修改,其中 HHVM 下的测试容许报错,请确保你的修改符合 PHP 5.4 ~ 5.6 和 PHP 7.0 的语法规范; +* 管理员不会合并造成 CI faild 的修改,若出现 CI faild 请检查自己的源代码或修改相应的[单元测试文件](tests); + +## GitHub Issue + +GitHub 提供了 Issue 功能,该功能可以用于: + +* 提出 bug +* 提出功能改进 +* 反馈使用体验 + +该功能不应该用于: + + * 提出修改意见(涉及代码署名和修订追溯问题) + * 不友善的言论 + +## 快速修改 + +**GitHub 提供了快速编辑文件的功能** + +1. 登录 GitHub 帐号; +2. 浏览项目文件,找到要进行修改的文件; +3. 点击右上角铅笔图标进行修改; +4. 填写 `Commit changes` 相关内容(Title 必填); +5. 提交修改,等待 CI 验证和管理员合并。 + +**若您需要一次提交大量修改,请继续阅读下面的内容** + +## 完整流程 + +1. `fork`本项目; +2. 克隆(`clone`)你 `fork` 的项目到本地; +3. 新建分支(`branch`)并检出(`checkout`)新分支; +4. 添加本项目到你的本地 git 仓库作为上游(`upstream`); +5. 进行修改,若你的修改包含方法或函数的增减,请记得修改[单元测试文件](tests); +6. 变基(衍合 `rebase`)你的分支到上游 master 分支; +7. `push` 你的本地仓库到 GitHub; +8. 提交 `pull request`; +9. 等待 CI 验证(若不通过则重复 5~7,不需要重新提交 `pull request`,GitHub 会自动更新你的 `pull request`); +10. 等待管理员处理,并及时 `rebase` 你的分支到上游 master 分支(若上游 master 分支有修改)。 + +*若有必要,可以 `git push -f` 强行推送 rebase 后的分支到自己的 `fork`* + +*绝对不可以使用 `git push -f` 强行推送修改到上游* + +### 注意事项 + +* 若对上述流程有任何不清楚的地方,请查阅 GIT 教程,如 [这个](http://backlogtool.com/git-guide/cn/); +* 对于代码**不同方面**的修改,请在自己 `fork` 的项目中**创建不同的分支**(原因参见`完整流程`第9条备注部分); +* 变基及交互式变基操作参见 [Git 交互式变基](http://pakchoi.me/2015/03/17/git-interactive-rebase/) + +## 推荐资源 + +### 开发环境 + +* XAMPP for Windows 5.5.x +* WampServer (for Windows) +* upupw Apache PHP5.4 ( for Windows) + +或自行安装 + +- Apache / Nginx +- PHP 5.4 ~ 5.6 +- MySQL / MariaDB + +*Windows 用户推荐添加 PHP bin 目录到 PATH,方便使用 composer* + +*Linux 用户自行配置环境, Mac 用户推荐使用内置 Apache 配合 Homebrew 安装 PHP 和 MariaDB* + +### 编辑器 + +Sublime Text 3 + phpfmt 插件 + +phpfmt 插件参数 + +```json +{ + "autocomplete": true, + "enable_auto_align": true, + "format_on_save": true, + "indent_with_space": true, + "psr1_naming": false, + "psr2": true, + "version": 4 +} +``` + +或其他 编辑器 / IDE 配合 PSR2 自动格式化工具 + +### Git GUI + +* SourceTree +* GitHub Desktop + +或其他 Git 图形界面客户端 diff --git a/thinkphp/LICENSE.txt b/thinkphp/LICENSE.txt new file mode 100644 index 0000000..2cb9a8a --- /dev/null +++ b/thinkphp/LICENSE.txt @@ -0,0 +1,32 @@ + +ThinkPHP遵循Apache2开源协议发布,并提供免费使用。 +版权所有Copyright © 2006-2017 by ThinkPHP (http://thinkphp.cn) +All rights reserved。 +ThinkPHP® 商标和著作权所有者为上海顶想信息科技有限公司。 + +Apache Licence是著名的非盈利开源组织Apache采用的协议。 +该协议和BSD类似,鼓励代码共享和尊重原作者的著作权, +允许代码修改,再作为开源或商业软件发布。需要满足 +的条件: +1. 需要给代码的用户一份Apache Licence ; +2. 如果你修改了代码,需要在被修改的文件中说明; +3. 在延伸的代码中(修改和有源代码衍生的代码中)需要 +带有原来代码中的协议,商标,专利声明和其他原来作者规 +定需要包含的说明; +4. 如果再发布的产品中包含一个Notice文件,则在Notice文 +件中需要带有本协议内容。你可以在Notice中增加自己的 +许可,但不可以表现为对Apache Licence构成更改。 +具体的协议参考:http://www.apache.org/licenses/LICENSE-2.0 + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. diff --git a/thinkphp/README.md b/thinkphp/README.md new file mode 100644 index 0000000..3200d31 --- /dev/null +++ b/thinkphp/README.md @@ -0,0 +1,69 @@ +# ThinkPHP 5.0(FastAdmin 团队长期维护) + +## 维护原因 + +FastAdmin 致力于服务开发者,为开发者节省时间,为了 FastAdmin 开源项目持续发展下去。 + +## 参与开源 + +[贡献代码](https://doc.fastadmin.net/doc/contributing.html) + + +## 使用方法 + +- 本框架已经应用在 FastAdmin 后台框架中,在 FastAdmin 项目中使用 `composer update topthink/framework -vvv` 命令即可更新。 + +- 非 FastAdmin 的 ThinkPHP5.0 项目使用此仓库,请修改 `composer.json` 添加以下配置,在执行`composer update topthink/framework -vvv` 命令,具体可以参考 FastAdmin 项目目录下的 `composer.json` 文件内容。 + ``` + "repositories": [ + { + "type": "git", + "url": "https://gitee.com/fastadminnet/framework.git" + } + ] + ``` + +## 环境要求 + +php 7.1+ + + + +## ThinkPHP 介绍 + +ThinkPHP5 在保持快速开发和大道至简的核心理念不变的同时,优化核心,减少依赖,基于全新的架构思想和命名空间实现,是 ThinkPHP 突破原有框架思路的颠覆之作,其主要特性包括: + + + 基于命名空间和众多PHP新特性 + + 核心功能组件化 + + 强化路由功能 + + 更灵活的控制器 + + 重构的模型和数据库类 + + 配置文件可分离 + + 重写的自动验证和完成 + + 简化扩展机制 + + API支持完善 + + 改进的Log类 + + 命令行访问支持 + + REST支持 + + 引导文件支持 + + 方便的自动生成定义 + + 真正惰性加载 + + 分布式环境支持 + + 支持Composer + + 支持MongoDb + +详细开发文档参考 [ThinkPHP5完全开发手册](http://www.kancloud.cn/manual/thinkphp5) 以及[ThinkPHP5入门系列教程](http://www.kancloud.cn/special/thinkphp5_quickstart) + +## 版权信息 + +ThinkPHP遵循Apache2开源协议发布,并提供免费使用。 + +本项目包含的第三方源码和二进制文件之版权信息另行标注。 + +版权所有Copyright © 2006-2024 by ThinkPHP (http://thinkphp.cn) + +All rights reserved。 + +ThinkPHP® 商标和著作权所有者为上海顶想信息科技有限公司。 + +更多细节参阅 [LICENSE.txt](LICENSE.txt) diff --git a/thinkphp/base.php b/thinkphp/base.php new file mode 100644 index 0000000..ba102fc --- /dev/null +++ b/thinkphp/base.php @@ -0,0 +1,65 @@ + +// +---------------------------------------------------------------------- + +define('THINK_VERSION', '5.0.28'); +define('THINK_START_TIME', microtime(true)); +define('THINK_START_MEM', memory_get_usage()); +define('EXT', '.php'); +define('DS', DIRECTORY_SEPARATOR); +defined('THINK_PATH') or define('THINK_PATH', __DIR__ . DS); +define('LIB_PATH', THINK_PATH . 'library' . DS); +define('CORE_PATH', LIB_PATH . 'think' . DS); +define('TRAIT_PATH', LIB_PATH . 'traits' . DS); +defined('APP_PATH') or define('APP_PATH', dirname($_SERVER['SCRIPT_FILENAME']) . DS); +defined('ROOT_PATH') or define('ROOT_PATH', dirname(realpath(APP_PATH)) . DS); +defined('EXTEND_PATH') or define('EXTEND_PATH', ROOT_PATH . 'extend' . DS); +defined('VENDOR_PATH') or define('VENDOR_PATH', ROOT_PATH . 'vendor' . DS); +defined('RUNTIME_PATH') or define('RUNTIME_PATH', ROOT_PATH . 'runtime' . DS); +defined('LOG_PATH') or define('LOG_PATH', RUNTIME_PATH . 'log' . DS); +defined('CACHE_PATH') or define('CACHE_PATH', RUNTIME_PATH . 'cache' . DS); +defined('TEMP_PATH') or define('TEMP_PATH', RUNTIME_PATH . 'temp' . DS); +defined('CONF_PATH') or define('CONF_PATH', APP_PATH); // 配置文件目录 +defined('CONF_EXT') or define('CONF_EXT', EXT); // 配置文件后缀 +defined('ENV_PREFIX') or define('ENV_PREFIX', 'PHP_'); // 环境变量的配置前缀 + +// 环境常量 +define('IS_CLI', PHP_SAPI == 'cli' ? true : false); +define('IS_WIN', strpos(PHP_OS, 'WIN') !== false); + +// 载入Loader类 +require CORE_PATH . 'Loader.php'; + +// 加载环境变量配置文件 +if (is_file(ROOT_PATH . '.env')) { + $env = parse_ini_file(ROOT_PATH . '.env', true); + + foreach ($env as $key => $val) { + $name = ENV_PREFIX . strtoupper($key); + + if (is_array($val)) { + foreach ($val as $k => $v) { + $item = $name . '_' . strtoupper($k); + putenv("$item=$v"); + } + } else { + putenv("$name=$val"); + } + } +} + +// 注册自动加载 +\think\Loader::register(); + +// 注册错误和异常处理机制 +\think\Error::register(); + +// 加载惯例配置文件 +\think\Config::set(include THINK_PATH . 'convention' . EXT); diff --git a/thinkphp/codecov.yml b/thinkphp/codecov.yml new file mode 100644 index 0000000..bef9d64 --- /dev/null +++ b/thinkphp/codecov.yml @@ -0,0 +1,12 @@ +comment: + layout: header, changes, diff +coverage: + ignore: + - base.php + - helper.php + - convention.php + - lang/zh-cn.php + - start.php + - console.php + status: + patch: false diff --git a/thinkphp/composer.json b/thinkphp/composer.json new file mode 100644 index 0000000..caf6c7e --- /dev/null +++ b/thinkphp/composer.json @@ -0,0 +1,35 @@ +{ + "name": "topthink/framework", + "description": "the new thinkphp framework", + "type": "think-framework", + "keywords": [ + "framework", + "thinkphp", + "ORM" + ], + "homepage": "http://thinkphp.cn/", + "license": "Apache-2.0", + "authors": [ + { + "name": "liu21st", + "email": "liu21st@gmail.com" + } + ], + "require": { + "php": ">=7.1.0", + "topthink/think-installer": "~1.0" + }, + "require-dev": { + "phpunit/phpunit": "4.8.*", + "johnkary/phpunit-speedtrap": "^1.0", + "mikey179/vfsstream": "~1.6", + "phploc/phploc": "2.*", + "sebastian/phpcpd": "2.*", + "phpdocumentor/reflection-docblock": "^2.0" + }, + "autoload": { + "psr-4": { + "think\\": "library/think" + } + } +} diff --git a/thinkphp/console.php b/thinkphp/console.php new file mode 100644 index 0000000..578e4a7 --- /dev/null +++ b/thinkphp/console.php @@ -0,0 +1,20 @@ + +// +---------------------------------------------------------------------- + +namespace think; + +// ThinkPHP 引导文件 +// 加载基础文件 +require __DIR__ . '/base.php'; + +// 执行应用 +App::initCommon(); +Console::init(); diff --git a/thinkphp/convention.php b/thinkphp/convention.php new file mode 100644 index 0000000..31a0a0c --- /dev/null +++ b/thinkphp/convention.php @@ -0,0 +1,298 @@ + '', + // 应用调试模式 + 'app_debug' => false, + // 应用Trace + 'app_trace' => false, + // 应用模式状态 + 'app_status' => '', + // 是否支持多模块 + 'app_multi_module' => true, + // 入口自动绑定模块 + 'auto_bind_module' => false, + // 注册的根命名空间 + 'root_namespace' => [], + // 扩展函数文件 + 'extra_file_list' => [THINK_PATH . 'helper' . EXT], + // 默认输出类型 + 'default_return_type' => 'html', + // 默认AJAX 数据返回格式,可选json xml ... + 'default_ajax_return' => 'json', + // 默认JSONP格式返回的处理方法 + 'default_jsonp_handler' => 'jsonpReturn', + // 默认JSONP处理方法 + 'var_jsonp_handler' => 'callback', + // 默认时区 + 'default_timezone' => 'PRC', + // 是否开启多语言 + 'lang_switch_on' => false, + // 默认全局过滤方法 用逗号分隔多个 + 'default_filter' => '', + // 默认语言 + 'default_lang' => 'zh-cn', + // 应用类库后缀 + 'class_suffix' => false, + // 控制器类后缀 + 'controller_suffix' => false, + + // +---------------------------------------------------------------------- + // | 模块设置 + // +---------------------------------------------------------------------- + + // 默认模块名 + 'default_module' => 'index', + // 禁止访问模块 + 'deny_module_list' => ['common'], + // 默认控制器名 + 'default_controller' => 'Index', + // 默认操作名 + 'default_action' => 'index', + // 默认验证器 + 'default_validate' => '', + // 默认的空控制器名 + 'empty_controller' => 'Error', + // 操作方法前缀 + 'use_action_prefix' => false, + // 操作方法后缀 + 'action_suffix' => '', + // 自动搜索控制器 + 'controller_auto_search' => false, + + // +---------------------------------------------------------------------- + // | URL设置 + // +---------------------------------------------------------------------- + + // PATHINFO变量名 用于兼容模式 + 'var_pathinfo' => 's', + // 兼容PATH_INFO获取 + 'pathinfo_fetch' => ['ORIG_PATH_INFO', 'REDIRECT_PATH_INFO', 'REDIRECT_URL'], + // pathinfo分隔符 + 'pathinfo_depr' => '/', + // HTTPS代理标识 + 'https_agent_name' => '', + // URL伪静态后缀 + 'url_html_suffix' => 'html', + // URL普通方式参数 用于自动生成 + 'url_common_param' => false, + // URL参数方式 0 按名称成对解析 1 按顺序解析 + 'url_param_type' => 0, + // 是否开启路由 + 'url_route_on' => true, + // 路由配置文件(支持配置多个) + 'route_config_file' => ['route'], + // 路由使用完整匹配 + 'route_complete_match' => false, + // 是否强制使用路由 + 'url_route_must' => false, + // 域名部署 + 'url_domain_deploy' => false, + // 域名根,如thinkphp.cn + 'url_domain_root' => '', + // 是否自动转换URL中的控制器和操作名 + 'url_convert' => true, + // 默认的访问控制器层 + 'url_controller_layer' => 'controller', + // 表单请求类型伪装变量 + 'var_method' => '_method', + // 表单ajax伪装变量 + 'var_ajax' => '_ajax', + // 表单pjax伪装变量 + 'var_pjax' => '_pjax', + // 是否开启请求缓存 true自动缓存 支持设置请求缓存规则 + 'request_cache' => false, + // 请求缓存有效期 + 'request_cache_expire' => null, + // 全局请求缓存排除规则 + 'request_cache_except' => [], + + // +---------------------------------------------------------------------- + // | 模板设置 + // +---------------------------------------------------------------------- + + 'template' => [ + // 默认模板渲染规则 1 解析为小写+下划线 2 全部转换小写 + 'auto_rule' => 1, + // 模板引擎类型 支持 php think 支持扩展 + 'type' => 'Think', + // 视图基础目录,配置目录为所有模块的视图起始目录 + 'view_base' => '', + // 当前模板的视图目录 留空为自动获取 + 'view_path' => '', + // 模板后缀 + 'view_suffix' => 'html', + // 模板文件名分隔符 + 'view_depr' => DS, + // 模板引擎普通标签开始标记 + 'tpl_begin' => '{', + // 模板引擎普通标签结束标记 + 'tpl_end' => '}', + // 标签库标签开始标记 + 'taglib_begin' => '{', + // 标签库标签结束标记 + 'taglib_end' => '}', + ], + + // 视图输出字符串内容替换 + 'view_replace_str' => [], + // 默认跳转页面对应的模板文件 + 'dispatch_success_tmpl' => THINK_PATH . 'tpl' . DS . 'dispatch_jump.tpl', + 'dispatch_error_tmpl' => THINK_PATH . 'tpl' . DS . 'dispatch_jump.tpl', + + // +---------------------------------------------------------------------- + // | 异常及错误设置 + // +---------------------------------------------------------------------- + + // 异常页面的模板文件 + 'exception_tmpl' => THINK_PATH . 'tpl' . DS . 'think_exception.tpl', + + // 错误显示信息,非调试模式有效 + 'error_message' => '页面错误!请稍后再试~', + // 显示错误信息 + 'show_error_msg' => false, + // 异常处理handle类 留空使用 \think\exception\Handle + 'exception_handle' => '', + // 是否记录trace信息到日志 + 'record_trace' => false, + + // +---------------------------------------------------------------------- + // | 日志设置 + // +---------------------------------------------------------------------- + + 'log' => [ + // 日志记录方式,内置 file socket 支持扩展 + 'type' => 'File', + // 日志保存目录 + 'path' => LOG_PATH, + // 日志记录级别 + 'level' => [], + ], + + // +---------------------------------------------------------------------- + // | Trace设置 开启 app_trace 后 有效 + // +---------------------------------------------------------------------- + 'trace' => [ + // 内置Html Console 支持扩展 + 'type' => 'Html', + ], + + // +---------------------------------------------------------------------- + // | 缓存设置 + // +---------------------------------------------------------------------- + + 'cache' => [ + // 驱动方式 + 'type' => 'File', + // 缓存保存目录 + 'path' => CACHE_PATH, + // 缓存前缀 + 'prefix' => '', + // 缓存有效期 0表示永久缓存 + 'expire' => 0, + ], + + // +---------------------------------------------------------------------- + // | 会话设置 + // +---------------------------------------------------------------------- + + 'session' => [ + 'id' => '', + // SESSION_ID的提交变量,解决flash上传跨域 + 'var_session_id' => '', + // SESSION 前缀 + 'prefix' => 'think', + // 驱动方式 支持redis memcache memcached + 'type' => '', + // 是否自动开启 SESSION + 'auto_start' => true, + 'httponly' => true, + 'secure' => false, + ], + + // +---------------------------------------------------------------------- + // | Cookie设置 + // +---------------------------------------------------------------------- + 'cookie' => [ + // cookie 名称前缀 + 'prefix' => '', + // cookie 保存时间 + 'expire' => 0, + // cookie 保存路径 + 'path' => '/', + // cookie 有效域名 + 'domain' => '', + // cookie 启用安全传输 + 'secure' => false, + // httponly设置 + 'httponly' => '', + // 是否使用 setcookie + 'setcookie' => true, + ], + + // +---------------------------------------------------------------------- + // | 数据库设置 + // +---------------------------------------------------------------------- + + 'database' => [ + // 数据库类型 + 'type' => 'mysql', + // 数据库连接DSN配置 + 'dsn' => '', + // 服务器地址 + 'hostname' => '127.0.0.1', + // 数据库名 + 'database' => '', + // 数据库用户名 + 'username' => 'root', + // 数据库密码 + 'password' => '', + // 数据库连接端口 + 'hostport' => '', + // 数据库连接参数 + 'params' => [], + // 数据库编码默认采用utf8 + 'charset' => 'utf8', + // 数据库表前缀 + 'prefix' => '', + // 数据库调试模式 + 'debug' => false, + // 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器) + 'deploy' => 0, + // 数据库读写是否分离 主从式有效 + 'rw_separate' => false, + // 读写分离后 主服务器数量 + 'master_num' => 1, + // 指定从服务器序号 + 'slave_no' => '', + // 是否严格检查字段是否存在 + 'fields_strict' => true, + // 数据集返回类型 + 'resultset_type' => 'array', + // 自动写入时间戳字段 + 'auto_timestamp' => false, + // 时间字段取出后的默认时间格式 + 'datetime_format' => 'Y-m-d H:i:s', + // 是否需要进行SQL性能分析 + 'sql_explain' => false, + ], + + //分页配置 + 'paginate' => [ + 'type' => 'bootstrap', + 'var_page' => 'page', + 'list_rows' => 15, + ], + + //控制台配置 + 'console' => [ + 'name' => 'Think Console', + 'version' => '0.1', + 'user' => null, + ], + +]; diff --git a/thinkphp/helper.php b/thinkphp/helper.php new file mode 100644 index 0000000..12683cf --- /dev/null +++ b/thinkphp/helper.php @@ -0,0 +1,589 @@ + +// +---------------------------------------------------------------------- + +//------------------------ +// ThinkPHP 助手函数 +//------------------------- + +use think\Cache; +use think\Config; +use think\Cookie; +use think\Db; +use think\Debug; +use think\exception\HttpException; +use think\exception\HttpResponseException; +use think\Lang; +use think\Loader; +use think\Log; +use think\Model; +use think\Request; +use think\Response; +use think\Session; +use think\Url; +use think\View; + +if (!function_exists('load_trait')) { + /** + * 快速导入Traits PHP5.5以上无需调用 + * @param string $class trait库 + * @param string $ext 类库后缀 + * @return boolean + */ + function load_trait($class, $ext = EXT) + { + return Loader::import($class, TRAIT_PATH, $ext); + } +} + +if (!function_exists('exception')) { + /** + * 抛出异常处理 + * + * @param string $msg 异常消息 + * @param integer $code 异常代码 默认为0 + * @param string $exception 异常类 + * + * @throws Exception + */ + function exception($msg, $code = 0, $exception = '') + { + $e = $exception ?: '\think\Exception'; + throw new $e($msg, $code); + } +} + +if (!function_exists('debug')) { + /** + * 记录时间(微秒)和内存使用情况 + * @param string $start 开始标签 + * @param string $end 结束标签 + * @param integer|string $dec 小数位 如果是m 表示统计内存占用 + * @return mixed + */ + function debug($start, $end = '', $dec = 6) + { + if ('' == $end) { + Debug::remark($start); + } else { + return 'm' == $dec ? Debug::getRangeMem($start, $end) : Debug::getRangeTime($start, $end, $dec); + } + } +} + +if (!function_exists('lang')) { + /** + * 获取语言变量值 + * @param string $name 语言变量名 + * @param array $vars 动态变量值 + * @param string $lang 语言 + * @return mixed + */ + function lang($name, $vars = [], $lang = '') + { + return Lang::get($name, $vars, $lang); + } +} + +if (!function_exists('config')) { + /** + * 获取和设置配置参数 + * @param string|array $name 参数名 + * @param mixed $value 参数值 + * @param string $range 作用域 + * @return mixed + */ + function config($name = '', $value = null, $range = '') + { + if (is_null($value) && is_string($name)) { + return 0 === strpos($name, '?') ? Config::has(substr($name, 1), $range) : Config::get($name, $range); + } else { + return Config::set($name, $value, $range); + } + } +} + +if (!function_exists('input')) { + /** + * 获取输入数据 支持默认值和过滤 + * @param string $key 获取的变量名 + * @param mixed $default 默认值 + * @param string $filter 过滤方法 + * @return mixed + */ + function input($key = '', $default = null, $filter = '') + { + if (0 === strpos($key, '?')) { + $key = substr($key, 1); + $has = true; + } + if ($pos = strpos($key, '.')) { + // 指定参数来源 + list($method, $key) = explode('.', $key, 2); + if (!in_array($method, ['get', 'post', 'put', 'patch', 'delete', 'route', 'param', 'request', 'session', 'cookie', 'server', 'env', 'path', 'file'])) { + $key = $method . '.' . $key; + $method = 'param'; + } + } else { + // 默认为自动判断 + $method = 'param'; + } + if (isset($has)) { + return request()->has($key, $method, $default); + } else { + return request()->$method($key, $default, $filter); + } + } +} + +if (!function_exists('widget')) { + /** + * 渲染输出Widget + * @param string $name Widget名称 + * @param array $data 传入的参数 + * @return mixed + */ + function widget($name, $data = []) + { + return Loader::action($name, $data, 'widget'); + } +} + +if (!function_exists('model')) { + /** + * 实例化Model + * @param string $name Model名称 + * @param string $layer 业务层名称 + * @param bool $appendSuffix 是否添加类名后缀 + * @return \think\Model + */ + function model($name = '', $layer = 'model', $appendSuffix = false) + { + return Loader::model($name, $layer, $appendSuffix); + } +} + +if (!function_exists('validate')) { + /** + * 实例化验证器 + * @param string $name 验证器名称 + * @param string $layer 业务层名称 + * @param bool $appendSuffix 是否添加类名后缀 + * @return \think\Validate + */ + function validate($name = '', $layer = 'validate', $appendSuffix = false) + { + return Loader::validate($name, $layer, $appendSuffix); + } +} + +if (!function_exists('db')) { + /** + * 实例化数据库类 + * @param string $name 操作的数据表名称(不含前缀) + * @param array|string $config 数据库配置参数 + * @param bool $force 是否强制重新连接 + * @return \think\db\Query + */ + function db($name = '', $config = [], $force = false) + { + return Db::connect($config, $force)->name($name); + } +} + +if (!function_exists('controller')) { + /** + * 实例化控制器 格式:[模块/]控制器 + * @param string $name 资源地址 + * @param string $layer 控制层名称 + * @param bool $appendSuffix 是否添加类名后缀 + * @return \think\Controller + */ + function controller($name, $layer = 'controller', $appendSuffix = false) + { + return Loader::controller($name, $layer, $appendSuffix); + } +} + +if (!function_exists('action')) { + /** + * 调用模块的操作方法 参数格式 [模块/控制器/]操作 + * @param string $url 调用地址 + * @param string|array $vars 调用参数 支持字符串和数组 + * @param string $layer 要调用的控制层名称 + * @param bool $appendSuffix 是否添加类名后缀 + * @return mixed + */ + function action($url, $vars = [], $layer = 'controller', $appendSuffix = false) + { + return Loader::action($url, $vars, $layer, $appendSuffix); + } +} + +if (!function_exists('import')) { + /** + * 导入所需的类库 同java的Import 本函数有缓存功能 + * @param string $class 类库命名空间字符串 + * @param string $baseUrl 起始路径 + * @param string $ext 导入的文件扩展名 + * @return boolean + */ + function import($class, $baseUrl = '', $ext = EXT) + { + return Loader::import($class, $baseUrl, $ext); + } +} + +if (!function_exists('vendor')) { + /** + * 快速导入第三方框架类库 所有第三方框架的类库文件统一放到 系统的Vendor目录下面 + * @param string $class 类库 + * @param string $ext 类库后缀 + * @return boolean + */ + function vendor($class, $ext = EXT) + { + return Loader::import($class, VENDOR_PATH, $ext); + } +} + +if (!function_exists('dump')) { + /** + * 浏览器友好的变量输出 + * @param mixed $var 变量 + * @param boolean $echo 是否输出 默认为true 如果为false 则返回输出字符串 + * @param string $label 标签 默认为空 + * @return void|string + */ + function dump($var, $echo = true, $label = null) + { + return Debug::dump($var, $echo, $label); + } +} + +if (!function_exists('url')) { + /** + * Url生成 + * @param string $url 路由地址 + * @param string|array $vars 变量 + * @param bool|string $suffix 生成的URL后缀 + * @param bool|string $domain 域名 + * @return string + */ + function url($url = '', $vars = '', $suffix = true, $domain = false) + { + return Url::build($url, $vars, $suffix, $domain); + } +} + +if (!function_exists('session')) { + /** + * Session管理 + * @param string|array $name session名称,如果为数组表示进行session设置 + * @param mixed $value session值 + * @param string $prefix 前缀 + * @return mixed + */ + function session($name, $value = '', $prefix = null) + { + if (is_array($name)) { + // 初始化 + Session::init($name); + } elseif (is_null($name)) { + // 清除 + Session::clear('' === $value ? null : $value); + } elseif ('' === $value) { + // 判断或获取 + return 0 === strpos($name, '?') ? Session::has(substr($name, 1), $prefix) : Session::get($name, $prefix); + } elseif (is_null($value)) { + // 删除 + return Session::delete($name, $prefix); + } else { + // 设置 + return Session::set($name, $value, $prefix); + } + } +} + +if (!function_exists('cookie')) { + /** + * Cookie管理 + * @param string|array $name cookie名称,如果为数组表示进行cookie设置 + * @param mixed $value cookie值 + * @param mixed $option 参数 + * @return mixed + */ + function cookie($name, $value = '', $option = null) + { + if (is_array($name)) { + // 初始化 + Cookie::init($name); + } elseif (is_null($name)) { + // 清除 + Cookie::clear($value); + } elseif ('' === $value) { + // 获取 + return 0 === strpos($name, '?') ? Cookie::has(substr($name, 1), $option) : Cookie::get($name, $option); + } elseif (is_null($value)) { + // 删除 + return Cookie::delete($name); + } else { + // 设置 + return Cookie::set($name, $value, $option); + } + } +} + +if (!function_exists('cache')) { + /** + * 缓存管理 + * @param mixed $name 缓存名称,如果为数组表示进行缓存设置 + * @param mixed $value 缓存值 + * @param mixed $options 缓存参数 + * @param string $tag 缓存标签 + * @return mixed + */ + function cache($name, $value = '', $options = null, $tag = null) + { + if (is_array($options)) { + // 缓存操作的同时初始化 + $cache = Cache::connect($options); + } elseif (is_array($name)) { + // 缓存初始化 + return Cache::connect($name); + } else { + $cache = Cache::init(); + } + + if (is_null($name)) { + return $cache->clear($value); + } elseif ('' === $value) { + // 获取缓存 + return 0 === strpos($name, '?') ? $cache->has(substr($name, 1)) : $cache->get($name); + } elseif (is_null($value)) { + // 删除缓存 + return $cache->rm($name); + } elseif (0 === strpos($name, '?') && '' !== $value) { + $expire = is_numeric($options) ? $options : null; + return $cache->remember(substr($name, 1), $value, $expire); + } else { + // 缓存数据 + if (is_array($options)) { + $expire = isset($options['expire']) ? $options['expire'] : null; //修复查询缓存无法设置过期时间 + } else { + $expire = is_numeric($options) ? $options : null; //默认快捷缓存设置过期时间 + } + if (is_null($tag)) { + return $cache->set($name, $value, $expire); + } else { + return $cache->tag($tag)->set($name, $value, $expire); + } + } + } +} + +if (!function_exists('trace')) { + /** + * 记录日志信息 + * @param mixed $log log信息 支持字符串和数组 + * @param string $level 日志级别 + * @return void|array + */ + function trace($log = '[think]', $level = 'log') + { + if ('[think]' === $log) { + return Log::getLog(); + } else { + Log::record($log, $level); + } + } +} + +if (!function_exists('request')) { + /** + * 获取当前Request对象实例 + * @return Request + */ + function request() + { + return Request::instance(); + } +} + +if (!function_exists('response')) { + /** + * 创建普通 Response 对象实例 + * @param mixed $data 输出数据 + * @param int|string $code 状态码 + * @param array $header 头信息 + * @param string $type + * @return Response + */ + function response($data = [], $code = 200, $header = [], $type = 'html') + { + return Response::create($data, $type, $code, $header); + } +} + +if (!function_exists('view')) { + /** + * 渲染模板输出 + * @param string $template 模板文件 + * @param array $vars 模板变量 + * @param array $replace 模板替换 + * @param integer $code 状态码 + * @return \think\response\View + */ + function view($template = '', $vars = [], $replace = [], $code = 200) + { + return Response::create($template, 'view', $code)->replace($replace)->assign($vars); + } +} + +if (!function_exists('json')) { + /** + * 获取\think\response\Json对象实例 + * @param mixed $data 返回的数据 + * @param integer $code 状态码 + * @param array $header 头部 + * @param array $options 参数 + * @return \think\response\Json + */ + function json($data = [], $code = 200, $header = [], $options = []) + { + return Response::create($data, 'json', $code, $header, $options); + } +} + +if (!function_exists('jsonp')) { + /** + * 获取\think\response\Jsonp对象实例 + * @param mixed $data 返回的数据 + * @param integer $code 状态码 + * @param array $header 头部 + * @param array $options 参数 + * @return \think\response\Jsonp + */ + function jsonp($data = [], $code = 200, $header = [], $options = []) + { + return Response::create($data, 'jsonp', $code, $header, $options); + } +} + +if (!function_exists('xml')) { + /** + * 获取\think\response\Xml对象实例 + * @param mixed $data 返回的数据 + * @param integer $code 状态码 + * @param array $header 头部 + * @param array $options 参数 + * @return \think\response\Xml + */ + function xml($data = [], $code = 200, $header = [], $options = []) + { + return Response::create($data, 'xml', $code, $header, $options); + } +} + +if (!function_exists('redirect')) { + /** + * 获取\think\response\Redirect对象实例 + * @param mixed $url 重定向地址 支持Url::build方法的地址 + * @param array|integer $params 额外参数 + * @param integer $code 状态码 + * @param array $with 隐式传参 + * @return \think\response\Redirect + */ + function redirect($url = [], $params = [], $code = 302, $with = []) + { + if (is_integer($params)) { + $code = $params; + $params = []; + } + return Response::create($url, 'redirect', $code)->params($params)->with($with); + } +} + +if (!function_exists('abort')) { + /** + * 抛出HTTP异常 + * @param integer|Response $code 状态码 或者 Response对象实例 + * @param string $message 错误信息 + * @param array $header 参数 + */ + function abort($code, $message = null, $header = []) + { + if ($code instanceof Response) { + throw new HttpResponseException($code); + } else { + throw new HttpException($code, $message, null, $header); + } + } +} + +if (!function_exists('halt')) { + /** + * 调试变量并且中断输出 + * @param mixed $var 调试变量或者信息 + */ + function halt($var) + { + dump($var); + throw new HttpResponseException(new Response); + } +} + +if (!function_exists('token')) { + /** + * 生成表单令牌 + * @param string $name 令牌名称 + * @param mixed $type 令牌生成方法 + * @return string + */ + function token($name = '__token__', $type = 'md5') + { + $token = Request::instance()->token($name, $type); + return ''; + } +} + +if (!function_exists('load_relation')) { + /** + * 延迟预载入关联查询 + * @param mixed $resultSet 数据集 + * @param mixed $relation 关联 + * @return array + */ + function load_relation($resultSet, $relation) + { + $item = current($resultSet); + if ($item instanceof Model) { + $item->eagerlyResultSet($resultSet, $relation); + } + return $resultSet; + } +} + +if (!function_exists('collection')) { + /** + * 数组转换为数据集对象 + * @param array $resultSet 数据集数组 + * @return \think\model\Collection|\think\Collection + */ + function collection($resultSet) + { + $item = current($resultSet); + if ($item instanceof Model) { + return \think\model\Collection::make($resultSet); + } else { + return \think\Collection::make($resultSet); + } + } +} diff --git a/thinkphp/lang/zh-cn.php b/thinkphp/lang/zh-cn.php new file mode 100644 index 0000000..eb7a914 --- /dev/null +++ b/thinkphp/lang/zh-cn.php @@ -0,0 +1,136 @@ + +// +---------------------------------------------------------------------- + +// 核心中文语言包 +return [ + // 系统错误提示 + 'Undefined variable' => '未定义变量', + 'Undefined index' => '未定义数组索引', + 'Undefined offset' => '未定义数组下标', + 'Parse error' => '语法解析错误', + 'Type error' => '类型错误', + 'Fatal error' => '致命错误', + 'syntax error' => '语法错误', + + // 框架核心错误提示 + 'dispatch type not support' => '不支持的调度类型', + 'method param miss' => '方法参数错误', + 'method not exists' => '方法不存在', + 'module not exists' => '模块不存在', + 'controller not exists' => '控制器不存在', + 'class not exists' => '类不存在', + 'property not exists' => '类的属性不存在', + 'template not exists' => '模板文件不存在', + 'illegal controller name' => '非法的控制器名称', + 'illegal action name' => '非法的操作名称', + 'url suffix deny' => '禁止的URL后缀访问', + 'Route Not Found' => '当前访问路由未定义', + 'Undefined db type' => '未定义数据库类型', + 'variable type error' => '变量类型错误', + 'PSR-4 error' => 'PSR-4 规范错误', + 'not support total' => '简洁模式下不能获取数据总数', + 'not support last' => '简洁模式下不能获取最后一页', + 'error session handler' => '错误的SESSION处理器类', + 'not allow php tag' => '模板不允许使用PHP语法', + 'not support' => '不支持', + 'redisd master' => 'Redisd 主服务器错误', + 'redisd slave' => 'Redisd 从服务器错误', + 'must run at sae' => '必须在SAE运行', + 'memcache init error' => '未开通Memcache服务,请在SAE管理平台初始化Memcache服务', + 'KVDB init error' => '没有初始化KVDB,请在SAE管理平台初始化KVDB服务', + 'fields not exists' => '数据表字段不存在', + 'where express error' => '查询表达式错误', + 'not support data' => '不支持的数据表达式', + 'no data to update' => '没有任何数据需要更新', + 'miss data to insert' => '缺少需要写入的数据', + 'miss complex primary data' => '缺少复合主键数据', + 'miss update condition' => '缺少更新条件', + 'model data Not Found' => '模型数据不存在', + 'table data not Found' => '表数据不存在', + 'delete without condition' => '没有条件不会执行删除操作', + 'miss relation data' => '缺少关联表数据', + 'tag attr must' => '模板标签属性必须', + 'tag error' => '模板标签错误', + 'cache write error' => '缓存写入失败', + 'sae mc write error' => 'SAE mc 写入错误', + 'route name not exists' => '路由标识不存在(或参数不够)', + 'invalid request' => '非法请求', + 'bind attr has exists' => '模型的属性已经存在', + 'relation data not exists' => '关联数据不存在', + 'relation not support' => '关联不支持', + 'chunk not support order' => 'Chunk不支持调用order方法', + 'closure not support cache(true)' => '使用闭包查询不支持cache(true),请指定缓存Key', + + // 上传错误信息 + 'unknown upload error' => '未知上传错误!', + 'file write error' => '文件写入失败!', + 'upload temp dir not found' => '找不到临时文件夹!', + 'no file to uploaded' => '没有文件被上传!', + 'only the portion of file is uploaded' => '文件只有部分被上传!', + 'upload File size exceeds the maximum value' => '上传文件大小超过了最大值!', + 'upload write error' => '文件上传保存错误!', + 'has the same filename: {:filename}' => '存在同名文件:{:filename}', + 'upload illegal files' => '非法上传文件', + 'illegal image files' => '非法图片文件', + 'extensions to upload is not allowed' => '上传文件后缀不允许', + 'mimetype to upload is not allowed' => '上传文件MIME类型不允许!', + 'filesize not match' => '上传文件大小不符!', + 'directory {:path} creation failed' => '目录 {:path} 创建失败!', + + // Validate Error Message + ':attribute require' => ':attribute不能为空', + ':attribute must be numeric' => ':attribute必须是数字', + ':attribute must be integer' => ':attribute必须是整数', + ':attribute must be float' => ':attribute必须是浮点数', + ':attribute must be bool' => ':attribute必须是布尔值', + ':attribute not a valid email address' => ':attribute格式不符', + ':attribute not a valid mobile' => ':attribute格式不符', + ':attribute must be a array' => ':attribute必须是数组', + ':attribute must be yes,on or 1' => ':attribute必须是yes、on或者1', + ':attribute not a valid datetime' => ':attribute不是一个有效的日期或时间格式', + ':attribute not a valid file' => ':attribute不是有效的上传文件', + ':attribute not a valid image' => ':attribute不是有效的图像文件', + ':attribute must be alpha' => ':attribute只能是字母', + ':attribute must be alpha-numeric' => ':attribute只能是字母和数字', + ':attribute must be alpha-numeric, dash, underscore' => ':attribute只能是字母、数字和下划线_及破折号-', + ':attribute not a valid domain or ip' => ':attribute不是有效的域名或者IP', + ':attribute must be chinese' => ':attribute只能是汉字', + ':attribute must be chinese or alpha' => ':attribute只能是汉字、字母', + ':attribute must be chinese,alpha-numeric' => ':attribute只能是汉字、字母和数字', + ':attribute must be chinese,alpha-numeric,underscore, dash' => ':attribute只能是汉字、字母、数字和下划线_及破折号-', + ':attribute not a valid url' => ':attribute不是有效的URL地址', + ':attribute not a valid ip' => ':attribute不是有效的IP地址', + ':attribute must be dateFormat of :rule' => ':attribute必须使用日期格式 :rule', + ':attribute must be in :rule' => ':attribute必须在 :rule 范围内', + ':attribute be notin :rule' => ':attribute不能在 :rule 范围内', + ':attribute must between :1 - :2' => ':attribute只能在 :1 - :2 之间', + ':attribute not between :1 - :2' => ':attribute不能在 :1 - :2 之间', + 'size of :attribute must be :rule' => ':attribute长度不符合要求 :rule', + 'max size of :attribute must be :rule' => ':attribute长度不能超过 :rule', + 'min size of :attribute must be :rule' => ':attribute长度不能小于 :rule', + ':attribute cannot be less than :rule' => ':attribute日期不能小于 :rule', + ':attribute cannot exceed :rule' => ':attribute日期不能超过 :rule', + ':attribute not within :rule' => '不在有效期内 :rule', + 'access IP is not allowed' => '不允许的IP访问', + 'access IP denied' => '禁止的IP访问', + ':attribute out of accord with :2' => ':attribute和确认字段:2不一致', + ':attribute cannot be same with :2' => ':attribute和比较字段:2不能相同', + ':attribute must greater than or equal :rule' => ':attribute必须大于等于 :rule', + ':attribute must greater than :rule' => ':attribute必须大于 :rule', + ':attribute must less than or equal :rule' => ':attribute必须小于等于 :rule', + ':attribute must less than :rule' => ':attribute必须小于 :rule', + ':attribute must equal :rule' => ':attribute必须等于 :rule', + ':attribute has exists' => ':attribute已存在', + ':attribute not conform to the rules' => ':attribute不符合指定规则', + 'invalid Request method' => '无效的请求类型', + 'invalid token' => '令牌数据无效', + 'not conform to the rules' => '规则错误', +]; diff --git a/thinkphp/library/think/App.php b/thinkphp/library/think/App.php new file mode 100644 index 0000000..a1b1f28 --- /dev/null +++ b/thinkphp/library/think/App.php @@ -0,0 +1,677 @@ + +// +---------------------------------------------------------------------- + +namespace think; + +use think\exception\ClassNotFoundException; +use think\exception\HttpException; +use think\exception\HttpResponseException; +use think\exception\RouteNotFoundException; + +/** + * App 应用管理 + * @author liu21st + */ +class App +{ + /** + * @var bool 是否初始化过 + */ + protected static $init = false; + + /** + * @var string 当前模块路径 + */ + public static $modulePath; + + /** + * @var bool 应用调试模式 + */ + public static $debug = true; + + /** + * @var string 应用类库命名空间 + */ + public static $namespace = 'app'; + + /** + * @var bool 应用类库后缀 + */ + public static $suffix = false; + + /** + * @var bool 应用路由检测 + */ + protected static $routeCheck; + + /** + * @var bool 严格路由检测 + */ + protected static $routeMust; + + /** + * @var array 请求调度分发 + */ + protected static $dispatch; + + /** + * @var array 额外加载文件 + */ + protected static $file = []; + + /** + * 执行应用程序 + * @access public + * @param Request $request 请求对象 + * @return Response + * @throws Exception + */ + public static function run(Request $request = null) + { + $request = is_null($request) ? Request::instance() : $request; + + try { + $config = self::initCommon(); + + // 模块/控制器绑定 + if (defined('BIND_MODULE')) { + BIND_MODULE && Route::bind(BIND_MODULE); + } elseif ($config['auto_bind_module']) { + // 入口自动绑定 + $name = pathinfo($request->baseFile(), PATHINFO_FILENAME); + if ($name && 'index' != $name && is_dir(APP_PATH . $name)) { + Route::bind($name); + } + } + + $request->filter($config['default_filter']); + + // 默认语言 + Lang::range($config['default_lang']); + // 开启多语言机制 检测当前语言 + $config['lang_switch_on'] && Lang::detect(); + $request->langset(Lang::range()); + + // 加载系统语言包 + Lang::load([ + THINK_PATH . 'lang' . DS . $request->langset() . EXT, + APP_PATH . 'lang' . DS . $request->langset() . EXT, + ]); + + // 监听 app_dispatch + Hook::listen('app_dispatch', self::$dispatch); + // 获取应用调度信息 + $dispatch = self::$dispatch; + + // 未设置调度信息则进行 URL 路由检测 + if (empty($dispatch)) { + $dispatch = self::routeCheck($request, $config); + } + + // 记录当前调度信息 + $request->dispatch($dispatch); + + // 记录路由和请求信息 + if (self::$debug) { + Log::record('[ ROUTE ] ' . var_export($dispatch, true), 'info'); + Log::record('[ HEADER ] ' . var_export($request->header(), true), 'info'); + Log::record('[ PARAM ] ' . var_export($request->param(), true), 'info'); + } + + // 监听 app_begin + Hook::listen('app_begin', $dispatch); + + // 请求缓存检查 + $request->cache( + $config['request_cache'], + $config['request_cache_expire'], + $config['request_cache_except'] + ); + + $data = self::exec($dispatch, $config); + } catch (HttpResponseException $exception) { + $data = $exception->getResponse(); + } + + // 清空类的实例化 + Loader::clearInstance(); + + // 输出数据到客户端 + if ($data instanceof Response) { + $response = $data; + } elseif (!is_null($data)) { + // 默认自动识别响应输出类型 + $type = $request->isAjax() ? + Config::get('default_ajax_return') : + Config::get('default_return_type'); + + $response = Response::create($data, $type); + } else { + $response = Response::create(); + } + + // 监听 app_end + Hook::listen('app_end', $response); + + return $response; + } + + /** + * 初始化应用,并返回配置信息 + * @access public + * @return array + */ + public static function initCommon() + { + if (empty(self::$init)) { + if (defined('APP_NAMESPACE')) { + self::$namespace = APP_NAMESPACE; + } + + Loader::addNamespace(self::$namespace, APP_PATH); + + // 初始化应用 + $config = self::init(); + self::$suffix = $config['class_suffix']; + + // 应用调试模式 + self::$debug = Env::get('app_debug', Config::get('app_debug')); + + if (!self::$debug) { + ini_set('display_errors', 'Off'); + } elseif (!IS_CLI) { + // 重新申请一块比较大的 buffer + if (ob_get_level() > 0) { + $output = ob_get_clean(); + } + + ob_start(); + + if (!empty($output)) { + echo $output; + } + + } + + if (!empty($config['root_namespace'])) { + Loader::addNamespace($config['root_namespace']); + } + + // 加载额外文件 + if (!empty($config['extra_file_list'])) { + foreach ($config['extra_file_list'] as $file) { + $file = strpos($file, '.') ? $file : APP_PATH . $file . EXT; + if (is_file($file) && !isset(self::$file[$file])) { + include $file; + self::$file[$file] = true; + } + } + } + + // 设置系统时区 + date_default_timezone_set($config['default_timezone']); + + // 监听 app_init + Hook::listen('app_init'); + + self::$init = true; + } + + return Config::get(); + } + + /** + * 初始化应用或模块 + * @access public + * @param string $module 模块名 + * @return array + */ + private static function init($module = '') + { + // 定位模块目录 + $module = $module ? $module . DS : ''; + + // 加载初始化文件 + if (is_file(APP_PATH . $module . 'init' . EXT)) { + include APP_PATH . $module . 'init' . EXT; + } elseif (is_file(RUNTIME_PATH . $module . 'init' . EXT)) { + include RUNTIME_PATH . $module . 'init' . EXT; + } else { + // 加载模块配置 + $config = Config::load(CONF_PATH . $module . 'config' . CONF_EXT); + + // 读取数据库配置文件 + $filename = CONF_PATH . $module . 'database' . CONF_EXT; + Config::load($filename, 'database'); + + // 读取扩展配置文件 + if (is_dir(CONF_PATH . $module . 'extra')) { + $dir = CONF_PATH . $module . 'extra'; + $files = scandir($dir); + foreach ($files as $file) { + if ('.' . pathinfo($file, PATHINFO_EXTENSION) === CONF_EXT) { + $filename = $dir . DS . $file; + Config::load($filename, pathinfo($file, PATHINFO_FILENAME)); + } + } + } + + // 加载应用状态配置 + if ($config['app_status']) { + Config::load(CONF_PATH . $module . $config['app_status'] . CONF_EXT); + } + + // 加载行为扩展文件 + if (is_file(CONF_PATH . $module . 'tags' . EXT)) { + Hook::import(include CONF_PATH . $module . 'tags' . EXT); + } + + // 加载公共文件 + $path = APP_PATH . $module; + if (is_file($path . 'common' . EXT)) { + include $path . 'common' . EXT; + } + + // 加载当前模块语言包 + if ($module) { + Lang::load($path . 'lang' . DS . Request::instance()->langset() . EXT); + } + } + + return Config::get(); + } + + /** + * 设置当前请求的调度信息 + * @access public + * @param array|string $dispatch 调度信息 + * @param string $type 调度类型 + * @return void + */ + public static function dispatch($dispatch, $type = 'module') + { + self::$dispatch = ['type' => $type, $type => $dispatch]; + } + + /** + * 执行函数或者闭包方法 支持参数调用 + * @access public + * @param string|array|\Closure $function 函数或者闭包 + * @param array $vars 变量 + * @return mixed + */ + public static function invokeFunction($function, $vars = []) + { + $reflect = new \ReflectionFunction($function); + $args = self::bindParams($reflect, $vars); + + // 记录执行信息 + self::$debug && Log::record('[ RUN ] ' . $reflect->__toString(), 'info'); + + return $reflect->invokeArgs($args); + } + + /** + * 调用反射执行类的方法 支持参数绑定 + * @access public + * @param string|array $method 方法 + * @param array $vars 变量 + * @return mixed + */ + public static function invokeMethod($method, $vars = []) + { + if (is_array($method)) { + $class = is_object($method[0]) ? $method[0] : self::invokeClass($method[0]); + $reflect = new \ReflectionMethod($class, $method[1]); + } else { + // 静态方法 + $reflect = new \ReflectionMethod($method); + } + + $args = self::bindParams($reflect, $vars); + + self::$debug && Log::record('[ RUN ] ' . $reflect->class . '->' . $reflect->name . '[ ' . $reflect->getFileName() . ' ]', 'info'); + + return $reflect->invokeArgs(isset($class) ? $class : null, $args); + } + + /** + * 调用反射执行类的实例化 支持依赖注入 + * @access public + * @param string $class 类名 + * @param array $vars 变量 + * @return mixed + */ + public static function invokeClass($class, $vars = []) + { + $reflect = new \ReflectionClass($class); + $constructor = $reflect->getConstructor(); + $args = $constructor ? self::bindParams($constructor, $vars) : []; + + return $reflect->newInstanceArgs($args); + } + + /** + * 绑定参数 + * @access private + * @param \ReflectionMethod|\ReflectionFunction $reflect 反射类 + * @param array $vars 变量 + * @return array + */ + private static function bindParams($reflect, $vars = []) + { + // 自动获取请求变量 + if (empty($vars)) { + $vars = Config::get('url_param_type') ? + Request::instance()->route() : + Request::instance()->param(); + } + + $args = []; + if ($reflect->getNumberOfParameters() > 0) { + // 判断数组类型 数字数组时按顺序绑定参数 + reset($vars); + $type = key($vars) === 0 ? 1 : 0; + + foreach ($reflect->getParameters() as $param) { + $args[] = self::getParamValue($param, $vars, $type); + } + } + + return $args; + } + + /** + * 获取参数值 + * @access private + * @param \ReflectionParameter $param 参数 + * @param array $vars 变量 + * @param string $type 类别 + * @return array + */ + private static function getParamValue($param, &$vars, $type) + { + $name = $param->getName(); + $reflectionType = $param->getType(); + + if ($reflectionType && $reflectionType->isBuiltin() === false) { + $className = $reflectionType->getName(); + $bind = Request::instance()->$name; + + if ($bind instanceof $className) { + $result = $bind; + } else { + if (method_exists($className, 'invoke')) { + $method = new \ReflectionMethod($className, 'invoke'); + + if ($method->isPublic() && $method->isStatic()) { + return $className::invoke(Request::instance()); + } + } + + $result = method_exists($className, 'instance') ? + $className::instance() : + new $className; + } + } elseif (1 == $type && !empty($vars)) { + $result = array_shift($vars); + } elseif (0 == $type && isset($vars[$name])) { + $result = $vars[$name]; + } elseif ($param->isDefaultValueAvailable()) { + $result = $param->getDefaultValue(); + } else { + throw new \InvalidArgumentException('method param miss:' . $name); + } + + return $result; + } + + /** + * 执行调用分发 + * @access protected + * @param array $dispatch 调用信息 + * @param array $config 配置信息 + * @return Response|mixed + * @throws \InvalidArgumentException + */ + protected static function exec($dispatch, $config) + { + switch ($dispatch['type']) { + case 'redirect': // 重定向跳转 + $data = Response::create($dispatch['url'], 'redirect') + ->code($dispatch['status']); + break; + case 'module': // 模块/控制器/操作 + $data = self::module( + $dispatch['module'], + $config, + isset($dispatch['convert']) ? $dispatch['convert'] : null + ); + break; + case 'controller': // 执行控制器操作 + $vars = array_merge(Request::instance()->param(), $dispatch['var']); + $data = Loader::action( + $dispatch['controller'], + $vars, + $config['url_controller_layer'], + $config['controller_suffix'] + ); + break; + case 'method': // 回调方法 + $vars = array_merge(Request::instance()->param(), $dispatch['var']); + $data = self::invokeMethod($dispatch['method'], $vars); + break; + case 'function': // 闭包 + $data = self::invokeFunction($dispatch['function']); + break; + case 'response': // Response 实例 + $data = $dispatch['response']; + break; + default: + throw new \InvalidArgumentException('dispatch type not support'); + } + + return $data; + } + + /** + * 执行模块 + * @access public + * @param array $result 模块/控制器/操作 + * @param array $config 配置参数 + * @param bool $convert 是否自动转换控制器和操作名 + * @return mixed + * @throws HttpException + */ + public static function module($result, $config, $convert = null) + { + if (is_string($result)) { + $result = explode('/', $result); + } + + $request = Request::instance(); + + if ($config['app_multi_module']) { + // 多模块部署 + $module = strip_tags(strtolower($result[0] ?: $config['default_module'])); + $bind = Route::getBind('module'); + $available = false; + + if ($bind) { + // 绑定模块 + list($bindModule) = explode('/', $bind); + + if (empty($result[0])) { + $module = $bindModule; + $available = true; + } elseif ($module == $bindModule) { + $available = true; + } + } elseif (!in_array($module, $config['deny_module_list']) && is_dir(APP_PATH . $module)) { + $available = true; + } + + // 模块初始化 + if ($module && $available) { + // 初始化模块 + $request->module($module); + $config = self::init($module); + + // 模块请求缓存检查 + $request->cache( + $config['request_cache'], + $config['request_cache_expire'], + $config['request_cache_except'] + ); + } else { + throw new HttpException(404, 'module not exists:' . $module); + } + } else { + // 单一模块部署 + $module = ''; + $request->module($module); + } + + // 设置默认过滤机制 + $request->filter($config['default_filter']); + + // 当前模块路径 + App::$modulePath = APP_PATH . ($module ? $module . DS : ''); + + // 是否自动转换控制器和操作名 + $convert = is_bool($convert) ? $convert : $config['url_convert']; + + // 获取控制器名 + $controller = strip_tags($result[1] ?: $config['default_controller']); + + if (!preg_match('/^[A-Za-z](\w|\.)*$/', $controller)) { + throw new HttpException(404, 'controller not exists:' . $controller); + } + + $controller = $convert ? strtolower($controller) : $controller; + + // 获取操作名 + $actionName = strip_tags($result[2] ?: $config['default_action']); + if (!empty($config['action_convert'])) { + $actionName = Loader::parseName($actionName, 1); + } else { + $actionName = $convert ? strtolower($actionName) : $actionName; + } + + // 设置当前请求的控制器、操作 + $request->controller(Loader::parseName($controller, 1))->action($actionName); + + // 监听module_init + Hook::listen('module_init', $request); + + try { + $instance = Loader::controller( + $controller, + $config['url_controller_layer'], + $config['controller_suffix'], + $config['empty_controller'] + ); + } catch (ClassNotFoundException $e) { + throw new HttpException(404, 'controller not exists:' . $e->getClass()); + } + + // 获取当前操作名 + $action = $actionName . $config['action_suffix']; + + $vars = []; + if (is_callable([$instance, $action])) { + // 执行操作方法 + $call = [$instance, $action]; + // 严格获取当前操作方法名 + $reflect = new \ReflectionMethod($instance, $action); + $methodName = $reflect->getName(); + $suffix = $config['action_suffix']; + $actionName = $suffix ? substr($methodName, 0, -strlen($suffix)) : $methodName; + $request->action($actionName); + + } elseif (is_callable([$instance, '_empty'])) { + // 空操作 + $call = [$instance, '_empty']; + $vars = [$actionName]; + } else { + // 操作不存在 + throw new HttpException(404, 'method not exists:' . get_class($instance) . '->' . $action . '()'); + } + + Hook::listen('action_begin', $call); + + return self::invokeMethod($call, $vars); + } + + /** + * URL路由检测(根据PATH_INFO) + * @access public + * @param \think\Request $request 请求实例 + * @param array $config 配置信息 + * @return array + * @throws \think\Exception + */ + public static function routeCheck($request, array $config) + { + $path = $request->path(); + $depr = $config['pathinfo_depr']; + $result = false; + + // 路由检测 + $check = !is_null(self::$routeCheck) ? self::$routeCheck : $config['url_route_on']; + if ($check) { + // 开启路由 + if (is_file(RUNTIME_PATH . 'route.php')) { + // 读取路由缓存 + $rules = include RUNTIME_PATH . 'route.php'; + is_array($rules) && Route::rules($rules); + } else { + $files = $config['route_config_file']; + foreach ($files as $file) { + if (is_file(CONF_PATH . $file . CONF_EXT)) { + // 导入路由配置 + $rules = include CONF_PATH . $file . CONF_EXT; + is_array($rules) && Route::import($rules); + } + } + } + + // 路由检测(根据路由定义返回不同的URL调度) + $result = Route::check($request, $path, $depr, $config['url_domain_deploy']); + $must = !is_null(self::$routeMust) ? self::$routeMust : $config['url_route_must']; + + if ($must && false === $result) { + // 路由无效 + throw new RouteNotFoundException(); + } + } + + // 路由无效 解析模块/控制器/操作/参数... 支持控制器自动搜索 + if (false === $result) { + $result = Route::parseUrl($path, $depr, $config['controller_auto_search']); + } + + return $result; + } + + /** + * 设置应用的路由检测机制 + * @access public + * @param bool $route 是否需要检测路由 + * @param bool $must 是否强制检测路由 + * @return void + */ + public static function route($route, $must = false) + { + self::$routeCheck = $route; + self::$routeMust = $must; + } +} diff --git a/thinkphp/library/think/Build.php b/thinkphp/library/think/Build.php new file mode 100644 index 0000000..de7c327 --- /dev/null +++ b/thinkphp/library/think/Build.php @@ -0,0 +1,235 @@ + +// +---------------------------------------------------------------------- + +namespace think; + +class Build +{ + /** + * 根据传入的 build 资料创建目录和文件 + * @access public + * @param array $build build 列表 + * @param string $namespace 应用类库命名空间 + * @param bool $suffix 类库后缀 + * @return void + * @throws Exception + */ + public static function run(array $build = [], $namespace = 'app', $suffix = false) + { + // 锁定 + $lock = APP_PATH . 'build.lock'; + + // 如果锁定文件不可写(不存在)则进行处理,否则表示已经有程序在处理了 + if (!is_writable($lock)) { + if (!touch($lock)) { + throw new Exception( + '应用目录[' . APP_PATH . ']不可写,目录无法自动生成!
请手动生成项目目录~', + 10006 + ); + } + + foreach ($build as $module => $list) { + if ('__dir__' == $module) { + // 创建目录列表 + self::buildDir($list); + } elseif ('__file__' == $module) { + // 创建文件列表 + self::buildFile($list); + } else { + // 创建模块 + self::module($module, $list, $namespace, $suffix); + } + } + + // 解除锁定 + unlink($lock); + } + } + + /** + * 创建目录 + * @access protected + * @param array $list 目录列表 + * @return void + */ + protected static function buildDir($list) + { + foreach ($list as $dir) { + // 目录不存在则创建目录 + !is_dir(APP_PATH . $dir) && mkdir(APP_PATH . $dir, 0755, true); + } + } + + /** + * 创建文件 + * @access protected + * @param array $list 文件列表 + * @return void + */ + protected static function buildFile($list) + { + foreach ($list as $file) { + // 先创建目录 + if (!is_dir(APP_PATH . dirname($file))) { + mkdir(APP_PATH . dirname($file), 0755, true); + } + + // 再创建文件 + if (!is_file(APP_PATH . $file)) { + file_put_contents( + APP_PATH . $file, + 'php' == pathinfo($file, PATHINFO_EXTENSION) ? " ['config.php', 'common.php'], + '__dir__' => ['controller', 'model', 'view'], + ]; + } + + // 创建子目录和文件 + foreach ($list as $path => $file) { + $modulePath = APP_PATH . $module . DS; + + if ('__dir__' == $path) { + // 生成子目录 + foreach ($file as $dir) { + self::checkDirBuild($modulePath . $dir); + } + } elseif ('__file__' == $path) { + // 生成(空白)文件 + foreach ($file as $name) { + if (!is_file($modulePath . $name)) { + file_put_contents( + $modulePath . $name, + 'php' == pathinfo($name, PATHINFO_EXTENSION) ? " +// +---------------------------------------------------------------------- + +namespace think; + +use think\cache\Driver; + +class Cache +{ + /** + * @var array 缓存的实例 + */ + public static $instance = []; + + /** + * @var int 缓存读取次数 + */ + public static $readTimes = 0; + + /** + * @var int 缓存写入次数 + */ + public static $writeTimes = 0; + + /** + * @var object 操作句柄 + */ + public static $handler; + + /** + * 连接缓存驱动 + * @access public + * @param array $options 配置数组 + * @param bool|string $name 缓存连接标识 true 强制重新连接 + * @return Driver + */ + public static function connect(array $options = [], $name = false) + { + $type = !empty($options['type']) ? $options['type'] : 'File'; + + if (false === $name) { + $name = md5(serialize($options)); + } + + if (true === $name || !isset(self::$instance[$name])) { + $class = false === strpos($type, '\\') ? + '\\think\\cache\\driver\\' . ucwords($type) : + $type; + + // 记录初始化信息 + App::$debug && Log::record('[ CACHE ] INIT ' . $type, 'info'); + + if (true === $name) { + return new $class($options); + } + + self::$instance[$name] = new $class($options); + } + + return self::$instance[$name]; + } + + /** + * 自动初始化缓存 + * @access public + * @param array $options 配置数组 + * @return Driver + */ + public static function init(array $options = []) + { + if (is_null(self::$handler)) { + if (empty($options) && 'complex' == Config::get('cache.type')) { + $default = Config::get('cache.default'); + // 获取默认缓存配置,并连接 + $options = Config::get('cache.' . $default['type']) ?: $default; + } elseif (empty($options)) { + $options = Config::get('cache'); + } + + self::$handler = self::connect($options); + } + + return self::$handler; + } + + /** + * 切换缓存类型 需要配置 cache.type 为 complex + * @access public + * @param string $name 缓存标识 + * @return Driver + */ + public static function store($name = '') + { + if ('' !== $name && 'complex' == Config::get('cache.type')) { + return self::connect(Config::get('cache.' . $name), strtolower($name)); + } + + return self::init(); + } + + /** + * 判断缓存是否存在 + * @access public + * @param string $name 缓存变量名 + * @return bool + */ + public static function has($name) + { + self::$readTimes++; + + return self::init()->has($name); + } + + /** + * 读取缓存 + * @access public + * @param string $name 缓存标识 + * @param mixed $default 默认值 + * @return mixed + */ + public static function get($name, $default = false) + { + self::$readTimes++; + + return self::init()->get($name, $default); + } + + /** + * 写入缓存 + * @access public + * @param string $name 缓存标识 + * @param mixed $value 存储数据 + * @param int|null $expire 有效时间 0为永久 + * @return boolean + */ + public static function set($name, $value, $expire = null) + { + self::$writeTimes++; + + return self::init()->set($name, $value, $expire); + } + + /** + * 自增缓存(针对数值缓存) + * @access public + * @param string $name 缓存变量名 + * @param int $step 步长 + * @return false|int + */ + public static function inc($name, $step = 1) + { + self::$writeTimes++; + + return self::init()->inc($name, $step); + } + + /** + * 自减缓存(针对数值缓存) + * @access public + * @param string $name 缓存变量名 + * @param int $step 步长 + * @return false|int + */ + public static function dec($name, $step = 1) + { + self::$writeTimes++; + + return self::init()->dec($name, $step); + } + + /** + * 删除缓存 + * @access public + * @param string $name 缓存标识 + * @return boolean + */ + public static function rm($name) + { + self::$writeTimes++; + + return self::init()->rm($name); + } + + /** + * 清除缓存 + * @access public + * @param string $tag 标签名 + * @return boolean + */ + public static function clear($tag = null) + { + self::$writeTimes++; + + return self::init()->clear($tag); + } + + /** + * 读取缓存并删除 + * @access public + * @param string $name 缓存变量名 + * @return mixed + */ + public static function pull($name) + { + self::$readTimes++; + self::$writeTimes++; + + return self::init()->pull($name); + } + + /** + * 如果不存在则写入缓存 + * @access public + * @param string $name 缓存变量名 + * @param mixed $value 存储数据 + * @param int $expire 有效时间 0为永久 + * @return mixed + */ + public static function remember($name, $value, $expire = null) + { + self::$readTimes++; + + return self::init()->remember($name, $value, $expire); + } + + /** + * 缓存标签 + * @access public + * @param string $name 标签名 + * @param string|array $keys 缓存标识 + * @param bool $overlay 是否覆盖 + * @return Driver + */ + public static function tag($name, $keys = null, $overlay = false) + { + return self::init()->tag($name, $keys, $overlay); + } + +} diff --git a/thinkphp/library/think/Collection.php b/thinkphp/library/think/Collection.php new file mode 100644 index 0000000..0ff1dfc --- /dev/null +++ b/thinkphp/library/think/Collection.php @@ -0,0 +1,474 @@ + +// +---------------------------------------------------------------------- + +namespace think; + +use ArrayAccess; +use ArrayIterator; +use Countable; +use IteratorAggregate; +use JsonSerializable; + +class Collection implements ArrayAccess, Countable, IteratorAggregate, JsonSerializable +{ + /** + * @var array 数据 + */ + protected $items = []; + + /** + * Collection constructor. + * @access public + * @param array $items 数据 + */ + public function __construct($items = []) + { + $this->items = $this->convertToArray($items); + } + + /** + * 创建 Collection 实例 + * @access public + * @param array $items 数据 + * @return static + */ + public static function make($items = []) + { + return new static($items); + } + + /** + * 判断数据是否为空 + * @access public + * @return bool + */ + public function isEmpty() + { + return empty($this->items); + } + + /** + * 将数据转成数组 + * @access public + * @return array + */ + public function toArray() + { + return array_map(function ($value) { + return ($value instanceof Model || $value instanceof self) ? + $value->toArray() : + $value; + }, $this->items); + } + + /** + * 获取全部的数据 + * @access public + * @return array + */ + public function all() + { + return $this->items; + } + + /** + * 交换数组中的键和值 + * @access public + * @return static + */ + public function flip() + { + return new static(array_flip($this->items)); + } + + /** + * 返回数组中所有的键名组成的新 Collection 实例 + * @access public + * @return static + */ + public function keys() + { + return new static(array_keys($this->items)); + } + + /** + * 返回数组中所有的值组成的新 Collection 实例 + * @access public + * @return static + */ + public function values() + { + return new static(array_values($this->items)); + } + + /** + * 合并数组并返回一个新的 Collection 实例 + * @access public + * @param mixed $items 新的数据 + * @return static + */ + public function merge($items) + { + return new static(array_merge($this->items, $this->convertToArray($items))); + } + + /** + * 比较数组,返回差集生成的新 Collection 实例 + * @access public + * @param mixed $items 做比较的数据 + * @return static + */ + public function diff($items) + { + return new static(array_diff($this->items, $this->convertToArray($items))); + } + + /** + * 比较数组,返回交集组成的 Collection 新实例 + * @access public + * @param mixed $items 比较数据 + * @return static + */ + public function intersect($items) + { + return new static(array_intersect($this->items, $this->convertToArray($items))); + } + + /** + * 返回并删除数据中的的最后一个元素(出栈) + * @access public + * @return mixed + */ + public function pop() + { + return array_pop($this->items); + } + + /** + * 返回并删除数据中首个元素 + * @access public + * @return mixed + */ + public function shift() + { + return array_shift($this->items); + } + + /** + * 在数组开头插入一个元素 + * @access public + * @param mixed $value 值 + * @param mixed $key 键名 + * @return void + */ + public function unshift($value, $key = null) + { + if (is_null($key)) { + array_unshift($this->items, $value); + } else { + $this->items = [$key => $value] + $this->items; + } + } + + /** + * 在数组结尾插入一个元素 + * @access public + * @param mixed $value 值 + * @param mixed $key 键名 + * @return void + */ + public function push($value, $key = null) + { + if (is_null($key)) { + $this->items[] = $value; + } else { + $this->items[$key] = $value; + } + } + + /** + * 通过使用用户自定义函数,以字符串返回数组 + * @access public + * @param callable $callback 回调函数 + * @param mixed $initial 初始值 + * @return mixed + */ + public function reduce(callable $callback, $initial = null) + { + return array_reduce($this->items, $callback, $initial); + } + + /** + * 以相反的顺序创建一个新的 Collection 实例 + * @access public + * @return static + */ + public function reverse() + { + return new static(array_reverse($this->items)); + } + + /** + * 把数据分割为新的数组块 + * @access public + * @param int $size 分隔长度 + * @param bool $preserveKeys 是否保持原数据索引 + * @return static + */ + public function chunk($size, $preserveKeys = false) + { + $chunks = []; + + foreach (array_chunk($this->items, $size, $preserveKeys) as $chunk) { + $chunks[] = new static($chunk); + } + + return new static($chunks); + } + + /** + * 给数据中的每个元素执行回调 + * @access public + * @param callable $callback 回调函数 + * @return $this + */ + public function each(callable $callback) + { + foreach ($this->items as $key => $item) { + $result = $callback($item, $key); + + if (false === $result) { + break; + } + + if (!is_object($item)) { + $this->items[$key] = $result; + } + } + + return $this; + } + + /** + * 用回调函数过滤数据中的元素 + * @access public + * @param callable|null $callback 回调函数 + * @return static + */ + public function filter(callable $callback = null) + { + return new static(array_filter($this->items, $callback ?: null)); + } + + /** + * 返回数据中指定的一列 + * @access public + * @param mixed $columnKey 键名 + * @param null $indexKey 作为索引值的列 + * @return array + */ + public function column($columnKey, $indexKey = null) + { + if (function_exists('array_column')) { + return array_column($this->items, $columnKey, $indexKey); + } + + $result = []; + foreach ($this->items as $row) { + $key = $value = null; + $keySet = $valueSet = false; + + if (null !== $indexKey && array_key_exists($indexKey, $row)) { + $key = (string) $row[$indexKey]; + $keySet = true; + } + + if (null === $columnKey) { + $valueSet = true; + $value = $row; + } elseif (is_array($row) && array_key_exists($columnKey, $row)) { + $valueSet = true; + $value = $row[$columnKey]; + } + + if ($valueSet) { + if ($keySet) { + $result[$key] = $value; + } else { + $result[] = $value; + } + } + } + + return $result; + } + + /** + * 对数据排序,并返回排序后的数据组成的新 Collection 实例 + * @access public + * @param callable|null $callback 回调函数 + * @return static + */ + public function sort(callable $callback = null) + { + $items = $this->items; + $callback = $callback ?: function ($a, $b) { + return $a == $b ? 0 : (($a < $b) ? -1 : 1); + }; + + uasort($items, $callback); + return new static($items); + } + + /** + * 将数据打乱后组成新的 Collection 实例 + * @access public + * @return static + */ + public function shuffle() + { + $items = $this->items; + + shuffle($items); + return new static($items); + } + + /** + * 截取数据并返回新的 Collection 实例 + * @access public + * @param int $offset 起始位置 + * @param int $length 截取长度 + * @param bool $preserveKeys 是否保持原先的键名 + * @return static + */ + public function slice($offset, $length = null, $preserveKeys = false) + { + return new static(array_slice($this->items, $offset, $length, $preserveKeys)); + } + + /** + * 指定的键是否存在 + * @access public + * @param mixed $offset 键名 + * @return bool + */ + #[\ReturnTypeWillChange] + public function offsetExists($offset) + { + return array_key_exists($offset, $this->items); + } + + /** + * 获取指定键对应的值 + * @access public + * @param mixed $offset 键名 + * @return mixed + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->items[$offset]; + } + + /** + * 设置键值 + * @access public + * @param mixed $offset 键名 + * @param mixed $value 值 + * @return void + */ + #[\ReturnTypeWillChange] + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->items[] = $value; + } else { + $this->items[$offset] = $value; + } + } + + /** + * 删除指定键值 + * @access public + * @param mixed $offset 键名 + * @return void + */ + #[\ReturnTypeWillChange] + public function offsetUnset($offset) + { + unset($this->items[$offset]); + } + + /** + * 统计数据的个数 + * @access public + * @return int + */ + #[\ReturnTypeWillChange] + public function count() + { + return count($this->items); + } + + /** + * 获取数据的迭代器 + * @access public + * @return ArrayIterator + */ + #[\ReturnTypeWillChange] + public function getIterator() + { + return new ArrayIterator($this->items); + } + + /** + * 将数据反序列化成数组 + * @access public + * @return array + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return $this->toArray(); + } + + /** + * 转换当前数据集为 JSON 字符串 + * @access public + * @param integer $options json 参数 + * @return string + */ + public function toJson($options = JSON_UNESCAPED_UNICODE) + { + return json_encode($this->toArray(), $options); + } + + /** + * 将数据转换成字符串 + * @access public + * @return string + */ + public function __toString() + { + return $this->toJson(); + } + + /** + * 将数据转换成数组 + * @access protected + * @param mixed $items 数据 + * @return array + */ + protected function convertToArray($items) + { + return $items instanceof self ? $items->all() : (array) $items; + } +} diff --git a/thinkphp/library/think/Config.php b/thinkphp/library/think/Config.php new file mode 100644 index 0000000..8fa668d --- /dev/null +++ b/thinkphp/library/think/Config.php @@ -0,0 +1,214 @@ + +// +---------------------------------------------------------------------- + +namespace think; + +class Config +{ + /** + * @var array 配置参数 + */ + private static $config = []; + + /** + * @var string 参数作用域 + */ + private static $range = '_sys_'; + + /** + * 设定配置参数的作用域 + * @access public + * @param string $range 作用域 + * @return void + */ + public static function range($range) + { + self::$range = $range; + + if (!isset(self::$config[$range])) self::$config[$range] = []; + } + + /** + * 解析配置文件或内容 + * @access public + * @param string $config 配置文件路径或内容 + * @param string $type 配置解析类型 + * @param string $name 配置名(如设置即表示二级配置) + * @param string $range 作用域 + * @return mixed + */ + public static function parse($config, $type = '', $name = '', $range = '') + { + $range = $range ?: self::$range; + + if (empty($type)) $type = pathinfo($config, PATHINFO_EXTENSION); + + $class = false !== strpos($type, '\\') ? + $type : + '\\think\\config\\driver\\' . ucwords($type); + + return self::set((new $class())->parse($config), $name, $range); + } + + /** + * 加载配置文件(PHP格式) + * @access public + * @param string $file 配置文件名 + * @param string $name 配置名(如设置即表示二级配置) + * @param string $range 作用域 + * @return mixed + */ + public static function load($file, $name = '', $range = '') + { + $range = $range ?: self::$range; + + if (!isset(self::$config[$range])) self::$config[$range] = []; + + if (is_file($file)) { + $name = strtolower($name); + $type = pathinfo($file, PATHINFO_EXTENSION); + + if ('php' == $type) { + return self::set(include $file, $name, $range); + } + + if ('yaml' == $type && function_exists('yaml_parse_file')) { + return self::set(yaml_parse_file($file), $name, $range); + } + + return self::parse($file, $type, $name, $range); + } + + return self::$config[$range]; + } + + /** + * 检测配置是否存在 + * @access public + * @param string $name 配置参数名(支持二级配置 . 号分割) + * @param string $range 作用域 + * @return bool + */ + public static function has($name, $range = '') + { + $range = $range ?: self::$range; + + if (!strpos($name, '.')) { + return isset(self::$config[$range][strtolower($name)]); + } + + // 二维数组设置和获取支持 + $name = explode('.', $name, 2); + return isset(self::$config[$range][strtolower($name[0])][$name[1]]); + } + + /** + * 获取配置参数 为空则获取所有配置 + * @access public + * @param string $name 配置参数名(支持二级配置 . 号分割) + * @param string $range 作用域 + * @return mixed + */ + public static function get($name = null, $range = '') + { + $range = $range ?: self::$range; + + // 无参数时获取所有 + if (empty($name) && isset(self::$config[$range])) { + return self::$config[$range]; + } + + // 非二级配置时直接返回 + if (!strpos($name, '.')) { + $name = strtolower($name); + return isset(self::$config[$range][$name]) ? self::$config[$range][$name] : null; + } + + // 二维数组设置和获取支持 + $name = explode('.', $name, 2); + $name[0] = strtolower($name[0]); + + if (!isset(self::$config[$range][$name[0]])) { + // 动态载入额外配置 + $module = Request::instance()->module(); + $file = CONF_PATH . ($module ? $module . DS : '') . 'extra' . DS . $name[0] . CONF_EXT; + + is_file($file) && self::load($file, $name[0]); + } + + return isset(self::$config[$range][$name[0]][$name[1]]) ? + self::$config[$range][$name[0]][$name[1]] : + null; + } + + /** + * 设置配置参数 name 为数组则为批量设置 + * @access public + * @param string|array $name 配置参数名(支持二级配置 . 号分割) + * @param mixed $value 配置值 + * @param string $range 作用域 + * @return mixed + */ + public static function set($name, $value = null, $range = '') + { + $range = $range ?: self::$range; + + if (!isset(self::$config[$range])) self::$config[$range] = []; + + // 字符串则表示单个配置设置 + if (is_string($name)) { + if (!strpos($name, '.')) { + self::$config[$range][strtolower($name)] = $value; + } else { + // 二维数组 + $name = explode('.', $name, 2); + self::$config[$range][strtolower($name[0])][$name[1]] = $value; + } + + return $value; + } + + // 数组则表示批量设置 + if (is_array($name)) { + if (!empty($value)) { + self::$config[$range][$value] = isset(self::$config[$range][$value]) ? + array_merge(self::$config[$range][$value], $name) : + $name; + + return self::$config[$range][$value]; + } + + return self::$config[$range] = array_merge( + self::$config[$range], array_change_key_case($name) + ); + } + + // 为空直接返回已有配置 + return self::$config[$range]; + } + + /** + * 重置配置参数 + * @access public + * @param string $range 作用域 + * @return void + */ + public static function reset($range = '') + { + $range = $range ?: self::$range; + + if (true === $range) { + self::$config = []; + } else { + self::$config[$range] = []; + } + } +} diff --git a/thinkphp/library/think/Console.php b/thinkphp/library/think/Console.php new file mode 100644 index 0000000..32b2572 --- /dev/null +++ b/thinkphp/library/think/Console.php @@ -0,0 +1,863 @@ + +// +---------------------------------------------------------------------- + +namespace think; + +use think\console\Command; +use think\console\command\Help as HelpCommand; +use think\console\Input; +use think\console\input\Argument as InputArgument; +use think\console\input\Definition as InputDefinition; +use think\console\input\Option as InputOption; +use think\console\Output; +use think\console\output\driver\Buffer; + +class Console +{ + /** + * @var string 命令名称 + */ + private $name; + + /** + * @var string 命令版本 + */ + private $version; + + /** + * @var Command[] 命令 + */ + private $commands = []; + + /** + * @var bool 是否需要帮助信息 + */ + private $wantHelps = false; + + /** + * @var bool 是否捕获异常 + */ + private $catchExceptions = true; + + /** + * @var bool 是否自动退出执行 + */ + private $autoExit = true; + + /** + * @var InputDefinition 输入定义 + */ + private $definition; + + /** + * @var string 默认执行的命令 + */ + private $defaultCommand; + + /** + * @var array 默认提供的命令 + */ + private static $defaultCommands = [ + "think\\console\\command\\Help", + "think\\console\\command\\Lists", + "think\\console\\command\\Build", + "think\\console\\command\\Clear", + "think\\console\\command\\make\\Controller", + "think\\console\\command\\make\\Model", + "think\\console\\command\\optimize\\Autoload", + "think\\console\\command\\optimize\\Config", + "think\\console\\command\\optimize\\Route", + "think\\console\\command\\optimize\\Schema", + ]; + + /** + * Console constructor. + * @access public + * @param string $name 名称 + * @param string $version 版本 + * @param null|string $user 执行用户 + */ + public function __construct($name = 'UNKNOWN', $version = 'UNKNOWN', $user = null) + { + $this->name = $name; + $this->version = $version; + + if ($user) { + $this->setUser($user); + } + + $this->defaultCommand = 'list'; + $this->definition = $this->getDefaultInputDefinition(); + + foreach ($this->getDefaultCommands() as $command) { + $this->add($command); + } + } + + /** + * 设置执行用户 + * @param $user + */ + public function setUser($user) + { + $user = posix_getpwnam($user); + if ($user) { + posix_setuid($user['uid']); + posix_setgid($user['gid']); + } + } + + /** + * 初始化 Console + * @access public + * @param bool $run 是否运行 Console + * @return int|Console + */ + public static function init($run = true) + { + static $console; + + if (!$console) { + $config = Config::get('console'); + // 实例化 console + $console = new self($config['name'], $config['version'], $config['user']); + + // 读取指令集 + if (is_file(CONF_PATH . 'command' . EXT)) { + $commands = include CONF_PATH . 'command' . EXT; + + if (is_array($commands)) { + foreach ($commands as $command) { + class_exists($command) && + is_subclass_of($command, "\\think\\console\\Command") && + $console->add(new $command()); // 注册指令 + } + } + } + } + + return $run ? $console->run() : $console; + } + + /** + * 调用命令 + * @access public + * @param string $command + * @param array $parameters + * @param string $driver + * @return Output + */ + public static function call($command, array $parameters = [], $driver = 'buffer') + { + $console = self::init(false); + + array_unshift($parameters, $command); + + $input = new Input($parameters); + $output = new Output($driver); + + $console->setCatchExceptions(false); + $console->find($command)->run($input, $output); + + return $output; + } + + /** + * 执行当前的指令 + * @access public + * @return int + * @throws \Exception + */ + public function run() + { + $input = new Input(); + $output = new Output(); + + $this->configureIO($input, $output); + + try { + $exitCode = $this->doRun($input, $output); + } catch (\Exception $e) { + if (!$this->catchExceptions) throw $e; + + $output->renderException($e); + + $exitCode = $e->getCode(); + + if (is_numeric($exitCode)) { + $exitCode = ((int) $exitCode) ?: 1; + } else { + $exitCode = 1; + } + } + + if ($this->autoExit) { + if ($exitCode > 255) $exitCode = 255; + + exit($exitCode); + } + + return $exitCode; + } + + /** + * 执行指令 + * @access public + * @param Input $input 输入 + * @param Output $output 输出 + * @return int + */ + public function doRun(Input $input, Output $output) + { + // 获取版本信息 + if (true === $input->hasParameterOption(['--version', '-V'])) { + $output->writeln($this->getLongVersion()); + + return 0; + } + + $name = $this->getCommandName($input); + + // 获取帮助信息 + if (true === $input->hasParameterOption(['--help', '-h'])) { + if (!$name) { + $name = 'help'; + $input = new Input(['help']); + } else { + $this->wantHelps = true; + } + } + + if (!$name) { + $name = $this->defaultCommand; + $input = new Input([$this->defaultCommand]); + } + + return $this->doRunCommand($this->find($name), $input, $output); + } + + /** + * 设置输入参数定义 + * @access public + * @param InputDefinition $definition 输入定义 + * @return $this; + */ + public function setDefinition(InputDefinition $definition) + { + $this->definition = $definition; + + return $this; + } + + /** + * 获取输入参数定义 + * @access public + * @return InputDefinition + */ + public function getDefinition() + { + return $this->definition; + } + + /** + * 获取帮助信息 + * @access public + * @return string + */ + public function getHelp() + { + return $this->getLongVersion(); + } + + /** + * 设置是否捕获异常 + * @access public + * @param bool $boolean 是否捕获 + * @return $this + */ + public function setCatchExceptions($boolean) + { + $this->catchExceptions = (bool) $boolean; + + return $this; + } + + /** + * 设置是否自动退出 + * @access public + * @param bool $boolean 是否自动退出 + * @return $this + */ + public function setAutoExit($boolean) + { + $this->autoExit = (bool) $boolean; + + return $this; + } + + /** + * 获取名称 + * @access public + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * 设置名称 + * @access public + * @param string $name 名称 + * @return $this + */ + public function setName($name) + { + $this->name = $name; + + return $this; + } + + /** + * 获取版本 + * @access public + * @return string + */ + public function getVersion() + { + return $this->version; + } + + /** + * 设置版本 + * @access public + * @param string $version 版本信息 + * @return $this + */ + public function setVersion($version) + { + $this->version = $version; + + return $this; + } + + /** + * 获取完整的版本号 + * @access public + * @return string + */ + public function getLongVersion() + { + if ('UNKNOWN' !== $this->getName() && 'UNKNOWN' !== $this->getVersion()) { + return sprintf( + '%s version %s', + $this->getName(), + $this->getVersion() + ); + } + + return 'Console Tool'; + } + + /** + * 注册一个指令 + * @access public + * @param string $name 指令名称 + * @return Command + */ + public function register($name) + { + return $this->add(new Command($name)); + } + + /** + * 批量添加指令 + * @access public + * @param Command[] $commands 指令实例 + * @return $this + */ + public function addCommands(array $commands) + { + foreach ($commands as $command) $this->add($command); + + return $this; + } + + /** + * 添加一个指令 + * @access public + * @param Command $command 命令实例 + * @return Command|bool + */ + public function add(Command $command) + { + if (!$command->isEnabled()) { + $command->setConsole(null); + return false; + } + + $command->setConsole($this); + + if (null === $command->getDefinition()) { + throw new \LogicException( + sprintf('Command class "%s" is not correctly initialized. You probably forgot to call the parent constructor.', get_class($command)) + ); + } + + $this->commands[$command->getName()] = $command; + + foreach ($command->getAliases() as $alias) { + $this->commands[$alias] = $command; + } + + return $command; + } + + /** + * 获取指令 + * @access public + * @param string $name 指令名称 + * @return Command + * @throws \InvalidArgumentException + */ + public function get($name) + { + if (!isset($this->commands[$name])) { + throw new \InvalidArgumentException( + sprintf('The command "%s" does not exist.', $name) + ); + } + + $command = $this->commands[$name]; + + if ($this->wantHelps) { + $this->wantHelps = false; + + /** @var HelpCommand $helpCommand */ + $helpCommand = $this->get('help'); + $helpCommand->setCommand($command); + + return $helpCommand; + } + + return $command; + } + + /** + * 某个指令是否存在 + * @access public + * @param string $name 指令名称 + * @return bool + */ + public function has($name) + { + return isset($this->commands[$name]); + } + + /** + * 获取所有的命名空间 + * @access public + * @return array + */ + public function getNamespaces() + { + $namespaces = []; + + foreach ($this->commands as $command) { + $namespaces = array_merge( + $namespaces, $this->extractAllNamespaces($command->getName()) + ); + + foreach ($command->getAliases() as $alias) { + $namespaces = array_merge( + $namespaces, $this->extractAllNamespaces($alias) + ); + } + } + + return array_values(array_unique(array_filter($namespaces))); + } + + /** + * 查找注册命名空间中的名称或缩写 + * @access public + * @param string $namespace + * @return string + * @throws \InvalidArgumentException + */ + public function findNamespace($namespace) + { + $expr = preg_replace_callback('{([^:]+|)}', function ($matches) { + return preg_quote($matches[1]) . '[^:]*'; + }, $namespace); + + $allNamespaces = $this->getNamespaces(); + $namespaces = preg_grep('{^' . $expr . '}', $allNamespaces); + + if (empty($namespaces)) { + $message = sprintf( + 'There are no commands defined in the "%s" namespace.', $namespace + ); + + if ($alternatives = $this->findAlternatives($namespace, $allNamespaces)) { + if (1 == count($alternatives)) { + $message .= "\n\nDid you mean this?\n "; + } else { + $message .= "\n\nDid you mean one of these?\n "; + } + + $message .= implode("\n ", $alternatives); + } + + throw new \InvalidArgumentException($message); + } + + $exact = in_array($namespace, $namespaces, true); + + if (count($namespaces) > 1 && !$exact) { + throw new \InvalidArgumentException( + sprintf( + 'The namespace "%s" is ambiguous (%s).', + $namespace, + $this->getAbbreviationSuggestions(array_values($namespaces))) + ); + } + + return $exact ? $namespace : reset($namespaces); + } + + /** + * 查找指令 + * @access public + * @param string $name 名称或者别名 + * @return Command + * @throws \InvalidArgumentException + */ + public function find($name) + { + $expr = preg_replace_callback('{([^:]+|)}', function ($matches) { + return preg_quote($matches[1]) . '[^:]*'; + }, $name); + + $allCommands = array_keys($this->commands); + $commands = preg_grep('{^' . $expr . '}', $allCommands); + + if (empty($commands) || count(preg_grep('{^' . $expr . '$}', $commands)) < 1) { + if (false !== ($pos = strrpos($name, ':'))) { + $this->findNamespace(substr($name, 0, $pos)); + } + + $message = sprintf('Command "%s" is not defined.', $name); + + if ($alternatives = $this->findAlternatives($name, $allCommands)) { + if (1 == count($alternatives)) { + $message .= "\n\nDid you mean this?\n "; + } else { + $message .= "\n\nDid you mean one of these?\n "; + } + $message .= implode("\n ", $alternatives); + } + + throw new \InvalidArgumentException($message); + } + + if (count($commands) > 1) { + $commandList = $this->commands; + $commands = array_filter($commands, function ($nameOrAlias) use ($commandList, $commands) { + $commandName = $commandList[$nameOrAlias]->getName(); + + return $commandName === $nameOrAlias || !in_array($commandName, $commands); + }); + } + + $exact = in_array($name, $commands, true); + if (count($commands) > 1 && !$exact) { + $suggestions = $this->getAbbreviationSuggestions(array_values($commands)); + + throw new \InvalidArgumentException( + sprintf('Command "%s" is ambiguous (%s).', $name, $suggestions) + ); + } + + return $this->get($exact ? $name : reset($commands)); + } + + /** + * 获取所有的指令 + * @access public + * @param string $namespace 命名空间 + * @return Command[] + */ + public function all($namespace = null) + { + if (null === $namespace) return $this->commands; + + $commands = []; + + foreach ($this->commands as $name => $command) { + $ext = $this->extractNamespace($name, substr_count($namespace, ':') + 1); + + if ($ext === $namespace) $commands[$name] = $command; + } + + return $commands; + } + + /** + * 获取可能的指令名 + * @access public + * @param array $names 指令名 + * @return array + */ + public static function getAbbreviations($names) + { + $abbrevs = []; + foreach ($names as $name) { + for ($len = strlen($name); $len > 0; --$len) { + $abbrev = substr($name, 0, $len); + $abbrevs[$abbrev][] = $name; + } + } + + return $abbrevs; + } + + /** + * 配置基于用户的参数和选项的输入和输出实例 + * @access protected + * @param Input $input 输入实例 + * @param Output $output 输出实例 + * @return void + */ + protected function configureIO(Input $input, Output $output) + { + if (true === $input->hasParameterOption(['--ansi'])) { + $output->setDecorated(true); + } elseif (true === $input->hasParameterOption(['--no-ansi'])) { + $output->setDecorated(false); + } + + if (true === $input->hasParameterOption(['--no-interaction', '-n'])) { + $input->setInteractive(false); + } + + if (true === $input->hasParameterOption(['--quiet', '-q'])) { + $output->setVerbosity(Output::VERBOSITY_QUIET); + } else { + if ($input->hasParameterOption('-vvv') || $input->hasParameterOption('--verbose=3') || $input->getParameterOption('--verbose') === 3) { + $output->setVerbosity(Output::VERBOSITY_DEBUG); + } elseif ($input->hasParameterOption('-vv') || $input->hasParameterOption('--verbose=2') || $input->getParameterOption('--verbose') === 2) { + $output->setVerbosity(Output::VERBOSITY_VERY_VERBOSE); + } elseif ($input->hasParameterOption('-v') || $input->hasParameterOption('--verbose=1') || $input->hasParameterOption('--verbose') || $input->getParameterOption('--verbose')) { + $output->setVerbosity(Output::VERBOSITY_VERBOSE); + } + } + } + + /** + * 执行指令 + * @access protected + * @param Command $command 指令实例 + * @param Input $input 输入实例 + * @param Output $output 输出实例 + * @return int + * @throws \Exception + */ + protected function doRunCommand(Command $command, Input $input, Output $output) + { + return $command->run($input, $output); + } + + /** + * 获取指令的名称 + * @access protected + * @param Input $input 输入实例 + * @return string + */ + protected function getCommandName(Input $input) + { + return $input->getFirstArgument(); + } + + /** + * 获取默认输入定义 + * @access protected + * @return InputDefinition + */ + protected function getDefaultInputDefinition() + { + return new InputDefinition([ + new InputArgument('command', InputArgument::REQUIRED, 'The command to execute'), + new InputOption('--help', '-h', InputOption::VALUE_NONE, 'Display this help message'), + new InputOption('--version', '-V', InputOption::VALUE_NONE, 'Display this console version'), + new InputOption('--quiet', '-q', InputOption::VALUE_NONE, 'Do not output any message'), + new InputOption('--verbose', '-v|vv|vvv', InputOption::VALUE_NONE, 'Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug'), + new InputOption('--ansi', '', InputOption::VALUE_NONE, 'Force ANSI output'), + new InputOption('--no-ansi', '', InputOption::VALUE_NONE, 'Disable ANSI output'), + new InputOption('--no-interaction', '-n', InputOption::VALUE_NONE, 'Do not ask any interactive question'), + ]); + } + + /** + * 获取默认命令 + * @access protected + * @return Command[] + */ + protected function getDefaultCommands() + { + $defaultCommands = []; + + foreach (self::$defaultCommands as $class) { + if (class_exists($class) && is_subclass_of($class, "think\\console\\Command")) { + $defaultCommands[] = new $class(); + } + } + + return $defaultCommands; + } + + /** + * 添加默认指令 + * @access public + * @param array $classes 指令 + * @return void + */ + public static function addDefaultCommands(array $classes) + { + self::$defaultCommands = array_merge(self::$defaultCommands, $classes); + } + + /** + * 获取可能的建议 + * @access private + * @param array $abbrevs + * @return string + */ + private function getAbbreviationSuggestions($abbrevs) + { + return sprintf( + '%s, %s%s', + $abbrevs[0], + $abbrevs[1], + count($abbrevs) > 2 ? sprintf(' and %d more', count($abbrevs) - 2) : '' + ); + } + + /** + * 返回指令的命名空间部分 + * @access public + * @param string $name 指令名称 + * @param string $limit 部分的命名空间的最大数量 + * @return string + */ + public function extractNamespace($name, $limit = null) + { + $parts = explode(':', $name); + array_pop($parts); + + return implode(':', null === $limit ? $parts : array_slice($parts, 0, $limit)); + } + + /** + * 查找可替代的建议 + * @access private + * @param string $name 指令名称 + * @param array|\Traversable $collection 建议集合 + * @return array + */ + private function findAlternatives($name, $collection) + { + $threshold = 1e3; + $alternatives = []; + $collectionParts = []; + + foreach ($collection as $item) { + $collectionParts[$item] = explode(':', $item); + } + + foreach (explode(':', $name) as $i => $subname) { + foreach ($collectionParts as $collectionName => $parts) { + $exists = isset($alternatives[$collectionName]); + + if (!isset($parts[$i]) && $exists) { + $alternatives[$collectionName] += $threshold; + continue; + } elseif (!isset($parts[$i])) { + continue; + } + + $lev = levenshtein($subname, $parts[$i]); + + if ($lev <= strlen($subname) / 3 || + '' !== $subname && + false !== strpos($parts[$i], $subname) + ) { + $alternatives[$collectionName] = $exists ? + $alternatives[$collectionName] + $lev : + $lev; + } elseif ($exists) { + $alternatives[$collectionName] += $threshold; + } + } + } + + foreach ($collection as $item) { + $lev = levenshtein($name, $item); + + if ($lev <= strlen($name) / 3 || false !== strpos($item, $name)) { + $alternatives[$item] = isset($alternatives[$item]) ? + $alternatives[$item] - $lev : + $lev; + } + } + + $alternatives = array_filter($alternatives, function ($lev) use ($threshold) { + return $lev < 2 * $threshold; + }); + + asort($alternatives); + + return array_keys($alternatives); + } + + /** + * 设置默认的指令 + * @access public + * @param string $commandName 指令名称 + * @return $this + */ + public function setDefaultCommand($commandName) + { + $this->defaultCommand = $commandName; + + return $this; + } + + /** + * 返回所有的命名空间 + * @access private + * @param string $name 指令名称 + * @return array + */ + private function extractAllNamespaces($name) + { + $namespaces = []; + + foreach (explode(':', $name, -1) as $part) { + if (count($namespaces)) { + $namespaces[] = end($namespaces) . ':' . $part; + } else { + $namespaces[] = $part; + } + } + + return $namespaces; + } + +} diff --git a/thinkphp/library/think/Controller.php b/thinkphp/library/think/Controller.php new file mode 100644 index 0000000..77225b7 --- /dev/null +++ b/thinkphp/library/think/Controller.php @@ -0,0 +1,229 @@ + +// +---------------------------------------------------------------------- + +namespace think; + +use think\exception\ValidateException; +use traits\controller\Jump; + +Loader::import('controller/Jump', TRAIT_PATH, EXT); + +class Controller +{ + use Jump; + + /** + * @var \think\View 视图类实例 + */ + protected $view; + + /** + * @var \think\Request Request 实例 + */ + protected $request; + + /** + * @var bool 验证失败是否抛出异常 + */ + protected $failException = false; + + /** + * @var bool 是否批量验证 + */ + protected $batchValidate = false; + + /** + * @var array 前置操作方法列表 + */ + protected $beforeActionList = []; + + /** + * 构造方法 + * @access public + * @param Request $request Request 对象 + */ + public function __construct(Request $request = null) + { + $this->view = View::instance(Config::get('template'), Config::get('view_replace_str')); + $this->request = is_null($request) ? Request::instance() : $request; + + // 控制器初始化 + $this->_initialize(); + + // 前置操作方法 + if ($this->beforeActionList) { + foreach ($this->beforeActionList as $method => $options) { + is_numeric($method) ? + $this->beforeAction($options) : + $this->beforeAction($method, $options); + } + } + } + + /** + * 初始化操作 + * @access protected + */ + protected function _initialize() + { + } + + /** + * 前置操作 + * @access protected + * @param string $method 前置操作方法名 + * @param array $options 调用参数 ['only'=>[...]] 或者 ['except'=>[...]] + * @return void + */ + protected function beforeAction($method, $options = []) + { + if (isset($options['only'])) { + if (is_string($options['only'])) { + $options['only'] = explode(',', $options['only']); + } + + if (!in_array($this->request->action(), $options['only'])) { + return; + } + } elseif (isset($options['except'])) { + if (is_string($options['except'])) { + $options['except'] = explode(',', $options['except']); + } + + if (in_array($this->request->action(), $options['except'])) { + return; + } + } + + call_user_func([$this, $method]); + } + + /** + * 加载模板输出 + * @access protected + * @param string $template 模板文件名 + * @param array $vars 模板输出变量 + * @param array $replace 模板替换 + * @param array $config 模板参数 + * @return mixed + */ + protected function fetch($template = '', $vars = [], $replace = [], $config = []) + { + return $this->view->fetch($template, $vars, $replace, $config); + } + + /** + * 渲染内容输出 + * @access protected + * @param string $content 模板内容 + * @param array $vars 模板输出变量 + * @param array $replace 替换内容 + * @param array $config 模板参数 + * @return mixed + */ + protected function display($content = '', $vars = [], $replace = [], $config = []) + { + return $this->view->display($content, $vars, $replace, $config); + } + + /** + * 模板变量赋值 + * @access protected + * @param mixed $name 要显示的模板变量 + * @param mixed $value 变量的值 + * @return $this + */ + protected function assign($name, $value = '') + { + $this->view->assign($name, $value); + + return $this; + } + + /** + * 初始化模板引擎 + * @access protected + * @param array|string $engine 引擎参数 + * @return $this + */ + protected function engine($engine) + { + $this->view->engine($engine); + + return $this; + } + + /** + * 设置验证失败后是否抛出异常 + * @access protected + * @param bool $fail 是否抛出异常 + * @return $this + */ + protected function validateFailException($fail = true) + { + $this->failException = $fail; + + return $this; + } + + /** + * 验证数据 + * @access protected + * @param array $data 数据 + * @param string|array $validate 验证器名或者验证规则数组 + * @param array $message 提示信息 + * @param bool $batch 是否批量验证 + * @param mixed $callback 回调方法(闭包) + * @return array|string|true + * @throws ValidateException + */ + protected function validate($data, $validate, $message = [], $batch = false, $callback = null) + { + if (is_array($validate)) { + $v = Loader::validate(); + $v->rule($validate); + } else { + // 支持场景 + if (strpos($validate, '.')) { + list($validate, $scene) = explode('.', $validate); + } + + $v = Loader::validate($validate); + + !empty($scene) && $v->scene($scene); + } + + // 批量验证 + if ($batch || $this->batchValidate) { + $v->batch(true); + } + + // 设置错误信息 + if (is_array($message)) { + $v->message($message); + } + + // 使用回调验证 + if ($callback && is_callable($callback)) { + call_user_func_array($callback, [$v, &$data]); + } + + if (!$v->check($data)) { + if ($this->failException) { + throw new ValidateException($v->getError()); + } + + return $v->getError(); + } + + return true; + } +} diff --git a/thinkphp/library/think/Cookie.php b/thinkphp/library/think/Cookie.php new file mode 100644 index 0000000..ad05f12 --- /dev/null +++ b/thinkphp/library/think/Cookie.php @@ -0,0 +1,280 @@ + +// +---------------------------------------------------------------------- + +namespace think; + +class Cookie +{ + /** + * @var array cookie 设置参数 + */ + protected static $config = [ + 'prefix' => '', // cookie 名称前缀 + 'expire' => 0, // cookie 保存时间 + 'path' => '/', // cookie 保存路径 + 'domain' => '', // cookie 有效域名 + 'secure' => false, // cookie 启用安全传输 + 'httponly' => false, // httponly 设置 + 'setcookie' => true, // 是否使用 setcookie + ]; + + /** + * @var bool 是否完成初始化了 + */ + protected static $init; + + /** + * Cookie初始化 + * @access public + * @param array $config 配置参数 + * @return void + */ + public static function init(array $config = []) + { + if (empty($config)) { + $config = Config::get('cookie'); + } + + self::$config = array_merge(self::$config, array_change_key_case($config)); + + if (!empty(self::$config['httponly']) && PHP_SESSION_ACTIVE != session_status()) { + ini_set('session.cookie_httponly', 1); + } + + self::$init = true; + } + + /** + * 设置或者获取 cookie 作用域(前缀) + * @access public + * @param string $prefix 前缀 + * @return string| + */ + public static function prefix($prefix = '') + { + if (empty($prefix)) { + return self::$config['prefix']; + } + + return self::$config['prefix'] = $prefix; + } + + /** + * Cookie 设置、获取、删除 + * @access public + * @param string $name cookie 名称 + * @param mixed $value cookie 值 + * @param mixed $option 可选参数 可能会是 null|integer|string + * @return void + */ + public static function set($name, $value = '', $option = null) + { + !isset(self::$init) && self::init(); + + // 参数设置(会覆盖黙认设置) + if (!is_null($option)) { + if (is_numeric($option)) { + $option = ['expire' => $option]; + } elseif (is_string($option)) { + parse_str($option, $option); + } + + $config = array_merge(self::$config, array_change_key_case($option)); + } else { + $config = self::$config; + } + + $name = $config['prefix'] . $name; + + // 设置 cookie + if (is_array($value)) { + array_walk_recursive($value, 'self::jsonFormatProtect', 'encode'); + $value = 'think:' . json_encode($value); + } + + $expire = !empty($config['expire']) ? + $_SERVER['REQUEST_TIME'] + intval($config['expire']) : + 0; + + if ($config['setcookie']) { + if (PHP_VERSION_ID >= 70300) { + // PHP 7.3+ 支持选项数组 + setcookie($name, $value, array_merge([ + 'expires' => $expire, + 'path' => $config['path'], + 'domain' => $config['domain'], + 'secure' => $config['secure'], + 'httponly' => $config['httponly'] + ], isset($config['samesite']) ? ['samesite' => $config['samesite']] : [])); + } else { + // 旧版本 PHP 使用传统参数方式 + setcookie( + $name, $value, $expire, $config['path'], $config['domain'], + $config['secure'], $config['httponly'] + ); + } + } + + $_COOKIE[$name] = $value; + } + + /** + * 永久保存 Cookie 数据 + * @access public + * @param string $name cookie 名称 + * @param mixed $value cookie 值 + * @param mixed $option 可选参数 可能会是 null|integer|string + * @return void + */ + public static function forever($name, $value = '', $option = null) + { + if (is_null($option) || is_numeric($option)) { + $option = []; + } + + $option['expire'] = 315360000; + + self::set($name, $value, $option); + } + + /** + * 判断是否有 Cookie 数据 + * @access public + * @param string $name cookie 名称 + * @param string|null $prefix cookie 前缀 + * @return bool + */ + public static function has($name, $prefix = null) + { + !isset(self::$init) && self::init(); + + $prefix = !is_null($prefix) ? $prefix : self::$config['prefix']; + + return isset($_COOKIE[$prefix . $name]); + } + + /** + * 获取 Cookie 的值 + * @access public + * @param string $name cookie 名称 + * @param string|null $prefix cookie 前缀 + * @return mixed + */ + public static function get($name = '', $prefix = null) + { + !isset(self::$init) && self::init(); + + $prefix = !is_null($prefix) ? $prefix : self::$config['prefix']; + $key = $prefix . $name; + + if ('' == $name) { + // 获取全部 + if ($prefix) { + $value = []; + + foreach ($_COOKIE as $k => $val) { + if (0 === strpos($k, $prefix)) { + $value[$k] = $val; + } + + } + } else { + $value = $_COOKIE; + } + } elseif (isset($_COOKIE[$key])) { + $value = $_COOKIE[$key]; + + if (0 === strpos($value, 'think:')) { + $value = json_decode(substr($value, 6), true); + array_walk_recursive($value, 'self::jsonFormatProtect', 'decode'); + } + } else { + $value = null; + } + + return $value; + } + + /** + * 删除 Cookie + * @access public + * @param string $name cookie 名称 + * @param string|null $prefix cookie 前缀 + * @return void + */ + public static function delete($name, $prefix = null) + { + !isset(self::$init) && self::init(); + + $config = self::$config; + $prefix = !is_null($prefix) ? $prefix : $config['prefix']; + $name = $prefix . $name; + + if ($config['setcookie']) { + setcookie( + $name, '', $_SERVER['REQUEST_TIME'] - 3600, $config['path'], + $config['domain'], $config['secure'], $config['httponly'] + ); + } + + // 删除指定 cookie + unset($_COOKIE[$name]); + } + + /** + * 清除指定前缀的所有 cookie + * @access public + * @param string|null $prefix cookie 前缀 + * @return void + */ + public static function clear($prefix = null) + { + if (empty($_COOKIE)) { + return; + } + + !isset(self::$init) && self::init(); + + // 要删除的 cookie 前缀,不指定则删除 config 设置的指定前缀 + $config = self::$config; + $prefix = !is_null($prefix) ? $prefix : $config['prefix']; + + if ($prefix) { + foreach ($_COOKIE as $key => $val) { + if (0 === strpos($key, $prefix)) { + if ($config['setcookie']) { + setcookie( + $key, '', $_SERVER['REQUEST_TIME'] - 3600, $config['path'], + $config['domain'], $config['secure'], $config['httponly'] + ); + } + + unset($_COOKIE[$key]); + } + } + } + } + + /** + * json 转换时的格式保护 + * @access protected + * @param mixed $val 要转换的值 + * @param string $key 键名 + * @param string $type 转换类别 + * @return void + */ + protected static function jsonFormatProtect(&$val, $key, $type = 'encode') + { + if (!empty($val) && true !== $val) { + $val = 'decode' == $type ? urldecode($val) : urlencode($val); + } + } +} diff --git a/thinkphp/library/think/Db.php b/thinkphp/library/think/Db.php new file mode 100644 index 0000000..c4b5f00 --- /dev/null +++ b/thinkphp/library/think/Db.php @@ -0,0 +1,180 @@ + +// +---------------------------------------------------------------------- + +namespace think; + +use think\db\Connection; +use think\db\Query; + +/** + * Class Db + * @package think + * @method static Query table(string $table) 指定数据表(含前缀) + * @method static Query name(string $name) 指定数据表(不含前缀) + * @method static Query where(mixed $field, string $op = null, mixed $condition = null) 查询条件 + * @method static Query join(mixed $join, mixed $condition = null, string $type = 'INNER') JOIN查询 + * @method static Query union(mixed $union, boolean $all = false) UNION查询 + * @method static Query limit(mixed $offset, integer $length = null) 查询LIMIT + * @method static Query order(mixed $field, string $order = null) 查询ORDER + * @method static Query cache(mixed $key = null , integer $expire = null) 设置查询缓存 + * @method static mixed value(string $field) 获取某个字段的值 + * @method static array column(string $field, string $key = '') 获取某个列的值 + * @method static Query view(mixed $join, mixed $field = null, mixed $on = null, string $type = 'INNER') 视图查询 + * @method static mixed find(mixed $data = null) 查询单个记录 + * @method static mixed select(mixed $data = null) 查询多个记录 + * @method static integer insert(array $data, boolean $replace = false, boolean $getLastInsID = false, string $sequence = null) 插入一条记录 + * @method static integer insertGetId(array $data, boolean $replace = false, string $sequence = null) 插入一条记录并返回自增ID + * @method static integer insertAll(array $dataSet) 插入多条记录 + * @method static integer update(array $data) 更新记录 + * @method static integer delete(mixed $data = null) 删除记录 + * @method static boolean chunk(integer $count, callable $callback, string $column = null) 分块获取数据 + * @method static mixed query(string $sql, array $bind = [], boolean $master = false, bool $pdo = false) SQL查询 + * @method static integer execute(string $sql, array $bind = [], boolean $fetch = false, boolean $getLastInsID = false, string $sequence = null) SQL执行 + * @method static Paginator paginate(integer $listRows = 15, mixed $simple = null, array $config = []) 分页查询 + * @method static mixed transaction(callable $callback) 执行数据库事务 + * @method static void startTrans() 启动事务 + * @method static void commit() 用于非自动提交状态下面的查询提交 + * @method static void rollback() 事务回滚 + * @method static boolean batchQuery(array $sqlArray) 批处理执行SQL语句 + * @method static string quote(string $str) SQL指令安全过滤 + * @method static string getLastInsID($sequence = null) 获取最近插入的ID + */ +class Db +{ + /** + * @var Connection[] 数据库连接实例 + */ + private static $instance = []; + + /** + * @var int 查询次数 + */ + public static $queryTimes = 0; + + /** + * @var int 执行次数 + */ + public static $executeTimes = 0; + + /** + * 数据库初始化,并取得数据库类实例 + * @access public + * @param mixed $config 连接配置 + * @param bool|string $name 连接标识 true 强制重新连接 + * @return Connection + * @throws Exception + */ + public static function connect($config = [], $name = false) + { + if (false === $name) { + $name = md5(serialize($config)); + } + + if (true === $name || !isset(self::$instance[$name])) { + // 解析连接参数 支持数组和字符串 + $options = self::parseConfig($config); + + if (empty($options['type'])) { + throw new \InvalidArgumentException('Undefined db type'); + } + + $class = false !== strpos($options['type'], '\\') ? + $options['type'] : + '\\think\\db\\connector\\' . ucwords($options['type']); + + // 记录初始化信息 + if (App::$debug) { + Log::record('[ DB ] INIT ' . $options['type'], 'info'); + } + + if (true === $name) { + $name = md5(serialize($config)); + } + + self::$instance[$name] = new $class($options); + } + + return self::$instance[$name]; + } + + /** + * 清除连接实例 + * @access public + * @return void + */ + public static function clear() + { + self::$instance = []; + } + + /** + * 数据库连接参数解析 + * @access private + * @param mixed $config 连接参数 + * @return array + */ + private static function parseConfig($config) + { + if (empty($config)) { + $config = Config::get('database'); + } elseif (is_string($config) && false === strpos($config, '/')) { + $config = Config::get($config); // 支持读取配置参数 + } + + return is_string($config) ? self::parseDsn($config) : $config; + } + + /** + * DSN 解析 + * 格式: mysql://username:passwd@localhost:3306/DbName?param1=val1¶m2=val2#utf8 + * @access private + * @param string $dsnStr 数据库 DSN 字符串解析 + * @return array + */ + private static function parseDsn($dsnStr) + { + $info = parse_url($dsnStr); + + if (!$info) { + return []; + } + + $dsn = [ + 'type' => $info['scheme'], + 'username' => isset($info['user']) ? $info['user'] : '', + 'password' => isset($info['pass']) ? $info['pass'] : '', + 'hostname' => isset($info['host']) ? $info['host'] : '', + 'hostport' => isset($info['port']) ? $info['port'] : '', + 'database' => !empty($info['path']) ? ltrim($info['path'], '/') : '', + 'charset' => isset($info['fragment']) ? $info['fragment'] : 'utf8', + ]; + + if (isset($info['query'])) { + parse_str($info['query'], $dsn['params']); + } else { + $dsn['params'] = []; + } + + return $dsn; + } + + /** + * 调用驱动类的方法 + * @access public + * @param string $method 方法名 + * @param array $params 参数 + * @return mixed + */ + public static function __callStatic($method, $params) + { + return call_user_func_array([self::connect(), $method], $params); + } +} diff --git a/thinkphp/library/think/Debug.php b/thinkphp/library/think/Debug.php new file mode 100644 index 0000000..df48748 --- /dev/null +++ b/thinkphp/library/think/Debug.php @@ -0,0 +1,252 @@ + +// +---------------------------------------------------------------------- + +namespace think; + +use think\exception\ClassNotFoundException; +use think\response\Redirect; + +class Debug +{ + /** + * @var array 区间时间信息 + */ + protected static $info = []; + + /** + * @var array 区间内存信息 + */ + protected static $mem = []; + + /** + * 记录时间(微秒)和内存使用情况 + * @access public + * @param string $name 标记位置 + * @param mixed $value 标记值(留空则取当前 time 表示仅记录时间 否则同时记录时间和内存) + * @return void + */ + public static function remark($name, $value = '') + { + self::$info[$name] = is_float($value) ? $value : microtime(true); + + if ('time' != $value) { + self::$mem['mem'][$name] = is_float($value) ? $value : memory_get_usage(); + self::$mem['peak'][$name] = memory_get_peak_usage(); + } + } + + /** + * 统计某个区间的时间(微秒)使用情况 返回值以秒为单位 + * @access public + * @param string $start 开始标签 + * @param string $end 结束标签 + * @param integer $dec 小数位 + * @return string + */ + public static function getRangeTime($start, $end, $dec = 6) + { + if (!isset(self::$info[$end])) { + self::$info[$end] = microtime(true); + } + + return number_format((self::$info[$end] - self::$info[$start]), $dec); + } + + /** + * 统计从开始到统计时的时间(微秒)使用情况 返回值以秒为单位 + * @access public + * @param integer $dec 小数位 + * @return string + */ + public static function getUseTime($dec = 6) + { + return number_format((microtime(true) - THINK_START_TIME), $dec); + } + + /** + * 获取当前访问的吞吐率情况 + * @access public + * @return string + */ + public static function getThroughputRate() + { + return number_format(1 / self::getUseTime(), 2) . 'req/s'; + } + + /** + * 记录区间的内存使用情况 + * @access public + * @param string $start 开始标签 + * @param string $end 结束标签 + * @param integer $dec 小数位 + * @return string + */ + public static function getRangeMem($start, $end, $dec = 2) + { + if (!isset(self::$mem['mem'][$end])) { + self::$mem['mem'][$end] = memory_get_usage(); + } + + $size = self::$mem['mem'][$end] - self::$mem['mem'][$start]; + $a = ['B', 'KB', 'MB', 'GB', 'TB']; + $pos = 0; + + while ($size >= 1024) { + $size /= 1024; + $pos++; + } + + return round($size, $dec) . " " . $a[$pos]; + } + + /** + * 统计从开始到统计时的内存使用情况 + * @access public + * @param integer $dec 小数位 + * @return string + */ + public static function getUseMem($dec = 2) + { + $size = memory_get_usage() - THINK_START_MEM; + $a = ['B', 'KB', 'MB', 'GB', 'TB']; + $pos = 0; + + while ($size >= 1024) { + $size /= 1024; + $pos++; + } + + return round($size, $dec) . " " . $a[$pos]; + } + + /** + * 统计区间的内存峰值情况 + * @access public + * @param string $start 开始标签 + * @param string $end 结束标签 + * @param integer $dec 小数位 + * @return string + */ + public static function getMemPeak($start, $end, $dec = 2) + { + if (!isset(self::$mem['peak'][$end])) { + self::$mem['peak'][$end] = memory_get_peak_usage(); + } + + $size = self::$mem['peak'][$end] - self::$mem['peak'][$start]; + $a = ['B', 'KB', 'MB', 'GB', 'TB']; + $pos = 0; + + while ($size >= 1024) { + $size /= 1024; + $pos++; + } + + return round($size, $dec) . " " . $a[$pos]; + } + + /** + * 获取文件加载信息 + * @access public + * @param bool $detail 是否显示详细 + * @return integer|array + */ + public static function getFile($detail = false) + { + $files = get_included_files(); + + if ($detail) { + $info = []; + + foreach ($files as $file) { + $info[] = $file . ' ( ' . number_format(filesize($file) / 1024, 2) . ' KB )'; + } + + return $info; + } + + return count($files); + } + + /** + * 浏览器友好的变量输出 + * @access public + * @param mixed $var 变量 + * @param boolean $echo 是否输出(默认为 true,为 false 则返回输出字符串) + * @param string|null $label 标签(默认为空) + * @param integer $flags htmlspecialchars 的标志 + * @return null|string + */ + public static function dump($var, $echo = true, $label = null, $flags = ENT_SUBSTITUTE) + { + $label = (null === $label) ? '' : rtrim($label) . ':'; + + ob_start(); + var_dump($var); + $output = preg_replace('/\]\=\>\n(\s+)/m', '] => ', ob_get_clean()); + + if (IS_CLI) { + $output = PHP_EOL . $label . $output . PHP_EOL; + } else { + if (!extension_loaded('xdebug')) { + $output = htmlspecialchars($output, $flags); + } + + $output = '
' . $label . $output . '
'; + } + + if ($echo) { + echo($output); + return; + } + + return $output; + } + + /** + * 调试信息注入到响应中 + * @access public + * @param Response $response 响应实例 + * @param string $content 返回的字符串 + * @return void + */ + public static function inject(Response $response, &$content) + { + $config = Config::get('trace'); + $type = isset($config['type']) ? $config['type'] : 'Html'; + $class = false !== strpos($type, '\\') ? $type : '\\think\\debug\\' . ucwords($type); + + unset($config['type']); + + if (!class_exists($class)) { + throw new ClassNotFoundException('class not exists:' . $class, $class); + } + + /** @var \think\debug\Console|\think\debug\Html $trace */ + $trace = new $class($config); + + if ($response instanceof Redirect) { + // TODO 记录 + } else { + $output = $trace->output($response, Log::getLog()); + + if (is_string($output)) { + // trace 调试信息注入 + $pos = strripos($content, ''); + if (false !== $pos) { + $content = substr($content, 0, $pos) . $output . substr($content, $pos); + } else { + $content = $content . $output; + } + } + } + } +} diff --git a/thinkphp/library/think/Env.php b/thinkphp/library/think/Env.php new file mode 100644 index 0000000..0a8b250 --- /dev/null +++ b/thinkphp/library/think/Env.php @@ -0,0 +1,39 @@ + +// +---------------------------------------------------------------------- + +namespace think; + +class Env +{ + /** + * 获取环境变量值 + * @access public + * @param string $name 环境变量名(支持二级 . 号分割) + * @param string $default 默认值 + * @return mixed + */ + public static function get($name, $default = null) + { + $result = getenv(ENV_PREFIX . strtoupper(str_replace('.', '_', $name))); + + if (false !== $result) { + if ('false' === $result) { + $result = false; + } elseif ('true' === $result) { + $result = true; + } + + return $result; + } + + return $default; + } +} diff --git a/thinkphp/library/think/Error.php b/thinkphp/library/think/Error.php new file mode 100644 index 0000000..5f361d5 --- /dev/null +++ b/thinkphp/library/think/Error.php @@ -0,0 +1,136 @@ + +// +---------------------------------------------------------------------- + +namespace think; + +use think\console\Output as ConsoleOutput; +use think\exception\ErrorException; +use think\exception\Handle; +use think\exception\ThrowableError; + +class Error +{ + /** + * 注册异常处理 + * @access public + * @return void + */ + public static function register() + { + error_reporting(E_ALL); + set_error_handler([__CLASS__, 'appError']); + set_exception_handler([__CLASS__, 'appException']); + register_shutdown_function([__CLASS__, 'appShutdown']); + } + + /** + * 异常处理 + * @access public + * @param \Exception|\Throwable $e 异常 + * @return void + */ + public static function appException($e) + { + if (!$e instanceof \Exception) { + $e = new ThrowableError($e); + } + + $handler = self::getExceptionHandler(); + $handler->report($e); + + if (IS_CLI) { + $handler->renderForConsole(new ConsoleOutput, $e); + } else { + $handler->render($e)->send(); + } + } + + /** + * 错误处理 + * @access public + * @param integer $errno 错误编号 + * @param integer $errstr 详细错误信息 + * @param string $errfile 出错的文件 + * @param integer $errline 出错行号 + * @return void + * @throws ErrorException + */ + public static function appError($errno, $errstr, $errfile = '', $errline = 0) + { + $exception = new ErrorException($errno, $errstr, $errfile, $errline); + + // 符合异常处理的则将错误信息托管至 think\exception\ErrorException + if (error_reporting() & $errno) { + throw $exception; + } + + self::getExceptionHandler()->report($exception); + } + + /** + * 异常中止处理 + * @access public + * @return void + */ + public static function appShutdown() + { + // 将错误信息托管至 think\ErrorException + if (!is_null($error = error_get_last()) && self::isFatal($error['type'])) { + self::appException(new ErrorException( + $error['type'], $error['message'], $error['file'], $error['line'] + )); + } + + // 写入日志 + Log::save(); + } + + /** + * 确定错误类型是否致命 + * @access protected + * @param int $type 错误类型 + * @return bool + */ + protected static function isFatal($type) + { + return in_array($type, [E_ERROR, E_CORE_ERROR, E_COMPILE_ERROR, E_PARSE]); + } + + /** + * 获取异常处理的实例 + * @access public + * @return Handle + */ + public static function getExceptionHandler() + { + static $handle; + + if (!$handle) { + // 异常处理 handle + $class = Config::get('exception_handle'); + + if ($class && is_string($class) && class_exists($class) && + is_subclass_of($class, "\\think\\exception\\Handle") + ) { + $handle = new $class; + } else { + $handle = new Handle; + + if ($class instanceof \Closure) { + $handle->setRender($class); + } + + } + } + + return $handle; + } +} diff --git a/thinkphp/library/think/Exception.php b/thinkphp/library/think/Exception.php new file mode 100644 index 0000000..1ef06bd --- /dev/null +++ b/thinkphp/library/think/Exception.php @@ -0,0 +1,55 @@ + +// +---------------------------------------------------------------------- + +namespace think; + +class Exception extends \Exception +{ + /** + * @var array 保存异常页面显示的额外 Debug 数据 + */ + protected $data = []; + + /** + * 设置异常额外的 Debug 数据 + * 数据将会显示为下面的格式 + * + * Exception Data + * -------------------------------------------------- + * Label 1 + * key1 value1 + * key2 value2 + * Label 2 + * key1 value1 + * key2 value2 + * + * @access protected + * @param string $label 数据分类,用于异常页面显示 + * @param array $data 需要显示的数据,必须为关联数组 + * @return void + */ + final protected function setData($label, array $data) + { + $this->data[$label] = $data; + } + + /** + * 获取异常额外 Debug 数据 + * 主要用于输出到异常页面便于调试 + * @access public + * @return array + */ + final public function getData() + { + return $this->data; + } + +} diff --git a/thinkphp/library/think/File.php b/thinkphp/library/think/File.php new file mode 100644 index 0000000..d2ed220 --- /dev/null +++ b/thinkphp/library/think/File.php @@ -0,0 +1,478 @@ + +// +---------------------------------------------------------------------- + +namespace think; + +use SplFileObject; + +class File extends SplFileObject +{ + /** + * @var string 错误信息 + */ + private $error = ''; + + /** + * @var string 当前完整文件名 + */ + protected $filename; + + /** + * @var string 上传文件名 + */ + protected $saveName; + + /** + * @var string 文件上传命名规则 + */ + protected $rule = 'date'; + + /** + * @var array 文件上传验证规则 + */ + protected $validate = []; + + /** + * @var bool 单元测试 + */ + protected $isTest; + + /** + * @var array 上传文件信息 + */ + protected $info; + + /** + * @var array 文件 hash 信息 + */ + protected $hash = []; + + /** + * File constructor. + * @access public + * @param string $filename 文件名称 + * @param string $mode 访问模式 + */ + public function __construct($filename, $mode = 'r') + { + parent::__construct($filename, $mode); + $this->filename = $this->getRealPath() ?: $this->getPathname(); + } + + /** + * 设置是否是单元测试 + * @access public + * @param bool $test 是否是测试 + * @return $this + */ + public function isTest($test = false) + { + $this->isTest = $test; + + return $this; + } + + /** + * 设置上传信息 + * @access public + * @param array $info 上传文件信息 + * @return $this + */ + public function setUploadInfo($info) + { + $this->info = $info; + + return $this; + } + + /** + * 获取上传文件的信息 + * @access public + * @param string $name 信息名称 + * @return array|string + */ + public function getInfo($name = '') + { + return isset($this->info[$name]) ? $this->info[$name] : $this->info; + } + + /** + * 获取上传文件的文件名 + * @access public + * @return string + */ + public function getSaveName() + { + return $this->saveName; + } + + /** + * 设置上传文件的保存文件名 + * @access public + * @param string $saveName 保存名称 + * @return $this + */ + public function setSaveName($saveName) + { + $this->saveName = $saveName; + + return $this; + } + + /** + * 获取文件的哈希散列值 + * @access public + * @param string $type 类型 + * @return string + */ + public function hash($type = 'sha1') + { + if (!isset($this->hash[$type])) { + $this->hash[$type] = hash_file($type, $this->filename); + } + + return $this->hash[$type]; + } + + /** + * 检查目录是否可写 + * @access protected + * @param string $path 目录 + * @return boolean + */ + protected function checkPath($path) + { + if (is_dir($path) || mkdir($path, 0755, true)) { + return true; + } + + $this->error = ['directory {:path} creation failed', ['path' => $path]]; + + return false; + } + + /** + * 获取文件类型信息 + * @access public + * @return string + */ + public function getMime() + { + $finfo = finfo_open(FILEINFO_MIME_TYPE); + + return finfo_file($finfo, $this->filename); + } + + /** + * 设置文件的命名规则 + * @access public + * @param string $rule 文件命名规则 + * @return $this + */ + public function rule($rule) + { + $this->rule = $rule; + + return $this; + } + + /** + * 设置上传文件的验证规则 + * @access public + * @param array $rule 验证规则 + * @return $this + */ + public function validate(array $rule = []) + { + $this->validate = $rule; + + return $this; + } + + /** + * 检测是否合法的上传文件 + * @access public + * @return bool + */ + public function isValid() + { + return $this->isTest ? is_file($this->filename) : is_uploaded_file($this->filename); + } + + /** + * 检测上传文件 + * @access public + * @param array $rule 验证规则 + * @return bool + */ + public function check($rule = []) + { + $rule = $rule ?: $this->validate; + + /* 检查文件大小 */ + if (isset($rule['size']) && !$this->checkSize($rule['size'])) { + $this->error = 'filesize not match'; + return false; + } + + /* 检查文件 Mime 类型 */ + if (isset($rule['type']) && !$this->checkMime($rule['type'])) { + $this->error = 'mimetype to upload is not allowed'; + return false; + } + + /* 检查文件后缀 */ + if (isset($rule['ext']) && !$this->checkExt($rule['ext'])) { + $this->error = 'extensions to upload is not allowed'; + return false; + } + + /* 检查图像文件 */ + if (!$this->checkImg()) { + $this->error = 'illegal image files'; + return false; + } + + return true; + } + + /** + * 检测上传文件后缀 + * @access public + * @param array|string $ext 允许后缀 + * @return bool + */ + public function checkExt($ext) + { + if (is_string($ext)) { + $ext = explode(',', $ext); + } + + $extension = strtolower(pathinfo($this->getInfo('name'), PATHINFO_EXTENSION)); + + return in_array($extension, $ext); + } + + /** + * 检测图像文件 + * @access public + * @return bool + */ + public function checkImg() + { + $extension = strtolower(pathinfo($this->getInfo('name'), PATHINFO_EXTENSION)); + + // 如果上传的不是图片,或者是图片而且后缀确实符合图片类型则返回 true + return !in_array($extension, ['gif', 'jpg', 'jpeg', 'bmp', 'png', 'swf']) || in_array($this->getImageType($this->filename), [1, 2, 3, 4, 6, 13]); + } + + /** + * 判断图像类型 + * @access protected + * @param string $image 图片名称 + * @return bool|int + */ + protected function getImageType($image) + { + if (function_exists('exif_imagetype')) { + return exif_imagetype($image); + } + + try { + $info = getimagesize($image); + return $info ? $info[2] : false; + } catch (\Exception $e) { + return false; + } + } + + /** + * 检测上传文件大小 + * @access public + * @param integer $size 最大大小 + * @return bool + */ + public function checkSize($size) + { + return $this->getSize() <= $size; + } + + /** + * 检测上传文件类型 + * @access public + * @param array|string $mime 允许类型 + * @return bool + */ + public function checkMime($mime) + { + $mime = is_string($mime) ? explode(',', $mime) : $mime; + + return in_array(strtolower($this->getMime()), $mime); + } + + /** + * 移动文件 + * @access public + * @param string $path 保存路径 + * @param string|bool $savename 保存的文件名 默认自动生成 + * @param boolean $replace 同名文件是否覆盖 + * @return false|File + */ + public function move($path, $savename = true, $replace = true) + { + // 文件上传失败,捕获错误代码 + if (!empty($this->info['error'])) { + $this->error($this->info['error']); + return false; + } + + // 检测合法性 + if (!$this->isValid()) { + $this->error = 'upload illegal files'; + return false; + } + + // 验证上传 + if (!$this->check()) { + return false; + } + + $path = rtrim($path, DS) . DS; + // 文件保存命名规则 + $saveName = $this->buildSaveName($savename); + $filename = $path . $saveName; + + // 检测目录 + if (false === $this->checkPath(dirname($filename))) { + return false; + } + + // 不覆盖同名文件 + if (!$replace && is_file($filename)) { + $this->error = ['has the same filename: {:filename}', ['filename' => $filename]]; + return false; + } + + /* 移动文件 */ + if ($this->isTest) { + rename($this->filename, $filename); + } elseif (!move_uploaded_file($this->filename, $filename)) { + $this->error = 'upload write error'; + return false; + } + + // 返回 File 对象实例 + $file = new self($filename); + $file->setSaveName($saveName)->setUploadInfo($this->info); + + return $file; + } + + /** + * 获取保存文件名 + * @access protected + * @param string|bool $savename 保存的文件名 默认自动生成 + * @return string + */ + protected function buildSaveName($savename) + { + // 自动生成文件名 + if (true === $savename) { + if ($this->rule instanceof \Closure) { + $savename = call_user_func_array($this->rule, [$this]); + } else { + switch ($this->rule) { + case 'date': + $savename = date('Ymd') . DS . md5(microtime(true)); + break; + default: + if (in_array($this->rule, hash_algos())) { + $hash = $this->hash($this->rule); + $savename = substr($hash, 0, 2) . DS . substr($hash, 2); + } elseif (is_callable($this->rule)) { + $savename = call_user_func($this->rule); + } else { + $savename = date('Ymd') . DS . md5(microtime(true)); + } + } + } + } elseif ('' === $savename || false === $savename) { + $savename = $this->getInfo('name'); + } + + if (!strpos($savename, '.')) { + $savename .= '.' . pathinfo($this->getInfo('name'), PATHINFO_EXTENSION); + } + + return $savename; + } + + /** + * 获取错误代码信息 + * @access private + * @param int $errorNo 错误号 + * @return $this + */ + private function error($errorNo) + { + switch ($errorNo) { + case 1: + case 2: + $this->error = 'upload File size exceeds the maximum value'; + break; + case 3: + $this->error = 'only the portion of file is uploaded'; + break; + case 4: + $this->error = 'no file to uploaded'; + break; + case 6: + $this->error = 'upload temp dir not found'; + break; + case 7: + $this->error = 'file write error'; + break; + default: + $this->error = 'unknown upload error'; + } + + return $this; + } + + /** + * 获取错误信息(支持多语言) + * @access public + * @return string + */ + public function getError() + { + if (is_array($this->error)) { + list($msg, $vars) = $this->error; + } else { + $msg = $this->error; + $vars = []; + } + + return Lang::has($msg) ? Lang::get($msg, $vars) : $msg; + } + + /** + * 魔法方法,获取文件的 hash 值 + * @access public + * @param string $method 方法名 + * @param mixed $args 调用参数 + * @return string + */ + public function __call($method, $args) + { + return $this->hash($method); + } +} diff --git a/thinkphp/library/think/Hook.php b/thinkphp/library/think/Hook.php new file mode 100644 index 0000000..a69ce54 --- /dev/null +++ b/thinkphp/library/think/Hook.php @@ -0,0 +1,148 @@ + +// +---------------------------------------------------------------------- + +namespace think; + +class Hook +{ + /** + * @var array 标签 + */ + private static $tags = []; + + /** + * 动态添加行为扩展到某个标签 + * @access public + * @param string $tag 标签名称 + * @param mixed $behavior 行为名称 + * @param bool $first 是否放到开头执行 + * @return void + */ + public static function add($tag, $behavior, $first = false) + { + isset(self::$tags[$tag]) || self::$tags[$tag] = []; + + if (is_array($behavior) && !is_callable($behavior)) { + if (!array_key_exists('_overlay', $behavior) || !$behavior['_overlay']) { + unset($behavior['_overlay']); + self::$tags[$tag] = array_merge(self::$tags[$tag], $behavior); + } else { + unset($behavior['_overlay']); + self::$tags[$tag] = $behavior; + } + } elseif ($first) { + array_unshift(self::$tags[$tag], $behavior); + } else { + self::$tags[$tag][] = $behavior; + } + } + + /** + * 批量导入插件 + * @access public + * @param array $tags 插件信息 + * @param boolean $recursive 是否递归合并 + * @return void + */ + public static function import(array $tags, $recursive = true) + { + if ($recursive) { + foreach ($tags as $tag => $behavior) { + self::add($tag, $behavior); + } + } else { + self::$tags = $tags + self::$tags; + } + } + + /** + * 获取插件信息 + * @access public + * @param string $tag 插件位置(留空获取全部) + * @return array + */ + public static function get($tag = '') + { + if (empty($tag)) { + return self::$tags; + } + + return array_key_exists($tag, self::$tags) ? self::$tags[$tag] : []; + } + + /** + * 监听标签的行为 + * @access public + * @param string $tag 标签名称 + * @param mixed $params 传入参数 + * @param mixed $extra 额外参数 + * @param bool $once 只获取一个有效返回值 + * @return mixed + */ + public static function listen($tag, &$params = null, $extra = null, $once = false) + { + $results = []; + + foreach (static::get($tag) as $key => $name) { + $results[$key] = self::exec($name, $tag, $params, $extra); + + // 如果返回 false,或者仅获取一个有效返回则中断行为执行 + if (false === $results[$key] || (!is_null($results[$key]) && $once)) { + break; + } + } + + return $once ? end($results) : $results; + } + + /** + * 执行某个行为 + * @access public + * @param mixed $class 要执行的行为 + * @param string $tag 方法名(标签名) + * @param mixed $params 传人的参数 + * @param mixed $extra 额外参数 + * @return mixed + */ + public static function exec($class, $tag = '', &$params = null, $extra = null) + { + App::$debug && Debug::remark('behavior_start', 'time'); + + $method = Loader::parseName($tag, 1, false); + + if ($class instanceof \Closure) { + $result = call_user_func_array($class, [ & $params, $extra]); + $class = 'Closure'; + } elseif (is_array($class)) { + list($class, $method) = $class; + + $result = (new $class())->$method($params, $extra); + $class = $class . '->' . $method; + } elseif (is_object($class)) { + $result = $class->$method($params, $extra); + $class = get_class($class); + } elseif (strpos($class, '::')) { + $result = call_user_func_array($class, [ & $params, $extra]); + } else { + $obj = new $class(); + $method = ($tag && is_callable([$obj, $method])) ? $method : 'run'; + $result = $obj->$method($params, $extra); + } + + if (App::$debug) { + Debug::remark('behavior_end', 'time'); + Log::record('[ BEHAVIOR ] Run ' . $class . ' @' . $tag . ' [ RunTime:' . Debug::getRangeTime('behavior_start', 'behavior_end') . 's ]', 'info'); + } + + return $result; + } + +} diff --git a/thinkphp/library/think/Lang.php b/thinkphp/library/think/Lang.php new file mode 100644 index 0000000..9e6adb3 --- /dev/null +++ b/thinkphp/library/think/Lang.php @@ -0,0 +1,271 @@ + +// +---------------------------------------------------------------------- + +namespace think; + +class Lang +{ + /** + * @var array 语言数据 + */ + private static $lang = []; + + /** + * @var string 语言作用域 + */ + private static $range = 'zh-cn'; + + /** + * @var string 语言自动侦测的变量 + */ + protected static $langDetectVar = 'lang'; + + /** + * @var string 语言 Cookie 变量 + */ + protected static $langCookieVar = 'think_var'; + + /** + * @var int 语言 Cookie 的过期时间 + */ + protected static $langCookieExpire = 3600; + + /** + * @var array 允许语言列表 + */ + protected static $allowLangList = []; + + /** + * @var array Accept-Language 转义为对应语言包名称 系统默认配置 + */ + protected static $acceptLanguage = ['zh-hans-cn' => 'zh-cn']; + + /** + * 设定当前的语言 + * @access public + * @param string $range 语言作用域 + * @return string + */ + public static function range($range = '') + { + if ($range) { + self::$range = $range; + } + + return self::$range; + } + + /** + * 设置语言定义(不区分大小写) + * @access public + * @param string|array $name 语言变量 + * @param string $value 语言值 + * @param string $range 语言作用域 + * @return mixed + */ + public static function set($name, $value = null, $range = '') + { + $range = $range ?: self::$range; + + if (!isset(self::$lang[$range])) { + self::$lang[$range] = []; + } + + if (is_array($name)) { + return self::$lang[$range] = array_change_key_case($name) + self::$lang[$range]; + } + + return self::$lang[$range][strtolower($name)] = $value; + } + + /** + * 加载语言定义(不区分大小写) + * @access public + * @param array|string $file 语言文件 + * @param string $range 语言作用域 + * @return mixed + */ + public static function load($file, $range = '') + { + $range = $range ?: self::$range; + $file = is_string($file) ? [$file] : $file; + + if (!isset(self::$lang[$range])) { + self::$lang[$range] = []; + } + + $lang = []; + + foreach ($file as $_file) { + if (is_file($_file)) { + // 记录加载信息 + App::$debug && Log::record('[ LANG ] ' . $_file, 'info'); + + $_lang = include $_file; + + if (is_array($_lang)) { + $lang = array_change_key_case($_lang) + $lang; + } + } + } + + if (!empty($lang)) { + self::$lang[$range] = $lang + self::$lang[$range]; + } + + return self::$lang[$range]; + } + + /** + * 获取语言定义(不区分大小写) + * @access public + * @param string|null $name 语言变量 + * @param string $range 语言作用域 + * @return mixed + */ + public static function has($name, $range = '') + { + $range = $range ?: self::$range; + + return isset(self::$lang[$range][strtolower($name)]); + } + + /** + * 获取语言定义(不区分大小写) + * @access public + * @param string|null $name 语言变量 + * @param array $vars 变量替换 + * @param string $range 语言作用域 + * @return mixed + */ + public static function get($name = null, $vars = [], $range = '') + { + $range = $range ?: self::$range; + + // 空参数返回所有定义 + if (empty($name)) { + return self::$lang[$range]; + } + + $key = strtolower($name); + $value = isset(self::$lang[$range][$key]) ? self::$lang[$range][$key] : $name; + + // 变量解析 + if (!empty($vars) && is_array($vars)) { + /** + * Notes: + * 为了检测的方便,数字索引的判断仅仅是参数数组的第一个元素的key为数字0 + * 数字索引采用的是系统的 sprintf 函数替换,用法请参考 sprintf 函数 + */ + if (key($vars) === 0) { + // 数字索引解析 + array_unshift($vars, $value); + $value = call_user_func_array('sprintf', $vars); + } else { + // 关联索引解析 + $replace = array_keys($vars); + foreach ($replace as &$v) { + $v = "{:{$v}}"; + } + $value = str_replace($replace, $vars, $value); + } + + } + + return $value; + } + + /** + * 自动侦测设置获取语言选择 + * @access public + * @return string + */ + public static function detect() + { + $langSet = ''; + + if (isset($_GET[self::$langDetectVar])) { + // url 中设置了语言变量 + $langSet = strtolower($_GET[self::$langDetectVar]); + } elseif (isset($_COOKIE[self::$langCookieVar])) { + // Cookie 中设置了语言变量 + $langSet = strtolower($_COOKIE[self::$langCookieVar]); + } elseif (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { + // 自动侦测浏览器语言 + preg_match('/^([a-z\d\-]+)/i', $_SERVER['HTTP_ACCEPT_LANGUAGE'], $matches); + $langSet = strtolower($matches[1] ?? ''); + $acceptLangs = Config::get('header_accept_lang'); + + if (isset($acceptLangs[$langSet])) { + $langSet = $acceptLangs[$langSet]; + } elseif (isset(self::$acceptLanguage[$langSet])) { + $langSet = self::$acceptLanguage[$langSet]; + } + } + + if (preg_match('/^([a-z0-9\-_]{2,10})$/i', $langSet, $matches)) { + $langSet = strtolower($matches[1]); + } else { + $langSet = self::$range; + } + + // 合法的语言 + if (empty(self::$allowLangList) || in_array($langSet, self::$allowLangList)) { + self::$range = $langSet ?: self::$range; + } + + return self::$range; + } + + /** + * 设置语言自动侦测的变量 + * @access public + * @param string $var 变量名称 + * @return void + */ + public static function setLangDetectVar($var) + { + self::$langDetectVar = $var; + } + + /** + * 设置语言的 cookie 保存变量 + * @access public + * @param string $var 变量名称 + * @return void + */ + public static function setLangCookieVar($var) + { + self::$langCookieVar = $var; + } + + /** + * 设置语言的 cookie 的过期时间 + * @access public + * @param string $expire 过期时间 + * @return void + */ + public static function setLangCookieExpire($expire) + { + self::$langCookieExpire = $expire; + } + + /** + * 设置允许的语言列表 + * @access public + * @param array $list 语言列表 + * @return void + */ + public static function setAllowLangList($list) + { + self::$allowLangList = $list; + } +} diff --git a/thinkphp/library/think/Loader.php b/thinkphp/library/think/Loader.php new file mode 100644 index 0000000..283a280 --- /dev/null +++ b/thinkphp/library/think/Loader.php @@ -0,0 +1,677 @@ + +// +---------------------------------------------------------------------- + +namespace think; + +use think\exception\ClassNotFoundException; + +class Loader +{ + /** + * @var array 实例数组 + */ + protected static $instance = []; + + /** + * @var array 类名映射 + */ + protected static $classMap = []; + + /** + * @var array 命名空间别名 + */ + protected static $namespaceAlias = []; + + /** + * @var array PSR-4 命名空间前缀长度映射 + */ + private static $prefixLengthsPsr4 = []; + + /** + * @var array PSR-4 的加载目录 + */ + private static $prefixDirsPsr4 = []; + + /** + * @var array PSR-4 加载失败的回退目录 + */ + private static $fallbackDirsPsr4 = []; + + /** + * @var array PSR-0 命名空间前缀映射 + */ + private static $prefixesPsr0 = []; + + /** + * @var array PSR-0 加载失败的回退目录 + */ + private static $fallbackDirsPsr0 = []; + + /** + * @var array 需要加载的文件 + */ + private static $files = []; + + /** + * 自动加载 + * @access public + * @param string $class 类名 + * @return bool + */ + public static function autoload($class) + { + // 检测命名空间别名 + if (!empty(self::$namespaceAlias)) { + $namespace = dirname($class); + if (isset(self::$namespaceAlias[$namespace])) { + $original = self::$namespaceAlias[$namespace] . '\\' . basename($class); + if (class_exists($original)) { + return class_alias($original, $class, false); + } + } + } + + if ($file = self::findFile($class)) { + // 非 Win 环境不严格区分大小写 + if (!IS_WIN || pathinfo($file, PATHINFO_FILENAME) == pathinfo(realpath($file), PATHINFO_FILENAME)) { + __include_file($file); + return true; + } + } + + return false; + } + + /** + * 查找文件 + * @access private + * @param string $class 类名 + * @return bool|string + */ + private static function findFile($class) + { + // 类库映射 + if (!empty(self::$classMap[$class])) { + return self::$classMap[$class]; + } + + // 查找 PSR-4 + $logicalPathPsr4 = strtr($class, '\\', DS) . EXT; + $first = $class[0]; + + if (isset(self::$prefixLengthsPsr4[$first])) { + foreach (self::$prefixLengthsPsr4[$first] as $prefix => $length) { + if (0 === strpos($class, $prefix)) { + foreach (self::$prefixDirsPsr4[$prefix] as $dir) { + if (is_file($file = $dir . DS . substr($logicalPathPsr4, $length))) { + return $file; + } + } + } + } + } + + // 查找 PSR-4 fallback dirs + foreach (self::$fallbackDirsPsr4 as $dir) { + if (is_file($file = $dir . DS . $logicalPathPsr4)) { + return $file; + } + } + + // 查找 PSR-0 + if (false !== $pos = strrpos($class, '\\')) { + // namespace class name + $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1) + . strtr(substr($logicalPathPsr4, $pos + 1), '_', DS); + } else { + // PEAR-like class name + $logicalPathPsr0 = strtr($class, '_', DS) . EXT; + } + + if (isset(self::$prefixesPsr0[$first])) { + foreach (self::$prefixesPsr0[$first] as $prefix => $dirs) { + if (0 === strpos($class, $prefix)) { + foreach ($dirs as $dir) { + if (is_file($file = $dir . DS . $logicalPathPsr0)) { + return $file; + } + } + } + } + } + + // 查找 PSR-0 fallback dirs + foreach (self::$fallbackDirsPsr0 as $dir) { + if (is_file($file = $dir . DS . $logicalPathPsr0)) { + return $file; + } + } + + // 找不到则设置映射为 false 并返回 + return self::$classMap[$class] = false; + } + + /** + * 注册 classmap + * @access public + * @param string|array $class 类名 + * @param string $map 映射 + * @return void + */ + public static function addClassMap($class, $map = '') + { + if (is_array($class)) { + self::$classMap = array_merge(self::$classMap, $class); + } else { + self::$classMap[$class] = $map; + } + } + + /** + * 注册命名空间 + * @access public + * @param string|array $namespace 命名空间 + * @param string $path 路径 + * @return void + */ + public static function addNamespace($namespace, $path = '') + { + if (is_array($namespace)) { + foreach ($namespace as $prefix => $paths) { + self::addPsr4($prefix . '\\', rtrim($paths, DS), true); + } + } else { + self::addPsr4($namespace . '\\', rtrim($path, DS), true); + } + } + + /** + * 添加 PSR-0 命名空间 + * @access private + * @param array|string $prefix 空间前缀 + * @param array $paths 路径 + * @param bool $prepend 预先设置的优先级更高 + * @return void + */ + private static function addPsr0($prefix, $paths, $prepend = false) + { + if (!$prefix) { + self::$fallbackDirsPsr0 = $prepend ? + array_merge((array) $paths, self::$fallbackDirsPsr0) : + array_merge(self::$fallbackDirsPsr0, (array) $paths); + } else { + $first = $prefix[0]; + + if (!isset(self::$prefixesPsr0[$first][$prefix])) { + self::$prefixesPsr0[$first][$prefix] = (array) $paths; + } else { + self::$prefixesPsr0[$first][$prefix] = $prepend ? + array_merge((array) $paths, self::$prefixesPsr0[$first][$prefix]) : + array_merge(self::$prefixesPsr0[$first][$prefix], (array) $paths); + } + } + } + + /** + * 添加 PSR-4 空间 + * @access private + * @param array|string $prefix 空间前缀 + * @param string $paths 路径 + * @param bool $prepend 预先设置的优先级更高 + * @return void + */ + private static function addPsr4($prefix, $paths, $prepend = false) + { + if (!$prefix) { + // Register directories for the root namespace. + self::$fallbackDirsPsr4 = $prepend ? + array_merge((array) $paths, self::$fallbackDirsPsr4) : + array_merge(self::$fallbackDirsPsr4, (array) $paths); + + } elseif (!isset(self::$prefixDirsPsr4[$prefix])) { + // Register directories for a new namespace. + $length = strlen($prefix); + if ('\\' !== $prefix[$length - 1]) { + throw new \InvalidArgumentException( + "A non-empty PSR-4 prefix must end with a namespace separator." + ); + } + + self::$prefixLengthsPsr4[$prefix[0]][$prefix] = $length; + self::$prefixDirsPsr4[$prefix] = (array) $paths; + + } else { + self::$prefixDirsPsr4[$prefix] = $prepend ? + // Prepend directories for an already registered namespace. + array_merge((array) $paths, self::$prefixDirsPsr4[$prefix]) : + // Append directories for an already registered namespace. + array_merge(self::$prefixDirsPsr4[$prefix], (array) $paths); + } + } + + /** + * 注册命名空间别名 + * @access public + * @param array|string $namespace 命名空间 + * @param string $original 源文件 + * @return void + */ + public static function addNamespaceAlias($namespace, $original = '') + { + if (is_array($namespace)) { + self::$namespaceAlias = array_merge(self::$namespaceAlias, $namespace); + } else { + self::$namespaceAlias[$namespace] = $original; + } + } + + /** + * 注册自动加载机制 + * @access public + * @param callable $autoload 自动加载处理方法 + * @return void + */ + public static function register($autoload = null) + { + // 注册系统自动加载 + spl_autoload_register($autoload ?: 'think\\Loader::autoload', true, true); + + // Composer 自动加载支持 + if (is_dir(VENDOR_PATH . 'composer')) { + if (PHP_VERSION_ID >= 50600 && is_file(VENDOR_PATH . 'composer' . DS . 'autoload_static.php')) { + require VENDOR_PATH . 'composer' . DS . 'autoload_static.php'; + + $declaredClass = get_declared_classes(); + $composerClass = array_pop($declaredClass); + + foreach (['prefixLengthsPsr4', 'prefixDirsPsr4', 'fallbackDirsPsr4', 'prefixesPsr0', 'fallbackDirsPsr0', 'classMap', 'files'] as $attr) { + if (property_exists($composerClass, $attr)) { + self::${$attr} = $composerClass::${$attr}; + } + } + } else { + self::registerComposerLoader(); + } + } + + // 注册命名空间定义 + self::addNamespace([ + 'think' => LIB_PATH . 'think' . DS, + 'behavior' => LIB_PATH . 'behavior' . DS, + 'traits' => LIB_PATH . 'traits' . DS, + ]); + + // 加载类库映射文件 + if (is_file(RUNTIME_PATH . 'classmap' . EXT)) { + self::addClassMap(__include_file(RUNTIME_PATH . 'classmap' . EXT)); + } + + self::loadComposerAutoloadFiles(); + + // 自动加载 extend 目录 + self::$fallbackDirsPsr4[] = rtrim(EXTEND_PATH, DS); + } + + /** + * 注册 composer 自动加载 + * @access private + * @return void + */ + private static function registerComposerLoader() + { + if (is_file(VENDOR_PATH . 'composer/autoload_namespaces.php')) { + $map = require VENDOR_PATH . 'composer/autoload_namespaces.php'; + foreach ($map as $namespace => $path) { + self::addPsr0($namespace, $path); + } + } + + if (is_file(VENDOR_PATH . 'composer/autoload_psr4.php')) { + $map = require VENDOR_PATH . 'composer/autoload_psr4.php'; + foreach ($map as $namespace => $path) { + self::addPsr4($namespace, $path); + } + } + + if (is_file(VENDOR_PATH . 'composer/autoload_classmap.php')) { + $classMap = require VENDOR_PATH . 'composer/autoload_classmap.php'; + if ($classMap) { + self::addClassMap($classMap); + } + } + + if (is_file(VENDOR_PATH . 'composer/autoload_files.php')) { + self::$files = require VENDOR_PATH . 'composer/autoload_files.php'; + } + } + + // 加载composer autofile文件 + public static function loadComposerAutoloadFiles() + { + foreach (self::$files as $fileIdentifier => $file) { + if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { + __require_file($file); + + $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true; + } + } + } + + /** + * 导入所需的类库 同 Java 的 Import 本函数有缓存功能 + * @access public + * @param string $class 类库命名空间字符串 + * @param string $baseUrl 起始路径 + * @param string $ext 导入的文件扩展名 + * @return bool + */ + public static function import($class, $baseUrl = '', $ext = EXT) + { + static $_file = []; + $key = $class . $baseUrl; + $class = str_replace(['.', '#'], [DS, '.'], $class); + + if (isset($_file[$key])) { + return true; + } + + if (empty($baseUrl)) { + list($name, $class) = explode(DS, $class, 2); + + if (isset(self::$prefixDirsPsr4[$name . '\\'])) { + // 注册的命名空间 + $baseUrl = self::$prefixDirsPsr4[$name . '\\']; + } elseif ('@' == $name) { + // 加载当前模块应用类库 + $baseUrl = App::$modulePath; + } elseif (is_dir(EXTEND_PATH . $name)) { + $baseUrl = EXTEND_PATH . $name . DS; + } else { + // 加载其它模块的类库 + $baseUrl = APP_PATH . $name . DS; + } + } elseif (substr($baseUrl, -1) != DS) { + $baseUrl .= DS; + } + + // 如果类存在则导入类库文件 + if (is_array($baseUrl)) { + foreach ($baseUrl as $path) { + if (is_file($filename = $path . DS . $class . $ext)) { + break; + } + } + } else { + $filename = $baseUrl . $class . $ext; + } + + if (!empty($filename) && + is_file($filename) && + (!IS_WIN || pathinfo($filename, PATHINFO_FILENAME) == pathinfo(realpath($filename), PATHINFO_FILENAME)) + ) { + __include_file($filename); + $_file[$key] = true; + + return true; + } + + return false; + } + + /** + * 实例化(分层)模型 + * @access public + * @param string $name Model名称 + * @param string $layer 业务层名称 + * @param bool $appendSuffix 是否添加类名后缀 + * @param string $common 公共模块名 + * @return object + * @throws ClassNotFoundException + */ + public static function model($name = '', $layer = 'model', $appendSuffix = false, $common = 'common') + { + $uid = $name . $layer; + + if (isset(self::$instance[$uid])) { + return self::$instance[$uid]; + } + + list($module, $class) = self::getModuleAndClass($name, $layer, $appendSuffix); + + if (class_exists($class)) { + $model = new $class(); + } else { + $class = str_replace('\\' . $module . '\\', '\\' . $common . '\\', $class); + + if (class_exists($class)) { + $model = new $class(); + } else { + throw new ClassNotFoundException('class not exists:' . $class, $class); + } + } + + return self::$instance[$uid] = $model; + } + + /** + * 实例化(分层)控制器 格式:[模块名/]控制器名 + * @access public + * @param string $name 资源地址 + * @param string $layer 控制层名称 + * @param bool $appendSuffix 是否添加类名后缀 + * @param string $empty 空控制器名称 + * @return object + * @throws ClassNotFoundException + */ + public static function controller($name, $layer = 'controller', $appendSuffix = false, $empty = '') + { + list($module, $class) = self::getModuleAndClass($name, $layer, $appendSuffix); + + if (class_exists($class)) { + return App::invokeClass($class); + } + + if ($empty) { + $emptyClass = self::parseClass($module, $layer, $empty, $appendSuffix); + + if (class_exists($emptyClass)) { + return new $emptyClass(Request::instance()); + } + } + + throw new ClassNotFoundException('class not exists:' . $class, $class); + } + + /** + * 实例化验证类 格式:[模块名/]验证器名 + * @access public + * @param string $name 资源地址 + * @param string $layer 验证层名称 + * @param bool $appendSuffix 是否添加类名后缀 + * @param string $common 公共模块名 + * @return object|false + * @throws ClassNotFoundException + */ + public static function validate($name = '', $layer = 'validate', $appendSuffix = false, $common = 'common') + { + $name = $name ?: Config::get('default_validate'); + + if (empty($name)) { + return new Validate; + } + + $uid = $name . $layer; + if (isset(self::$instance[$uid])) { + return self::$instance[$uid]; + } + + list($module, $class) = self::getModuleAndClass($name, $layer, $appendSuffix); + + if (class_exists($class)) { + $validate = new $class; + } else { + $class = str_replace('\\' . $module . '\\', '\\' . $common . '\\', $class); + + if (class_exists($class)) { + $validate = new $class; + } else { + throw new ClassNotFoundException('class not exists:' . $class, $class); + } + } + + return self::$instance[$uid] = $validate; + } + + /** + * 解析模块和类名 + * @access protected + * @param string $name 资源地址 + * @param string $layer 验证层名称 + * @param bool $appendSuffix 是否添加类名后缀 + * @return array + */ + protected static function getModuleAndClass($name, $layer, $appendSuffix) + { + if (false !== strpos($name, '\\')) { + $module = Request::instance()->module(); + $class = $name; + } else { + if (strpos($name, '/')) { + list($module, $name) = explode('/', $name, 2); + } else { + $module = Request::instance()->module(); + } + + $class = self::parseClass($module, $layer, $name, $appendSuffix); + } + + return [$module, $class]; + } + + /** + * 数据库初始化 并取得数据库类实例 + * @access public + * @param mixed $config 数据库配置 + * @param bool|string $name 连接标识 true 强制重新连接 + * @return \think\db\Connection + */ + public static function db($config = [], $name = false) + { + return Db::connect($config, $name); + } + + /** + * 远程调用模块的操作方法 参数格式 [模块/控制器/]操作 + * @access public + * @param string $url 调用地址 + * @param string|array $vars 调用参数 支持字符串和数组 + * @param string $layer 要调用的控制层名称 + * @param bool $appendSuffix 是否添加类名后缀 + * @return mixed + */ + public static function action($url, $vars = [], $layer = 'controller', $appendSuffix = false) + { + $info = pathinfo($url); + $action = $info['basename']; + $module = '.' != $info['dirname'] ? $info['dirname'] : Request::instance()->controller(); + $class = self::controller($module, $layer, $appendSuffix); + + if ($class) { + if (is_scalar($vars)) { + if (strpos($vars, '=')) { + parse_str($vars, $vars); + } else { + $vars = [$vars]; + } + } + + return App::invokeMethod([$class, $action . Config::get('action_suffix')], $vars); + } + + return false; + } + + /** + * 字符串命名风格转换 + * type 0 将 Java 风格转换为 C 的风格 1 将 C 风格转换为 Java 的风格 + * @access public + * @param string $name 字符串 + * @param integer $type 转换类型 + * @param bool $ucfirst 首字母是否大写(驼峰规则) + * @return string + */ + public static function parseName($name, $type = 0, $ucfirst = true) + { + if ($type) { + $name = preg_replace_callback('/_([a-zA-Z])/', function ($match) { + return strtoupper($match[1]); + }, $name ?? ''); + + return $ucfirst ? ucfirst($name) : lcfirst($name); + } + + return strtolower(trim(preg_replace("/[A-Z]/", "_\\0", $name), "_")); + } + + /** + * 解析应用类的类名 + * @access public + * @param string $module 模块名 + * @param string $layer 层名 controller model ... + * @param string $name 类名 + * @param bool $appendSuffix 是否添加类名后缀 + * @return string + */ + public static function parseClass($module, $layer, $name, $appendSuffix = false) + { + + $array = explode('\\', str_replace(['/', '.'], '\\', $name)); + $class = self::parseName(array_pop($array), 1); + $class = $class . (App::$suffix || $appendSuffix ? ucfirst($layer) : ''); + $path = $array ? implode('\\', $array) . '\\' : ''; + + return App::$namespace . '\\' . + ($module ? $module . '\\' : '') . + $layer . '\\' . $path . $class; + } + + /** + * 初始化类的实例 + * @access public + * @return void + */ + public static function clearInstance() + { + self::$instance = []; + } +} + +// 作用范围隔离 + +/** + * include + * @param string $file 文件路径 + * @return mixed + */ +function __include_file($file) +{ + return include $file; +} + +/** + * require + * @param string $file 文件路径 + * @return mixed + */ +function __require_file($file) +{ + return require $file; +} diff --git a/thinkphp/library/think/Log.php b/thinkphp/library/think/Log.php new file mode 100644 index 0000000..a84eda8 --- /dev/null +++ b/thinkphp/library/think/Log.php @@ -0,0 +1,237 @@ + +// +---------------------------------------------------------------------- + +namespace think; + +use think\exception\ClassNotFoundException; + +/** + * Class Log + * @package think + * + * @method static void log($msg) 记录一般日志 + * @method static void error($msg) 记录错误日志 + * @method static void info($msg) 记录一般信息日志 + * @method static void sql($msg) 记录 SQL 查询日志 + * @method static void notice($msg) 记录提示日志 + * @method static void alert($msg) 记录报警日志 + */ +class Log +{ + const LOG = 'log'; + const ERROR = 'error'; + const INFO = 'info'; + const SQL = 'sql'; + const NOTICE = 'notice'; + const ALERT = 'alert'; + const DEBUG = 'debug'; + + /** + * @var array 日志信息 + */ + protected static $log = []; + + /** + * @var array 配置参数 + */ + protected static $config = []; + + /** + * @var array 日志类型 + */ + protected static $type = ['log', 'error', 'info', 'sql', 'notice', 'alert', 'debug']; + + /** + * @var log\driver\File|log\driver\Test|log\driver\Socket 日志写入驱动 + */ + protected static $driver; + + /** + * @var string 当前日志授权 key + */ + protected static $key; + + /** + * 日志初始化 + * @access public + * @param array $config 配置参数 + * @return void + */ + public static function init($config = []) + { + $type = isset($config['type']) ? $config['type'] : 'File'; + $class = false !== strpos($type, '\\') ? $type : '\\think\\log\\driver\\' . ucwords($type); + + self::$config = $config; + unset($config['type']); + + if (class_exists($class)) { + self::$driver = new $class($config); + } else { + throw new ClassNotFoundException('class not exists:' . $class, $class); + } + + // 记录初始化信息 + App::$debug && Log::record('[ LOG ] INIT ' . $type, 'info'); + } + + /** + * 获取日志信息 + * @access public + * @param string $type 信息类型 + * @return array|string + */ + public static function getLog($type = '') + { + return $type ? self::$log[$type] : self::$log; + } + + /** + * 记录调试信息 + * @access public + * @param mixed $msg 调试信息 + * @param string $type 信息类型 + * @return void + */ + public static function record($msg, $type = 'log') + { + self::$log[$type][] = $msg; + + // 命令行下面日志写入改进 + IS_CLI && self::save(); + } + + /** + * 清空日志信息 + * @access public + * @return void + */ + public static function clear() + { + self::$log = []; + } + + /** + * 设置当前日志记录的授权 key + * @access public + * @param string $key 授权 key + * @return void + */ + public static function key($key) + { + self::$key = $key; + } + + /** + * 检查日志写入权限 + * @access public + * @param array $config 当前日志配置参数 + * @return bool + */ + public static function check($config) + { + return !self::$key || empty($config['allow_key']) || in_array(self::$key, $config['allow_key']); + } + + /** + * 保存调试信息 + * @access public + * @return bool + */ + public static function save() + { + // 没有需要保存的记录则直接返回 + if (empty(self::$log)) { + return true; + } + + is_null(self::$driver) && self::init(Config::get('log')); + + // 检测日志写入权限 + if (!self::check(self::$config)) { + return false; + } + + if (empty(self::$config['level'])) { + // 获取全部日志 + $log = self::$log; + if (!App::$debug && isset($log['debug'])) { + unset($log['debug']); + } + } else { + // 记录允许级别 + $log = []; + foreach (self::$config['level'] as $level) { + if (isset(self::$log[$level])) { + $log[$level] = self::$log[$level]; + } + } + } + + if ($result = self::$driver->save($log, true)) { + self::$log = []; + } + + Hook::listen('log_write_done', $log); + + return $result; + } + + /** + * 实时写入日志信息 并支持行为 + * @access public + * @param mixed $msg 调试信息 + * @param string $type 信息类型 + * @param bool $force 是否强制写入 + * @return bool + */ + public static function write($msg, $type = 'log', $force = false) + { + $log = self::$log; + + // 如果不是强制写入,而且信息类型不在可记录的类别中则直接返回 false 不做记录 + if (true !== $force && !empty(self::$config['level']) && !in_array($type, self::$config['level'])) { + return false; + } + + // 封装日志信息 + $log[$type][] = $msg; + + // 监听 log_write + Hook::listen('log_write', $log); + + is_null(self::$driver) && self::init(Config::get('log')); + + // 写入日志 + if ($result = self::$driver->save($log, false)) { + self::$log = []; + } + + return $result; + } + + /** + * 静态方法调用 + * @access public + * @param string $method 调用方法 + * @param mixed $args 参数 + * @return void + */ + public static function __callStatic($method, $args) + { + if (in_array($method, self::$type)) { + array_push($args, $method); + + call_user_func_array('\\think\\Log::record', $args); + } + } + +} diff --git a/thinkphp/library/think/Model.php b/thinkphp/library/think/Model.php new file mode 100644 index 0000000..92aca5b --- /dev/null +++ b/thinkphp/library/think/Model.php @@ -0,0 +1,2363 @@ + +// +---------------------------------------------------------------------- + +namespace think; + +use BadMethodCallException; +use InvalidArgumentException; +use think\db\Query; +use think\exception\ValidateException; +use think\model\Collection as ModelCollection; +use think\model\Relation; +use think\model\relation\BelongsTo; +use think\model\relation\BelongsToMany; +use think\model\relation\HasMany; +use think\model\relation\HasManyThrough; +use think\model\relation\HasOne; +use think\model\relation\MorphMany; +use think\model\relation\MorphOne; +use think\model\relation\MorphTo; + +/** + * Class Model + * @package think + * @mixin Query + */ +abstract class Model implements \JsonSerializable, \ArrayAccess +{ + // 数据库查询对象池 + protected static $links = []; + // 数据库配置 + protected $connection = []; + // 父关联模型对象 + protected $parent; + // 数据库查询对象 + protected $query; + // 当前模型名称 + protected $name; + // 数据表名称 + protected $table; + // 当前类名称 + protected $class; + // 回调事件 + private static $event = []; + // 错误信息 + protected $error; + // 字段验证规则 + protected $validate; + // 数据表主键 复合主键使用数组定义 不设置则自动获取 + protected $pk; + // 数据表字段信息 留空则自动获取 + protected $field = []; + // 数据排除字段 + protected $except = []; + // 数据废弃字段 + protected $disuse = []; + // 只读字段 + protected $readonly = []; + // 显示属性 + protected $visible = []; + // 隐藏属性 + protected $hidden = []; + // 追加属性 + protected $append = []; + // 数据信息 + protected $data = []; + // 原始数据 + protected $origin = []; + // 关联模型 + protected $relation = []; + + // 保存自动完成列表 + protected $auto = []; + // 新增自动完成列表 + protected $insert = []; + // 更新自动完成列表 + protected $update = []; + // 是否需要自动写入时间戳 如果设置为字符串 则表示时间字段的类型 + protected $autoWriteTimestamp; + // 创建时间字段 + protected $createTime = 'create_time'; + // 更新时间字段 + protected $updateTime = 'update_time'; + // 时间字段取出后的默认时间格式 + protected $dateFormat; + // 字段类型或者格式转换 + protected $type = []; + // 是否为更新数据 + protected $isUpdate = false; + // 是否使用Replace + protected $replace = false; + // 是否强制更新所有数据 + protected $force = false; + // 更新条件 + protected $updateWhere; + // 验证失败是否抛出异常 + protected $failException = false; + // 全局查询范围 + protected $useGlobalScope = true; + // 是否采用批量验证 + protected $batchValidate = false; + // 查询数据集对象 + protected $resultSetType; + // 关联自动写入 + protected $relationWrite; + + /** + * 初始化过的模型. + * + * @var array + */ + protected static $initialized = []; + + /** + * 是否从主库读取(主从分布式有效) + * @var array + */ + protected static $readMaster; + + /** + * 构造方法 + * @access public + * @param array|object $data 数据 + */ + public function __construct($data = []) + { + if (is_object($data)) { + $this->data = get_object_vars($data); + } else { + $this->data = $data; + } + + if ($this->disuse) { + // 废弃字段 + foreach ((array) $this->disuse as $key) { + if (array_key_exists($key, $this->data)) { + unset($this->data[$key]); + } + } + } + + // 记录原始数据 + $this->origin = $this->data; + + // 当前类名 + $this->class = get_called_class(); + + if (empty($this->name)) { + // 当前模型名 + $name = str_replace('\\', '/', $this->class); + $this->name = basename($name); + if (Config::get('class_suffix')) { + $suffix = basename(dirname($name)); + $this->name = substr($this->name, 0, -strlen($suffix)); + } + } + + if (is_null($this->autoWriteTimestamp)) { + // 自动写入时间戳 + $this->autoWriteTimestamp = $this->getQuery()->getConfig('auto_timestamp'); + } + + if (is_null($this->dateFormat)) { + // 设置时间戳格式 + $this->dateFormat = $this->getQuery()->getConfig('datetime_format'); + } + + if (is_null($this->resultSetType)) { + $this->resultSetType = $this->getQuery()->getConfig('resultset_type'); + } + // 执行初始化操作 + $this->initialize(); + } + + /** + * 是否从主库读取数据(主从分布有效) + * @access public + * @param bool $all 是否所有模型生效 + * @return $this + */ + public function readMaster($all = false) + { + $model = $all ? '*' : $this->class; + + static::$readMaster[$model] = true; + return $this; + } + + /** + * 创建模型的查询对象 + * @access protected + * @return Query + */ + protected function buildQuery() + { + // 合并数据库配置 + if (!empty($this->connection)) { + if (is_array($this->connection)) { + $connection = array_merge(Config::get('database'), $this->connection); + } else { + $connection = $this->connection; + } + } else { + $connection = []; + } + + $con = Db::connect($connection); + // 设置当前模型 确保查询返回模型对象 + $queryClass = $this->query ?: $con->getConfig('query'); + $query = new $queryClass($con, $this); + + if (isset(static::$readMaster['*']) || isset(static::$readMaster[$this->class])) { + $query->master(true); + } + + // 设置当前数据表和模型名 + if (!empty($this->table)) { + $query->setTable($this->table); + } else { + $query->name($this->name); + } + + if (!empty($this->pk)) { + $query->pk($this->pk); + } + + return $query; + } + + /** + * 创建新的模型实例 + * @access public + * @param array|object $data 数据 + * @param bool $isUpdate 是否为更新 + * @param mixed $where 更新条件 + * @return Model + */ + public function newInstance($data = [], $isUpdate = false, $where = null) + { + return (new static($data))->isUpdate($isUpdate, $where); + } + + /** + * 获取当前模型的查询对象 + * @access public + * @param bool $buildNewQuery 创建新的查询对象 + * @return Query + */ + public function getQuery($buildNewQuery = false) + { + if ($buildNewQuery) { + return $this->buildQuery(); + } elseif (!isset(self::$links[$this->class])) { + // 创建模型查询对象 + self::$links[$this->class] = $this->buildQuery(); + } + + return self::$links[$this->class]; + } + + /** + * 获取当前模型的数据库查询对象 + * @access public + * @param bool $useBaseQuery 是否调用全局查询范围 + * @param bool $buildNewQuery 创建新的查询对象 + * @return Query + */ + public function db($useBaseQuery = true, $buildNewQuery = true) + { + $query = $this->getQuery($buildNewQuery); + + // 全局作用域 + if ($useBaseQuery && method_exists($this, 'base')) { + call_user_func_array([$this, 'base'], [ & $query]); + } + + // 返回当前模型的数据库查询对象 + return $query; + } + + /** + * 初始化模型 + * @access protected + * @return void + */ + protected function initialize() + { + $class = get_class($this); + if (!isset(static::$initialized[$class])) { + static::$initialized[$class] = true; + static::init(); + } + } + + /** + * 初始化处理 + * @access protected + * @return void + */ + protected static function init() + { + } + + /** + * 设置父关联对象 + * @access public + * @param Model $model 模型对象 + * @return $this + */ + public function setParent($model) + { + $this->parent = $model; + return $this; + } + + /** + * 获取父关联对象 + * @access public + * @return Model + */ + public function getParent() + { + return $this->parent; + } + + /** + * 设置数据对象值 + * @access public + * @param mixed $data 数据或者属性名 + * @param mixed $value 值 + * @return $this + */ + public function data($data, $value = null) + { + if (is_string($data)) { + $this->data[$data] = $value; + } else { + // 清空数据 + $this->data = []; + if (is_object($data)) { + $data = get_object_vars($data); + } + if (true === $value) { + // 数据对象赋值 + foreach ($data as $key => $value) { + $this->setAttr($key, $value, $data); + } + } else { + $this->data = $data; + } + } + return $this; + } + + /** + * 获取对象原始数据 如果不存在指定字段返回false + * @access public + * @param string $name 字段名 留空获取全部 + * @return mixed + * @throws InvalidArgumentException + */ + public function getData($name = null) + { + if (is_null($name)) { + return $this->data; + } elseif (array_key_exists($name, $this->data)) { + return $this->data[$name]; + } elseif (array_key_exists($name, $this->relation)) { + return $this->relation[$name]; + } else { + throw new InvalidArgumentException('property not exists:' . $this->class . '->' . $name); + } + } + + /** + * 是否需要自动写入时间字段 + * @access public + * @param bool $auto + * @return $this + */ + public function isAutoWriteTimestamp($auto) + { + $this->autoWriteTimestamp = $auto; + return $this; + } + + /** + * 更新是否强制写入数据 而不做比较 + * @access public + * @param bool $force + * @return $this + */ + public function force($force = true) + { + $this->force = $force; + return $this; + } + + /** + * 修改器 设置数据对象值 + * @access public + * @param string $name 属性名 + * @param mixed $value 属性值 + * @param array $data 数据 + * @return $this + */ + public function setAttr($name, $value, $data = []) + { + if (is_null($value) && $this->autoWriteTimestamp && in_array($name, [$this->createTime, $this->updateTime])) { + // 自动写入的时间戳字段 + $value = $this->autoWriteTimestamp($name); + } else { + // 检测修改器 + $method = 'set' . Loader::parseName($name, 1) . 'Attr'; + if (method_exists($this, $method)) { + $value = $this->$method($value, array_merge($this->data, $data), $this->relation); + } elseif (isset($this->type[$name])) { + // 类型转换 + $value = $this->writeTransform($value, $this->type[$name]); + } + } + + // 设置数据对象属性 + $this->data[$name] = $value; + return $this; + } + + /** + * 获取当前模型的关联模型数据 + * @access public + * @param string $name 关联方法名 + * @return mixed + */ + public function getRelation($name = null) + { + if (is_null($name)) { + return $this->relation; + } elseif (array_key_exists($name, $this->relation)) { + return $this->relation[$name]; + } else { + return; + } + } + + /** + * 设置关联数据对象值 + * @access public + * @param string $name 属性名 + * @param mixed $value 属性值 + * @return $this + */ + public function setRelation($name, $value) + { + $this->relation[$name] = $value; + return $this; + } + + /** + * 自动写入时间戳 + * @access public + * @param string $name 时间戳字段 + * @return mixed + */ + protected function autoWriteTimestamp($name) + { + if (isset($this->type[$name])) { + $type = $this->type[$name]; + if (strpos($type, ':')) { + list($type, $param) = explode(':', $type, 2); + } + switch ($type) { + case 'datetime': + case 'date': + $format = !empty($param) ? $param : $this->dateFormat; + $value = $this->formatDateTime(time(), $format); + break; + case 'timestamp': + case 'integer': + default: + $value = time(); + break; + } + } elseif (is_string($this->autoWriteTimestamp) && in_array(strtolower($this->autoWriteTimestamp), [ + 'datetime', + 'date', + 'timestamp', + ]) + ) { + $value = $this->formatDateTime(time(), $this->dateFormat); + } else { + $value = $this->formatDateTime(time(), $this->dateFormat, true); + } + return $value; + } + + /** + * 时间日期字段格式化处理 + * @access public + * @param mixed $time 时间日期表达式 + * @param mixed $format 日期格式 + * @param bool $timestamp 是否进行时间戳转换 + * @return mixed + */ + protected function formatDateTime($time, $format, $timestamp = false) + { + if (false !== strpos($format, '\\')) { + $time = new $format($time); + } elseif (!$timestamp && false !== $format) { + $time = date($format, $time); + } + return $time; + } + + /** + * 数据写入 类型转换 + * @access public + * @param mixed $value 值 + * @param string|array $type 要转换的类型 + * @return mixed + */ + protected function writeTransform($value, $type) + { + if (is_null($value)) { + return; + } + + if (is_array($type)) { + list($type, $param) = $type; + } elseif (strpos($type, ':')) { + list($type, $param) = explode(':', $type, 2); + } + switch ($type) { + case 'integer': + $value = (int) $value; + break; + case 'float': + if (empty($param)) { + $value = (float) $value; + } else { + $value = (float) number_format($value, $param, '.', ''); + } + break; + case 'boolean': + $value = (bool) $value; + break; + case 'timestamp': + if (!is_numeric($value)) { + $value = strtotime($value); + } + break; + case 'datetime': + $format = !empty($param) ? $param : $this->dateFormat; + $value = is_numeric($value) ? $value : strtotime($value); + $value = $this->formatDateTime($value, $format); + break; + case 'object': + if (is_object($value)) { + $value = json_encode($value, JSON_FORCE_OBJECT); + } + break; + case 'array': + $value = (array) $value; + case 'json': + $option = !empty($param) ? (int) $param : JSON_UNESCAPED_UNICODE; + $value = json_encode($value, $option); + break; + case 'serialize': + $value = serialize($value); + break; + + } + return $value; + } + + /** + * 获取器 获取数据对象的值 + * @access public + * @param string $name 名称 + * @return mixed + * @throws InvalidArgumentException + */ + public function getAttr($name) + { + try { + $notFound = false; + $value = $this->getData($name); + } catch (InvalidArgumentException $e) { + $notFound = true; + $value = null; + } + + // 检测属性获取器 + $method = 'get' . Loader::parseName($name, 1) . 'Attr'; + if (method_exists($this, $method)) { + $value = $this->$method($value, $this->data, $this->relation); + } elseif (isset($this->type[$name])) { + // 类型转换 + $value = $this->readTransform($value, $this->type[$name]); + } elseif (in_array($name, [$this->createTime, $this->updateTime])) { + if (is_string($this->autoWriteTimestamp) && in_array(strtolower($this->autoWriteTimestamp), [ + 'datetime', + 'date', + 'timestamp', + ]) + ) { + $value = $this->formatDateTime(strtotime($value), $this->dateFormat); + } else { + $value = $this->formatDateTime($value, $this->dateFormat); + } + } elseif ($notFound) { + $relation = Loader::parseName($name, 1, false); + if (method_exists($this, $relation)) { + $modelRelation = $this->$relation(); + // 不存在该字段 获取关联数据 + $value = $this->getRelationData($modelRelation); + // 保存关联对象值 + $this->relation[$name] = $value; + } else { + throw new InvalidArgumentException('property not exists:' . $this->class . '->' . $name); + } + } + return $value; + } + + /** + * 获取关联模型数据 + * @access public + * @param Relation $modelRelation 模型关联对象 + * @return mixed + * @throws BadMethodCallException + */ + protected function getRelationData(Relation $modelRelation) + { + if ($this->parent && !$modelRelation->isSelfRelation() && get_class($modelRelation->getModel()) == get_class($this->parent)) { + $value = $this->parent; + } else { + // 首先获取关联数据 + if (method_exists($modelRelation, 'getRelation')) { + $value = $modelRelation->getRelation(); + } else { + throw new BadMethodCallException('method not exists:' . get_class($modelRelation) . '-> getRelation'); + } + } + return $value; + } + + /** + * 数据读取 类型转换 + * @access public + * @param mixed $value 值 + * @param string|array $type 要转换的类型 + * @return mixed + */ + protected function readTransform($value, $type) + { + if (is_null($value)) { + return; + } + + if (is_array($type)) { + list($type, $param) = $type; + } elseif (strpos($type, ':')) { + list($type, $param) = explode(':', $type, 2); + } + switch ($type) { + case 'integer': + $value = (int) $value; + break; + case 'float': + if (empty($param)) { + $value = (float) $value; + } else { + $value = (float) number_format($value, $param, '.', ''); + } + break; + case 'boolean': + $value = (bool) $value; + break; + case 'timestamp': + if (!is_null($value)) { + $format = !empty($param) ? $param : $this->dateFormat; + $value = $this->formatDateTime($value, $format); + } + break; + case 'datetime': + if (!is_null($value)) { + $format = !empty($param) ? $param : $this->dateFormat; + $value = $this->formatDateTime(strtotime($value), $format); + } + break; + case 'json': + $value = json_decode($value, true); + break; + case 'array': + $value = empty($value) ? [] : json_decode($value, true); + break; + case 'object': + $value = empty($value) ? new \stdClass() : json_decode($value); + break; + case 'serialize': + try { + $value = unserialize($value); + } catch (\Exception $e) { + $value = null; + } + break; + default: + if (false !== strpos($type, '\\')) { + // 对象类型 + $value = new $type($value); + } + } + return $value; + } + + /** + * 设置需要追加的输出属性 + * @access public + * @param array $append 属性列表 + * @param bool $override 是否覆盖 + * @return $this + */ + public function append($append = [], $override = false) + { + $this->append = $override ? $append : array_merge($this->append, $append); + return $this; + } + + /** + * 设置附加关联对象的属性 + * @access public + * @param string $relation 关联方法 + * @param string|array $append 追加属性名 + * @return $this + * @throws Exception + */ + public function appendRelationAttr($relation, $append) + { + if (is_string($append)) { + $append = explode(',', $append); + } + + $relation = Loader::parseName($relation, 1, false); + + // 获取关联数据 + if (isset($this->relation[$relation])) { + $model = $this->relation[$relation]; + } else { + $model = $this->getRelationData($this->$relation()); + } + + if ($model instanceof Model) { + foreach ($append as $key => $attr) { + $key = is_numeric($key) ? $attr : $key; + if (isset($this->data[$key])) { + throw new Exception('bind attr has exists:' . $key); + } else { + $this->data[$key] = $model->getAttr($attr); + } + } + } + return $this; + } + + /** + * 设置需要隐藏的输出属性 + * @access public + * @param array $hidden 属性列表 + * @param bool $override 是否覆盖 + * @return $this + */ + public function hidden($hidden = [], $override = false) + { + $this->hidden = $override ? $hidden : array_merge($this->hidden, $hidden); + return $this; + } + + /** + * 设置需要输出的属性 + * @access public + * @param array $visible + * @param bool $override 是否覆盖 + * @return $this + */ + public function visible($visible = [], $override = false) + { + $this->visible = $override ? $visible : array_merge($this->visible, $visible); + return $this; + } + + /** + * 解析隐藏及显示属性 + * @access protected + * @param array $attrs 属性 + * @param array $result 结果集 + * @param bool $visible + * @return array + */ + protected function parseAttr($attrs, &$result, $visible = true) + { + $array = []; + foreach ($attrs as $key => $val) { + if (is_array($val)) { + if ($visible) { + $array[] = $key; + } + $result[$key] = $val; + } elseif (strpos($val, '.')) { + list($key, $name) = explode('.', $val); + if ($visible) { + $array[] = $key; + } + $result[$key][] = $name; + } else { + $array[] = $val; + } + } + return $array; + } + + /** + * 转换子模型对象 + * @access protected + * @param Model|ModelCollection $model + * @param $visible + * @param $hidden + * @param $key + * @return array + */ + protected function subToArray($model, $visible, $hidden, $key) + { + // 关联模型对象 + if (isset($visible[$key])) { + $model->visible($visible[$key]); + } elseif (isset($hidden[$key])) { + $model->hidden($hidden[$key]); + } + return $model->toArray(); + } + + /** + * 转换当前模型对象为数组 + * @access public + * @return array + */ + public function toArray() + { + $item = []; + $visible = []; + $hidden = []; + + $data = array_merge($this->data, $this->relation); + + // 过滤属性 + if (!empty($this->visible)) { + $array = $this->parseAttr($this->visible, $visible); + $data = array_intersect_key($data, array_flip($array)); + } elseif (!empty($this->hidden)) { + $array = $this->parseAttr($this->hidden, $hidden, false); + $data = array_diff_key($data, array_flip($array)); + } + + foreach ($data as $key => $val) { + if ($val instanceof Model || $val instanceof ModelCollection) { + // 关联模型对象 + $item[$key] = $this->subToArray($val, $visible, $hidden, $key); + } elseif (is_array($val) && reset($val) instanceof Model) { + // 关联模型数据集 + $arr = []; + foreach ($val as $k => $value) { + $arr[$k] = $this->subToArray($value, $visible, $hidden, $key); + } + $item[$key] = $arr; + } else { + // 模型属性 + $item[$key] = $this->getAttr($key); + } + } + // 追加属性(必须定义获取器) + if (!empty($this->append)) { + foreach ($this->append as $key => $name) { + if (is_array($name)) { + // 追加关联对象属性 + $relation = $this->getAttr($key); + $item[$key] = $relation->append($name)->toArray(); + } elseif (strpos($name, '.')) { + list($key, $attr) = explode('.', $name); + // 追加关联对象属性 + $relation = $this->getAttr($key); + $item[$key] = $relation->append([$attr])->toArray(); + } else { + $relation = Loader::parseName($name, 1, false); + if (method_exists($this, $relation)) { + $modelRelation = $this->$relation(); + $value = $this->getRelationData($modelRelation); + + if (method_exists($modelRelation, 'getBindAttr')) { + $bindAttr = $modelRelation->getBindAttr(); + if ($bindAttr) { + foreach ($bindAttr as $key => $attr) { + $key = is_numeric($key) ? $attr : $key; + if (isset($this->data[$key])) { + throw new Exception('bind attr has exists:' . $key); + } else { + $item[$key] = $value ? $value->getAttr($attr) : null; + } + } + continue; + } + } + $item[$name] = $value; + } else { + $item[$name] = $this->getAttr($name); + } + } + } + } + return !empty($item) ? $item : []; + } + + /** + * 转换当前模型对象为JSON字符串 + * @access public + * @param integer $options json参数 + * @return string + */ + public function toJson($options = JSON_UNESCAPED_UNICODE) + { + return json_encode($this->toArray(), $options); + } + + /** + * 移除当前模型的关联属性 + * @access public + * @return $this + */ + public function removeRelation() + { + $this->relation = []; + return $this; + } + + /** + * 转换当前模型数据集为数据集对象 + * @access public + * @param array|\think\Collection $collection 数据集 + * @return \think\Collection + */ + public function toCollection($collection) + { + if ($this->resultSetType) { + if ('collection' == $this->resultSetType) { + $collection = new ModelCollection($collection); + } elseif (false !== strpos($this->resultSetType, '\\')) { + $class = $this->resultSetType; + $collection = new $class($collection); + } + } + return $collection; + } + + /** + * 关联数据一起更新 + * @access public + * @param mixed $relation 关联 + * @return $this + */ + public function together($relation) + { + if (is_string($relation)) { + $relation = explode(',', $relation); + } + $this->relationWrite = $relation; + return $this; + } + + /** + * 获取模型对象的主键 + * @access public + * @param string $name 模型名 + * @return mixed + */ + public function getPk($name = '') + { + if (!empty($name)) { + $table = $this->getQuery()->getTable($name); + return $this->getQuery()->getPk($table); + } elseif (empty($this->pk)) { + $this->pk = $this->getQuery()->getPk(); + } + return $this->pk; + } + + /** + * 判断一个字段名是否为主键字段 + * @access public + * @param string $key 名称 + * @return bool + */ + protected function isPk($key) + { + $pk = $this->getPk(); + if (is_string($pk) && $pk == $key) { + return true; + } elseif (is_array($pk) && in_array($key, $pk)) { + return true; + } + return false; + } + + /** + * 新增数据是否使用Replace + * @access public + * @param bool $replace + * @return $this + */ + public function replace($replace = true) + { + $this->replace = $replace; + return $this; + } + + /** + * 保存当前数据对象 + * @access public + * @param array $data 数据 + * @param array $where 更新条件 + * @param string $sequence 自增序列名 + * @return integer|false + */ + public function save($data = [], $where = [], $sequence = null) + { + if (is_string($data)) { + $sequence = $data; + $data = []; + } + + // 数据自动验证 + if (!empty($data)) { + if (!$this->validateData($data)) { + return false; + } + + // 数据对象赋值 + foreach ($data as $key => $value) { + $this->setAttr($key, $value, $data); + } + } + + if (!empty($where)) { + $this->isUpdate = true; + $this->updateWhere = $where; + } + + // 自动关联写入 + if (!empty($this->relationWrite)) { + $relation = []; + foreach ($this->relationWrite as $key => $name) { + if (is_array($name)) { + if (key($name) === 0) { + $relation[$key] = []; + foreach ($name as $val) { + if (isset($this->data[$val])) { + $relation[$key][$val] = $this->data[$val]; + unset($this->data[$val]); + } + } + } else { + $relation[$key] = $name; + } + } elseif (isset($this->relation[$name])) { + $relation[$name] = $this->relation[$name]; + } elseif (isset($this->data[$name])) { + $relation[$name] = $this->data[$name]; + unset($this->data[$name]); + } + } + } + + // 数据自动完成 + $this->autoCompleteData($this->auto); + + // 事件回调 + if (false === $this->trigger('before_write', $this)) { + return false; + } + $pk = $this->getPk(); + if ($this->isUpdate) { + // 自动更新 + $this->autoCompleteData($this->update); + + // 事件回调 + if (false === $this->trigger('before_update', $this)) { + return false; + } + + // 获取有更新的数据 + $data = $this->getChangedData(); + + if (empty($data) || (count($data) == 1 && is_string($pk) && isset($data[$pk]))) { + // 关联更新 + if (isset($relation)) { + $this->autoRelationUpdate($relation); + } + return 0; + } elseif ($this->autoWriteTimestamp && $this->updateTime && !isset($data[$this->updateTime])) { + // 自动写入更新时间 + $data[$this->updateTime] = $this->autoWriteTimestamp($this->updateTime); + $this->data[$this->updateTime] = $data[$this->updateTime]; + } + + if (empty($where) && !empty($this->updateWhere)) { + $where = $this->updateWhere; + } + + // 保留主键数据 + foreach ($this->data as $key => $val) { + if ($this->isPk($key)) { + $data[$key] = $val; + } + } + + $array = []; + + foreach ((array) $pk as $key) { + if (isset($data[$key])) { + $array[$key] = $data[$key]; + unset($data[$key]); + } + } + + if (!empty($array)) { + $where = $array; + } + + // 检测字段 + $allowFields = $this->checkAllowField(array_merge($this->auto, $this->update)); + + // 模型更新 + if (!empty($allowFields)) { + $result = $this->getQuery()->where($where)->strict(false)->field($allowFields)->update($data); + } else { + $result = $this->getQuery()->where($where)->update($data); + } + + // 关联更新 + if (isset($relation)) { + $this->autoRelationUpdate($relation); + } + + // 更新回调 + $this->trigger('after_update', $this); + + } else { + // 自动写入 + $this->autoCompleteData($this->insert); + + // 自动写入创建时间和更新时间 + if ($this->autoWriteTimestamp) { + if ($this->createTime && !isset($this->data[$this->createTime])) { + $this->data[$this->createTime] = $this->autoWriteTimestamp($this->createTime); + } + if ($this->updateTime && !isset($this->data[$this->updateTime])) { + $this->data[$this->updateTime] = $this->autoWriteTimestamp($this->updateTime); + } + } + + if (false === $this->trigger('before_insert', $this)) { + return false; + } + + // 检测字段 + $allowFields = $this->checkAllowField(array_merge($this->auto, $this->insert)); + if (!empty($allowFields)) { + $result = $this->getQuery()->strict(false)->field($allowFields)->insert($this->data, $this->replace, false, $sequence); + } else { + $result = $this->getQuery()->insert($this->data, $this->replace, false, $sequence); + } + + // 获取自动增长主键 + if ($result && $insertId = $this->getQuery()->getLastInsID($sequence)) { + foreach ((array) $pk as $key) { + if (!isset($this->data[$key]) || '' == $this->data[$key]) { + $this->data[$key] = $insertId; + } + } + } + + // 关联写入 + if (isset($relation)) { + foreach ($relation as $name => $val) { + $method = Loader::parseName($name, 1, false); + $this->$method()->save($val); + } + } + + // 标记为更新 + $this->isUpdate = true; + + // 新增回调 + $this->trigger('after_insert', $this); + } + // 写入回调 + $this->trigger('after_write', $this); + + // 重新记录原始数据 + $this->origin = $this->data; + + return $result; + } + + protected function checkAllowField($auto = []) + { + if (true === $this->field) { + $this->field = $this->getQuery()->getTableInfo('', 'fields'); + $field = $this->field; + } elseif (!empty($this->field)) { + $field = array_merge($this->field, $auto); + if ($this->autoWriteTimestamp) { + array_push($field, $this->createTime, $this->updateTime); + } + } elseif (!empty($this->except)) { + $fields = $this->getQuery()->getTableInfo('', 'fields'); + $field = array_diff($fields, (array) $this->except); + $this->field = $field; + } else { + $field = []; + } + + if ($this->disuse) { + // 废弃字段 + $field = array_diff($field, (array) $this->disuse); + } + return $field; + } + + protected function autoRelationUpdate($relation) + { + foreach ($relation as $name => $val) { + if ($val instanceof Model) { + $val->save(); + } else { + unset($this->data[$name]); + $model = $this->getAttr($name); + if ($model instanceof Model) { + $model->save($val); + } + } + } + } + + /** + * 获取变化的数据 并排除只读数据 + * @access public + * @return array + */ + public function getChangedData() + { + if ($this->force) { + $data = $this->data; + } else { + $data = array_udiff_assoc($this->data, $this->origin, function ($a, $b) { + if (is_numeric($a) && is_numeric($b)) { + if (strcmp($a, $b) !== 0) { + return 1; + } + if ($a == $b) { + return 0; + } + } + if ((empty($a) || empty($b)) && $a !== $b) { + return 1; + } + return is_object($a) || $a !== $b ? 1 : 0; + }); + } + + if (!empty($this->readonly)) { + // 只读字段不允许更新 + foreach ($this->readonly as $key => $field) { + if (isset($data[$field])) { + unset($data[$field]); + } + } + } + + return $data; + } + + /** + * 字段值(延迟)增长 + * @access public + * @param string $field 字段名 + * @param integer $step 增长值 + * @param integer $lazyTime 延时时间(s) + * @return integer|true + * @throws Exception + */ + public function setInc($field, $step = 1, $lazyTime = 0) + { + // 更新条件 + $where = $this->getWhere(); + + $result = $this->getQuery()->where($where)->setInc($field, $step, $lazyTime); + if (true !== $result) { + $this->data[$field] += $step; + } + + return $result; + } + + /** + * 字段值(延迟)减少 + * @access public + * @param string $field 字段名 + * @param integer $step 减少值 + * @param integer $lazyTime 延时时间(s) + * @return integer|true + * @throws Exception + */ + public function setDec($field, $step = 1, $lazyTime = 0) + { + // 更新条件 + $where = $this->getWhere(); + $result = $this->getQuery()->where($where)->setDec($field, $step, $lazyTime); + if (true !== $result) { + $this->data[$field] -= $step; + } + + return $result; + } + + /** + * 获取更新条件 + * @access protected + * @return mixed + */ + protected function getWhere() + { + // 删除条件 + $pk = $this->getPk(); + + if (is_string($pk) && isset($this->data[$pk])) { + $where = [$pk => $this->data[$pk]]; + } elseif (!empty($this->updateWhere)) { + $where = $this->updateWhere; + } else { + $where = null; + } + return $where; + } + + /** + * 保存多个数据到当前数据对象 + * @access public + * @param array $dataSet 数据 + * @param boolean $replace 是否自动识别更新和写入 + * @return array|false + * @throws \Exception + */ + public function saveAll($dataSet, $replace = true) + { + if ($this->validate) { + // 数据批量验证 + $validate = $this->validate; + foreach ($dataSet as $data) { + if (!$this->validateData($data, $validate)) { + return false; + } + } + } + + $result = []; + $db = $this->getQuery(); + $db->startTrans(); + try { + $pk = $this->getPk(); + if (is_string($pk) && $replace) { + $auto = true; + } + foreach ($dataSet as $key => $data) { + if ($this->isUpdate || (!empty($auto) && isset($data[$pk]))) { + $result[$key] = self::update($data, [], $this->field); + } else { + $result[$key] = self::create($data, $this->field); + } + } + $db->commit(); + return $this->toCollection($result); + } catch (\Exception $e) { + $db->rollback(); + throw $e; + } + } + + /** + * 设置允许写入的字段 + * @access public + * @param string|array $field 允许写入的字段 如果为true只允许写入数据表字段 + * @return $this + */ + public function allowField($field) + { + if (is_string($field)) { + $field = explode(',', $field); + } + $this->field = $field; + return $this; + } + + /** + * 设置排除写入的字段 + * @access public + * @param string|array $field 排除允许写入的字段 + * @return $this + */ + public function except($field) + { + if (is_string($field)) { + $field = explode(',', $field); + } + $this->except = $field; + return $this; + } + + /** + * 设置只读字段 + * @access public + * @param mixed $field 只读字段 + * @return $this + */ + public function readonly($field) + { + if (is_string($field)) { + $field = explode(',', $field); + } + $this->readonly = $field; + return $this; + } + + /** + * 是否为更新数据 + * @access public + * @param bool $update + * @param mixed $where + * @return $this + */ + public function isUpdate($update = true, $where = null) + { + $this->isUpdate = $update; + if (!empty($where)) { + $this->updateWhere = $where; + } + return $this; + } + + /** + * 数据自动完成 + * @access public + * @param array $auto 要自动更新的字段列表 + * @return void + */ + protected function autoCompleteData($auto = []) + { + foreach ($auto as $field => $value) { + if (is_integer($field)) { + $field = $value; + $value = null; + } + + if (!isset($this->data[$field])) { + $default = null; + } else { + $default = $this->data[$field]; + } + + $this->setAttr($field, !is_null($value) ? $value : $default); + } + } + + /** + * 删除当前的记录 + * @access public + * @return integer + */ + public function delete() + { + if (false === $this->trigger('before_delete', $this)) { + return false; + } + + // 删除条件 + $where = $this->getWhere(); + + // 删除当前模型数据 + $result = $this->getQuery()->where($where)->delete(); + + // 关联删除 + if (!empty($this->relationWrite)) { + foreach ($this->relationWrite as $key => $name) { + $name = is_numeric($key) ? $name : $key; + $model = $this->getAttr($name); + if ($model instanceof Model) { + $model->delete(); + } + } + } + + $this->trigger('after_delete', $this); + // 清空原始数据 + $this->origin = []; + + return $result; + } + + /** + * 设置自动完成的字段( 规则通过修改器定义) + * @access public + * @param array $fields 需要自动完成的字段 + * @return $this + */ + public function auto($fields) + { + $this->auto = $fields; + return $this; + } + + /** + * 设置字段验证 + * @access public + * @param array|string|bool $rule 验证规则 true表示自动读取验证器类 + * @param array $msg 提示信息 + * @param bool $batch 批量验证 + * @return $this + */ + public function validate($rule = true, $msg = [], $batch = false) + { + if (is_array($rule)) { + $this->validate = [ + 'rule' => $rule, + 'msg' => $msg, + ]; + } else { + $this->validate = true === $rule ? $this->name : $rule; + } + $this->batchValidate = $batch; + return $this; + } + + /** + * 设置验证失败后是否抛出异常 + * @access public + * @param bool $fail 是否抛出异常 + * @return $this + */ + public function validateFailException($fail = true) + { + $this->failException = $fail; + return $this; + } + + /** + * 自动验证数据 + * @access protected + * @param array $data 验证数据 + * @param mixed $rule 验证规则 + * @param bool $batch 批量验证 + * @return bool + */ + protected function validateData($data, $rule = null, $batch = null) + { + $info = is_null($rule) ? $this->validate : $rule; + + if (!empty($info)) { + if (is_array($info)) { + $validate = Loader::validate(); + $validate->rule($info['rule']); + $validate->message($info['msg']); + } else { + $name = is_string($info) ? $info : $this->name; + if (strpos($name, '.')) { + list($name, $scene) = explode('.', $name); + } + $validate = Loader::validate($name); + if (!empty($scene)) { + $validate->scene($scene); + } + } + $batch = is_null($batch) ? $this->batchValidate : $batch; + + if (!$validate->batch($batch)->check($data)) { + $this->error = $validate->getError(); + if ($this->failException) { + throw new ValidateException($this->error); + } else { + return false; + } + } + $this->validate = null; + } + return true; + } + + /** + * 返回模型的错误信息 + * @access public + * @return string|array + */ + public function getError() + { + return $this->error; + } + + /** + * 注册回调方法 + * @access public + * @param string $event 事件名 + * @param callable $callback 回调方法 + * @param bool $override 是否覆盖 + * @return void + */ + public static function event($event, $callback, $override = false) + { + $class = get_called_class(); + if ($override) { + self::$event[$class][$event] = []; + } + self::$event[$class][$event][] = $callback; + } + + /** + * 触发事件 + * @access protected + * @param string $event 事件名 + * @param mixed $params 传入参数(引用) + * @return bool + */ + protected function trigger($event, &$params) + { + if (isset(self::$event[$this->class][$event])) { + foreach (self::$event[$this->class][$event] as $callback) { + if (is_callable($callback)) { + $result = call_user_func_array($callback, [ & $params]); + if (false === $result) { + return false; + } + } + } + } + return true; + } + + /** + * 写入数据 + * @access public + * @param array $data 数据数组 + * @param array|true $field 允许字段 + * @return $this + */ + public static function create($data = [], $field = null) + { + $model = new static(); + if (!empty($field)) { + $model->allowField($field); + } + $model->isUpdate(false)->save($data, []); + return $model; + } + + /** + * 更新数据 + * @access public + * @param array $data 数据数组 + * @param array $where 更新条件 + * @param array|true $field 允许字段 + * @return $this + */ + public static function update($data = [], $where = [], $field = null) + { + $model = new static(); + if (!empty($field)) { + $model->allowField($field); + } + $result = $model->isUpdate(true)->save($data, $where); + return $model; + } + + /** + * 查找单条记录 + * @access public + * @param mixed $data 主键值或者查询条件(闭包) + * @param array|string $with 关联预查询 + * @param bool $cache 是否缓存 + * @return static|null + * @throws exception\DbException + */ + public static function get($data, $with = [], $cache = false) + { + if (is_null($data)) { + return; + } + + if (true === $with || is_int($with)) { + $cache = $with; + $with = []; + } + $query = static::parseQuery($data, $with, $cache); + return $query->find($data); + } + + /** + * 查找所有记录 + * @access public + * @param mixed $data 主键列表或者查询条件(闭包) + * @param array|string $with 关联预查询 + * @param bool $cache 是否缓存 + * @return static[]|false + * @throws exception\DbException + */ + public static function all($data = null, $with = [], $cache = false) + { + if (true === $with || is_int($with)) { + $cache = $with; + $with = []; + } + $query = static::parseQuery($data, $with, $cache); + return $query->select($data); + } + + /** + * 分析查询表达式 + * @access public + * @param mixed $data 主键列表或者查询条件(闭包) + * @param string $with 关联预查询 + * @param bool $cache 是否缓存 + * @return Query + */ + protected static function parseQuery(&$data, $with, $cache) + { + $result = self::with($with)->cache($cache); + if (is_array($data) && key($data) !== 0) { + $result = $result->where($data); + $data = null; + } elseif ($data instanceof \Closure) { + call_user_func_array($data, [ & $result]); + $data = null; + } elseif ($data instanceof Query) { + $result = $data->with($with)->cache($cache); + $data = null; + } + return $result; + } + + /** + * 删除记录 + * @access public + * @param mixed $data 主键列表 支持闭包查询条件 + * @return integer 成功删除的记录数 + */ + public static function destroy($data) + { + $model = new static(); + $query = $model->db(); + if (empty($data) && 0 !== $data) { + return 0; + } elseif (is_array($data) && key($data) !== 0) { + $query->where($data); + $data = null; + } elseif ($data instanceof \Closure) { + call_user_func_array($data, [ & $query]); + $data = null; + } + $resultSet = $query->select($data); + $count = 0; + if ($resultSet) { + foreach ($resultSet as $data) { + $result = $data->delete(); + $count += $result; + } + } + return $count; + } + + /** + * 命名范围 + * @access public + * @param string|array|\Closure $name 命名范围名称 逗号分隔 + * @internal mixed ...$params 参数调用 + * @return Query + */ + public static function scope($name) + { + $model = new static(); + $query = $model->db(); + $params = func_get_args(); + array_shift($params); + array_unshift($params, $query); + if ($name instanceof \Closure) { + call_user_func_array($name, $params); + } elseif (is_string($name)) { + $name = explode(',', $name); + } + if (is_array($name)) { + foreach ($name as $scope) { + $method = 'scope' . trim($scope); + if (method_exists($model, $method)) { + call_user_func_array([$model, $method], $params); + } + } + } + return $query; + } + + /** + * 设置是否使用全局查询范围 + * @param bool $use 是否启用全局查询范围 + * @access public + * @return Query + */ + public static function useGlobalScope($use) + { + $model = new static(); + return $model->db($use); + } + + /** + * 根据关联条件查询当前模型 + * @access public + * @param string $relation 关联方法名 + * @param mixed $operator 比较操作符 + * @param integer $count 个数 + * @param string $id 关联表的统计字段 + * @return Relation|Query + */ + public static function has($relation, $operator = '>=', $count = 1, $id = '*') + { + $relation = (new static())->$relation(); + if (is_array($operator) || $operator instanceof \Closure) { + return $relation->hasWhere($operator); + } + return $relation->has($operator, $count, $id); + } + + /** + * 根据关联条件查询当前模型 + * @access public + * @param string $relation 关联方法名 + * @param mixed $where 查询条件(数组或者闭包) + * @param mixed $fields 字段 + * @return Relation|Query + */ + public static function hasWhere($relation, $where = [], $fields = null) + { + return (new static())->$relation()->hasWhere($where, $fields); + } + + /** + * 解析模型的完整命名空间 + * @access public + * @param string $model 模型名(或者完整类名) + * @return string + */ + protected function parseModel($model) + { + if (false === strpos($model, '\\')) { + $path = explode('\\', get_called_class()); + array_pop($path); + array_push($path, Loader::parseName($model, 1)); + $model = implode('\\', $path); + } + return $model; + } + + /** + * 查询当前模型的关联数据 + * @access public + * @param string|array $relations 关联名 + * @return $this + */ + public function relationQuery($relations) + { + if (is_string($relations)) { + $relations = explode(',', $relations); + } + + foreach ($relations as $key => $relation) { + $subRelation = ''; + $closure = null; + if ($relation instanceof \Closure) { + // 支持闭包查询过滤关联条件 + $closure = $relation; + $relation = $key; + } + if (is_array($relation)) { + $subRelation = $relation; + $relation = $key; + } elseif (strpos($relation, '.')) { + list($relation, $subRelation) = explode('.', $relation, 2); + } + $method = Loader::parseName($relation, 1, false); + $this->data[$relation] = $this->$method()->getRelation($subRelation, $closure); + } + return $this; + } + + /** + * 预载入关联查询 返回数据集 + * @access public + * @param array $resultSet 数据集 + * @param string $relation 关联名 + * @return array + */ + public function eagerlyResultSet(&$resultSet, $relation) + { + $relations = is_string($relation) ? explode(',', $relation) : $relation; + foreach ($relations as $key => $relation) { + $subRelation = ''; + $closure = false; + if ($relation instanceof \Closure) { + $closure = $relation; + $relation = $key; + } + if (is_array($relation)) { + $subRelation = $relation; + $relation = $key; + } elseif (strpos($relation, '.')) { + list($relation, $subRelation) = explode('.', $relation, 2); + } + $relation = Loader::parseName($relation, 1, false); + $this->$relation()->eagerlyResultSet($resultSet, $relation, $subRelation, $closure); + } + } + + /** + * 预载入关联查询 返回模型对象 + * @access public + * @param Model $result 数据对象 + * @param string $relation 关联名 + * @return Model + */ + public function eagerlyResult(&$result, $relation) + { + $relations = is_string($relation) ? explode(',', $relation) : $relation; + + foreach ($relations as $key => $relation) { + $subRelation = ''; + $closure = false; + if ($relation instanceof \Closure) { + $closure = $relation; + $relation = $key; + } + if (is_array($relation)) { + $subRelation = $relation; + $relation = $key; + } elseif (strpos($relation, '.')) { + list($relation, $subRelation) = explode('.', $relation, 2); + } + $relation = Loader::parseName($relation, 1, false); + $this->$relation()->eagerlyResult($result, $relation, $subRelation, $closure); + } + } + + /** + * 关联统计 + * @access public + * @param Model $result 数据对象 + * @param string|array $relation 关联名 + * @return void + */ + public function relationCount(&$result, $relation) + { + $relations = is_string($relation) ? explode(',', $relation) : $relation; + + foreach ($relations as $key => $relation) { + $closure = false; + if ($relation instanceof \Closure) { + $closure = $relation; + $relation = $key; + } elseif (is_string($key)) { + $name = $relation; + $relation = $key; + } + $relation = Loader::parseName($relation, 1, false); + $count = $this->$relation()->relationCount($result, $closure); + if (!isset($name)) { + $name = Loader::parseName($relation) . '_count'; + } + $result->setAttr($name, $count); + } + } + + /** + * 获取模型的默认外键名 + * @access public + * @param string $name 模型名 + * @return string + */ + protected function getForeignKey($name) + { + if (strpos($name, '\\')) { + $name = basename(str_replace('\\', '/', $name)); + } + return Loader::parseName($name) . '_id'; + } + + /** + * HAS ONE 关联定义 + * @access public + * @param string $model 模型名 + * @param string $foreignKey 关联外键 + * @param string $localKey 当前模型主键 + * @param array $alias 别名定义(已经废弃) + * @param string $joinType JOIN类型 + * @return HasOne + */ + public function hasOne($model, $foreignKey = '', $localKey = '', $alias = [], $joinType = 'INNER') + { + // 记录当前关联信息 + $model = $this->parseModel($model); + $localKey = $localKey ?: $this->getPk(); + $foreignKey = $foreignKey ?: $this->getForeignKey($this->name); + return new HasOne($this, $model, $foreignKey, $localKey, $joinType); + } + + /** + * BELONGS TO 关联定义 + * @access public + * @param string $model 模型名 + * @param string $foreignKey 关联外键 + * @param string $localKey 关联主键 + * @param array $alias 别名定义(已经废弃) + * @param string $joinType JOIN类型 + * @return BelongsTo + */ + public function belongsTo($model, $foreignKey = '', $localKey = '', $alias = [], $joinType = 'INNER') + { + // 记录当前关联信息 + $model = $this->parseModel($model); + $foreignKey = $foreignKey ?: $this->getForeignKey($model); + $localKey = $localKey ?: (new $model)->getPk(); + $trace = debug_backtrace(false, 2); + $relation = Loader::parseName($trace[1]['function']); + return new BelongsTo($this, $model, $foreignKey, $localKey, $joinType, $relation); + } + + /** + * HAS MANY 关联定义 + * @access public + * @param string $model 模型名 + * @param string $foreignKey 关联外键 + * @param string $localKey 当前模型主键 + * @return HasMany + */ + public function hasMany($model, $foreignKey = '', $localKey = '') + { + // 记录当前关联信息 + $model = $this->parseModel($model); + $localKey = $localKey ?: $this->getPk(); + $foreignKey = $foreignKey ?: $this->getForeignKey($this->name); + return new HasMany($this, $model, $foreignKey, $localKey); + } + + /** + * HAS MANY 远程关联定义 + * @access public + * @param string $model 模型名 + * @param string $through 中间模型名 + * @param string $foreignKey 关联外键 + * @param string $throughKey 关联外键 + * @param string $localKey 当前模型主键 + * @return HasManyThrough + */ + public function hasManyThrough($model, $through, $foreignKey = '', $throughKey = '', $localKey = '') + { + // 记录当前关联信息 + $model = $this->parseModel($model); + $through = $this->parseModel($through); + $localKey = $localKey ?: $this->getPk(); + $foreignKey = $foreignKey ?: $this->getForeignKey($this->name); + $throughKey = $throughKey ?: $this->getForeignKey($through); + return new HasManyThrough($this, $model, $through, $foreignKey, $throughKey, $localKey); + } + + /** + * BELONGS TO MANY 关联定义 + * @access public + * @param string $model 模型名 + * @param string $table 中间表名 + * @param string $foreignKey 关联外键 + * @param string $localKey 当前模型关联键 + * @return BelongsToMany + */ + public function belongsToMany($model, $table = '', $foreignKey = '', $localKey = '') + { + // 记录当前关联信息 + $model = $this->parseModel($model); + $name = Loader::parseName(basename(str_replace('\\', '/', $model))); + $table = $table ?: Loader::parseName($this->name) . '_' . $name; + $foreignKey = $foreignKey ?: $name . '_id'; + $localKey = $localKey ?: $this->getForeignKey($this->name); + return new BelongsToMany($this, $model, $table, $foreignKey, $localKey); + } + + /** + * MORPH MANY 关联定义 + * @access public + * @param string $model 模型名 + * @param string|array $morph 多态字段信息 + * @param string $type 多态类型 + * @return MorphMany + */ + public function morphMany($model, $morph = null, $type = '') + { + // 记录当前关联信息 + $model = $this->parseModel($model); + if (is_null($morph)) { + $trace = debug_backtrace(false, 2); + $morph = Loader::parseName($trace[1]['function']); + } + $type = $type ?: get_class($this); + if (is_array($morph)) { + list($morphType, $foreignKey) = $morph; + } else { + $morphType = $morph . '_type'; + $foreignKey = $morph . '_id'; + } + return new MorphMany($this, $model, $foreignKey, $morphType, $type); + } + + /** + * MORPH One 关联定义 + * @access public + * @param string $model 模型名 + * @param string|array $morph 多态字段信息 + * @param string $type 多态类型 + * @return MorphOne + */ + public function morphOne($model, $morph = null, $type = '') + { + // 记录当前关联信息 + $model = $this->parseModel($model); + if (is_null($morph)) { + $trace = debug_backtrace(false, 2); + $morph = Loader::parseName($trace[1]['function']); + } + $type = $type ?: get_class($this); + if (is_array($morph)) { + list($morphType, $foreignKey) = $morph; + } else { + $morphType = $morph . '_type'; + $foreignKey = $morph . '_id'; + } + return new MorphOne($this, $model, $foreignKey, $morphType, $type); + } + + /** + * MORPH TO 关联定义 + * @access public + * @param string|array $morph 多态字段信息 + * @param array $alias 多态别名定义 + * @return MorphTo + */ + public function morphTo($morph = null, $alias = []) + { + $trace = debug_backtrace(false, 2); + $relation = Loader::parseName($trace[1]['function']); + + if (is_null($morph)) { + $morph = $relation; + } + // 记录当前关联信息 + if (is_array($morph)) { + list($morphType, $foreignKey) = $morph; + } else { + $morphType = $morph . '_type'; + $foreignKey = $morph . '_id'; + } + return new MorphTo($this, $morphType, $foreignKey, $alias, $relation); + } + + public function __call($method, $args) + { + $query = $this->db(true, false); + if (method_exists($this, 'scope' . $method)) { + // 动态调用命名范围 + $method = 'scope' . $method; + array_unshift($args, $query); + call_user_func_array([$this, $method], $args); + return $this; + } else { + return call_user_func_array([$query, $method], $args); + } + } + + public static function __callStatic($method, $args) + { + $model = new static(); + $query = $model->db(); + if (method_exists($model, 'scope' . $method)) { + // 动态调用命名范围 + $method = 'scope' . $method; + array_unshift($args, $query); + + call_user_func_array([$model, $method], $args); + return $query; + } else { + return call_user_func_array([$query, $method], $args); + } + } + + /** + * 修改器 设置数据对象的值 + * @access public + * @param string $name 名称 + * @param mixed $value 值 + * @return void + */ + public function __set($name, $value) + { + $this->setAttr($name, $value); + } + + /** + * 获取器 获取数据对象的值 + * @access public + * @param string $name 名称 + * @return mixed + */ + public function __get($name) + { + return $this->getAttr($name); + } + + /** + * 检测数据对象的值 + * @access public + * @param string $name 名称 + * @return boolean + */ + public function __isset($name) + { + try { + if (array_key_exists($name, $this->data) || array_key_exists($name, $this->relation)) { + return true; + } else { + $this->getAttr($name); + return true; + } + } catch (InvalidArgumentException $e) { + return false; + } + + } + + /** + * 销毁数据对象的值 + * @access public + * @param string $name 名称 + * @return void + */ + public function __unset($name) + { + unset($this->data[$name], $this->relation[$name]); + } + + public function __toString() + { + return $this->toJson(); + } + + // JsonSerializable + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return $this->toArray(); + } + + // ArrayAccess + #[\ReturnTypeWillChange] + public function offsetSet($name, $value) + { + $this->setAttr($name, $value); + } + + #[\ReturnTypeWillChange] + public function offsetExists($name) + { + return $this->__isset($name); + } + + #[\ReturnTypeWillChange] + public function offsetUnset($name) + { + $this->__unset($name); + } + + #[\ReturnTypeWillChange] + public function offsetGet($name) + { + return $this->getAttr($name); + } + + /** + * 解序列化后处理 + */ + public function __wakeup() + { + $this->initialize(); + } + + /** + * 模型事件快捷方法 + * @param $callback + * @param bool $override + */ + protected static function beforeInsert($callback, $override = false) + { + self::event('before_insert', $callback, $override); + } + + protected static function afterInsert($callback, $override = false) + { + self::event('after_insert', $callback, $override); + } + + protected static function beforeUpdate($callback, $override = false) + { + self::event('before_update', $callback, $override); + } + + protected static function afterUpdate($callback, $override = false) + { + self::event('after_update', $callback, $override); + } + + protected static function beforeWrite($callback, $override = false) + { + self::event('before_write', $callback, $override); + } + + protected static function afterWrite($callback, $override = false) + { + self::event('after_write', $callback, $override); + } + + protected static function beforeDelete($callback, $override = false) + { + self::event('before_delete', $callback, $override); + } + + protected static function afterDelete($callback, $override = false) + { + self::event('after_delete', $callback, $override); + } + +} diff --git a/thinkphp/library/think/Paginator.php b/thinkphp/library/think/Paginator.php new file mode 100644 index 0000000..d19472e --- /dev/null +++ b/thinkphp/library/think/Paginator.php @@ -0,0 +1,416 @@ + +// +---------------------------------------------------------------------- + +namespace think; + +use ArrayAccess; +use ArrayIterator; +use Countable; +use IteratorAggregate; +use JsonSerializable; +use Traversable; + +abstract class Paginator implements ArrayAccess, Countable, IteratorAggregate, JsonSerializable +{ + /** @var bool 是否为简洁模式 */ + protected $simple = false; + + /** @var Collection 数据集 */ + protected $items; + + /** @var integer 当前页 */ + protected $currentPage; + + /** @var integer 最后一页 */ + protected $lastPage; + + /** @var integer|null 数据总数 */ + protected $total; + + /** @var integer 每页的数量 */ + protected $listRows; + + /** @var bool 是否有下一页 */ + protected $hasMore; + + /** @var array 一些配置 */ + protected $options = [ + 'var_page' => 'page', + 'path' => '/', + 'query' => [], + 'fragment' => '', + ]; + + /** @var mixed simple模式下的下个元素 */ + protected $nextItem; + + public function __construct($items, $listRows, $currentPage = null, $total = null, $simple = false, $options = []) + { + $this->options = array_merge($this->options, $options); + + $this->options['path'] = '/' != $this->options['path'] ? rtrim($this->options['path'], '/') : $this->options['path']; + + $this->simple = $simple; + $this->listRows = $listRows; + + if (!$items instanceof Collection) { + $items = Collection::make($items); + } + + if ($simple) { + $this->currentPage = $this->setCurrentPage($currentPage); + $this->hasMore = count($items) > ($this->listRows); + if ($this->hasMore) { + $this->nextItem = $items->slice($this->listRows, 1); + } + $items = $items->slice(0, $this->listRows); + } else { + $this->total = $total; + $this->lastPage = (int) ceil($total / $listRows); + $this->currentPage = $this->setCurrentPage($currentPage); + $this->hasMore = $this->currentPage < $this->lastPage; + } + $this->items = $items; + } + + /** + * @param $items + * @param $listRows + * @param null $currentPage + * @param bool $simple + * @param null $total + * @param array $options + * @return Paginator + */ + public static function make($items, $listRows, $currentPage = null, $total = null, $simple = false, $options = []) + { + return new static($items, $listRows, $currentPage, $total, $simple, $options); + } + + protected function setCurrentPage($currentPage) + { + if (!$this->simple && $currentPage > $this->lastPage) { + return $this->lastPage > 0 ? $this->lastPage : 1; + } + + return $currentPage; + } + + /** + * 获取页码对应的链接 + * + * @param $page + * @return string + */ + protected function url($page) + { + if ($page <= 0) { + $page = 1; + } + + if (strpos($this->options['path'], '[PAGE]') === false) { + $parameters = [$this->options['var_page'] => $page]; + $path = $this->options['path']; + } else { + $parameters = []; + $path = str_replace('[PAGE]', $page, $this->options['path']); + } + if (count($this->options['query']) > 0) { + $parameters = array_merge($this->options['query'], $parameters); + } + $url = $path; + if (!empty($parameters)) { + $url .= '?' . http_build_query($parameters, '', '&'); + } + return $url . $this->buildFragment(); + } + + /** + * 自动获取当前页码 + * @param string $varPage + * @param int $default + * @return int + */ + public static function getCurrentPage($varPage = 'page', $default = 1) + { + $page = (int) Request::instance()->param($varPage); + + if (filter_var($page, FILTER_VALIDATE_INT) !== false && $page >= 1) { + return $page; + } + + return $default; + } + + /** + * 自动获取当前的path + * @return string + */ + public static function getCurrentPath() + { + return Request::instance()->baseUrl(); + } + + public function total() + { + if ($this->simple) { + throw new \DomainException('not support total'); + } + return $this->total; + } + + public function listRows() + { + return $this->listRows; + } + + public function currentPage() + { + return $this->currentPage; + } + + public function lastPage() + { + if ($this->simple) { + throw new \DomainException('not support last'); + } + return $this->lastPage; + } + + /** + * 数据是否足够分页 + * @return boolean + */ + public function hasPages() + { + return !(1 == $this->currentPage && !$this->hasMore); + } + + /** + * 创建一组分页链接 + * + * @param int $start + * @param int $end + * @return array + */ + public function getUrlRange($start, $end) + { + $urls = []; + + for ($page = $start; $page <= $end; $page++) { + $urls[$page] = $this->url($page); + } + + return $urls; + } + + /** + * 设置URL锚点 + * + * @param string|null $fragment + * @return $this + */ + public function fragment($fragment) + { + $this->options['fragment'] = $fragment; + return $this; + } + + /** + * 添加URL参数 + * + * @param array|string $key + * @param string|null $value + * @return $this + */ + public function appends($key, $value = null) + { + if (!is_array($key)) { + $queries = [$key => $value]; + } else { + $queries = $key; + } + + foreach ($queries as $k => $v) { + if ($k !== $this->options['var_page']) { + $this->options['query'][$k] = $v; + } + } + + return $this; + } + + /** + * 构造锚点字符串 + * + * @return string + */ + protected function buildFragment() + { + return $this->options['fragment'] ? '#' . $this->options['fragment'] : ''; + } + + /** + * 渲染分页html + * @return mixed + */ + abstract public function render(); + + public function items() + { + return $this->items->all(); + } + + public function getCollection() + { + return $this->items; + } + + public function isEmpty() + { + return $this->items->isEmpty(); + } + + /** + * 给每个元素执行个回调 + * + * @param callable $callback + * @return $this + */ + public function each(callable $callback) + { + foreach ($this->items as $key => $item) { + $result = $callback($item, $key); + if (false === $result) { + break; + } elseif (!is_object($item)) { + $this->items[$key] = $result; + } + } + + return $this; + } + + /** + * Retrieve an external iterator + * @return Traversable An instance of an object implementing Iterator or + * Traversable + */ + #[\ReturnTypeWillChange] + public function getIterator() + { + return new ArrayIterator($this->items->all()); + } + + /** + * Whether a offset exists + * @param mixed $offset + * @return bool + */ + #[\ReturnTypeWillChange] + public function offsetExists($offset) + { + return $this->items->offsetExists($offset); + } + + /** + * Offset to retrieve + * @param mixed $offset + * @return mixed + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->items->offsetGet($offset); + } + + /** + * Offset to set + * @param mixed $offset + * @param mixed $value + */ + #[\ReturnTypeWillChange] + public function offsetSet($offset, $value) + { + $this->items->offsetSet($offset, $value); + } + + /** + * Offset to unset + * @param mixed $offset + * @return void + * @since 5.0.0 + */ + #[\ReturnTypeWillChange] + public function offsetUnset($offset) + { + $this->items->offsetUnset($offset); + } + + /** + * Count elements of an object + */ + #[\ReturnTypeWillChange] + public function count() + { + return $this->items->count(); + } + + public function __toString() + { + return (string) $this->render(); + } + + public function toArray() + { + if ($this->simple) { + return [ + 'per_page' => $this->listRows, + 'current_page' => $this->currentPage, + 'has_more' => $this->hasMore, + 'next_item' => $this->nextItem, + 'data' => $this->items->toArray(), + ]; + } else { + return [ + 'total' => $this->total, + 'per_page' => $this->listRows, + 'current_page' => $this->currentPage, + 'last_page' => $this->lastPage, + 'data' => $this->items->toArray(), + ]; + } + + } + + /** + * Specify data which should be serialized to JSON + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return $this->toArray(); + } + + public function __call($name, $arguments) + { + $collection = $this->getCollection(); + + $result = call_user_func_array([$collection, $name], $arguments); + + if ($result === $collection) { + return $this; + } + + return $result; + } + +} diff --git a/thinkphp/library/think/Process.php b/thinkphp/library/think/Process.php new file mode 100644 index 0000000..6f3faa3 --- /dev/null +++ b/thinkphp/library/think/Process.php @@ -0,0 +1,1205 @@ + +// +---------------------------------------------------------------------- + +namespace think; + +use think\process\exception\Failed as ProcessFailedException; +use think\process\exception\Timeout as ProcessTimeoutException; +use think\process\pipes\Pipes; +use think\process\pipes\Unix as UnixPipes; +use think\process\pipes\Windows as WindowsPipes; +use think\process\Utils; + +class Process +{ + + const ERR = 'err'; + const OUT = 'out'; + + const STATUS_READY = 'ready'; + const STATUS_STARTED = 'started'; + const STATUS_TERMINATED = 'terminated'; + + const STDIN = 0; + const STDOUT = 1; + const STDERR = 2; + + const TIMEOUT_PRECISION = 0.2; + + private $callback; + private $commandline; + private $cwd; + private $env; + private $input; + private $starttime; + private $lastOutputTime; + private $timeout; + private $idleTimeout; + private $options; + private $exitcode; + private $fallbackExitcode; + private $processInformation; + private $outputDisabled = false; + private $stdout; + private $stderr; + private $enhanceWindowsCompatibility = true; + private $enhanceSigchildCompatibility; + private $process; + private $status = self::STATUS_READY; + private $incrementalOutputOffset = 0; + private $incrementalErrorOutputOffset = 0; + private $tty; + private $pty; + + private $useFileHandles = false; + + /** @var Pipes */ + private $processPipes; + + private $latestSignal; + + private static $sigchild; + + /** + * @var array + */ + public static $exitCodes = [ + 0 => 'OK', + 1 => 'General error', + 2 => 'Misuse of shell builtins', + 126 => 'Invoked command cannot execute', + 127 => 'Command not found', + 128 => 'Invalid exit argument', + // signals + 129 => 'Hangup', + 130 => 'Interrupt', + 131 => 'Quit and dump core', + 132 => 'Illegal instruction', + 133 => 'Trace/breakpoint trap', + 134 => 'Process aborted', + 135 => 'Bus error: "access to undefined portion of memory object"', + 136 => 'Floating point exception: "erroneous arithmetic operation"', + 137 => 'Kill (terminate immediately)', + 138 => 'User-defined 1', + 139 => 'Segmentation violation', + 140 => 'User-defined 2', + 141 => 'Write to pipe with no one reading', + 142 => 'Signal raised by alarm', + 143 => 'Termination (request to terminate)', + // 144 - not defined + 145 => 'Child process terminated, stopped (or continued*)', + 146 => 'Continue if stopped', + 147 => 'Stop executing temporarily', + 148 => 'Terminal stop signal', + 149 => 'Background process attempting to read from tty ("in")', + 150 => 'Background process attempting to write to tty ("out")', + 151 => 'Urgent data available on socket', + 152 => 'CPU time limit exceeded', + 153 => 'File size limit exceeded', + 154 => 'Signal raised by timer counting virtual time: "virtual timer expired"', + 155 => 'Profiling timer expired', + // 156 - not defined + 157 => 'Pollable event', + // 158 - not defined + 159 => 'Bad syscall', + ]; + + /** + * 构造方法 + * @param string $commandline 指令 + * @param string|null $cwd 工作目录 + * @param array|null $env 环境变量 + * @param string|null $input 输入 + * @param int|float|null $timeout 超时时间 + * @param array $options proc_open的选项 + * @throws \RuntimeException + * @api + */ + public function __construct($commandline, $cwd = null, array $env = null, $input = null, $timeout = 60, array $options = []) + { + if (!function_exists('proc_open')) { + throw new \RuntimeException('The Process class relies on proc_open, which is not available on your PHP installation.'); + } + + $this->commandline = $commandline; + $this->cwd = $cwd; + + if (null === $this->cwd && (defined('ZEND_THREAD_SAFE') || '\\' === DS)) { + $this->cwd = getcwd(); + } + if (null !== $env) { + $this->setEnv($env); + } + + $this->input = $input; + $this->setTimeout($timeout); + $this->useFileHandles = '\\' === DS; + $this->pty = false; + $this->enhanceWindowsCompatibility = true; + $this->enhanceSigchildCompatibility = '\\' !== DS && $this->isSigchildEnabled(); + $this->options = array_replace([ + 'suppress_errors' => true, + 'binary_pipes' => true, + ], $options); + } + + public function __destruct() + { + $this->stop(); + } + + public function __clone() + { + $this->resetProcessData(); + } + + /** + * 运行指令 + * @param callback|null $callback + * @return int + */ + public function run($callback = null) + { + $this->start($callback); + + return $this->wait(); + } + + /** + * 运行指令 + * @param callable|null $callback + * @return self + * @throws \RuntimeException + * @throws ProcessFailedException + */ + public function mustRun($callback = null) + { + if ($this->isSigchildEnabled() && !$this->enhanceSigchildCompatibility) { + throw new \RuntimeException('This PHP has been compiled with --enable-sigchild. You must use setEnhanceSigchildCompatibility() to use this method.'); + } + + if (0 !== $this->run($callback)) { + throw new ProcessFailedException($this); + } + + return $this; + } + + /** + * 启动进程并写到 STDIN 输入后返回。 + * @param callable|null $callback + * @throws \RuntimeException + * @throws \RuntimeException + * @throws \LogicException + */ + public function start($callback = null) + { + if ($this->isRunning()) { + throw new \RuntimeException('Process is already running'); + } + if ($this->outputDisabled && null !== $callback) { + throw new \LogicException('Output has been disabled, enable it to allow the use of a callback.'); + } + + $this->resetProcessData(); + $this->starttime = $this->lastOutputTime = microtime(true); + $this->callback = $this->buildCallback($callback); + $descriptors = $this->getDescriptors(); + + $commandline = $this->commandline; + + if ('\\' === DS && $this->enhanceWindowsCompatibility) { + $commandline = 'cmd /V:ON /E:ON /C "(' . $commandline . ')'; + foreach ($this->processPipes->getFiles() as $offset => $filename) { + $commandline .= ' ' . $offset . '>' . Utils::escapeArgument($filename); + } + $commandline .= '"'; + + if (!isset($this->options['bypass_shell'])) { + $this->options['bypass_shell'] = true; + } + } + + $this->process = proc_open($commandline, $descriptors, $this->processPipes->pipes, $this->cwd, $this->env, $this->options); + + if (!is_resource($this->process)) { + throw new \RuntimeException('Unable to launch a new process.'); + } + $this->status = self::STATUS_STARTED; + + if ($this->tty) { + return; + } + + $this->updateStatus(false); + $this->checkTimeout(); + } + + /** + * 重启进程 + * @param callable|null $callback + * @return Process + * @throws \RuntimeException + * @throws \RuntimeException + */ + public function restart($callback = null) + { + if ($this->isRunning()) { + throw new \RuntimeException('Process is already running'); + } + + $process = clone $this; + $process->start($callback); + + return $process; + } + + /** + * 等待要终止的进程 + * @param callable|null $callback + * @return int + */ + public function wait($callback = null) + { + $this->requireProcessIsStarted(__FUNCTION__); + + $this->updateStatus(false); + if (null !== $callback) { + $this->callback = $this->buildCallback($callback); + } + + do { + $this->checkTimeout(); + $running = '\\' === DS ? $this->isRunning() : $this->processPipes->areOpen(); + $close = '\\' !== DS || !$running; + $this->readPipes(true, $close); + } while ($running); + + while ($this->isRunning()) { + usleep(1000); + } + + if ($this->processInformation['signaled'] && $this->processInformation['termsig'] !== $this->latestSignal) { + throw new \RuntimeException(sprintf('The process has been signaled with signal "%s".', $this->processInformation['termsig'])); + } + + return $this->exitcode; + } + + /** + * 获取PID + * @return int|null + * @throws \RuntimeException + */ + public function getPid() + { + if ($this->isSigchildEnabled()) { + throw new \RuntimeException('This PHP has been compiled with --enable-sigchild. The process identifier can not be retrieved.'); + } + + $this->updateStatus(false); + + return $this->isRunning() ? $this->processInformation['pid'] : null; + } + + /** + * 将一个 POSIX 信号发送到进程中 + * @param int $signal + * @return Process + */ + public function signal($signal) + { + $this->doSignal($signal, true); + + return $this; + } + + /** + * 禁用从底层过程获取输出和错误输出。 + * @return Process + */ + public function disableOutput() + { + if ($this->isRunning()) { + throw new \RuntimeException('Disabling output while the process is running is not possible.'); + } + if (null !== $this->idleTimeout) { + throw new \LogicException('Output can not be disabled while an idle timeout is set.'); + } + + $this->outputDisabled = true; + + return $this; + } + + /** + * 开启从底层过程获取输出和错误输出。 + * @return Process + * @throws \RuntimeException + */ + public function enableOutput() + { + if ($this->isRunning()) { + throw new \RuntimeException('Enabling output while the process is running is not possible.'); + } + + $this->outputDisabled = false; + + return $this; + } + + /** + * 输出是否禁用 + * @return bool + */ + public function isOutputDisabled() + { + return $this->outputDisabled; + } + + /** + * 获取当前的输出管道 + * @return string + * @throws \LogicException + * @throws \LogicException + * @api + */ + public function getOutput() + { + if ($this->outputDisabled) { + throw new \LogicException('Output has been disabled.'); + } + + $this->requireProcessIsStarted(__FUNCTION__); + + $this->readPipes(false, '\\' === DS ? !$this->processInformation['running'] : true); + + return $this->stdout; + } + + /** + * 以增量方式返回的输出结果。 + * @return string + */ + public function getIncrementalOutput() + { + $this->requireProcessIsStarted(__FUNCTION__); + + $data = $this->getOutput(); + + $latest = substr($data, $this->incrementalOutputOffset); + + if (false === $latest) { + return ''; + } + + $this->incrementalOutputOffset = strlen($data); + + return $latest; + } + + /** + * 清空输出 + * @return Process + */ + public function clearOutput() + { + $this->stdout = ''; + $this->incrementalOutputOffset = 0; + + return $this; + } + + /** + * 返回当前的错误输出的过程 (STDERR)。 + * @return string + */ + public function getErrorOutput() + { + if ($this->outputDisabled) { + throw new \LogicException('Output has been disabled.'); + } + + $this->requireProcessIsStarted(__FUNCTION__); + + $this->readPipes(false, '\\' === DS ? !$this->processInformation['running'] : true); + + return $this->stderr; + } + + /** + * 以增量方式返回 errorOutput + * @return string + */ + public function getIncrementalErrorOutput() + { + $this->requireProcessIsStarted(__FUNCTION__); + + $data = $this->getErrorOutput(); + + $latest = substr($data, $this->incrementalErrorOutputOffset); + + if (false === $latest) { + return ''; + } + + $this->incrementalErrorOutputOffset = strlen($data); + + return $latest; + } + + /** + * 清空 errorOutput + * @return Process + */ + public function clearErrorOutput() + { + $this->stderr = ''; + $this->incrementalErrorOutputOffset = 0; + + return $this; + } + + /** + * 获取退出码 + * @return null|int + */ + public function getExitCode() + { + if ($this->isSigchildEnabled() && !$this->enhanceSigchildCompatibility) { + throw new \RuntimeException('This PHP has been compiled with --enable-sigchild. You must use setEnhanceSigchildCompatibility() to use this method.'); + } + + $this->updateStatus(false); + + return $this->exitcode; + } + + /** + * 获取退出文本 + * @return null|string + */ + public function getExitCodeText() + { + if (null === $exitcode = $this->getExitCode()) { + return; + } + + return isset(self::$exitCodes[$exitcode]) ? self::$exitCodes[$exitcode] : 'Unknown error'; + } + + /** + * 检查是否成功 + * @return bool + */ + public function isSuccessful() + { + return 0 === $this->getExitCode(); + } + + /** + * 是否未捕获的信号已被终止子进程 + * @return bool + */ + public function hasBeenSignaled() + { + $this->requireProcessIsTerminated(__FUNCTION__); + + if ($this->isSigchildEnabled()) { + throw new \RuntimeException('This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved.'); + } + + $this->updateStatus(false); + + return $this->processInformation['signaled']; + } + + /** + * 返回导致子进程终止其执行的数。 + * @return int + */ + public function getTermSignal() + { + $this->requireProcessIsTerminated(__FUNCTION__); + + if ($this->isSigchildEnabled()) { + throw new \RuntimeException('This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved.'); + } + + $this->updateStatus(false); + + return $this->processInformation['termsig']; + } + + /** + * 检查子进程信号是否已停止 + * @return bool + */ + public function hasBeenStopped() + { + $this->requireProcessIsTerminated(__FUNCTION__); + + $this->updateStatus(false); + + return $this->processInformation['stopped']; + } + + /** + * 返回导致子进程停止其执行的数。 + * @return int + */ + public function getStopSignal() + { + $this->requireProcessIsTerminated(__FUNCTION__); + + $this->updateStatus(false); + + return $this->processInformation['stopsig']; + } + + /** + * 检查是否正在运行 + * @return bool + */ + public function isRunning() + { + if (self::STATUS_STARTED !== $this->status) { + return false; + } + + $this->updateStatus(false); + + return $this->processInformation['running']; + } + + /** + * 检查是否已开始 + * @return bool + */ + public function isStarted() + { + return self::STATUS_READY != $this->status; + } + + /** + * 检查是否已终止 + * @return bool + */ + public function isTerminated() + { + $this->updateStatus(false); + + return self::STATUS_TERMINATED == $this->status; + } + + /** + * 获取当前的状态 + * @return string + */ + public function getStatus() + { + $this->updateStatus(false); + + return $this->status; + } + + /** + * 终止进程 + */ + public function stop() + { + if ($this->isRunning()) { + if ('\\' === DS && !$this->isSigchildEnabled()) { + exec(sprintf('taskkill /F /T /PID %d 2>&1', $this->getPid()), $output, $exitCode); + if ($exitCode > 0) { + throw new \RuntimeException('Unable to kill the process'); + } + } else { + $pids = preg_split('/\s+/', `ps -o pid --no-heading --ppid {$this->getPid()}`); + foreach ($pids as $pid) { + if (is_numeric($pid)) { + posix_kill($pid, 9); + } + } + } + } + + $this->updateStatus(false); + if ($this->processInformation['running']) { + $this->close(); + } + + return $this->exitcode; + } + + /** + * 添加一行输出 + * @param string $line + */ + public function addOutput($line) +{ + $this->lastOutputTime = microtime(true); + $this->stdout .= $line; + } + + /** + * 添加一行错误输出 + * @param string $line + */ + public function addErrorOutput($line) +{ + $this->lastOutputTime = microtime(true); + $this->stderr .= $line; + } + + /** + * 获取被执行的指令 + * @return string + */ + public function getCommandLine() +{ + return $this->commandline; + } + + /** + * 设置指令 + * @param string $commandline + * @return self + */ + public function setCommandLine($commandline) +{ + $this->commandline = $commandline; + + return $this; + } + + /** + * 获取超时时间 + * @return float|null + */ + public function getTimeout() +{ + return $this->timeout; + } + + /** + * 获取idle超时时间 + * @return float|null + */ + public function getIdleTimeout() +{ + return $this->idleTimeout; + } + + /** + * 设置超时时间 + * @param int|float|null $timeout + * @return self + */ + public function setTimeout($timeout) +{ + $this->timeout = $this->validateTimeout($timeout); + + return $this; + } + + /** + * 设置idle超时时间 + * @param int|float|null $timeout + * @return self + */ + public function setIdleTimeout($timeout) +{ + if (null !== $timeout && $this->outputDisabled) { + throw new \LogicException('Idle timeout can not be set while the output is disabled.'); + } + + $this->idleTimeout = $this->validateTimeout($timeout); + + return $this; + } + + /** + * 设置TTY + * @param bool $tty + * @return self + */ + public function setTty($tty) +{ + if ('\\' === DS && $tty) { + throw new \RuntimeException('TTY mode is not supported on Windows platform.'); + } + if ($tty && (!file_exists('/dev/tty') || !is_readable('/dev/tty'))) { + throw new \RuntimeException('TTY mode requires /dev/tty to be readable.'); + } + + $this->tty = (bool) $tty; + + return $this; + } + + /** + * 检查是否是tty模式 + * @return bool + */ + public function isTty() +{ + return $this->tty; + } + + /** + * 设置pty模式 + * @param bool $bool + * @return self + */ + public function setPty($bool) +{ + $this->pty = (bool) $bool; + + return $this; + } + + /** + * 是否是pty模式 + * @return bool + */ + public function isPty() +{ + return $this->pty; + } + + /** + * 获取工作目录 + * @return string|null + */ + public function getWorkingDirectory() +{ + if (null === $this->cwd) { + return getcwd() ?: null; + } + + return $this->cwd; + } + + /** + * 设置工作目录 + * @param string $cwd + * @return self + */ + public function setWorkingDirectory($cwd) +{ + $this->cwd = $cwd; + + return $this; + } + + /** + * 获取环境变量 + * @return array + */ + public function getEnv() +{ + return $this->env; + } + + /** + * 设置环境变量 + * @param array $env + * @return self + */ + public function setEnv(array $env) +{ + $env = array_filter($env, function ($value) { + return !is_array($value); + }); + + $this->env = []; + foreach ($env as $key => $value) { + $this->env[(binary) $key] = (binary) $value; + } + + return $this; + } + + /** + * 获取输入 + * @return null|string + */ + public function getInput() +{ + return $this->input; + } + + /** + * 设置输入 + * @param mixed $input + * @return self + */ + public function setInput($input) +{ + if ($this->isRunning()) { + throw new \LogicException('Input can not be set while the process is running.'); + } + + $this->input = Utils::validateInput(sprintf('%s::%s', __CLASS__, __FUNCTION__), $input); + + return $this; + } + + /** + * 获取proc_open的选项 + * @return array + */ + public function getOptions() +{ + return $this->options; + } + + /** + * 设置proc_open的选项 + * @param array $options + * @return self + */ + public function setOptions(array $options) +{ + $this->options = $options; + + return $this; + } + + /** + * 是否兼容windows + * @return bool + */ + public function getEnhanceWindowsCompatibility() +{ + return $this->enhanceWindowsCompatibility; + } + + /** + * 设置是否兼容windows + * @param bool $enhance + * @return self + */ + public function setEnhanceWindowsCompatibility($enhance) +{ + $this->enhanceWindowsCompatibility = (bool) $enhance; + + return $this; + } + + /** + * 返回是否 sigchild 兼容模式激活 + * @return bool + */ + public function getEnhanceSigchildCompatibility() +{ + return $this->enhanceSigchildCompatibility; + } + + /** + * 激活 sigchild 兼容性模式。 + * @param bool $enhance + * @return self + */ + public function setEnhanceSigchildCompatibility($enhance) +{ + $this->enhanceSigchildCompatibility = (bool) $enhance; + + return $this; + } + + /** + * 是否超时 + */ + public function checkTimeout() +{ + if (self::STATUS_STARTED !== $this->status) { + return; + } + + if (null !== $this->timeout && $this->timeout < microtime(true) - $this->starttime) { + $this->stop(); + + throw new ProcessTimeoutException($this, ProcessTimeoutException::TYPE_GENERAL); + } + + if (null !== $this->idleTimeout && $this->idleTimeout < microtime(true) - $this->lastOutputTime) { + $this->stop(); + + throw new ProcessTimeoutException($this, ProcessTimeoutException::TYPE_IDLE); + } + } + + /** + * 是否支持pty + * @return bool + */ + public static function isPtySupported() +{ + static $result; + + if (null !== $result) { + return $result; + } + + if ('\\' === DS) { + return $result = false; + } + + $proc = @proc_open('echo 1', [['pty'], ['pty'], ['pty']], $pipes); + if (is_resource($proc)) { + proc_close($proc); + + return $result = true; + } + + return $result = false; + } + + /** + * 创建所需的 proc_open 的描述符 + * @return array + */ + private function getDescriptors() +{ + if ('\\' === DS) { + $this->processPipes = WindowsPipes::create($this, $this->input); + } else { + $this->processPipes = UnixPipes::create($this, $this->input); + } + $descriptors = $this->processPipes->getDescriptors($this->outputDisabled); + + if (!$this->useFileHandles && $this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) { + + $descriptors = array_merge($descriptors, [['pipe', 'w']]); + + $this->commandline = '(' . $this->commandline . ') 3>/dev/null; code=$?; echo $code >&3; exit $code'; + } + + return $descriptors; + } + + /** + * 建立 wait () 使用的回调。 + * @param callable|null $callback + * @return callable + */ + protected function buildCallback($callback) +{ + $out = self::OUT; + $callback = function ($type, $data) use ($callback, $out) { + if ($out == $type) { + $this->addOutput($data); + } else { + $this->addErrorOutput($data); + } + + if (null !== $callback) { + call_user_func($callback, $type, $data); + } + }; + + return $callback; + } + + /** + * 更新状态 + * @param bool $blocking + */ + protected function updateStatus($blocking) +{ + if (self::STATUS_STARTED !== $this->status) { + return; + } + + $this->processInformation = proc_get_status($this->process); + $this->captureExitCode(); + + $this->readPipes($blocking, '\\' === DS ? !$this->processInformation['running'] : true); + + if (!$this->processInformation['running']) { + $this->close(); + } + } + + /** + * 是否开启 '--enable-sigchild' + * @return bool + */ + protected function isSigchildEnabled() +{ + if (null !== self::$sigchild) { + return self::$sigchild; + } + + if (!function_exists('phpinfo')) { + return self::$sigchild = false; + } + + ob_start(); + phpinfo(INFO_GENERAL); + + return self::$sigchild = false !== strpos(ob_get_clean(), '--enable-sigchild'); + } + + /** + * 验证是否超时 + * @param int|float|null $timeout + * @return float|null + */ + private function validateTimeout($timeout) +{ + $timeout = (float) $timeout; + + if (0.0 === $timeout) { + $timeout = null; + } elseif ($timeout < 0) { + throw new \InvalidArgumentException('The timeout value must be a valid positive integer or float number.'); + } + + return $timeout; + } + + /** + * 读取pipes + * @param bool $blocking + * @param bool $close + */ + private function readPipes($blocking, $close) +{ + $result = $this->processPipes->readAndWrite($blocking, $close); + + $callback = $this->callback; + foreach ($result as $type => $data) { + if (3 == $type) { + $this->fallbackExitcode = (int) $data; + } else { + $callback(self::STDOUT === $type ? self::OUT : self::ERR, $data); + } + } + } + + /** + * 捕获退出码 + */ + private function captureExitCode() +{ + if (isset($this->processInformation['exitcode']) && -1 != $this->processInformation['exitcode']) { + $this->exitcode = $this->processInformation['exitcode']; + } + } + + /** + * 关闭资源 + * @return int 退出码 + */ + private function close() +{ + $this->processPipes->close(); + if (is_resource($this->process)) { + $exitcode = proc_close($this->process); + } else { + $exitcode = -1; + } + + $this->exitcode = -1 !== $exitcode ? $exitcode : (null !== $this->exitcode ? $this->exitcode : -1); + $this->status = self::STATUS_TERMINATED; + + if (-1 === $this->exitcode && null !== $this->fallbackExitcode) { + $this->exitcode = $this->fallbackExitcode; + } elseif (-1 === $this->exitcode && $this->processInformation['signaled'] + && 0 < $this->processInformation['termsig'] + ) { + $this->exitcode = 128 + $this->processInformation['termsig']; + } + + return $this->exitcode; + } + + /** + * 重置数据 + */ + private function resetProcessData() +{ + $this->starttime = null; + $this->callback = null; + $this->exitcode = null; + $this->fallbackExitcode = null; + $this->processInformation = null; + $this->stdout = null; + $this->stderr = null; + $this->process = null; + $this->latestSignal = null; + $this->status = self::STATUS_READY; + $this->incrementalOutputOffset = 0; + $this->incrementalErrorOutputOffset = 0; + } + + /** + * 将一个 POSIX 信号发送到进程中。 + * @param int $signal + * @param bool $throwException + * @return bool + */ + private function doSignal($signal, $throwException) +{ + if (!$this->isRunning()) { + if ($throwException) { + throw new \LogicException('Can not send signal on a non running process.'); + } + + return false; + } + + if ($this->isSigchildEnabled()) { + if ($throwException) { + throw new \RuntimeException('This PHP has been compiled with --enable-sigchild. The process can not be signaled.'); + } + + return false; + } + + if (true !== @proc_terminate($this->process, $signal)) { + if ($throwException) { + throw new \RuntimeException(sprintf('Error while sending signal `%s`.', $signal)); + } + + return false; + } + + $this->latestSignal = $signal; + + return true; + } + + /** + * 确保进程已经开启 + * @param string $functionName + */ + private function requireProcessIsStarted($functionName) +{ + if (!$this->isStarted()) { + throw new \LogicException(sprintf('Process must be started before calling %s.', $functionName)); + } + } + + /** + * 确保进程已经终止 + * @param string $functionName + */ + private function requireProcessIsTerminated($functionName) +{ + if (!$this->isTerminated()) { + throw new \LogicException(sprintf('Process must be terminated before calling %s.', $functionName)); + } + } +} diff --git a/thinkphp/library/think/Request.php b/thinkphp/library/think/Request.php new file mode 100644 index 0000000..4baf026 --- /dev/null +++ b/thinkphp/library/think/Request.php @@ -0,0 +1,1690 @@ + +// +---------------------------------------------------------------------- + +namespace think; + +class Request +{ + /** + * @var object 对象实例 + */ + protected static $instance; + + protected $method; + /** + * @var string 域名(含协议和端口) + */ + protected $domain; + + /** + * @var string URL地址 + */ + protected $url; + + /** + * @var string 基础URL + */ + protected $baseUrl; + + /** + * @var string 当前执行的文件 + */ + protected $baseFile; + + /** + * @var string 访问的ROOT地址 + */ + protected $root; + + /** + * @var string pathinfo + */ + protected $pathinfo; + + /** + * @var string pathinfo(不含后缀) + */ + protected $path; + + /** + * @var array 当前路由信息 + */ + protected $routeInfo = []; + + /** + * @var array 环境变量 + */ + protected $env; + + /** + * @var array 当前调度信息 + */ + protected $dispatch = []; + protected $module; + protected $controller; + protected $action; + // 当前语言集 + protected $langset; + + /** + * @var array 请求参数 + */ + protected $param = []; + protected $get = []; + protected $post = []; + protected $request = []; + protected $route = []; + protected $put; + protected $session = []; + protected $file = []; + protected $cookie = []; + protected $server = []; + protected $header = []; + + /** + * @var array 资源类型 + */ + protected $mimeType = [ + 'xml' => 'application/xml,text/xml,application/x-xml', + 'json' => 'application/json,text/x-json,application/jsonrequest,text/json', + 'js' => 'text/javascript,application/javascript,application/x-javascript', + 'css' => 'text/css', + 'rss' => 'application/rss+xml', + 'yaml' => 'application/x-yaml,text/yaml', + 'atom' => 'application/atom+xml', + 'pdf' => 'application/pdf', + 'text' => 'text/plain', + 'image' => 'image/png,image/jpg,image/jpeg,image/pjpeg,image/gif,image/webp,image/*', + 'csv' => 'text/csv', + 'html' => 'text/html,application/xhtml+xml,*/*', + ]; + + protected $content; + + // 全局过滤规则 + protected $filter; + // Hook扩展方法 + protected static $hook = []; + // 绑定的属性 + protected $bind = []; + // php://input + protected $input; + // 请求缓存 + protected $cache; + // 缓存是否检查 + protected $isCheckCache; + /** + * 是否合并Param + * @var bool + */ + protected $mergeParam = false; + + /** + * 构造函数 + * @access protected + * @param array $options 参数 + */ + protected function __construct($options = []) + { + foreach ($options as $name => $item) { + if (property_exists($this, $name)) { + $this->$name = $item; + } + } + if (is_null($this->filter)) { + $this->filter = Config::get('default_filter'); + } + + // 保存 php://input + $this->input = file_get_contents('php://input'); + } + + public function __call($method, $args) + { + if (array_key_exists($method, self::$hook)) { + array_unshift($args, $this); + return call_user_func_array(self::$hook[$method], $args); + } else { + throw new Exception('method not exists:' . __CLASS__ . '->' . $method); + } + } + + /** + * Hook 方法注入 + * @access public + * @param string|array $method 方法名 + * @param mixed $callback callable + * @return void + */ + public static function hook($method, $callback = null) + { + if (is_array($method)) { + self::$hook = array_merge(self::$hook, $method); + } else { + self::$hook[$method] = $callback; + } + } + + /** + * 初始化 + * @access public + * @param array $options 参数 + * @return \think\Request + */ + public static function instance($options = []) + { + if (is_null(self::$instance)) { + self::$instance = new static($options); + } + return self::$instance; + } + + /** + * 销毁当前请求对象 + * @access public + * @return void + */ + public static function destroy() + { + if (!is_null(self::$instance)) { + self::$instance = null; + } + } + + /** + * 创建一个URL请求 + * @access public + * @param string $uri URL地址 + * @param string $method 请求类型 + * @param array $params 请求参数 + * @param array $cookie + * @param array $files + * @param array $server + * @param string $content + * @return \think\Request + */ + public static function create($uri, $method = 'GET', $params = [], $cookie = [], $files = [], $server = [], $content = null) + { + $server['PATH_INFO'] = ''; + $server['REQUEST_METHOD'] = strtoupper($method); + $info = parse_url($uri); + if (isset($info['host'])) { + $server['SERVER_NAME'] = $info['host']; + $server['HTTP_HOST'] = $info['host']; + } + if (isset($info['scheme'])) { + if ('https' === $info['scheme']) { + $server['HTTPS'] = 'on'; + $server['SERVER_PORT'] = 443; + } else { + unset($server['HTTPS']); + $server['SERVER_PORT'] = 80; + } + } + if (isset($info['port'])) { + $server['SERVER_PORT'] = $info['port']; + $server['HTTP_HOST'] = $server['HTTP_HOST'] . ':' . $info['port']; + } + if (isset($info['user'])) { + $server['PHP_AUTH_USER'] = $info['user']; + } + if (isset($info['pass'])) { + $server['PHP_AUTH_PW'] = $info['pass']; + } + if (!isset($info['path'])) { + $info['path'] = '/'; + } + $options = []; + $options[strtolower($method)] = $params; + $queryString = ''; + if (isset($info['query'])) { + parse_str(html_entity_decode($info['query']), $query); + if (!empty($params)) { + $params = array_replace($query, $params); + $queryString = http_build_query($params, '', '&'); + } else { + $params = $query; + $queryString = $info['query']; + } + } elseif (!empty($params)) { + $queryString = http_build_query($params, '', '&'); + } + if ($queryString) { + parse_str($queryString, $get); + $options['get'] = isset($options['get']) ? array_merge($get, $options['get']) : $get; + } + + $server['REQUEST_URI'] = $info['path'] . ('' !== $queryString ? '?' . $queryString : ''); + $server['QUERY_STRING'] = $queryString; + $options['cookie'] = $cookie; + $options['param'] = $params; + $options['file'] = $files; + $options['server'] = $server; + $options['url'] = $server['REQUEST_URI']; + $options['baseUrl'] = $info['path']; + $options['pathinfo'] = '/' == $info['path'] ? '/' : ltrim($info['path'], '/'); + $options['method'] = $server['REQUEST_METHOD']; + $options['domain'] = isset($info['scheme']) ? $info['scheme'] . '://' . $server['HTTP_HOST'] : ''; + $options['content'] = $content; + self::$instance = new self($options); + return self::$instance; + } + + /** + * 设置或获取当前包含协议的域名 + * @access public + * @param string $domain 域名 + * @return string + */ + public function domain($domain = null) + { + if (!is_null($domain)) { + $this->domain = $domain; + return $this; + } elseif (!$this->domain) { + $this->domain = $this->scheme() . '://' . $this->host(); + } + return $this->domain; + } + + /** + * 设置或获取当前完整URL 包括QUERY_STRING + * @access public + * @param string|true $url URL地址 true 带域名获取 + * @return string + */ + public function url($url = null) + { + if (!is_null($url) && true !== $url) { + $this->url = $url; + return $this; + } elseif (!$this->url) { + if (IS_CLI) { + $this->url = isset($_SERVER['argv'][1]) ? $_SERVER['argv'][1] : ''; + } elseif (isset($_SERVER['HTTP_X_REWRITE_URL'])) { + $this->url = $_SERVER['HTTP_X_REWRITE_URL']; + } elseif (isset($_SERVER['REQUEST_URI'])) { + $this->url = $_SERVER['REQUEST_URI']; + } elseif (isset($_SERVER['ORIG_PATH_INFO'])) { + $this->url = $_SERVER['ORIG_PATH_INFO'] . (!empty($_SERVER['QUERY_STRING']) ? '?' . $_SERVER['QUERY_STRING'] : ''); + } else { + $this->url = ''; + } + } + return true === $url ? $this->domain() . $this->url : $this->url; + } + + /** + * 设置或获取当前URL 不含QUERY_STRING + * @access public + * @param string $url URL地址 + * @return string + */ + public function baseUrl($url = null) + { + if (!is_null($url) && true !== $url) { + $this->baseUrl = $url; + return $this; + } elseif (!$this->baseUrl) { + $str = $this->url(); + $this->baseUrl = strpos($str, '?') ? strstr($str, '?', true) : $str; + } + return true === $url ? $this->domain() . $this->baseUrl : $this->baseUrl; + } + + /** + * 设置或获取当前执行的文件 SCRIPT_NAME + * @access public + * @param string $file 当前执行的文件 + * @return string + */ + public function baseFile($file = null) + { + if (!is_null($file) && true !== $file) { + $this->baseFile = $file; + return $this; + } elseif (!$this->baseFile) { + $url = ''; + if (!IS_CLI) { + $script_name = basename($_SERVER['SCRIPT_FILENAME']); + if (basename($_SERVER['SCRIPT_NAME']) === $script_name) { + $url = $_SERVER['SCRIPT_NAME']; + } elseif (basename($_SERVER['PHP_SELF']) === $script_name) { + $url = $_SERVER['PHP_SELF']; + } elseif (isset($_SERVER['ORIG_SCRIPT_NAME']) && basename($_SERVER['ORIG_SCRIPT_NAME']) === $script_name) { + $url = $_SERVER['ORIG_SCRIPT_NAME']; + } elseif (($pos = strpos($_SERVER['PHP_SELF'], '/' . $script_name)) !== false) { + $url = substr($_SERVER['SCRIPT_NAME'], 0, $pos) . '/' . $script_name; + } elseif (isset($_SERVER['DOCUMENT_ROOT']) && strpos($_SERVER['SCRIPT_FILENAME'], $_SERVER['DOCUMENT_ROOT']) === 0) { + $url = str_replace('\\', '/', str_replace($_SERVER['DOCUMENT_ROOT'], '', $_SERVER['SCRIPT_FILENAME'])); + } + } + $this->baseFile = $url; + } + return true === $file ? $this->domain() . $this->baseFile : $this->baseFile; + } + + /** + * 设置或获取URL访问根地址 + * @access public + * @param string $url URL地址 + * @return string + */ + public function root($url = null) + { + if (!is_null($url) && true !== $url) { + $this->root = $url; + return $this; + } elseif (!$this->root) { + $file = $this->baseFile(); + if ($file && 0 !== strpos($this->url(), $file)) { + $file = str_replace('\\', '/', dirname($file)); + } + $this->root = rtrim($file, '/'); + } + return true === $url ? $this->domain() . $this->root : $this->root; + } + + /** + * 获取当前请求URL的pathinfo信息(含URL后缀) + * @access public + * @return string + */ + public function pathinfo() + { + if (is_null($this->pathinfo)) { + if (isset($_GET[Config::get('var_pathinfo')])) { + // 判断URL里面是否有兼容模式参数 + $_SERVER['PATH_INFO'] = $_GET[Config::get('var_pathinfo')]; + unset($_GET[Config::get('var_pathinfo')]); + } elseif (IS_CLI) { + // CLI模式下 index.php module/controller/action/params/... + $_SERVER['PATH_INFO'] = isset($_SERVER['argv'][1]) ? $_SERVER['argv'][1] : ''; + } + + // 分析PATHINFO信息 + if (!isset($_SERVER['PATH_INFO'])) { + foreach (Config::get('pathinfo_fetch') as $type) { + if (!empty($_SERVER[$type])) { + $_SERVER['PATH_INFO'] = (0 === strpos($_SERVER[$type], $_SERVER['SCRIPT_NAME'])) ? + substr($_SERVER[$type], strlen($_SERVER['SCRIPT_NAME'])) : $_SERVER[$type]; + break; + } + } + } + $this->pathinfo = empty($_SERVER['PATH_INFO']) ? '/' : ltrim($_SERVER['PATH_INFO'], '/'); + } + return $this->pathinfo; + } + + /** + * 获取当前请求URL的pathinfo信息(不含URL后缀) + * @access public + * @return string + */ + public function path() + { + if (is_null($this->path)) { + $suffix = Config::get('url_html_suffix'); + $pathinfo = $this->pathinfo(); + if (false === $suffix) { + // 禁止伪静态访问 + $this->path = $pathinfo; + } elseif ($suffix) { + // 去除正常的URL后缀 + $this->path = preg_replace('/\.(' . ltrim($suffix, '.') . ')$/i', '', $pathinfo); + } else { + // 允许任何后缀访问 + $this->path = preg_replace('/\.' . $this->ext() . '$/i', '', $pathinfo); + } + } + return $this->path; + } + + /** + * 当前URL的访问后缀 + * @access public + * @return string + */ + public function ext() + { + return pathinfo($this->pathinfo(), PATHINFO_EXTENSION); + } + + /** + * 获取当前请求的时间 + * @access public + * @param bool $float 是否使用浮点类型 + * @return integer|float + */ + public function time($float = false) + { + return $float ? $_SERVER['REQUEST_TIME_FLOAT'] : $_SERVER['REQUEST_TIME']; + } + + /** + * 当前请求的资源类型 + * @access public + * @return false|string + */ + public function type() + { + $accept = $this->server('HTTP_ACCEPT'); + if (empty($accept)) { + return false; + } + + foreach ($this->mimeType as $key => $val) { + $array = explode(',', $val); + foreach ($array as $k => $v) { + if (stristr($accept, $v)) { + return $key; + } + } + } + return false; + } + + /** + * 设置资源类型 + * @access public + * @param string|array $type 资源类型名 + * @param string $val 资源类型 + * @return void + */ + public function mimeType($type, $val = '') + { + if (is_array($type)) { + $this->mimeType = array_merge($this->mimeType, $type); + } else { + $this->mimeType[$type] = $val; + } + } + + /** + * 当前的请求类型 + * @access public + * @param bool $method true 获取原始请求类型 + * @return string + */ + public function method($method = false) + { + if (true === $method) { + // 获取原始请求类型 + return $this->server('REQUEST_METHOD') ?: 'GET'; + } elseif (!$this->method) { + if (isset($_POST[Config::get('var_method')])) { + $method = strtoupper($_POST[Config::get('var_method')]); + if (in_array($method, ['GET', 'POST', 'DELETE', 'PUT', 'PATCH'])) { + $this->method = $method; + $this->{$this->method}($_POST); + } else { + $this->method = 'POST'; + } + unset($_POST[Config::get('var_method')]); + } elseif (isset($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'])) { + $this->method = strtoupper($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE']); + } else { + $this->method = $this->server('REQUEST_METHOD') ?: 'GET'; + } + } + return $this->method; + } + + /** + * 是否为GET请求 + * @access public + * @return bool + */ + public function isGet() + { + return $this->method() == 'GET'; + } + + /** + * 是否为POST请求 + * @access public + * @return bool + */ + public function isPost() + { + return $this->method() == 'POST'; + } + + /** + * 是否为PUT请求 + * @access public + * @return bool + */ + public function isPut() + { + return $this->method() == 'PUT'; + } + + /** + * 是否为DELTE请求 + * @access public + * @return bool + */ + public function isDelete() + { + return $this->method() == 'DELETE'; + } + + /** + * 是否为HEAD请求 + * @access public + * @return bool + */ + public function isHead() + { + return $this->method() == 'HEAD'; + } + + /** + * 是否为PATCH请求 + * @access public + * @return bool + */ + public function isPatch() + { + return $this->method() == 'PATCH'; + } + + /** + * 是否为OPTIONS请求 + * @access public + * @return bool + */ + public function isOptions() + { + return $this->method() == 'OPTIONS'; + } + + /** + * 是否为cli + * @access public + * @return bool + */ + public function isCli() + { + return PHP_SAPI == 'cli'; + } + + /** + * 是否为cgi + * @access public + * @return bool + */ + public function isCgi() + { + return strpos(PHP_SAPI, 'cgi') === 0; + } + + /** + * 获取当前请求的参数 + * @access public + * @param string|array $name 变量名 + * @param mixed $default 默认值 + * @param string|array $filter 过滤方法 + * @return mixed + */ + public function param($name = '', $default = null, $filter = '') + { + if (empty($this->mergeParam)) { + $method = $this->method(true); + // 自动获取请求变量 + switch ($method) { + case 'POST': + $vars = $this->post(false); + break; + case 'PUT': + case 'DELETE': + case 'PATCH': + $vars = $this->put(false); + break; + default: + $vars = []; + } + // 当前请求参数和URL地址中的参数合并 + $this->param = array_merge($this->param, $this->get(false), $vars, $this->route(false)); + $this->mergeParam = true; + } + if (true === $name) { + // 获取包含文件上传信息的数组 + $file = $this->file(); + $data = is_array($file) ? array_merge($this->param, $file) : $this->param; + return $this->input($data, '', $default, $filter); + } + return $this->input($this->param, $name, $default, $filter); + } + + /** + * 设置获取路由参数 + * @access public + * @param string|array $name 变量名 + * @param mixed $default 默认值 + * @param string|array $filter 过滤方法 + * @return mixed + */ + public function route($name = '', $default = null, $filter = '') + { + if (is_array($name)) { + $this->param = []; + $this->mergeParam = false; + return $this->route = array_merge($this->route, $name); + } + return $this->input($this->route, $name, $default, $filter); + } + + /** + * 设置获取GET参数 + * @access public + * @param string|array $name 变量名 + * @param mixed $default 默认值 + * @param string|array $filter 过滤方法 + * @return mixed + */ + public function get($name = '', $default = null, $filter = '') + { + if (empty($this->get)) { + $this->get = $_GET; + } + if (is_array($name)) { + $this->param = []; + $this->mergeParam = false; + return $this->get = array_merge($this->get, $name); + } + return $this->input($this->get, $name, $default, $filter); + } + + /** + * 设置获取POST参数 + * @access public + * @param string $name 变量名 + * @param mixed $default 默认值 + * @param string|array $filter 过滤方法 + * @return mixed + */ + public function post($name = '', $default = null, $filter = '') + { + if (empty($this->post)) { + $content = $this->input; + if (empty($_POST) && false !== strpos($this->contentType(), 'application/json')) { + $this->post = (array) json_decode($content, true); + } else { + $this->post = $_POST; + } + } + if (is_array($name)) { + $this->param = []; + $this->mergeParam = false; + return $this->post = array_merge($this->post, $name); + } + return $this->input($this->post, $name, $default, $filter); + } + + /** + * 设置获取PUT参数 + * @access public + * @param string|array $name 变量名 + * @param mixed $default 默认值 + * @param string|array $filter 过滤方法 + * @return mixed + */ + public function put($name = '', $default = null, $filter = '') + { + if (is_null($this->put)) { + $content = $this->input; + if (false !== strpos($this->contentType(), 'application/json')) { + $this->put = (array) json_decode($content, true); + } else { + parse_str($content, $this->put); + } + } + if (is_array($name)) { + $this->param = []; + $this->mergeParam = false; + return $this->put = is_null($this->put) ? $name : array_merge($this->put, $name); + } + + return $this->input($this->put, $name, $default, $filter); + } + + /** + * 设置获取DELETE参数 + * @access public + * @param string|array $name 变量名 + * @param mixed $default 默认值 + * @param string|array $filter 过滤方法 + * @return mixed + */ + public function delete($name = '', $default = null, $filter = '') + { + return $this->put($name, $default, $filter); + } + + /** + * 设置获取PATCH参数 + * @access public + * @param string|array $name 变量名 + * @param mixed $default 默认值 + * @param string|array $filter 过滤方法 + * @return mixed + */ + public function patch($name = '', $default = null, $filter = '') + { + return $this->put($name, $default, $filter); + } + + /** + * 获取request变量 + * @param string $name 数据名称 + * @param string $default 默认值 + * @param string|array $filter 过滤方法 + * @return mixed + */ + public function request($name = '', $default = null, $filter = '') + { + if (empty($this->request)) { + $this->request = $_REQUEST; + } + if (is_array($name)) { + $this->param = []; + $this->mergeParam = false; + return $this->request = array_merge($this->request, $name); + } + return $this->input($this->request, $name, $default, $filter); + } + + /** + * 获取session数据 + * @access public + * @param string|array $name 数据名称 + * @param string $default 默认值 + * @param string|array $filter 过滤方法 + * @return mixed + */ + public function session($name = '', $default = null, $filter = '') + { + if (empty($this->session)) { + $this->session = Session::get(); + } + if (is_array($name)) { + return $this->session = array_merge($this->session, $name); + } + return $this->input($this->session, $name, $default, $filter); + } + + /** + * 获取cookie参数 + * @access public + * @param string|array $name 数据名称 + * @param string $default 默认值 + * @param string|array $filter 过滤方法 + * @return mixed + */ + public function cookie($name = '', $default = null, $filter = '') + { + if (empty($this->cookie)) { + $this->cookie = Cookie::get(); + } + if (is_array($name)) { + return $this->cookie = array_merge($this->cookie, $name); + } elseif (!empty($name)) { + $data = Cookie::has($name) ? Cookie::get($name) : $default; + } else { + $data = $this->cookie; + } + + // 解析过滤器 + $filter = $this->getFilter($filter, $default); + + if (is_array($data)) { + array_walk_recursive($data, [$this, 'filterValue'], $filter); + reset($data); + } else { + $this->filterValue($data, $name, $filter); + } + return $data; + } + + /** + * 获取server参数 + * @access public + * @param string|array $name 数据名称 + * @param string $default 默认值 + * @param string|array $filter 过滤方法 + * @return mixed + */ + public function server($name = '', $default = null, $filter = '') + { + if (empty($this->server)) { + $this->server = $_SERVER; + } + if (is_array($name)) { + return $this->server = array_merge($this->server, $name); + } + return $this->input($this->server, false === $name ? false : strtoupper($name), $default, $filter); + } + + /** + * 获取上传的文件信息 + * @access public + * @param string|array $name 名称 + * @return null|array|\think\File + */ + public function file($name = '') + { + if (empty($this->file)) { + $this->file = isset($_FILES) ? $_FILES : []; + } + if (is_array($name)) { + return $this->file = array_merge($this->file, $name); + } + $files = $this->file; + if (!empty($files)) { + // 处理上传文件 + $array = []; + foreach ($files as $key => $file) { + if (is_array($file['name'])) { + $item = []; + $keys = array_keys($file); + $count = count($file['name']); + for ($i = 0; $i < $count; $i++) { + if (empty($file['tmp_name'][$i]) || !is_file($file['tmp_name'][$i])) { + continue; + } + $temp['key'] = $key; + foreach ($keys as $_key) { + $temp[$_key] = $file[$_key][$i]; + } + $item[] = (new File($temp['tmp_name']))->setUploadInfo($temp); + } + $array[$key] = $item; + } else { + if ($file instanceof File) { + $array[$key] = $file; + } else { + if (empty($file['tmp_name']) || !is_file($file['tmp_name'])) { + continue; + } + $array[$key] = (new File($file['tmp_name']))->setUploadInfo($file); + } + } + } + if (strpos($name, '.')) { + list($name, $sub) = explode('.', $name); + } + if ('' === $name) { + // 获取全部文件 + return $array; + } elseif (isset($sub) && isset($array[$name][$sub])) { + return $array[$name][$sub]; + } elseif (isset($array[$name])) { + return $array[$name]; + } + } + return; + } + + /** + * 获取环境变量 + * @param string|array $name 数据名称 + * @param string $default 默认值 + * @param string|array $filter 过滤方法 + * @return mixed + */ + public function env($name = '', $default = null, $filter = '') + { + if (empty($this->env)) { + $this->env = $_ENV; + } + if (is_array($name)) { + return $this->env = array_merge($this->env, $name); + } + return $this->input($this->env, false === $name ? false : strtoupper($name), $default, $filter); + } + + /** + * 设置或者获取当前的Header + * @access public + * @param string|array $name header名称 + * @param string $default 默认值 + * @return string + */ + public function header($name = '', $default = null) + { + if (empty($this->header)) { + $header = []; + if (function_exists('apache_request_headers') && $result = apache_request_headers()) { + $header = $result; + } else { + $server = $this->server ?: $_SERVER; + foreach ($server as $key => $val) { + if (0 === strpos($key, 'HTTP_')) { + $key = str_replace('_', '-', strtolower(substr($key, 5))); + $header[$key] = $val; + } + } + if (isset($server['CONTENT_TYPE'])) { + $header['content-type'] = $server['CONTENT_TYPE']; + } + if (isset($server['CONTENT_LENGTH'])) { + $header['content-length'] = $server['CONTENT_LENGTH']; + } + } + $this->header = array_change_key_case($header); + } + if (is_array($name)) { + return $this->header = array_merge($this->header, $name); + } + if ('' === $name) { + return $this->header; + } + $name = str_replace('_', '-', strtolower($name)); + return isset($this->header[$name]) ? $this->header[$name] : $default; + } + + /** + * 获取变量 支持过滤和默认值 + * @param array $data 数据源 + * @param string|false $name 字段名 + * @param mixed $default 默认值 + * @param string|array $filter 过滤函数 + * @return mixed + */ + public function input($data = [], $name = '', $default = null, $filter = '') + { + if (false === $name) { + // 获取原始数据 + return $data; + } + $name = (string) $name; + if ('' != $name) { + // 解析name + if (strpos($name, '/')) { + list($name, $type) = explode('/', $name); + } else { + $type = 's'; + } + // 按.拆分成多维数组进行判断 + foreach (explode('.', $name) as $val) { + if (isset($data[$val])) { + $data = $data[$val]; + } else { + // 无输入数据,返回默认值 + return $default; + } + } + if (is_object($data)) { + return $data; + } + } + + // 解析过滤器 + $filter = $this->getFilter($filter, $default); + + if (is_array($data)) { + array_walk_recursive($data, [$this, 'filterValue'], $filter); + reset($data); + } else { + $this->filterValue($data, $name, $filter); + } + + if (isset($type) && $data !== $default) { + // 强制类型转换 + $this->typeCast($data, $type); + } + return $data; + } + + /** + * 设置或获取当前的过滤规则 + * @param mixed $filter 过滤规则 + * @return mixed + */ + public function filter($filter = null) + { + if (is_null($filter)) { + return $this->filter; + } else { + $this->filter = $filter; + } + } + + protected function getFilter($filter, $default) + { + if (is_null($filter)) { + $filter = []; + } else { + $filter = $filter ?: $this->filter; + if (is_string($filter) && false === strpos($filter, '/')) { + $filter = explode(',', $filter); + } else { + $filter = (array) $filter; + } + } + + $filter[] = $default; + return $filter; + } + + /** + * 递归过滤给定的值 + * @param mixed $value 键值 + * @param mixed $key 键名 + * @param array $filters 过滤方法+默认值 + * @return mixed + */ + private function filterValue(&$value, $key, $filters) + { + $default = array_pop($filters); + foreach ($filters as $filter) { + if (is_callable($filter)) { + // 调用函数或者方法过滤 + $value = call_user_func($filter, $value ?? ''); + } elseif (is_scalar($value)) { + if (false !== strpos($filter, '/')) { + // 正则过滤 + if (!preg_match($filter, $value)) { + // 匹配不成功返回默认值 + $value = $default; + break; + } + } elseif (!empty($filter)) { + // filter函数不存在时, 则使用filter_var进行过滤 + // filter为非整形值时, 调用filter_id取得过滤id + $value = filter_var($value, is_int($filter) ? $filter : filter_id($filter)); + if (false === $value) { + $value = $default; + break; + } + } + } + } + return $this->filterExp($value); + } + + /** + * 过滤表单中的表达式 + * @param string $value + * @return void + */ + public function filterExp(&$value) + { + // 过滤查询特殊字符 + if (is_string($value) && preg_match('/^(EXP|NEQ|GT|EGT|LT|ELT|OR|XOR|LIKE|NOTLIKE|NOT LIKE|NOT BETWEEN|NOTBETWEEN|BETWEEN|NOT EXISTS|NOTEXISTS|EXISTS|NOT NULL|NOTNULL|NULL|BETWEEN TIME|NOT BETWEEN TIME|NOTBETWEEN TIME|NOTIN|NOT IN|IN)$/i', $value)) { + $value .= ' '; + } + // TODO 其他安全过滤 + } + + /** + * 强制类型转换 + * @param string $data + * @param string $type + * @return mixed + */ + private function typeCast(&$data, $type) + { + switch (strtolower($type)) { + // 数组 + case 'a': + $data = (array) $data; + break; + // 数字 + case 'd': + $data = (int) $data; + break; + // 浮点 + case 'f': + $data = (float) $data; + break; + // 布尔 + case 'b': + $data = (boolean) $data; + break; + // 字符串 + case 's': + default: + if (is_scalar($data)) { + $data = (string) $data; + } else { + throw new \InvalidArgumentException('variable type error:' . gettype($data)); + } + } + } + + /** + * 是否存在某个请求参数 + * @access public + * @param string $name 变量名 + * @param string $type 变量类型 + * @param bool $checkEmpty 是否检测空值 + * @return mixed + */ + public function has($name, $type = 'param', $checkEmpty = false) + { + if (empty($this->$type)) { + $param = $this->$type(); + } else { + $param = $this->$type; + } + // 按.拆分成多维数组进行判断 + foreach (explode('.', $name) as $val) { + if (isset($param[$val])) { + $param = $param[$val]; + } else { + return false; + } + } + return ($checkEmpty && '' === $param) ? false : true; + } + + /** + * 获取指定的参数 + * @access public + * @param string|array $name 变量名 + * @param string $type 变量类型 + * @return mixed + */ + public function only($name, $type = 'param') + { + $param = $this->$type(); + if (is_string($name)) { + $name = explode(',', $name); + } + $item = []; + foreach ($name as $key) { + if (isset($param[$key])) { + $item[$key] = $param[$key]; + } + } + return $item; + } + + /** + * 排除指定参数获取 + * @access public + * @param string|array $name 变量名 + * @param string $type 变量类型 + * @return mixed + */ + public function except($name, $type = 'param') + { + $param = $this->$type(); + if (is_string($name)) { + $name = explode(',', $name); + } + foreach ($name as $key) { + if (isset($param[$key])) { + unset($param[$key]); + } + } + return $param; + } + + /** + * 当前是否ssl + * @access public + * @return bool + */ + public function isSsl() + { + $server = array_merge($_SERVER, $this->server); + if (isset($server['HTTPS']) && ('1' == $server['HTTPS'] || 'on' == strtolower($server['HTTPS']))) { + return true; + } elseif (isset($server['REQUEST_SCHEME']) && 'https' == $server['REQUEST_SCHEME']) { + return true; + } elseif (isset($server['SERVER_PORT']) && ('443' == $server['SERVER_PORT'])) { + return true; + } elseif (isset($server['HTTP_X_FORWARDED_PROTO']) && 'https' == $server['HTTP_X_FORWARDED_PROTO']) { + return true; + } elseif (Config::get('https_agent_name') && isset($server[Config::get('https_agent_name')])) { + return true; + } + return false; + } + + /** + * 当前是否Ajax请求 + * @access public + * @param bool $ajax true 获取原始ajax请求 + * @return bool + */ + public function isAjax($ajax = false) + { + $value = $this->server('HTTP_X_REQUESTED_WITH', '', 'strtolower'); + $result = ('xmlhttprequest' == $value) ? true : false; + if (true === $ajax) { + return $result; + } else { + $result = $this->param(Config::get('var_ajax')) ? true : $result; + $this->mergeParam = false; + return $result; + } + } + + /** + * 当前是否Pjax请求 + * @access public + * @param bool $pjax true 获取原始pjax请求 + * @return bool + */ + public function isPjax($pjax = false) + { + $result = !is_null($this->server('HTTP_X_PJAX')) ? true : false; + if (true === $pjax) { + return $result; + } else { + $result = $this->param(Config::get('var_pjax')) ? true : $result; + $this->mergeParam = false; + return $result; + } + } + + /** + * 获取客户端IP地址 + * @param integer $type 返回类型 0 返回IP地址 1 返回IPV4地址数字 + * @param boolean $adv 是否进行高级模式获取(有可能被伪装) + * @return mixed + */ + public function ip($type = 0, $adv = true) + { + $type = $type ? 1 : 0; + static $ip = null; + if (null !== $ip) { + return $ip[$type]; + } + + $httpAgentIp = Config::get('http_agent_ip'); + + if ($httpAgentIp && isset($_SERVER[$httpAgentIp])) { + $ip = $_SERVER[$httpAgentIp]; + } elseif ($adv) { + if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { + $arr = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']); + $pos = array_search('unknown', $arr); + if (false !== $pos) { + unset($arr[$pos]); + } + $ip = trim(current($arr)); + } elseif (isset($_SERVER['HTTP_CLIENT_IP'])) { + $ip = $_SERVER['HTTP_CLIENT_IP']; + } elseif (isset($_SERVER['REMOTE_ADDR'])) { + $ip = $_SERVER['REMOTE_ADDR']; + } + } elseif (isset($_SERVER['REMOTE_ADDR'])) { + $ip = $_SERVER['REMOTE_ADDR']; + } + // IP地址合法验证 + $long = sprintf("%u", ip2long($ip)); + $ip = $long ? [$ip, $long] : ['0.0.0.0', 0]; + return $ip[$type]; + } + + /** + * 检测是否使用手机访问 + * @access public + * @return bool + */ + public function isMobile() + { + if (isset($_SERVER['HTTP_VIA']) && stristr($_SERVER['HTTP_VIA'], "wap")) { + return true; + } elseif (isset($_SERVER['HTTP_ACCEPT']) && strpos(strtoupper($_SERVER['HTTP_ACCEPT']), "VND.WAP.WML")) { + return true; + } elseif (isset($_SERVER['HTTP_X_WAP_PROFILE']) || isset($_SERVER['HTTP_PROFILE'])) { + return true; + } elseif (isset($_SERVER['HTTP_USER_AGENT']) && preg_match('/(blackberry|configuration\/cldc|hp |hp-|htc |htc_|htc-|iemobile|kindle|midp|mmp|motorola|mobile|nokia|opera mini|opera |Googlebot-Mobile|YahooSeeker\/M1A1-R2D2|android|iphone|ipod|mobi|palm|palmos|pocket|portalmmm|ppc;|smartphone|sonyericsson|sqh|spv|symbian|treo|up.browser|up.link|vodafone|windows ce|xda |xda_)/i', $_SERVER['HTTP_USER_AGENT'])) { + return true; + } else { + return false; + } + } + + /** + * 当前URL地址中的scheme参数 + * @access public + * @return string + */ + public function scheme() + { + return $this->isSsl() ? 'https' : 'http'; + } + + /** + * 当前请求URL地址中的query参数 + * @access public + * @return string + */ + public function query() + { + return $this->server('QUERY_STRING'); + } + + /** + * 当前请求的host + * @access public + * @param bool $strict true 仅仅获取HOST + * @return string + */ + public function host($strict = false) + { + if (isset($_SERVER['HTTP_X_REAL_HOST'])) { + $host = $_SERVER['HTTP_X_REAL_HOST']; + } else { + $host = $this->server('HTTP_HOST'); + } + + return true === $strict && strpos($host, ':') ? strstr($host, ':', true) : $host; + } + + /** + * 当前请求URL地址中的port参数 + * @access public + * @return integer + */ + public function port() + { + return $this->server('SERVER_PORT'); + } + + /** + * 当前请求 SERVER_PROTOCOL + * @access public + * @return integer + */ + public function protocol() + { + return $this->server('SERVER_PROTOCOL'); + } + + /** + * 当前请求 REMOTE_PORT + * @access public + * @return integer + */ + public function remotePort() + { + return $this->server('REMOTE_PORT'); + } + + /** + * 当前请求 HTTP_CONTENT_TYPE + * @access public + * @return string + */ + public function contentType() + { + $contentType = $this->server('CONTENT_TYPE'); + if ($contentType) { + if (strpos($contentType, ';')) { + list($type) = explode(';', $contentType); + } else { + $type = $contentType; + } + return trim($type); + } + return ''; + } + + /** + * 获取当前请求的路由信息 + * @access public + * @param array $route 路由名称 + * @return array + */ + public function routeInfo($route = []) + { + if (!empty($route)) { + $this->routeInfo = $route; + } else { + return $this->routeInfo; + } + } + + /** + * 设置或者获取当前请求的调度信息 + * @access public + * @param array $dispatch 调度信息 + * @return array + */ + public function dispatch($dispatch = null) + { + if (!is_null($dispatch)) { + $this->dispatch = $dispatch; + } + return $this->dispatch; + } + + /** + * 设置或者获取当前的模块名 + * @access public + * @param string $module 模块名 + * @return string|Request + */ + public function module($module = null) + { + if (!is_null($module)) { + $this->module = $module; + return $this; + } else { + return $this->module ?: ''; + } + } + + /** + * 设置或者获取当前的控制器名 + * @access public + * @param string $controller 控制器名 + * @return string|Request + */ + public function controller($controller = null) + { + if (!is_null($controller)) { + $this->controller = $controller; + return $this; + } else { + return $this->controller ?: ''; + } + } + + /** + * 设置或者获取当前的操作名 + * @access public + * @param string $action 操作名 + * @return string|Request + */ + public function action($action = null) + { + if (!is_null($action) && !is_bool($action)) { + $this->action = $action; + return $this; + } else { + $name = $this->action ?: ''; + return true === $action ? $name : strtolower($name); + } + } + + /** + * 设置或者获取当前的语言 + * @access public + * @param string $lang 语言名 + * @return string|Request + */ + public function langset($lang = null) + { + if (!is_null($lang)) { + $this->langset = $lang; + return $this; + } else { + return $this->langset ?: ''; + } + } + + /** + * 设置或者获取当前请求的content + * @access public + * @return string + */ + public function getContent() + { + if (is_null($this->content)) { + $this->content = $this->input; + } + return $this->content; + } + + /** + * 获取当前请求的php://input + * @access public + * @return string + */ + public function getInput() + { + return $this->input; + } + + /** + * 生成请求令牌 + * @access public + * @param string $name 令牌名称 + * @param mixed $type 令牌生成方法 + * @return string + */ + public function token($name = '__token__', $type = 'md5') + { + $type = is_callable($type) ? $type : 'md5'; + $token = call_user_func($type, $_SERVER['REQUEST_TIME_FLOAT']); + if ($this->isAjax()) { + header($name . ': ' . $token); + } + Session::set($name, $token); + return $token; + } + + /** + * 设置当前地址的请求缓存 + * @access public + * @param string $key 缓存标识,支持变量规则 ,例如 item/:name/:id + * @param mixed $expire 缓存有效期 + * @param array $except 缓存排除 + * @param string $tag 缓存标签 + * @return void + */ + public function cache($key, $expire = null, $except = [], $tag = null) + { + if (!is_array($except)) { + $tag = $except; + $except = []; + } + + if (false !== $key && $this->isGet() && !$this->isCheckCache) { + // 标记请求缓存检查 + $this->isCheckCache = true; + if (false === $expire) { + // 关闭当前缓存 + return; + } + if ($key instanceof \Closure) { + $key = call_user_func_array($key, [$this]); + } elseif (true === $key) { + foreach ($except as $rule) { + if (0 === stripos($this->url(), $rule)) { + return; + } + } + // 自动缓存功能 + $key = '__URL__'; + } elseif (strpos($key, '|')) { + list($key, $fun) = explode('|', $key); + } + // 特殊规则替换 + if (false !== strpos($key, '__')) { + $key = str_replace(['__MODULE__', '__CONTROLLER__', '__ACTION__', '__URL__', ''], [$this->module, $this->controller, $this->action, md5($this->url(true))], $key); + } + + if (false !== strpos($key, ':')) { + $param = $this->param(); + foreach ($param as $item => $val) { + if (is_string($val) && false !== strpos($key, ':' . $item)) { + $key = str_replace(':' . $item, $val, $key); + } + } + } elseif (strpos($key, ']')) { + if ('[' . $this->ext() . ']' == $key) { + // 缓存某个后缀的请求 + $key = md5($this->url()); + } else { + return; + } + } + if (isset($fun)) { + $key = $fun($key); + } + + if (strtotime($this->server('HTTP_IF_MODIFIED_SINCE')) + $expire > $_SERVER['REQUEST_TIME']) { + // 读取缓存 + $response = Response::create()->code(304); + throw new \think\exception\HttpResponseException($response); + } elseif (Cache::has($key)) { + list($content, $header) = Cache::get($key); + $response = Response::create($content)->header($header); + throw new \think\exception\HttpResponseException($response); + } else { + $this->cache = [$key, $expire, $tag]; + } + } + } + + /** + * 读取请求缓存设置 + * @access public + * @return array + */ + public function getCache() + { + return $this->cache; + } + + /** + * 设置当前请求绑定的对象实例 + * @access public + * @param string|array $name 绑定的对象标识 + * @param mixed $obj 绑定的对象实例 + * @return mixed + */ + public function bind($name, $obj = null) + { + if (is_array($name)) { + $this->bind = array_merge($this->bind, $name); + } else { + $this->bind[$name] = $obj; + } + } + + public function __set($name, $value) + { + $this->bind[$name] = $value; + } + + public function __get($name) + { + return isset($this->bind[$name]) ? $this->bind[$name] : null; + } + + public function __isset($name) + { + return isset($this->bind[$name]); + } +} diff --git a/thinkphp/library/think/Response.php b/thinkphp/library/think/Response.php new file mode 100644 index 0000000..c5c1520 --- /dev/null +++ b/thinkphp/library/think/Response.php @@ -0,0 +1,332 @@ + +// +---------------------------------------------------------------------- + +namespace think; + +use think\response\Json as JsonResponse; +use think\response\Jsonp as JsonpResponse; +use think\response\Redirect as RedirectResponse; +use think\response\View as ViewResponse; +use think\response\Xml as XmlResponse; + +class Response +{ + // 原始数据 + protected $data; + + // 当前的contentType + protected $contentType = 'text/html'; + + // 字符集 + protected $charset = 'utf-8'; + + //状态 + protected $code = 200; + + // 输出参数 + protected $options = []; + // header参数 + protected $header = []; + + protected $content = null; + + /** + * 构造函数 + * @access public + * @param mixed $data 输出数据 + * @param int $code + * @param array $header + * @param array $options 输出参数 + */ + public function __construct($data = '', $code = 200, array $header = [], $options = []) + { + $this->data($data); + if (!empty($options)) { + $this->options = array_merge($this->options, $options); + } + $this->contentType($this->contentType, $this->charset); + $this->header = array_merge($this->header, $header); + $this->code = $code; + } + + /** + * 创建Response对象 + * @access public + * @param mixed $data 输出数据 + * @param string $type 输出类型 + * @param int $code + * @param array $header + * @param array $options 输出参数 + * @return Response|JsonResponse|ViewResponse|XmlResponse|RedirectResponse|JsonpResponse + */ + public static function create($data = '', $type = '', $code = 200, array $header = [], $options = []) + { + $class = false !== strpos($type, '\\') ? $type : '\\think\\response\\' . ucfirst(strtolower($type)); + if (class_exists($class)) { + $response = new $class($data, $code, $header, $options); + } else { + $response = new static($data, $code, $header, $options); + } + + return $response; + } + + /** + * 发送数据到客户端 + * @access public + * @return mixed + * @throws \InvalidArgumentException + */ + public function send() + { + // 监听response_send + Hook::listen('response_send', $this); + + // 处理输出数据 + $data = $this->getContent(); + + // Trace调试注入 + if (Env::get('app_trace', Config::get('app_trace'))) { + Debug::inject($this, $data); + } + + if (200 == $this->code) { + $cache = Request::instance()->getCache(); + if ($cache) { + $this->header['Cache-Control'] = 'max-age=' . $cache[1] . ',must-revalidate'; + $this->header['Last-Modified'] = gmdate('D, d M Y H:i:s') . ' GMT'; + $this->header['Expires'] = gmdate('D, d M Y H:i:s', $_SERVER['REQUEST_TIME'] + $cache[1]) . ' GMT'; + Cache::tag($cache[2])->set($cache[0], [$data, $this->header], $cache[1]); + } + } + + if (!headers_sent() && !empty($this->header)) { + // 发送状态码 + http_response_code($this->code); + // 发送头部信息 + foreach ($this->header as $name => $val) { + if (is_null($val)) { + header($name); + } else { + header($name . ':' . $val); + } + } + } + + echo $data; + + if (function_exists('fastcgi_finish_request')) { + // 提高页面响应 + fastcgi_finish_request(); + } + + // 监听response_end + Hook::listen('response_end', $this); + + // 清空当次请求有效的数据 + if (!($this instanceof RedirectResponse)) { + Session::flush(); + } + } + + /** + * 处理数据 + * @access protected + * @param mixed $data 要处理的数据 + * @return mixed + */ + protected function output($data) + { + return $data; + } + + /** + * 输出的参数 + * @access public + * @param mixed $options 输出参数 + * @return $this + */ + public function options($options = []) + { + $this->options = array_merge($this->options, $options); + return $this; + } + + /** + * 输出数据设置 + * @access public + * @param mixed $data 输出数据 + * @return $this + */ + public function data($data) + { + $this->data = $data; + return $this; + } + + /** + * 设置响应头 + * @access public + * @param string|array $name 参数名 + * @param string $value 参数值 + * @return $this + */ + public function header($name, $value = null) + { + if (is_array($name)) { + $this->header = array_merge($this->header, $name); + } else { + $this->header[$name] = $value; + } + return $this; + } + + /** + * 设置页面输出内容 + * @param $content + * @return $this + */ + public function content($content) + { + if (null !== $content && !is_string($content) && !is_numeric($content) && !is_callable([ + $content, + '__toString', + ]) + ) { + throw new \InvalidArgumentException(sprintf('variable type error: %s', gettype($content))); + } + + $this->content = (string) $content; + + return $this; + } + + /** + * 发送HTTP状态 + * @param integer $code 状态码 + * @return $this + */ + public function code($code) + { + $this->code = $code; + return $this; + } + + /** + * LastModified + * @param string $time + * @return $this + */ + public function lastModified($time) + { + $this->header['Last-Modified'] = $time; + return $this; + } + + /** + * Expires + * @param string $time + * @return $this + */ + public function expires($time) + { + $this->header['Expires'] = $time; + return $this; + } + + /** + * ETag + * @param string $eTag + * @return $this + */ + public function eTag($eTag) + { + $this->header['ETag'] = $eTag; + return $this; + } + + /** + * 页面缓存控制 + * @param string $cache 状态码 + * @return $this + */ + public function cacheControl($cache) + { + $this->header['Cache-control'] = $cache; + return $this; + } + + /** + * 页面输出类型 + * @param string $contentType 输出类型 + * @param string $charset 输出编码 + * @return $this + */ + public function contentType($contentType, $charset = 'utf-8') + { + $this->header['Content-Type'] = $contentType . '; charset=' . $charset; + return $this; + } + + /** + * 获取头部信息 + * @param string $name 头部名称 + * @return mixed + */ + public function getHeader($name = '') + { + if (!empty($name)) { + return isset($this->header[$name]) ? $this->header[$name] : null; + } else { + return $this->header; + } + } + + /** + * 获取原始数据 + * @return mixed + */ + public function getData() + { + return $this->data; + } + + /** + * 获取输出数据 + * @return mixed + */ + public function getContent() + { + if (null == $this->content) { + $content = $this->output($this->data); + + if (null !== $content && !is_string($content) && !is_numeric($content) && !is_callable([ + $content, + '__toString', + ]) + ) { + throw new \InvalidArgumentException(sprintf('variable type error: %s', gettype($content))); + } + + $this->content = (string) $content; + } + return $this->content; + } + + /** + * 获取状态码 + * @return integer + */ + public function getCode() + { + return $this->code; + } +} diff --git a/thinkphp/library/think/Route.php b/thinkphp/library/think/Route.php new file mode 100644 index 0000000..ab53aa2 --- /dev/null +++ b/thinkphp/library/think/Route.php @@ -0,0 +1,1645 @@ + +// +---------------------------------------------------------------------- + +namespace think; + +use think\exception\HttpException; + +class Route +{ + // 路由规则 + private static $rules = [ + 'get' => [], + 'post' => [], + 'put' => [], + 'delete' => [], + 'patch' => [], + 'head' => [], + 'options' => [], + '*' => [], + 'alias' => [], + 'domain' => [], + 'pattern' => [], + 'name' => [], + ]; + + // REST路由操作方法定义 + private static $rest = [ + 'index' => ['get', '', 'index'], + 'create' => ['get', '/create', 'create'], + 'edit' => ['get', '/:id/edit', 'edit'], + 'read' => ['get', '/:id', 'read'], + 'save' => ['post', '', 'save'], + 'update' => ['put', '/:id', 'update'], + 'delete' => ['delete', '/:id', 'delete'], + ]; + + // 不同请求类型的方法前缀 + private static $methodPrefix = [ + 'get' => 'get', + 'post' => 'post', + 'put' => 'put', + 'delete' => 'delete', + 'patch' => 'patch', + ]; + + // 子域名 + private static $subDomain = ''; + // 域名绑定 + private static $bind = []; + // 当前分组信息 + private static $group = []; + // 当前子域名绑定 + private static $domainBind; + private static $domainRule; + // 当前域名 + private static $domain; + // 当前路由执行过程中的参数 + private static $option = []; + + /** + * 注册变量规则 + * @access public + * @param string|array $name 变量名 + * @param string $rule 变量规则 + * @return void + */ + public static function pattern($name = null, $rule = '') + { + if (is_array($name)) { + self::$rules['pattern'] = array_merge(self::$rules['pattern'], $name); + } else { + self::$rules['pattern'][$name] = $rule; + } + } + + /** + * 注册子域名部署规则 + * @access public + * @param string|array $domain 子域名 + * @param mixed $rule 路由规则 + * @param array $option 路由参数 + * @param array $pattern 变量规则 + * @return void + */ + public static function domain($domain, $rule = '', $option = [], $pattern = []) + { + if (is_array($domain)) { + foreach ($domain as $key => $item) { + self::domain($key, $item, $option, $pattern); + } + } elseif ($rule instanceof \Closure) { + // 执行闭包 + self::setDomain($domain); + call_user_func_array($rule, []); + self::setDomain(null); + } elseif (is_array($rule)) { + self::setDomain($domain); + self::group('', function () use ($rule) { + // 动态注册域名的路由规则 + self::registerRules($rule); + }, $option, $pattern); + self::setDomain(null); + } else { + self::$rules['domain'][$domain]['[bind]'] = [$rule, $option, $pattern]; + } + } + + private static function setDomain($domain) + { + self::$domain = $domain; + } + + /** + * 设置路由绑定 + * @access public + * @param mixed $bind 绑定信息 + * @param string $type 绑定类型 默认为module 支持 namespace class controller + * @return mixed + */ + public static function bind($bind, $type = 'module') + { + self::$bind = ['type' => $type, $type => $bind]; + } + + /** + * 设置或者获取路由标识 + * @access public + * @param string|array $name 路由命名标识 数组表示批量设置 + * @param array $value 路由地址及变量信息 + * @return array + */ + public static function name($name = '', $value = null) + { + if (is_array($name)) { + return self::$rules['name'] = $name; + } elseif ('' === $name) { + return self::$rules['name']; + } elseif (!is_null($value)) { + self::$rules['name'][strtolower($name)][] = $value; + } else { + $name = strtolower($name); + return isset(self::$rules['name'][$name]) ? self::$rules['name'][$name] : null; + } + } + + /** + * 读取路由绑定 + * @access public + * @param string $type 绑定类型 + * @return mixed + */ + public static function getBind($type) + { + return isset(self::$bind[$type]) ? self::$bind[$type] : null; + } + + /** + * 导入配置文件的路由规则 + * @access public + * @param array $rule 路由规则 + * @param string $type 请求类型 + * @return void + */ + public static function import(array $rule, $type = '*') + { + // 检查域名部署 + if (isset($rule['__domain__'])) { + self::domain($rule['__domain__']); + unset($rule['__domain__']); + } + + // 检查变量规则 + if (isset($rule['__pattern__'])) { + self::pattern($rule['__pattern__']); + unset($rule['__pattern__']); + } + + // 检查路由别名 + if (isset($rule['__alias__'])) { + self::alias($rule['__alias__']); + unset($rule['__alias__']); + } + + // 检查资源路由 + if (isset($rule['__rest__'])) { + self::resource($rule['__rest__']); + unset($rule['__rest__']); + } + + self::registerRules($rule, strtolower($type)); + } + + // 批量注册路由 + protected static function registerRules($rules, $type = '*') + { + foreach ($rules as $key => $val) { + if (is_numeric($key)) { + $key = array_shift($val); + } + if (empty($val)) { + continue; + } + if (is_string($key) && 0 === strpos($key, '[')) { + $key = substr($key, 1, -1); + self::group($key, $val); + } elseif (is_array($val)) { + self::setRule($key, $val[0], $type, $val[1], isset($val[2]) ? $val[2] : []); + } else { + self::setRule($key, $val, $type); + } + } + } + + /** + * 注册路由规则 + * @access public + * @param string|array $rule 路由规则 + * @param string $route 路由地址 + * @param string $type 请求类型 + * @param array $option 路由参数 + * @param array $pattern 变量规则 + * @return void + */ + public static function rule($rule, $route = '', $type = '*', $option = [], $pattern = []) + { + $group = self::getGroup('name'); + + if (!is_null($group)) { + // 路由分组 + $option = array_merge(self::getGroup('option'), $option); + $pattern = array_merge(self::getGroup('pattern'), $pattern); + } + + $type = strtolower($type); + + if (strpos($type, '|')) { + $option['method'] = $type; + $type = '*'; + } + if (is_array($rule) && empty($route)) { + foreach ($rule as $key => $val) { + if (is_numeric($key)) { + $key = array_shift($val); + } + if (is_array($val)) { + $route = $val[0]; + $option1 = array_merge($option, $val[1]); + $pattern1 = array_merge($pattern, isset($val[2]) ? $val[2] : []); + } else { + $option1 = null; + $pattern1 = null; + $route = $val; + } + self::setRule($key, $route, $type, !is_null($option1) ? $option1 : $option, !is_null($pattern1) ? $pattern1 : $pattern, $group); + } + } else { + self::setRule($rule, $route, $type, $option, $pattern, $group); + } + + } + + /** + * 设置路由规则 + * @access public + * @param string|array $rule 路由规则 + * @param string $route 路由地址 + * @param string $type 请求类型 + * @param array $option 路由参数 + * @param array $pattern 变量规则 + * @param string $group 所属分组 + * @return void + */ + protected static function setRule($rule, $route, $type = '*', $option = [], $pattern = [], $group = '') + { + if (is_array($rule)) { + $name = $rule[0]; + $rule = $rule[1]; + } elseif (is_string($route)) { + $name = $route; + } + if (!isset($option['complete_match'])) { + if (Config::get('route_complete_match')) { + $option['complete_match'] = true; + } elseif ('$' == substr($rule, -1, 1)) { + // 是否完整匹配 + $option['complete_match'] = true; + } + } elseif (empty($option['complete_match']) && '$' == substr($rule, -1, 1)) { + // 是否完整匹配 + $option['complete_match'] = true; + } + + if ('$' == substr($rule, -1, 1)) { + $rule = substr($rule, 0, -1); + } + + if ('/' != $rule || $group) { + $rule = trim($rule, '/'); + } + $vars = self::parseVar($rule); + if (isset($name)) { + $key = $group ? $group . ($rule ? '/' . $rule : '') : $rule; + $suffix = isset($option['ext']) ? $option['ext'] : null; + self::name($name, [$key, $vars, self::$domain, $suffix]); + } + if (isset($option['modular'])) { + $route = $option['modular'] . '/' . $route; + } + if ($group) { + if ('*' != $type) { + $option['method'] = $type; + } + if (self::$domain) { + self::$rules['domain'][self::$domain]['*'][$group]['rule'][] = ['rule' => $rule, 'route' => $route, 'var' => $vars, 'option' => $option, 'pattern' => $pattern]; + } else { + self::$rules['*'][$group]['rule'][] = ['rule' => $rule, 'route' => $route, 'var' => $vars, 'option' => $option, 'pattern' => $pattern]; + } + } else { + if ('*' != $type && isset(self::$rules['*'][$rule])) { + unset(self::$rules['*'][$rule]); + } + if (self::$domain) { + self::$rules['domain'][self::$domain][$type][$rule] = ['rule' => $rule, 'route' => $route, 'var' => $vars, 'option' => $option, 'pattern' => $pattern]; + } else { + self::$rules[$type][$rule] = ['rule' => $rule, 'route' => $route, 'var' => $vars, 'option' => $option, 'pattern' => $pattern]; + } + if ('*' == $type) { + // 注册路由快捷方式 + foreach (['get', 'post', 'put', 'delete', 'patch', 'head', 'options'] as $method) { + if (self::$domain && !isset(self::$rules['domain'][self::$domain][$method][$rule])) { + self::$rules['domain'][self::$domain][$method][$rule] = true; + } elseif (!self::$domain && !isset(self::$rules[$method][$rule])) { + self::$rules[$method][$rule] = true; + } + } + } + } + } + + /** + * 设置当前执行的参数信息 + * @access public + * @param array $options 参数信息 + * @return mixed + */ + protected static function setOption($options = []) + { + self::$option[] = $options; + } + + /** + * 获取当前执行的所有参数信息 + * @access public + * @return array + */ + public static function getOption() + { + return self::$option; + } + + /** + * 获取当前的分组信息 + * @access public + * @param string $type 分组信息名称 name option pattern + * @return mixed + */ + public static function getGroup($type) + { + if (isset(self::$group[$type])) { + return self::$group[$type]; + } else { + return 'name' == $type ? null : []; + } + } + + /** + * 设置当前的路由分组 + * @access public + * @param string $name 分组名称 + * @param array $option 分组路由参数 + * @param array $pattern 分组变量规则 + * @return void + */ + public static function setGroup($name, $option = [], $pattern = []) + { + self::$group['name'] = $name; + self::$group['option'] = $option ?: []; + self::$group['pattern'] = $pattern ?: []; + } + + /** + * 注册路由分组 + * @access public + * @param string|array $name 分组名称或者参数 + * @param array|\Closure $routes 路由地址 + * @param array $option 路由参数 + * @param array $pattern 变量规则 + * @return void + */ + public static function group($name, $routes, $option = [], $pattern = []) + { + if (is_array($name)) { + $option = $name; + $name = isset($option['name']) ? $option['name'] : ''; + } + // 分组 + $currentGroup = self::getGroup('name'); + if ($currentGroup) { + $name = $currentGroup . ($name ? '/' . ltrim($name, '/') : ''); + } + if (!empty($name)) { + if ($routes instanceof \Closure) { + $currentOption = self::getGroup('option'); + $currentPattern = self::getGroup('pattern'); + self::setGroup($name, array_merge($currentOption, $option), array_merge($currentPattern, $pattern)); + call_user_func_array($routes, []); + self::setGroup($currentGroup, $currentOption, $currentPattern); + if ($currentGroup != $name) { + self::$rules['*'][$name]['route'] = ''; + self::$rules['*'][$name]['var'] = self::parseVar($name); + self::$rules['*'][$name]['option'] = $option; + self::$rules['*'][$name]['pattern'] = $pattern; + } + } else { + $item = []; + $completeMatch = Config::get('route_complete_match'); + foreach ($routes as $key => $val) { + if (is_numeric($key)) { + $key = array_shift($val); + } + if (is_array($val)) { + $route = $val[0]; + $option1 = array_merge($option, isset($val[1]) ? $val[1] : []); + $pattern1 = array_merge($pattern, isset($val[2]) ? $val[2] : []); + } else { + $route = $val; + } + + $options = isset($option1) ? $option1 : $option; + $patterns = isset($pattern1) ? $pattern1 : $pattern; + if ('$' == substr($key, -1, 1)) { + // 是否完整匹配 + $options['complete_match'] = true; + $key = substr($key, 0, -1); + } elseif ($completeMatch) { + $options['complete_match'] = true; + } + $key = trim($key, '/'); + $vars = self::parseVar($key); + $item[] = ['rule' => $key, 'route' => $route, 'var' => $vars, 'option' => $options, 'pattern' => $patterns]; + // 设置路由标识 + $suffix = isset($options['ext']) ? $options['ext'] : null; + self::name($route, [$name . ($key ? '/' . $key : ''), $vars, self::$domain, $suffix]); + } + self::$rules['*'][$name] = ['rule' => $item, 'route' => '', 'var' => [], 'option' => $option, 'pattern' => $pattern]; + } + + foreach (['get', 'post', 'put', 'delete', 'patch', 'head', 'options'] as $method) { + if (!isset(self::$rules[$method][$name])) { + self::$rules[$method][$name] = true; + } elseif (is_array(self::$rules[$method][$name])) { + self::$rules[$method][$name] = array_merge(self::$rules['*'][$name], self::$rules[$method][$name]); + } + } + + } elseif ($routes instanceof \Closure) { + // 闭包注册 + $currentOption = self::getGroup('option'); + $currentPattern = self::getGroup('pattern'); + self::setGroup('', array_merge($currentOption, $option), array_merge($currentPattern, $pattern)); + call_user_func_array($routes, []); + self::setGroup($currentGroup, $currentOption, $currentPattern); + } else { + // 批量注册路由 + self::rule($routes, '', '*', $option, $pattern); + } + } + + /** + * 注册路由 + * @access public + * @param string|array $rule 路由规则 + * @param string $route 路由地址 + * @param array $option 路由参数 + * @param array $pattern 变量规则 + * @return void + */ + public static function any($rule, $route = '', $option = [], $pattern = []) + { + self::rule($rule, $route, '*', $option, $pattern); + } + + /** + * 注册GET路由 + * @access public + * @param string|array $rule 路由规则 + * @param string $route 路由地址 + * @param array $option 路由参数 + * @param array $pattern 变量规则 + * @return void + */ + public static function get($rule, $route = '', $option = [], $pattern = []) + { + self::rule($rule, $route, 'GET', $option, $pattern); + } + + /** + * 注册POST路由 + * @access public + * @param string|array $rule 路由规则 + * @param string $route 路由地址 + * @param array $option 路由参数 + * @param array $pattern 变量规则 + * @return void + */ + public static function post($rule, $route = '', $option = [], $pattern = []) + { + self::rule($rule, $route, 'POST', $option, $pattern); + } + + /** + * 注册PUT路由 + * @access public + * @param string|array $rule 路由规则 + * @param string $route 路由地址 + * @param array $option 路由参数 + * @param array $pattern 变量规则 + * @return void + */ + public static function put($rule, $route = '', $option = [], $pattern = []) + { + self::rule($rule, $route, 'PUT', $option, $pattern); + } + + /** + * 注册DELETE路由 + * @access public + * @param string|array $rule 路由规则 + * @param string $route 路由地址 + * @param array $option 路由参数 + * @param array $pattern 变量规则 + * @return void + */ + public static function delete($rule, $route = '', $option = [], $pattern = []) + { + self::rule($rule, $route, 'DELETE', $option, $pattern); + } + + /** + * 注册PATCH路由 + * @access public + * @param string|array $rule 路由规则 + * @param string $route 路由地址 + * @param array $option 路由参数 + * @param array $pattern 变量规则 + * @return void + */ + public static function patch($rule, $route = '', $option = [], $pattern = []) + { + self::rule($rule, $route, 'PATCH', $option, $pattern); + } + + /** + * 注册资源路由 + * @access public + * @param string|array $rule 路由规则 + * @param string $route 路由地址 + * @param array $option 路由参数 + * @param array $pattern 变量规则 + * @return void + */ + public static function resource($rule, $route = '', $option = [], $pattern = []) + { + if (is_array($rule)) { + foreach ($rule as $key => $val) { + if (is_array($val)) { + list($val, $option, $pattern) = array_pad($val, 3, []); + } + self::resource($key, $val, $option, $pattern); + } + } else { + if (strpos($rule, '.')) { + // 注册嵌套资源路由 + $array = explode('.', $rule); + $last = array_pop($array); + $item = []; + foreach ($array as $val) { + $item[] = $val . '/:' . (isset($option['var'][$val]) ? $option['var'][$val] : $val . '_id'); + } + $rule = implode('/', $item) . '/' . $last; + } + // 注册资源路由 + foreach (self::$rest as $key => $val) { + if ((isset($option['only']) && !in_array($key, $option['only'])) + || (isset($option['except']) && in_array($key, $option['except']))) { + continue; + } + if (isset($last) && strpos($val[1], ':id') && isset($option['var'][$last])) { + $val[1] = str_replace(':id', ':' . $option['var'][$last], $val[1]); + } elseif (strpos($val[1], ':id') && isset($option['var'][$rule])) { + $val[1] = str_replace(':id', ':' . $option['var'][$rule], $val[1]); + } + $item = ltrim($rule . $val[1], '/'); + $option['rest'] = $key; + self::rule($item . '$', $route . '/' . $val[2], $val[0], $option, $pattern); + } + } + } + + /** + * 注册控制器路由 操作方法对应不同的请求后缀 + * @access public + * @param string $rule 路由规则 + * @param string $route 路由地址 + * @param array $option 路由参数 + * @param array $pattern 变量规则 + * @return void + */ + public static function controller($rule, $route = '', $option = [], $pattern = []) + { + foreach (self::$methodPrefix as $type => $val) { + self::$type($rule . '/:action', $route . '/' . $val . ':action', $option, $pattern); + } + } + + /** + * 注册别名路由 + * @access public + * @param string|array $rule 路由别名 + * @param string $route 路由地址 + * @param array $option 路由参数 + * @return void + */ + public static function alias($rule = null, $route = '', $option = []) + { + if (is_array($rule)) { + self::$rules['alias'] = array_merge(self::$rules['alias'], $rule); + } else { + self::$rules['alias'][$rule] = $option ? [$route, $option] : $route; + } + } + + /** + * 设置不同请求类型下面的方法前缀 + * @access public + * @param string $method 请求类型 + * @param string $prefix 类型前缀 + * @return void + */ + public static function setMethodPrefix($method, $prefix = '') + { + if (is_array($method)) { + self::$methodPrefix = array_merge(self::$methodPrefix, array_change_key_case($method)); + } else { + self::$methodPrefix[strtolower($method)] = $prefix; + } + } + + /** + * rest方法定义和修改 + * @access public + * @param string|array $name 方法名称 + * @param array|bool $resource 资源 + * @return void + */ + public static function rest($name, $resource = []) + { + if (is_array($name)) { + self::$rest = $resource ? $name : array_merge(self::$rest, $name); + } else { + self::$rest[$name] = $resource; + } + } + + /** + * 注册未匹配路由规则后的处理 + * @access public + * @param string $route 路由地址 + * @param string $method 请求类型 + * @param array $option 路由参数 + * @return void + */ + public static function miss($route, $method = '*', $option = []) + { + self::rule('__miss__', $route, $method, $option, []); + } + + /** + * 注册一个自动解析的URL路由 + * @access public + * @param string $route 路由地址 + * @return void + */ + public static function auto($route) + { + self::rule('__auto__', $route, '*', [], []); + } + + /** + * 获取或者批量设置路由定义 + * @access public + * @param mixed $rules 请求类型或者路由定义数组 + * @return array + */ + public static function rules($rules = '') + { + if (is_array($rules)) { + self::$rules = $rules; + } elseif ($rules) { + return true === $rules ? self::$rules : self::$rules[strtolower($rules)]; + } else { + $rules = self::$rules; + unset($rules['pattern'], $rules['alias'], $rules['domain'], $rules['name']); + return $rules; + } + } + + /** + * 检测子域名部署 + * @access public + * @param Request $request Request请求对象 + * @param array $currentRules 当前路由规则 + * @param string $method 请求类型 + * @return void + */ + public static function checkDomain($request, &$currentRules, $method = 'get') + { + // 域名规则 + $rules = self::$rules['domain']; + // 开启子域名部署 支持二级和三级域名 + if (!empty($rules)) { + $host = $request->host(true); + if (isset($rules[$host])) { + // 完整域名或者IP配置 + $item = $rules[$host]; + } else { + $rootDomain = Config::get('url_domain_root'); + if ($rootDomain) { + // 配置域名根 例如 thinkphp.cn 163.com.cn 如果是国家级域名 com.cn net.cn 之类的域名需要配置 + $domain = explode('.', rtrim(stristr($host, $rootDomain, true), '.')); + } else { + $domain = explode('.', $host, -2); + } + // 子域名配置 + if (!empty($domain)) { + // 当前子域名 + $subDomain = implode('.', $domain); + self::$subDomain = $subDomain; + $domain2 = array_pop($domain); + if ($domain) { + // 存在三级域名 + $domain3 = array_pop($domain); + } + if ($subDomain && isset($rules[$subDomain])) { + // 子域名配置 + $item = $rules[$subDomain]; + } elseif (isset($rules['*.' . $domain2]) && !empty($domain3)) { + // 泛三级域名 + $item = $rules['*.' . $domain2]; + $panDomain = $domain3; + } elseif (isset($rules['*']) && !empty($domain2)) { + // 泛二级域名 + if ('www' != $domain2) { + $item = $rules['*']; + $panDomain = $domain2; + } + } + } + } + if (!empty($item)) { + if (isset($panDomain)) { + // 保存当前泛域名 + $request->route(['__domain__' => $panDomain]); + } + if (isset($item['[bind]'])) { + // 解析子域名部署规则 + list($rule, $option, $pattern) = $item['[bind]']; + if (!empty($option['https']) && !$request->isSsl()) { + // https检测 + throw new HttpException(404, 'must use https request:' . $host); + } + + if (strpos($rule, '?')) { + // 传入其它参数 + $array = parse_url($rule); + $result = $array['path']; + parse_str($array['query'], $params); + if (isset($panDomain)) { + $pos = array_search('*', $params); + if (false !== $pos) { + // 泛域名作为参数 + $params[$pos] = $panDomain; + } + } + $_GET = array_merge($_GET, $params); + } else { + $result = $rule; + } + + if (0 === strpos($result, '\\')) { + // 绑定到命名空间 例如 \app\index\behavior + self::$bind = ['type' => 'namespace', 'namespace' => $result]; + } elseif (0 === strpos($result, '@')) { + // 绑定到类 例如 @app\index\controller\User + self::$bind = ['type' => 'class', 'class' => substr($result, 1)]; + } else { + // 绑定到模块/控制器 例如 index/user + self::$bind = ['type' => 'module', 'module' => $result]; + } + self::$domainBind = true; + } else { + self::$domainRule = $item; + $currentRules = isset($item[$method]) ? $item[$method] : $item['*']; + } + } + } + } + + /** + * 检测URL路由 + * @access public + * @param Request $request Request请求对象 + * @param string $url URL地址 + * @param string $depr URL分隔符 + * @param bool $checkDomain 是否检测域名规则 + * @return false|array + */ + public static function check($request, $url, $depr = '/', $checkDomain = false) + { + //检查解析缓存 + if (!App::$debug && Config::get('route_check_cache')) { + $key = self::getCheckCacheKey($request); + if (Cache::has($key)) { + list($rule, $route, $pathinfo, $option, $matches) = Cache::get($key); + return self::parseRule($rule, $route, $pathinfo, $option, $matches, true); + } + } + + // 分隔符替换 确保路由定义使用统一的分隔符 + $url = str_replace($depr, '|', $url); + + if (isset(self::$rules['alias'][$url]) || isset(self::$rules['alias'][strstr($url, '|', true)])) { + // 检测路由别名 + $result = self::checkRouteAlias($request, $url, $depr); + if (false !== $result) { + return $result; + } + } + $method = strtolower($request->method()); + // 获取当前请求类型的路由规则 + $rules = isset(self::$rules[$method]) ? self::$rules[$method] : []; + // 检测域名部署 + if ($checkDomain) { + self::checkDomain($request, $rules, $method); + } + // 检测URL绑定 + $return = self::checkUrlBind($url, $rules, $depr); + if (false !== $return) { + return $return; + } + if ('|' != $url) { + $url = rtrim($url, '|'); + } + $item = str_replace('|', '/', $url); + if (isset($rules[$item])) { + // 静态路由规则检测 + $rule = $rules[$item]; + if (true === $rule) { + $rule = self::getRouteExpress($item); + } + if (!empty($rule['route']) && self::checkOption($rule['option'], $request)) { + self::setOption($rule['option']); + return self::parseRule($item, $rule['route'], $url, $rule['option']); + } + } + + // 路由规则检测 + if (!empty($rules)) { + return self::checkRoute($request, $rules, $url, $depr); + } + return false; + } + + private static function getRouteExpress($key) + { + return self::$domainRule ? self::$domainRule['*'][$key] : self::$rules['*'][$key]; + } + + /** + * 检测路由规则 + * @access private + * @param Request $request + * @param array $rules 路由规则 + * @param string $url URL地址 + * @param string $depr URL分割符 + * @param string $group 路由分组名 + * @param array $options 路由参数(分组) + * @return mixed + */ + private static function checkRoute($request, $rules, $url, $depr = '/', $group = '', $options = []) + { + foreach ($rules as $key => $item) { + if (true === $item) { + $item = self::getRouteExpress($key); + } + if (!isset($item['rule'])) { + continue; + } + $rule = $item['rule']; + $route = $item['route']; + $vars = $item['var']; + $option = $item['option']; + $pattern = $item['pattern']; + + // 检查参数有效性 + if (!self::checkOption($option, $request)) { + continue; + } + + if (isset($option['ext'])) { + // 路由ext参数 优先于系统配置的URL伪静态后缀参数 + $url = preg_replace('/\.' . $request->ext() . '$/i', '', $url); + } + + if (is_array($rule)) { + // 分组路由 + $pos = strpos(str_replace('<', ':', $key), ':'); + if (false !== $pos) { + $str = substr($key, 0, $pos); + } else { + $str = $key; + } + if (is_string($str) && $str && 0 !== stripos(str_replace('|', '/', $url), $str)) { + continue; + } + self::setOption($option); + $result = self::checkRoute($request, $rule, $url, $depr, $key, $option); + if (false !== $result) { + return $result; + } + } elseif ($route) { + if ('__miss__' == $rule || '__auto__' == $rule) { + // 指定特殊路由 + $var = trim($rule, '__'); + ${$var} = $item; + continue; + } + if ($group) { + $rule = $group . ($rule ? '/' . ltrim($rule, '/') : ''); + } + + self::setOption($option); + if (isset($options['bind_model']) && isset($option['bind_model'])) { + $option['bind_model'] = array_merge($options['bind_model'], $option['bind_model']); + } + $result = self::checkRule($rule, $route, $url, $pattern, $option, $depr); + if (false !== $result) { + return $result; + } + } + } + if (isset($auto)) { + // 自动解析URL地址 + return self::parseUrl($auto['route'] . '/' . $url, $depr); + } elseif (isset($miss)) { + // 未匹配所有路由的路由规则处理 + return self::parseRule('', $miss['route'], $url, $miss['option']); + } + return false; + } + + /** + * 检测路由别名 + * @access private + * @param Request $request + * @param string $url URL地址 + * @param string $depr URL分隔符 + * @return mixed + */ + private static function checkRouteAlias($request, $url, $depr) + { + $array = explode('|', $url); + $alias = array_shift($array); + $item = self::$rules['alias'][$alias]; + + if (is_array($item)) { + list($rule, $option) = $item; + $action = $array[0]; + if (isset($option['allow']) && !in_array($action, explode(',', $option['allow']))) { + // 允许操作 + return false; + } elseif (isset($option['except']) && in_array($action, explode(',', $option['except']))) { + // 排除操作 + return false; + } + if (isset($option['method'][$action])) { + $option['method'] = $option['method'][$action]; + } + } else { + $rule = $item; + } + $bind = implode('|', $array); + // 参数有效性检查 + if (isset($option) && !self::checkOption($option, $request)) { + // 路由不匹配 + return false; + } elseif (0 === strpos($rule, '\\')) { + // 路由到类 + return self::bindToClass($bind, substr($rule, 1), $depr); + } elseif (0 === strpos($rule, '@')) { + // 路由到控制器类 + return self::bindToController($bind, substr($rule, 1), $depr); + } else { + // 路由到模块/控制器 + return self::bindToModule($bind, $rule, $depr); + } + } + + /** + * 检测URL绑定 + * @access private + * @param string $url URL地址 + * @param array $rules 路由规则 + * @param string $depr URL分隔符 + * @return mixed + */ + private static function checkUrlBind(&$url, &$rules, $depr = '/') + { + if (!empty(self::$bind)) { + $type = self::$bind['type']; + $bind = self::$bind[$type]; + // 记录绑定信息 + App::$debug && Log::record('[ BIND ] ' . var_export($bind, true), 'info'); + // 如果有URL绑定 则进行绑定检测 + switch ($type) { + case 'class': + // 绑定到类 + return self::bindToClass($url, $bind, $depr); + case 'controller': + // 绑定到控制器类 + return self::bindToController($url, $bind, $depr); + case 'namespace': + // 绑定到命名空间 + return self::bindToNamespace($url, $bind, $depr); + } + } + return false; + } + + /** + * 绑定到类 + * @access public + * @param string $url URL地址 + * @param string $class 类名(带命名空间) + * @param string $depr URL分隔符 + * @return array + */ + public static function bindToClass($url, $class, $depr = '/') + { + $url = str_replace($depr, '|', $url); + $array = explode('|', $url, 2); + $action = !empty($array[0]) ? $array[0] : Config::get('default_action'); + if (!empty($array[1])) { + self::parseUrlParams($array[1]); + } + return ['type' => 'method', 'method' => [$class, $action], 'var' => []]; + } + + /** + * 绑定到命名空间 + * @access public + * @param string $url URL地址 + * @param string $namespace 命名空间 + * @param string $depr URL分隔符 + * @return array + */ + public static function bindToNamespace($url, $namespace, $depr = '/') + { + $url = str_replace($depr, '|', $url); + $array = explode('|', $url, 3); + $class = !empty($array[0]) ? $array[0] : Config::get('default_controller'); + $method = !empty($array[1]) ? $array[1] : Config::get('default_action'); + if (!empty($array[2])) { + self::parseUrlParams($array[2]); + } + return ['type' => 'method', 'method' => [$namespace . '\\' . Loader::parseName($class, 1), $method], 'var' => []]; + } + + /** + * 绑定到控制器类 + * @access public + * @param string $url URL地址 + * @param string $controller 控制器名 (支持带模块名 index/user ) + * @param string $depr URL分隔符 + * @return array + */ + public static function bindToController($url, $controller, $depr = '/') + { + $url = str_replace($depr, '|', $url); + $array = explode('|', $url, 2); + $action = !empty($array[0]) ? $array[0] : Config::get('default_action'); + if (!empty($array[1])) { + self::parseUrlParams($array[1]); + } + return ['type' => 'controller', 'controller' => $controller . '/' . $action, 'var' => []]; + } + + /** + * 绑定到模块/控制器 + * @access public + * @param string $url URL地址 + * @param string $controller 控制器类名(带命名空间) + * @param string $depr URL分隔符 + * @return array + */ + public static function bindToModule($url, $controller, $depr = '/') + { + $url = str_replace($depr, '|', $url); + $array = explode('|', $url, 2); + $action = !empty($array[0]) ? $array[0] : Config::get('default_action'); + if (!empty($array[1])) { + self::parseUrlParams($array[1]); + } + return ['type' => 'module', 'module' => $controller . '/' . $action]; + } + + /** + * 路由参数有效性检查 + * @access private + * @param array $option 路由参数 + * @param Request $request Request对象 + * @return bool + */ + private static function checkOption($option, $request) + { + if ((isset($option['method']) && is_string($option['method']) && false === stripos($option['method'], $request->method())) + || (isset($option['ajax']) && $option['ajax'] && !$request->isAjax()) // Ajax检测 + || (isset($option['ajax']) && !$option['ajax'] && $request->isAjax()) // 非Ajax检测 + || (isset($option['pjax']) && $option['pjax'] && !$request->isPjax()) // Pjax检测 + || (isset($option['pjax']) && !$option['pjax'] && $request->isPjax()) // 非Pjax检测 + || (isset($option['ext']) && false === stripos('|' . $option['ext'] . '|', '|' . $request->ext() . '|')) // 伪静态后缀检测 + || (isset($option['deny_ext']) && false !== stripos('|' . $option['deny_ext'] . '|', '|' . $request->ext() . '|')) + || (isset($option['domain']) && !in_array($option['domain'], [$_SERVER['HTTP_HOST'], self::$subDomain])) // 域名检测 + || (isset($option['https']) && $option['https'] && !$request->isSsl()) // https检测 + || (isset($option['https']) && !$option['https'] && $request->isSsl()) // https检测 + || (!empty($option['before_behavior']) && false === Hook::exec($option['before_behavior'])) // 行为检测 + || (!empty($option['callback']) && is_callable($option['callback']) && false === call_user_func($option['callback'])) // 自定义检测 + ) { + return false; + } + return true; + } + + /** + * 检测路由规则 + * @access private + * @param string $rule 路由规则 + * @param string $route 路由地址 + * @param string $url URL地址 + * @param array $pattern 变量规则 + * @param array $option 路由参数 + * @param string $depr URL分隔符(全局) + * @return array|false + */ + private static function checkRule($rule, $route, $url, $pattern, $option, $depr) + { + // 检查完整规则定义 + if (isset($pattern['__url__']) && !preg_match(0 === strpos($pattern['__url__'], '/') ? $pattern['__url__'] : '/^' . $pattern['__url__'] . '/', str_replace('|', $depr, $url))) { + return false; + } + // 检查路由的参数分隔符 + if (isset($option['param_depr'])) { + $url = str_replace(['|', $option['param_depr']], [$depr, '|'], $url); + } + + $len1 = substr_count($url, '|'); + $len2 = substr_count($rule, '/'); + // 多余参数是否合并 + $merge = !empty($option['merge_extra_vars']); + if ($merge && $len1 > $len2) { + $url = str_replace('|', $depr, $url); + $url = implode('|', explode($depr, $url, $len2 + 1)); + } + + if ($len1 >= $len2 || strpos($rule, '[')) { + if (!empty($option['complete_match'])) { + // 完整匹配 + if (!$merge && $len1 != $len2 && (false === strpos($rule, '[') || $len1 > $len2 || $len1 < $len2 - substr_count($rule, '['))) { + return false; + } + } + $pattern = array_merge(self::$rules['pattern'], $pattern); + if (false !== $match = self::match($url, $rule, $pattern)) { + // 匹配到路由规则 + return self::parseRule($rule, $route, $url, $option, $match); + } + } + return false; + } + + /** + * 解析模块的URL地址 [模块/控制器/操作?]参数1=值1&参数2=值2... + * @access public + * @param string $url URL地址 + * @param string $depr URL分隔符 + * @param bool $autoSearch 是否自动深度搜索控制器 + * @return array + */ + public static function parseUrl($url, $depr = '/', $autoSearch = false) + { + + if (isset(self::$bind['module'])) { + $bind = str_replace('/', $depr, self::$bind['module']); + // 如果有模块/控制器绑定 + $url = $bind . ('.' != substr($bind, -1) ? $depr : '') . ltrim($url, $depr); + } + $url = str_replace($depr, '|', $url); + list($path, $var) = self::parseUrlPath($url); + $route = [null, null, null]; + if (isset($path)) { + // 解析模块 + $module = Config::get('app_multi_module') ? array_shift($path) : null; + if ($autoSearch) { + // 自动搜索控制器 + $dir = APP_PATH . ($module ? $module . DS : '') . Config::get('url_controller_layer'); + $suffix = App::$suffix || Config::get('controller_suffix') ? ucfirst(Config::get('url_controller_layer')) : ''; + $item = []; + $find = false; + foreach ($path as $val) { + $item[] = $val; + $file = $dir . DS . str_replace('.', DS, $val) . $suffix . EXT; + $file = pathinfo($file, PATHINFO_DIRNAME) . DS . Loader::parseName(pathinfo($file, PATHINFO_FILENAME), 1) . EXT; + if (is_file($file)) { + $find = true; + break; + } else { + $dir .= DS . Loader::parseName($val); + } + } + if ($find) { + $controller = implode('.', $item); + $path = array_slice($path, count($item)); + } else { + $controller = array_shift($path); + } + } else { + // 解析控制器 + $controller = !empty($path) ? array_shift($path) : null; + } + // 解析操作 + $action = !empty($path) ? array_shift($path) : null; + // 解析额外参数 + self::parseUrlParams(empty($path) ? '' : implode('|', $path)); + // 封装路由 + $route = [$module, $controller, $action]; + // 检查地址是否被定义过路由 + $name = strtolower($module . '/' . Loader::parseName($controller, 1) . '/' . $action); + $name2 = ''; + if (empty($module) || isset($bind) && $module == $bind) { + $name2 = strtolower(Loader::parseName($controller, 1) . '/' . $action); + } + + if (isset(self::$rules['name'][$name]) || isset(self::$rules['name'][$name2])) { + throw new HttpException(404, 'invalid request:' . str_replace('|', $depr, $url)); + } + } + return ['type' => 'module', 'module' => $route]; + } + + /** + * 解析URL的pathinfo参数和变量 + * @access private + * @param string $url URL地址 + * @return array + */ + private static function parseUrlPath($url) + { + // 分隔符替换 确保路由定义使用统一的分隔符 + $url = str_replace('|', '/', $url); + $url = trim($url, '/'); + $var = []; + if (false !== strpos($url, '?')) { + // [模块/控制器/操作?]参数1=值1&参数2=值2... + $info = parse_url($url); + $path = explode('/', $info['path']); + parse_str($info['query'], $var); + } elseif (strpos($url, '/')) { + // [模块/控制器/操作] + $path = explode('/', $url); + } else { + $path = [$url]; + } + return [$path, $var]; + } + + /** + * 检测URL和规则路由是否匹配 + * @access private + * @param string $url URL地址 + * @param string $rule 路由规则 + * @param array $pattern 变量规则 + * @return array|false + */ + private static function match($url, $rule, $pattern) + { + $m2 = explode('/', $rule); + $m1 = explode('|', $url); + + $var = []; + foreach ($m2 as $key => $val) { + // val中定义了多个变量 + if (false !== strpos($val, '<') && preg_match_all('/<(\w+(\??))>/', $val, $matches)) { + $value = []; + $replace = []; + foreach ($matches[1] as $name) { + if (strpos($name, '?')) { + $name = substr($name, 0, -1); + $replace[] = '(' . (isset($pattern[$name]) ? $pattern[$name] : '\w+') . ')?'; + } else { + $replace[] = '(' . (isset($pattern[$name]) ? $pattern[$name] : '\w+') . ')'; + } + $value[] = $name; + } + $val = str_replace($matches[0], $replace, $val); + if (preg_match('/^' . $val . '$/', isset($m1[$key]) ? $m1[$key] : '', $match)) { + array_shift($match); + foreach ($value as $k => $name) { + if (isset($match[$k])) { + $var[$name] = $match[$k]; + } + } + continue; + } else { + return false; + } + } + + if (0 === strpos($val, '[:')) { + // 可选参数 + $val = substr($val, 1, -1); + $optional = true; + } else { + $optional = false; + } + if (0 === strpos($val, ':')) { + // URL变量 + $name = substr($val, 1); + if (!$optional && !isset($m1[$key])) { + return false; + } + if (isset($m1[$key]) && isset($pattern[$name])) { + // 检查变量规则 + if ($pattern[$name] instanceof \Closure) { + $result = call_user_func_array($pattern[$name], [$m1[$key]]); + if (false === $result) { + return false; + } + } elseif (!preg_match(0 === strpos($pattern[$name], '/') ? $pattern[$name] : '/^' . $pattern[$name] . '$/', $m1[$key])) { + return false; + } + } + $var[$name] = isset($m1[$key]) ? $m1[$key] : ''; + } elseif (!isset($m1[$key]) || 0 !== strcasecmp($val, $m1[$key])) { + return false; + } + } + // 成功匹配后返回URL中的动态变量数组 + return $var; + } + + /** + * 解析规则路由 + * @access private + * @param string $rule 路由规则 + * @param string $route 路由地址 + * @param string $pathinfo URL地址 + * @param array $option 路由参数 + * @param array $matches 匹配的变量 + * @param bool $fromCache 通过缓存解析 + * @return array + */ + private static function parseRule($rule, $route, $pathinfo, $option = [], $matches = [], $fromCache = false) + { + $request = Request::instance(); + + //保存解析缓存 + if (Config::get('route_check_cache') && !$fromCache) { + try { + $key = self::getCheckCacheKey($request); + Cache::tag('route_check')->set($key, [$rule, $route, $pathinfo, $option, $matches]); + } catch (\Exception $e) { + + } + } + + // 解析路由规则 + if ($rule) { + $rule = explode('/', $rule); + // 获取URL地址中的参数 + $paths = explode('|', $pathinfo); + foreach ($rule as $item) { + $fun = ''; + if (0 === strpos($item, '[:')) { + $item = substr($item, 1, -1); + } + if (0 === strpos($item, ':')) { + $var = substr($item, 1); + $matches[$var] = array_shift($paths); + } else { + // 过滤URL中的静态变量 + array_shift($paths); + } + } + } else { + $paths = explode('|', $pathinfo); + } + + // 获取路由地址规则 + if (is_string($route) && isset($option['prefix'])) { + // 路由地址前缀 + $route = $option['prefix'] . $route; + } + // 替换路由地址中的变量 + if (is_string($route) && !empty($matches)) { + foreach ($matches as $key => $val) { + if (false !== strpos($route, ':' . $key)) { + $route = str_replace(':' . $key, $val, $route); + } + } + } + + // 绑定模型数据 + if (isset($option['bind_model'])) { + $bind = []; + foreach ($option['bind_model'] as $key => $val) { + if ($val instanceof \Closure) { + $result = call_user_func_array($val, [$matches]); + } else { + if (is_array($val)) { + $fields = explode('&', $val[1]); + $model = $val[0]; + $exception = isset($val[2]) ? $val[2] : true; + } else { + $fields = ['id']; + $model = $val; + $exception = true; + } + $where = []; + $match = true; + foreach ($fields as $field) { + if (!isset($matches[$field])) { + $match = false; + break; + } else { + $where[$field] = $matches[$field]; + } + } + if ($match) { + $query = strpos($model, '\\') ? $model::where($where) : Loader::model($model)->where($where); + $result = $query->failException($exception)->find(); + } + } + if (!empty($result)) { + $bind[$key] = $result; + } + } + $request->bind($bind); + } + + if (!empty($option['response'])) { + Hook::add('response_send', $option['response']); + } + + // 解析额外参数 + self::parseUrlParams(empty($paths) ? '' : implode('|', $paths), $matches); + // 记录匹配的路由信息 + $request->routeInfo(['rule' => $rule, 'route' => $route, 'option' => $option, 'var' => $matches]); + + // 检测路由after行为 + if (!empty($option['after_behavior'])) { + if ($option['after_behavior'] instanceof \Closure) { + $result = call_user_func_array($option['after_behavior'], []); + } else { + foreach ((array) $option['after_behavior'] as $behavior) { + $result = Hook::exec($behavior, ''); + if (!is_null($result)) { + break; + } + } + } + // 路由规则重定向 + if ($result instanceof Response) { + return ['type' => 'response', 'response' => $result]; + } elseif (is_array($result)) { + return $result; + } + } + + if ($route instanceof \Closure) { + // 执行闭包 + $result = ['type' => 'function', 'function' => $route]; + } elseif (0 === strpos($route, '/') || strpos($route, '://')) { + // 路由到重定向地址 + $result = ['type' => 'redirect', 'url' => $route, 'status' => isset($option['status']) ? $option['status'] : 301]; + } elseif (false !== strpos($route, '\\')) { + // 路由到方法 + list($path, $var) = self::parseUrlPath($route); + $route = str_replace('/', '@', implode('/', $path)); + $method = strpos($route, '@') ? explode('@', $route) : $route; + $result = ['type' => 'method', 'method' => $method, 'var' => $var]; + } elseif (0 === strpos($route, '@')) { + // 路由到控制器 + $route = substr($route, 1); + list($route, $var) = self::parseUrlPath($route); + $result = ['type' => 'controller', 'controller' => implode('/', $route), 'var' => $var]; + $request->action(array_pop($route)); + $request->controller($route ? array_pop($route) : Config::get('default_controller')); + $request->module($route ? array_pop($route) : Config::get('default_module')); + App::$modulePath = APP_PATH . (Config::get('app_multi_module') ? $request->module() . DS : ''); + } else { + // 路由到模块/控制器/操作 + $result = self::parseModule($route, isset($option['convert']) ? $option['convert'] : false); + } + // 开启请求缓存 + if ($request->isGet() && isset($option['cache'])) { + $cache = $option['cache']; + if (is_array($cache)) { + list($key, $expire, $tag) = array_pad($cache, 3, null); + } else { + $key = str_replace('|', '/', $pathinfo); + $expire = $cache; + $tag = null; + } + $request->cache($key, $expire, $tag); + } + return $result; + } + + /** + * 解析URL地址为 模块/控制器/操作 + * @access private + * @param string $url URL地址 + * @param bool $convert 是否自动转换URL地址 + * @return array + */ + private static function parseModule($url, $convert = false) + { + list($path, $var) = self::parseUrlPath($url); + $action = array_pop($path); + $controller = !empty($path) ? array_pop($path) : null; + $module = Config::get('app_multi_module') && !empty($path) ? array_pop($path) : null; + $method = Request::instance()->method(); + if (Config::get('use_action_prefix') && !empty(self::$methodPrefix[$method])) { + // 操作方法前缀支持 + $action = 0 !== strpos($action, self::$methodPrefix[$method]) ? self::$methodPrefix[$method] . $action : $action; + } + // 设置当前请求的路由变量 + Request::instance()->route($var); + // 路由到模块/控制器/操作 + return ['type' => 'module', 'module' => [$module, $controller, $action], 'convert' => $convert]; + } + + /** + * 解析URL地址中的参数Request对象 + * @access private + * @param string $url 路由规则 + * @param array $var 变量 + * @return void + */ + private static function parseUrlParams($url, &$var = []) + { + if ($url) { + if (Config::get('url_param_type')) { + $var += explode('|', $url); + } else { + preg_replace_callback('/(\w+)\|([^\|]+)/', function ($match) use (&$var) { + $var[$match[1]] = strip_tags($match[2]); + }, $url); + } + } + // 设置当前请求的参数 + Request::instance()->route($var); + } + + // 分析路由规则中的变量 + private static function parseVar($rule) + { + // 提取路由规则中的变量 + $var = []; + foreach (explode('/', $rule) as $val) { + $optional = false; + if (false !== strpos($val, '<') && preg_match_all('/<(\w+(\??))>/', $val, $matches)) { + foreach ($matches[1] as $name) { + if (strpos($name, '?')) { + $name = substr($name, 0, -1); + $optional = true; + } else { + $optional = false; + } + $var[$name] = $optional ? 2 : 1; + } + } + + if (0 === strpos($val, '[:')) { + // 可选参数 + $optional = true; + $val = substr($val, 1, -1); + } + if (0 === strpos($val, ':')) { + // URL变量 + $name = substr($val, 1); + $var[$name] = $optional ? 2 : 1; + } + } + return $var; + } + + /** + * 获取路由解析缓存的key + * @param Request $request + * @return string + */ + private static function getCheckCacheKey(Request $request) + { + static $key; + + if (empty($key)) { + if ($callback = Config::get('route_check_cache_key')) { + $key = call_user_func($callback, $request); + } else { + $key = "{$request->host(true)}|{$request->method()}|{$request->path()}"; + } + } + + return $key; + } +} diff --git a/thinkphp/library/think/Session.php b/thinkphp/library/think/Session.php new file mode 100644 index 0000000..61150bc --- /dev/null +++ b/thinkphp/library/think/Session.php @@ -0,0 +1,366 @@ + +// +---------------------------------------------------------------------- + +namespace think; + +use think\exception\ClassNotFoundException; + +class Session +{ + protected static $prefix = ''; + protected static $init = null; + + /** + * 设置或者获取session作用域(前缀) + * @param string $prefix + * @return string|void + */ + public static function prefix($prefix = '') + { + empty(self::$init) && self::boot(); + if (empty($prefix) && null !== $prefix) { + return self::$prefix; + } else { + self::$prefix = $prefix; + } + } + + /** + * session初始化 + * @param array $config + * @return void + * @throws \think\Exception + */ + public static function init(array $config = []) + { + if (empty($config)) { + $config = Config::get('session'); + } + // 记录初始化信息 + App::$debug && Log::record('[ SESSION ] INIT ' . var_export($config, true), 'info'); + $isDoStart = false; + if (isset($config['use_trans_sid'])) { + ini_set('session.use_trans_sid', $config['use_trans_sid'] ? 1 : 0); + } + + // 启动session + if (!empty($config['auto_start']) && PHP_SESSION_ACTIVE != session_status()) { + ini_set('session.auto_start', 0); + $isDoStart = true; + } + + if (isset($config['prefix']) && ('' === self::$prefix || null === self::$prefix)) { + self::$prefix = $config['prefix']; + } + if (isset($config['var_session_id']) && isset($_REQUEST[$config['var_session_id']])) { + session_id($_REQUEST[$config['var_session_id']]); + } elseif (isset($config['id']) && !empty($config['id'])) { + session_id($config['id']); + } + if (isset($config['name'])) { + session_name($config['name']); + } + if (isset($config['path'])) { + session_save_path($config['path']); + } + if (isset($config['domain'])) { + ini_set('session.cookie_domain', $config['domain']); + } + if (isset($config['expire'])) { + ini_set('session.gc_maxlifetime', $config['expire']); + ini_set('session.cookie_lifetime', $config['expire']); + } + if (isset($config['secure'])) { + ini_set('session.cookie_secure', $config['secure']); + } + if (isset($config['httponly'])) { + ini_set('session.cookie_httponly', $config['httponly']); + } + if (isset($config['use_cookies'])) { + ini_set('session.use_cookies', $config['use_cookies'] ? 1 : 0); + } + if (isset($config['cache_limiter'])) { + session_cache_limiter($config['cache_limiter']); + } + if (isset($config['cache_expire'])) { + session_cache_expire($config['cache_expire']); + } + if (!empty($config['type'])) { + // 读取session驱动 + $class = false !== strpos($config['type'], '\\') ? $config['type'] : '\\think\\session\\driver\\' . ucwords($config['type']); + + // 检查驱动类 + if (!class_exists($class) || !session_set_save_handler(new $class($config))) { + throw new ClassNotFoundException('error session handler:' . $class, $class); + } + } + if ($isDoStart) { + session_start(); + self::$init = true; + } else { + self::$init = false; + } + } + + /** + * session自动启动或者初始化 + * @return void + */ + public static function boot() + { + if (is_null(self::$init)) { + self::init(); + } elseif (false === self::$init) { + if (PHP_SESSION_ACTIVE != session_status()) { + session_start(); + } + self::$init = true; + } + } + + /** + * session设置 + * @param string $name session名称 + * @param mixed $value session值 + * @param string|null $prefix 作用域(前缀) + * @return void + */ + public static function set($name, $value = '', $prefix = null) + { + empty(self::$init) && self::boot(); + + $prefix = !is_null($prefix) ? $prefix : self::$prefix; + if (strpos($name, '.')) { + // 二维数组赋值 + list($name1, $name2) = explode('.', $name); + if ($prefix) { + $_SESSION[$prefix][$name1][$name2] = $value; + } else { + $_SESSION[$name1][$name2] = $value; + } + } elseif ($prefix) { + $_SESSION[$prefix][$name] = $value; + } else { + $_SESSION[$name] = $value; + } + } + + /** + * session获取 + * @param string $name session名称 + * @param string|null $prefix 作用域(前缀) + * @return mixed + */ + public static function get($name = '', $prefix = null) + { + empty(self::$init) && self::boot(); + $prefix = !is_null($prefix) ? $prefix : self::$prefix; + if ('' == $name) { + // 获取全部的session + $value = $prefix ? (!empty($_SESSION[$prefix]) ? $_SESSION[$prefix] : []) : $_SESSION; + } elseif ($prefix) { + // 获取session + if (strpos($name, '.')) { + list($name1, $name2) = explode('.', $name); + $value = isset($_SESSION[$prefix][$name1][$name2]) ? $_SESSION[$prefix][$name1][$name2] : null; + } else { + $value = isset($_SESSION[$prefix][$name]) ? $_SESSION[$prefix][$name] : null; + } + } else { + if (strpos($name, '.')) { + list($name1, $name2) = explode('.', $name); + $value = isset($_SESSION[$name1][$name2]) ? $_SESSION[$name1][$name2] : null; + } else { + $value = isset($_SESSION[$name]) ? $_SESSION[$name] : null; + } + } + return $value; + } + + /** + * session获取并删除 + * @param string $name session名称 + * @param string|null $prefix 作用域(前缀) + * @return mixed + */ + public static function pull($name, $prefix = null) + { + $result = self::get($name, $prefix); + if ($result) { + self::delete($name, $prefix); + return $result; + } else { + return; + } + } + + /** + * session设置 下一次请求有效 + * @param string $name session名称 + * @param mixed $value session值 + * @param string|null $prefix 作用域(前缀) + * @return void + */ + public static function flash($name, $value) + { + self::set($name, $value); + if (!self::has('__flash__.__time__')) { + self::set('__flash__.__time__', $_SERVER['REQUEST_TIME_FLOAT']); + } + self::push('__flash__', $name); + } + + /** + * 清空当前请求的session数据 + * @return void + */ + public static function flush() + { + if (self::$init) { + $item = self::get('__flash__'); + + if (!empty($item)) { + $time = $item['__time__']; + if ($_SERVER['REQUEST_TIME_FLOAT'] > $time) { + unset($item['__time__']); + self::delete($item); + self::set('__flash__', []); + } + } + } + } + + /** + * 删除session数据 + * @param string|array $name session名称 + * @param string|null $prefix 作用域(前缀) + * @return void + */ + public static function delete($name, $prefix = null) + { + empty(self::$init) && self::boot(); + $prefix = !is_null($prefix) ? $prefix : self::$prefix; + if (is_array($name)) { + foreach ($name as $key) { + self::delete($key, $prefix); + } + } elseif (strpos($name, '.')) { + list($name1, $name2) = explode('.', $name); + if ($prefix) { + unset($_SESSION[$prefix][$name1][$name2]); + } else { + unset($_SESSION[$name1][$name2]); + } + } else { + if ($prefix) { + unset($_SESSION[$prefix][$name]); + } else { + unset($_SESSION[$name]); + } + } + } + + /** + * 清空session数据 + * @param string|null $prefix 作用域(前缀) + * @return void + */ + public static function clear($prefix = null) + { + empty(self::$init) && self::boot(); + $prefix = !is_null($prefix) ? $prefix : self::$prefix; + if ($prefix) { + unset($_SESSION[$prefix]); + } else { + $_SESSION = []; + } + } + + /** + * 判断session数据 + * @param string $name session名称 + * @param string|null $prefix + * @return bool + */ + public static function has($name, $prefix = null) + { + empty(self::$init) && self::boot(); + $prefix = !is_null($prefix) ? $prefix : self::$prefix; + if (strpos($name, '.')) { + // 支持数组 + list($name1, $name2) = explode('.', $name); + return $prefix ? isset($_SESSION[$prefix][$name1][$name2]) : isset($_SESSION[$name1][$name2]); + } else { + return $prefix ? isset($_SESSION[$prefix][$name]) : isset($_SESSION[$name]); + } + } + + /** + * 添加数据到一个session数组 + * @param string $key + * @param mixed $value + * @return void + */ + public static function push($key, $value) + { + $array = self::get($key); + if (is_null($array)) { + $array = []; + } + $array[] = $value; + self::set($key, $array); + } + + /** + * 启动session + * @return void + */ + public static function start() + { + session_start(); + self::$init = true; + } + + /** + * 销毁session + * @return void + */ + public static function destroy() + { + if (!empty($_SESSION)) { + $_SESSION = []; + } + session_unset(); + session_destroy(); + self::$init = null; + } + + /** + * 重新生成session_id + * @param bool $delete 是否删除关联会话文件 + * @return void + */ + public static function regenerate($delete = false) + { + session_regenerate_id($delete); + } + + /** + * 暂停session + * @return void + */ + public static function pause() + { + // 暂停session + session_write_close(); + self::$init = false; + } +} diff --git a/thinkphp/library/think/Template.php b/thinkphp/library/think/Template.php new file mode 100644 index 0000000..75034fa --- /dev/null +++ b/thinkphp/library/think/Template.php @@ -0,0 +1,1139 @@ + +// +---------------------------------------------------------------------- + +namespace think; + +use think\exception\TemplateNotFoundException; +use think\template\TagLib; + +/** + * ThinkPHP分离出来的模板引擎 + * 支持XML标签和普通标签的模板解析 + * 编译型模板引擎 支持动态缓存 + */ +class Template +{ + // 模板变量 + protected $data = []; + // 引擎配置 + protected $config = [ + 'view_path' => '', // 模板路径 + 'view_base' => '', + 'view_suffix' => 'html', // 默认模板文件后缀 + 'view_depr' => DS, + 'cache_suffix' => 'php', // 默认模板缓存后缀 + 'tpl_deny_func_list' => 'echo,exit', // 模板引擎禁用函数 + 'tpl_deny_php' => false, // 默认模板引擎是否禁用PHP原生代码 + 'tpl_begin' => '{', // 模板引擎普通标签开始标记 + 'tpl_end' => '}', // 模板引擎普通标签结束标记 + 'strip_space' => false, // 是否去除模板文件里面的html空格与换行 + 'tpl_cache' => true, // 是否开启模板编译缓存,设为false则每次都会重新编译 + 'compile_type' => 'file', // 模板编译类型 + 'cache_prefix' => '', // 模板缓存前缀标识,可以动态改变 + 'cache_time' => 0, // 模板缓存有效期 0 为永久,(以数字为值,单位:秒) + 'layout_on' => false, // 布局模板开关 + 'layout_name' => 'layout', // 布局模板入口文件 + 'layout_item' => '{__CONTENT__}', // 布局模板的内容替换标识 + 'taglib_begin' => '{', // 标签库标签开始标记 + 'taglib_end' => '}', // 标签库标签结束标记 + 'taglib_load' => true, // 是否使用内置标签库之外的其它标签库,默认自动检测 + 'taglib_build_in' => 'cx', // 内置标签库名称(标签使用不必指定标签库名称),以逗号分隔 注意解析顺序 + 'taglib_pre_load' => '', // 需要额外加载的标签库(须指定标签库名称),多个以逗号分隔 + 'display_cache' => false, // 模板渲染缓存 + 'cache_id' => '', // 模板缓存ID + 'tpl_replace_string' => [], + 'tpl_var_identify' => 'array', // .语法变量识别,array|object|'', 为空时自动识别 + ]; + + private $literal = []; + private $includeFile = []; // 记录所有模板包含的文件路径及更新时间 + protected $storage; + + /** + * 构造函数 + * @access public + * @param array $config + */ + public function __construct(array $config = []) + { + $this->config['cache_path'] = TEMP_PATH; + $this->config = array_merge($this->config, $config); + + $this->config['taglib_begin_origin'] = $this->config['taglib_begin']; + $this->config['taglib_end_origin'] = $this->config['taglib_end']; + + $this->config['taglib_begin'] = preg_quote($this->config['taglib_begin'], '/'); + $this->config['taglib_end'] = preg_quote($this->config['taglib_end'], '/'); + $this->config['tpl_begin'] = preg_quote($this->config['tpl_begin'], '/'); + $this->config['tpl_end'] = preg_quote($this->config['tpl_end'], '/'); + + // 初始化模板编译存储器 + $type = $this->config['compile_type'] ? $this->config['compile_type'] : 'File'; + $class = false !== strpos($type, '\\') ? $type : '\\think\\template\\driver\\' . ucwords($type); + $this->storage = new $class(); + } + + /** + * 模板变量赋值 + * @access public + * @param mixed $name + * @param mixed $value + * @return void + */ + public function assign($name, $value = '') + { + if (is_array($name)) { + $this->data = array_merge($this->data, $name); + } else { + $this->data[$name] = $value; + } + } + + /** + * 模板引擎参数赋值 + * @access public + * @param mixed $name + * @param mixed $value + */ + public function __set($name, $value) + { + $this->config[$name] = $value; + } + + /** + * 模板引擎配置项 + * @access public + * @param array|string $config + * @return string|void|array + */ + public function config($config) + { + if (is_array($config)) { + $this->config = array_merge($this->config, $config); + } elseif (isset($this->config[$config])) { + return $this->config[$config]; + } else { + return; + } + } + + /** + * 模板变量获取 + * @access public + * @param string $name 变量名 + * @return mixed + */ + public function get($name = '') + { + if ('' == $name) { + return $this->data; + } else { + $data = $this->data; + foreach (explode('.', $name) as $key => $val) { + if (isset($data[$val])) { + $data = $data[$val]; + } else { + $data = null; + break; + } + } + return $data; + } + } + + /** + * 渲染模板文件 + * @access public + * @param string $template 模板文件 + * @param array $vars 模板变量 + * @param array $config 模板参数 + * @return void + */ + public function fetch($template, $vars = [], $config = []) + { + if ($vars) { + $this->data = $vars; + } + if ($config) { + $this->config($config); + } + if (!empty($this->config['cache_id']) && $this->config['display_cache']) { + // 读取渲染缓存 + $cacheContent = Cache::get($this->config['cache_id']); + if (false !== $cacheContent) { + echo $cacheContent; + return; + } + } + $template = $this->parseTemplateFile($template); + if ($template) { + $cacheFile = $this->config['cache_path'] . $this->config['cache_prefix'] . md5($this->config['layout_name'] . $template) . '.' . ltrim($this->config['cache_suffix'], '.'); + if (!$this->checkCache($cacheFile)) { + // 缓存无效 重新模板编译 + $content = file_get_contents($template); + $this->compiler($content, $cacheFile); + } + // 页面缓存 + ob_start(); + ob_implicit_flush(0); + // 读取编译存储 + $this->storage->read($cacheFile, $this->data); + // 获取并清空缓存 + $content = ob_get_clean(); + if (!empty($this->config['cache_id']) && $this->config['display_cache']) { + // 缓存页面输出 + Cache::set($this->config['cache_id'], $content, $this->config['cache_time']); + } + echo $content; + } + } + + /** + * 渲染模板内容 + * @access public + * @param string $content 模板内容 + * @param array $vars 模板变量 + * @param array $config 模板参数 + * @return void + */ + public function display($content, $vars = [], $config = []) + { + if ($vars) { + $this->data = $vars; + } + if ($config) { + $this->config($config); + } + $cacheFile = $this->config['cache_path'] . $this->config['cache_prefix'] . md5($content) . '.' . ltrim($this->config['cache_suffix'], '.'); + if (!$this->checkCache($cacheFile)) { + // 缓存无效 模板编译 + $this->compiler($content, $cacheFile); + } + // 读取编译存储 + $this->storage->read($cacheFile, $this->data); + } + + /** + * 设置布局 + * @access public + * @param mixed $name 布局模板名称 false 则关闭布局 + * @param string $replace 布局模板内容替换标识 + * @return Template + */ + public function layout($name, $replace = '') + { + if (false === $name) { + // 关闭布局 + $this->config['layout_on'] = false; + } else { + // 开启布局 + $this->config['layout_on'] = true; + // 名称必须为字符串 + if (is_string($name)) { + $this->config['layout_name'] = $name; + } + if (!empty($replace)) { + $this->config['layout_item'] = $replace; + } + } + return $this; + } + + /** + * 检查编译缓存是否有效 + * 如果无效则需要重新编译 + * @access private + * @param string $cacheFile 缓存文件名 + * @return boolean + */ + private function checkCache($cacheFile) + { + // 未开启缓存功能 + if (!$this->config['tpl_cache']) { + return false; + } + // 缓存文件不存在 + if (!is_file($cacheFile)) { + return false; + } + // 读取缓存文件失败 + if (!$handle = @fopen($cacheFile, "r")) { + return false; + } + // 读取第一行 + preg_match('/\/\*(.+?)\*\//', fgets($handle), $matches); + if (!isset($matches[1])) { + return false; + } + $includeFile = unserialize($matches[1]); + if (!is_array($includeFile)) { + return false; + } + // 检查模板文件是否有更新 + foreach ($includeFile as $path => $time) { + if (is_file($path) && filemtime($path) > $time) { + // 模板文件如果有更新则缓存需要更新 + return false; + } + } + // 检查编译存储是否有效 + return $this->storage->check($cacheFile, $this->config['cache_time']); + } + + /** + * 检查编译缓存是否存在 + * @access public + * @param string $cacheId 缓存的id + * @return boolean + */ + public function isCache($cacheId) + { + if ($cacheId && $this->config['display_cache']) { + // 缓存页面输出 + return Cache::has($cacheId); + } + return false; + } + + /** + * 编译模板文件内容 + * @access private + * @param string $content 模板内容 + * @param string $cacheFile 缓存文件名 + * @return void + */ + private function compiler(&$content, $cacheFile) + { + // 判断是否启用布局 + if ($this->config['layout_on']) { + if (false !== strpos($content, '{__NOLAYOUT__}')) { + // 可以单独定义不使用布局 + $content = str_replace('{__NOLAYOUT__}', '', $content); + } else { + // 读取布局模板 + $layoutFile = $this->parseTemplateFile($this->config['layout_name']); + if ($layoutFile) { + // 替换布局的主体内容 + $content = str_replace($this->config['layout_item'], $content, file_get_contents($layoutFile)); + } + } + } else { + $content = str_replace('{__NOLAYOUT__}', '', $content); + } + + // 模板解析 + $this->parse($content); + if ($this->config['strip_space']) { + /* 去除html空格与换行 */ + $find = ['~>\s+<~', '~>(\s+\n|\r)~']; + $replace = ['><', '>']; + $content = preg_replace($find, $replace, $content); + } + // 优化生成的php代码 + $content = preg_replace('/\?>\s*<\?php\s(?!echo\b)/s', '', $content); + // 模板过滤输出 + $replace = $this->config['tpl_replace_string']; + $content = str_replace(array_keys($replace), array_values($replace), $content); + // 添加安全代码及模板引用记录 + $content = 'includeFile) . '*/ ?>' . "\n" . $content; + // 编译存储 + $this->storage->write($cacheFile, $content); + $this->includeFile = []; + return; + } + + /** + * 模板解析入口 + * 支持普通标签和TagLib解析 支持自定义标签库 + * @access public + * @param string $content 要解析的模板内容 + * @return void + */ + public function parse(&$content) + { + // 内容为空不解析 + if (empty($content)) { + return; + } + // 替换literal标签内容 + $this->parseLiteral($content); + // 解析继承 + $this->parseExtend($content); + // 解析布局 + $this->parseLayout($content); + // 检查include语法 + $this->parseInclude($content); + // 替换包含文件中literal标签内容 + $this->parseLiteral($content); + // 检查PHP语法 + $this->parsePhp($content); + + // 获取需要引入的标签库列表 + // 标签库只需要定义一次,允许引入多个一次 + // 一般放在文件的最前面 + // 格式: + // 当TAGLIB_LOAD配置为true时才会进行检测 + if ($this->config['taglib_load']) { + $tagLibs = $this->getIncludeTagLib($content); + if (!empty($tagLibs)) { + // 对导入的TagLib进行解析 + foreach ($tagLibs as $tagLibName) { + $this->parseTagLib($tagLibName, $content); + } + } + } + // 预先加载的标签库 无需在每个模板中使用taglib标签加载 但必须使用标签库XML前缀 + if ($this->config['taglib_pre_load']) { + $tagLibs = explode(',', $this->config['taglib_pre_load']); + foreach ($tagLibs as $tag) { + $this->parseTagLib($tag, $content); + } + } + // 内置标签库 无需使用taglib标签导入就可以使用 并且不需使用标签库XML前缀 + $tagLibs = explode(',', $this->config['taglib_build_in']); + foreach ($tagLibs as $tag) { + $this->parseTagLib($tag, $content, true); + } + // 解析普通模板标签 {$tagName} + $this->parseTag($content); + + // 还原被替换的Literal标签 + $this->parseLiteral($content, true); + return; + } + + /** + * 检查PHP语法 + * @access private + * @param string $content 要解析的模板内容 + * @return void + * @throws \think\Exception + */ + private function parsePhp(&$content) + { + // 短标签的情况要将' . "\n", $content); + // PHP语法检查 + if ($this->config['tpl_deny_php'] && false !== strpos($content, 'getRegex('layout'), $content, $matches)) { + // 替换Layout标签 + $content = str_replace($matches[0], '', $content); + // 解析Layout标签 + $array = $this->parseAttr($matches[0]); + if (!$this->config['layout_on'] || $this->config['layout_name'] != $array['name']) { + // 读取布局模板 + $layoutFile = $this->parseTemplateFile($array['name']); + if ($layoutFile) { + $replace = isset($array['replace']) ? $array['replace'] : $this->config['layout_item']; + // 替换布局的主体内容 + $content = str_replace($replace, $content, file_get_contents($layoutFile)); + } + } + } else { + $content = str_replace('{__NOLAYOUT__}', '', $content); + } + return; + } + + /** + * 解析模板中的include标签 + * @access private + * @param string $content 要解析的模板内容 + * @return void + */ + private function parseInclude(&$content) + { + $regex = $this->getRegex('include'); + $func = function ($template) use (&$func, &$regex, &$content) { + if (preg_match_all($regex, $template, $matches, PREG_SET_ORDER)) { + foreach ($matches as $match) { + $array = $this->parseAttr($match[0]); + $file = $array['file']; + unset($array['file']); + // 分析模板文件名并读取内容 + $parseStr = $this->parseTemplateName($file); + foreach ($array as $k => $v) { + // 以$开头字符串转换成模板变量 + if (0 === strpos($v, '$')) { + $v = $this->get(substr($v, 1)); + } + $parseStr = str_replace('[' . $k . ']', $v, $parseStr); + } + $content = str_replace($match[0], $parseStr, $content); + // 再次对包含文件进行模板分析 + $func($parseStr); + } + unset($matches); + } + }; + // 替换模板中的include标签 + $func($content); + return; + } + + /** + * 解析模板中的extend标签 + * @access private + * @param string $content 要解析的模板内容 + * @return void + */ + private function parseExtend(&$content) + { + $regex = $this->getRegex('extend'); + $array = $blocks = $baseBlocks = []; + $extend = ''; + $func = function ($template) use (&$func, &$regex, &$array, &$extend, &$blocks, &$baseBlocks) { + if (preg_match($regex, $template, $matches)) { + if (!isset($array[$matches['name']])) { + $array[$matches['name']] = 1; + // 读取继承模板 + $extend = $this->parseTemplateName($matches['name']); + // 递归检查继承 + $func($extend); + // 取得block标签内容 + $blocks = array_merge($blocks, $this->parseBlock($template)); + return; + } + } else { + // 取得顶层模板block标签内容 + $baseBlocks = $this->parseBlock($template, true); + if (empty($extend)) { + // 无extend标签但有block标签的情况 + $extend = $template; + } + } + }; + + $func($content); + if (!empty($extend)) { + if ($baseBlocks) { + $children = []; + foreach ($baseBlocks as $name => $val) { + $replace = $val['content']; + if (!empty($children[$name])) { + // 如果包含有子block标签 + foreach ($children[$name] as $key) { + $replace = str_replace($baseBlocks[$key]['begin'] . $baseBlocks[$key]['content'] . $baseBlocks[$key]['end'], $blocks[$key]['content'], $replace); + } + } + if (isset($blocks[$name])) { + // 带有{__block__}表示与所继承模板的相应标签合并,而不是覆盖 + $replace = str_replace(['{__BLOCK__}', '{__block__}'], $replace, $blocks[$name]['content']); + if (!empty($val['parent'])) { + // 如果不是最顶层的block标签 + $parent = $val['parent']; + if (isset($blocks[$parent])) { + $blocks[$parent]['content'] = str_replace($blocks[$name]['begin'] . $blocks[$name]['content'] . $blocks[$name]['end'], $replace, $blocks[$parent]['content']); + } + $blocks[$name]['content'] = $replace; + $children[$parent][] = $name; + continue; + } + } elseif (!empty($val['parent'])) { + // 如果子标签没有被继承则用原值 + $children[$val['parent']][] = $name; + $blocks[$name] = $val; + } + if (!$val['parent']) { + // 替换模板中的顶级block标签 + $extend = str_replace($val['begin'] . $val['content'] . $val['end'], $replace, $extend); + } + } + } + $content = $extend; + unset($blocks, $baseBlocks); + } + return; + } + + /** + * 替换页面中的literal标签 + * @access private + * @param string $content 模板内容 + * @param boolean $restore 是否为还原 + * @return void + */ + private function parseLiteral(&$content, $restore = false) + { + $regex = $this->getRegex($restore ? 'restoreliteral' : 'literal'); + if (preg_match_all($regex, $content, $matches, PREG_SET_ORDER)) { + if (!$restore) { + $count = count($this->literal); + // 替换literal标签 + foreach ($matches as $match) { + $this->literal[] = substr($match[0], strlen($match[1]), -strlen($match[2])); + $content = str_replace($match[0], "", $content); + $count++; + } + } else { + // 还原literal标签 + foreach ($matches as $match) { + $content = str_replace($match[0], $this->literal[$match[1]], $content); + } + // 清空literal记录 + $this->literal = []; + } + unset($matches); + } + return; + } + + /** + * 获取模板中的block标签 + * @access private + * @param string $content 模板内容 + * @param boolean $sort 是否排序 + * @return array + */ + private function parseBlock(&$content, $sort = false) + { + $regex = $this->getRegex('block'); + $result = []; + if (preg_match_all($regex, $content, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE)) { + $right = $keys = []; + foreach ($matches as $match) { + if (empty($match['name'][0])) { + if (count($right) > 0) { + $tag = array_pop($right); + $start = $tag['offset'] + strlen($tag['tag']); + $length = $match[0][1] - $start; + $result[$tag['name']] = [ + 'begin' => $tag['tag'], + 'content' => substr($content, $start, $length), + 'end' => $match[0][0], + 'parent' => count($right) ? end($right)['name'] : '', + ]; + $keys[$tag['name']] = $match[0][1]; + } + } else { + // 标签头压入栈 + $right[] = [ + 'name' => $match[2][0], + 'offset' => $match[0][1], + 'tag' => $match[0][0], + ]; + } + } + unset($right, $matches); + if ($sort) { + // 按block标签结束符在模板中的位置排序 + array_multisort($keys, $result); + } + } + return $result; + } + + /** + * 搜索模板页面中包含的TagLib库 + * 并返回列表 + * @access private + * @param string $content 模板内容 + * @return array|null + */ + private function getIncludeTagLib(&$content) + { + // 搜索是否有TagLib标签 + if (preg_match($this->getRegex('taglib'), $content, $matches)) { + // 替换TagLib标签 + $content = str_replace($matches[0], '', $content); + return explode(',', $matches['name']); + } + return; + } + + /** + * TagLib库解析 + * @access public + * @param string $tagLib 要解析的标签库 + * @param string $content 要解析的模板内容 + * @param boolean $hide 是否隐藏标签库前缀 + * @return void + */ + public function parseTagLib($tagLib, &$content, $hide = false) + { + if (false !== strpos($tagLib, '\\')) { + // 支持指定标签库的命名空间 + $className = $tagLib; + $tagLib = substr($tagLib, strrpos($tagLib, '\\') + 1); + } else { + $className = '\\think\\template\\taglib\\' . ucwords($tagLib); + } + /** @var Taglib $tLib */ + $tLib = new $className($this); + $tLib->parseTag($content, $hide ? '' : $tagLib); + return; + } + + /** + * 分析标签属性 + * @access public + * @param string $str 属性字符串 + * @param string $name 不为空时返回指定的属性名 + * @return array + */ + public function parseAttr($str, $name = null) + { + $regex = '/\s+(?>(?P[\w-]+)\s*)=(?>\s*)([\"\'])(?P(?:(?!\\2).)*)\\2/is'; + $array = []; + if (preg_match_all($regex, $str, $matches, PREG_SET_ORDER)) { + foreach ($matches as $match) { + $array[$match['name']] = $match['value']; + } + unset($matches); + } + if (!empty($name) && isset($array[$name])) { + return $array[$name]; + } else { + return $array; + } + } + + /** + * 模板标签解析 + * 格式: {TagName:args [|content] } + * @access private + * @param string $content 要解析的模板内容 + * @return void + */ + private function parseTag(&$content) + { + $regex = $this->getRegex('tag'); + if (preg_match_all($regex, $content, $matches, PREG_SET_ORDER)) { + foreach ($matches as $match) { + $str = stripslashes($match[1]); + $flag = substr($str, 0, 1); + switch ($flag) { + case '$': + // 解析模板变量 格式 {$varName} + // 是否带有?号 + if (false !== $pos = strpos($str, '?')) { + $array = preg_split('/([!=]={1,2}|(?<]={0,1})/', substr($str, 0, $pos), 2, PREG_SPLIT_DELIM_CAPTURE); + $name = $array[0]; + $this->parseVar($name); + $this->parseVarFunction($name); + + $str = trim(substr($str, $pos + 1)); + $this->parseVar($str); + $first = substr($str, 0, 1); + if (strpos($name, ')')) { + // $name为对象或是自动识别,或者含有函数 + if (isset($array[1])) { + $this->parseVar($array[2]); + $name .= $array[1] . $array[2]; + } + switch ($first) { + case '?': + $str = ''; + break; + case '=': + $str = ''; + break; + default: + $str = ''; + } + } else { + if (isset($array[1])) { + $this->parseVar($array[2]); + $express = $name . $array[1] . $array[2]; + } else { + $express = false; + } + // $name为数组 + switch ($first) { + case '?': + // {$varname??'xxx'} $varname有定义则输出$varname,否则输出xxx + $str = ''; + break; + case '=': + // {$varname?='xxx'} $varname为真时才输出xxx + $str = ''; + break; + case ':': + // {$varname?:'xxx'} $varname为真时输出$varname,否则输出xxx + $str = ''; + break; + default: + $str = ''; + } + } + } else { + $this->parseVar($str); + $this->parseVarFunction($str); + $str = ''; + } + break; + case ':': + // 输出某个函数的结果 + $str = substr($str, 1); + $this->parseVar($str); + $str = ''; + break; + case '~': + // 执行某个函数 + $str = substr($str, 1); + $this->parseVar($str); + $str = ''; + break; + case '-': + case '+': + // 输出计算 + $this->parseVar($str); + $str = ''; + break; + case '/': + // 注释标签 + $flag2 = substr($str, 1, 1); + if ('/' == $flag2 || ('*' == $flag2 && substr(rtrim($str), -2) == '*/')) { + $str = ''; + } + break; + default: + // 未识别的标签直接返回 + $str = $this->config['tpl_begin'] . $str . $this->config['tpl_end']; + break; + } + $content = str_replace($match[0], $str, $content); + } + unset($matches); + } + return; + } + + /** + * 模板变量解析,支持使用函数 + * 格式: {$varname|function1|function2=arg1,arg2} + * @access public + * @param string $varStr 变量数据 + * @return void + */ + public function parseVar(&$varStr) + { + $varStr = trim($varStr); + if (preg_match_all('/\$[a-zA-Z_](?>\w*)(?:[:\.][0-9a-zA-Z_](?>\w*))+/', $varStr, $matches, PREG_OFFSET_CAPTURE)) { + static $_varParseList = []; + while ($matches[0]) { + $match = array_pop($matches[0]); + //如果已经解析过该变量字串,则直接返回变量值 + if (isset($_varParseList[$match[0]])) { + $parseStr = $_varParseList[$match[0]]; + } else { + if (strpos($match[0], '.')) { + $vars = explode('.', $match[0]); + $first = array_shift($vars); + if ('$Think' == $first) { + // 所有以Think.打头的以特殊变量对待 无需模板赋值就可以输出 + $parseStr = $this->parseThinkVar($vars); + } elseif ('$Request' == $first) { + // 获取Request请求对象参数 + $method = array_shift($vars); + if (!empty($vars)) { + $params = implode('.', $vars); + if ('true' != $params) { + $params = '\'' . $params . '\''; + } + } else { + $params = ''; + } + $parseStr = '\think\Request::instance()->' . $method . '(' . $params . ')'; + } else { + switch ($this->config['tpl_var_identify']) { + case 'array': // 识别为数组 + $parseStr = $first . '[\'' . implode('\'][\'', $vars) . '\']'; + break; + case 'obj': // 识别为对象 + $parseStr = $first . '->' . implode('->', $vars); + break; + default: // 自动判断数组或对象 + $parseStr = '(is_array(' . $first . ')?' . $first . '[\'' . implode('\'][\'', $vars) . '\']:' . $first . '->' . implode('->', $vars) . ')'; + } + } + } else { + $parseStr = str_replace(':', '->', $match[0]); + } + $_varParseList[$match[0]] = $parseStr; + } + $varStr = substr_replace($varStr, $parseStr, $match[1], strlen($match[0])); + } + unset($matches); + } + return; + } + + /** + * 对模板中使用了函数的变量进行解析 + * 格式 {$varname|function1|function2=arg1,arg2} + * @access public + * @param string $varStr 变量字符串 + * @return void + */ + public function parseVarFunction(&$varStr) + { + if (false == strpos($varStr, '|')) { + return; + } + static $_varFunctionList = []; + $_key = md5($varStr); + //如果已经解析过该变量字串,则直接返回变量值 + if (isset($_varFunctionList[$_key])) { + $varStr = $_varFunctionList[$_key]; + } else { + $varArray = explode('|', $varStr); + // 取得变量名称 + $name = array_shift($varArray); + // 对变量使用函数 + $length = count($varArray); + // 取得模板禁止使用函数列表 + $template_deny_funs = explode(',', $this->config['tpl_deny_func_list']); + for ($i = 0; $i < $length; $i++) { + $args = explode('=', $varArray[$i], 2); + // 模板函数过滤 + $fun = trim($args[0]); + switch ($fun) { + case 'default': // 特殊模板函数 + if (false === strpos($name, '(')) { + $name = '(isset(' . $name . ') && (' . $name . ' !== \'\')?' . $name . ':' . $args[1] . ')'; + } else { + $name = '(' . $name . ' ?: ' . $args[1] . ')'; + } + break; + default: // 通用模板函数 + if (!in_array($fun, $template_deny_funs)) { + if (isset($args[1])) { + if (strstr($args[1], '###')) { + $args[1] = str_replace('###', $name, $args[1]); + $name = "$fun($args[1])"; + } else { + $name = "$fun($name ?? '',$args[1])"; + } + } else { + if (!empty($args[0])) { + $name = "$fun($name ?? '')"; + } + } + } + } + } + $_varFunctionList[$_key] = $name; + $varStr = $name; + } + return; + } + + /** + * 特殊模板变量解析 + * 格式 以 $Think. 打头的变量属于特殊模板变量 + * @access public + * @param array $vars 变量数组 + * @return string + */ + public function parseThinkVar($vars) + { + $type = strtoupper(trim(array_shift($vars))); + $param = implode('.', $vars); + if ($vars) { + switch ($type) { + case 'SERVER': + $parseStr = '\\think\\Request::instance()->server(\'' . $param . '\')'; + break; + case 'GET': + $parseStr = '\\think\\Request::instance()->get(\'' . $param . '\')'; + break; + case 'POST': + $parseStr = '\\think\\Request::instance()->post(\'' . $param . '\')'; + break; + case 'COOKIE': + $parseStr = '\\think\\Cookie::get(\'' . $param . '\')'; + break; + case 'SESSION': + $parseStr = '\\think\\Session::get(\'' . $param . '\')'; + break; + case 'ENV': + $parseStr = '\\think\\Request::instance()->env(\'' . $param . '\')'; + break; + case 'REQUEST': + $parseStr = '\\think\\Request::instance()->request(\'' . $param . '\')'; + break; + case 'CONST': + $parseStr = strtoupper($param); + break; + case 'LANG': + $parseStr = '\\think\\Lang::get(\'' . $param . '\')'; + break; + case 'CONFIG': + $parseStr = '\\think\\Config::get(\'' . $param . '\')'; + break; + default: + $parseStr = '\'\''; + break; + } + } else { + switch ($type) { + case 'NOW': + $parseStr = "date('Y-m-d g:i a',time())"; + break; + case 'VERSION': + $parseStr = 'THINK_VERSION'; + break; + case 'LDELIM': + $parseStr = '\'' . ltrim($this->config['tpl_begin'], '\\') . '\''; + break; + case 'RDELIM': + $parseStr = '\'' . ltrim($this->config['tpl_end'], '\\') . '\''; + break; + default: + if (defined($type)) { + $parseStr = $type; + } else { + $parseStr = ''; + } + } + } + return $parseStr; + } + + /** + * 分析加载的模板文件并读取内容 支持多个模板文件读取 + * @access private + * @param string $templateName 模板文件名 + * @return string + */ + private function parseTemplateName($templateName) + { + $array = explode(',', $templateName); + $parseStr = ''; + foreach ($array as $templateName) { + if (empty($templateName)) { + continue; + } + if (0 === strpos($templateName, '$')) { + //支持加载变量文件名 + $templateName = $this->get(substr($templateName, 1)); + } + $template = $this->parseTemplateFile($templateName); + if ($template) { + // 获取模板文件内容 + $parseStr .= file_get_contents($template); + } + } + return $parseStr; + } + + /** + * 解析模板文件名 + * @access private + * @param string $template 文件名 + * @return string|false + */ + private function parseTemplateFile($template) + { + if ('' == pathinfo($template, PATHINFO_EXTENSION)) { + if (strpos($template, '@')) { + list($module, $template) = explode('@', $template); + } + if (0 !== strpos($template, '/')) { + $template = str_replace(['/', ':'], $this->config['view_depr'], $template); + } else { + $template = str_replace(['/', ':'], $this->config['view_depr'], substr($template, 1)); + } + if ($this->config['view_base']) { + $module = isset($module) ? $module : Request::instance()->module(); + $path = $this->config['view_base'] . ($module ? $module . DS : ''); + } else { + $path = isset($module) ? APP_PATH . $module . DS . basename($this->config['view_path']) . DS : $this->config['view_path']; + } + $template = realpath($path . $template . '.' . ltrim($this->config['view_suffix'], '.')); + } + + if (is_file($template)) { + // 记录模板文件的更新时间 + $this->includeFile[$template] = filemtime($template); + return $template; + } else { + throw new TemplateNotFoundException('template not exists:' . $template, $template); + } + } + + /** + * 按标签生成正则 + * @access private + * @param string $tagName 标签名 + * @return string + */ + private function getRegex($tagName) + { + $regex = ''; + if ('tag' == $tagName) { + $begin = $this->config['tpl_begin']; + $end = $this->config['tpl_end']; + if (strlen(ltrim($begin, '\\')) == 1 && strlen(ltrim($end, '\\')) == 1) { + $regex = $begin . '((?:[\$]{1,2}[a-wA-w_]|[\:\~][\$a-wA-w_]|[+]{2}[\$][a-wA-w_]|[-]{2}[\$][a-wA-w_]|\/[\*\/])(?>[^' . $end . ']*))' . $end; + } else { + $regex = $begin . '((?:[\$]{1,2}[a-wA-w_]|[\:\~][\$a-wA-w_]|[+]{2}[\$][a-wA-w_]|[-]{2}[\$][a-wA-w_]|\/[\*\/])(?>(?:(?!' . $end . ').)*))' . $end; + } + } else { + $begin = $this->config['taglib_begin']; + $end = $this->config['taglib_end']; + $single = strlen(ltrim($begin, '\\')) == 1 && strlen(ltrim($end, '\\')) == 1 ? true : false; + switch ($tagName) { + case 'block': + if ($single) { + $regex = $begin . '(?:' . $tagName . '\b(?>(?:(?!name=).)*)\bname=([\'\"])(?P[\$\w\-\/\.]+)\\1(?>[^' . $end . ']*)|\/' . $tagName . ')' . $end; + } else { + $regex = $begin . '(?:' . $tagName . '\b(?>(?:(?!name=).)*)\bname=([\'\"])(?P[\$\w\-\/\.]+)\\1(?>(?:(?!' . $end . ').)*)|\/' . $tagName . ')' . $end; + } + break; + case 'literal': + if ($single) { + $regex = '(' . $begin . $tagName . '\b(?>[^' . $end . ']*)' . $end . ')'; + $regex .= '(?:(?>[^' . $begin . ']*)(?>(?!' . $begin . '(?>' . $tagName . '\b[^' . $end . ']*|\/' . $tagName . ')' . $end . ')' . $begin . '[^' . $begin . ']*)*)'; + $regex .= '(' . $begin . '\/' . $tagName . $end . ')'; + } else { + $regex = '(' . $begin . $tagName . '\b(?>(?:(?!' . $end . ').)*)' . $end . ')'; + $regex .= '(?:(?>(?:(?!' . $begin . ').)*)(?>(?!' . $begin . '(?>' . $tagName . '\b(?>(?:(?!' . $end . ').)*)|\/' . $tagName . ')' . $end . ')' . $begin . '(?>(?:(?!' . $begin . ').)*))*)'; + $regex .= '(' . $begin . '\/' . $tagName . $end . ')'; + } + break; + case 'restoreliteral': + $regex = ''; + break; + case 'include': + $name = 'file'; + case 'taglib': + case 'layout': + case 'extend': + if (empty($name)) { + $name = 'name'; + } + if ($single) { + $regex = $begin . $tagName . '\b(?>(?:(?!' . $name . '=).)*)\b' . $name . '=([\'\"])(?P[\$\w\-\/\.\:@,\\\\]+)\\1(?>[^' . $end . ']*)' . $end; + } else { + $regex = $begin . $tagName . '\b(?>(?:(?!' . $name . '=).)*)\b' . $name . '=([\'\"])(?P[\$\w\-\/\.\:@,\\\\]+)\\1(?>(?:(?!' . $end . ').)*)' . $end; + } + break; + } + } + return '/' . $regex . '/is'; + } +} diff --git a/thinkphp/library/think/Url.php b/thinkphp/library/think/Url.php new file mode 100644 index 0000000..53a545f --- /dev/null +++ b/thinkphp/library/think/Url.php @@ -0,0 +1,333 @@ + +// +---------------------------------------------------------------------- + +namespace think; + +class Url +{ + // 生成URL地址的root + protected static $root; + protected static $bindCheck; + + /** + * URL生成 支持路由反射 + * @param string $url 路由地址 + * @param string|array $vars 参数(支持数组和字符串)a=val&b=val2... ['a'=>'val1', 'b'=>'val2'] + * @param string|bool $suffix 伪静态后缀,默认为true表示获取配置值 + * @param boolean|string $domain 是否显示域名 或者直接传入域名 + * @return string + */ + public static function build($url = '', $vars = '', $suffix = true, $domain = false) + { + if (false === $domain && Route::rules('domain')) { + $domain = true; + } + // 解析URL + if (0 === strpos($url, '[') && $pos = strpos($url, ']')) { + // [name] 表示使用路由命名标识生成URL + $name = substr($url, 1, $pos - 1); + $url = 'name' . substr($url, $pos + 1); + } + if (false === strpos($url, '://') && 0 !== strpos($url, '/')) { + $info = parse_url($url); + $url = !empty($info['path']) ? $info['path'] : ''; + if (isset($info['fragment'])) { + // 解析锚点 + $anchor = $info['fragment']; + if (false !== strpos($anchor, '?')) { + // 解析参数 + list($anchor, $info['query']) = explode('?', $anchor, 2); + } + if (false !== strpos($anchor, '@')) { + // 解析域名 + list($anchor, $domain) = explode('@', $anchor, 2); + } + } elseif (strpos($url, '@') && false === strpos($url, '\\')) { + // 解析域名 + list($url, $domain) = explode('@', $url, 2); + } + } + + // 解析参数 + if (is_string($vars)) { + // aaa=1&bbb=2 转换成数组 + parse_str($vars, $vars); + } + + if ($url) { + $rule = Route::name(isset($name) ? $name : $url . (isset($info['query']) ? '?' . $info['query'] : '')); + if (is_null($rule) && isset($info['query'])) { + $rule = Route::name($url); + // 解析地址里面参数 合并到vars + parse_str($info['query'], $params); + $vars = array_merge($params, $vars); + unset($info['query']); + } + } + if (!empty($rule) && $match = self::getRuleUrl($rule, $vars)) { + // 匹配路由命名标识 + $url = $match[0]; + // 替换可选分隔符 + $url = preg_replace(['/(\W)\?$/', '/(\W)\?/'], ['', '\1'], $url); + if (!empty($match[1])) { + $domain = $match[1]; + } + if (!is_null($match[2])) { + $suffix = $match[2]; + } + } elseif (!empty($rule) && isset($name)) { + throw new \InvalidArgumentException('route name not exists:' . $name); + } else { + // 检查别名路由 + $alias = Route::rules('alias'); + $matchAlias = false; + if ($alias) { + // 别名路由解析 + foreach ($alias as $key => $val) { + if (is_array($val)) { + $val = $val[0]; + } + if (0 === strpos($url, $val)) { + $url = $key . substr($url, strlen($val)); + $matchAlias = true; + break; + } + } + } + if (!$matchAlias) { + // 路由标识不存在 直接解析 + $url = self::parseUrl($url, $domain); + } + if (isset($info['query'])) { + // 解析地址里面参数 合并到vars + parse_str($info['query'], $params); + $vars = array_merge($params, $vars); + } + } + + // 检测URL绑定 + if (!self::$bindCheck) { + $type = Route::getBind('type'); + if ($type) { + $bind = Route::getBind($type); + if ($bind && 0 === strpos($url, $bind)) { + $url = substr($url, strlen($bind) + 1); + } + } + } + // 还原URL分隔符 + $depr = Config::get('pathinfo_depr'); + $url = str_replace('/', $depr, $url); + + // URL后缀 + $suffix = in_array($url, ['/', '']) ? '' : self::parseSuffix($suffix); + // 锚点 + $anchor = !empty($anchor) ? '#' . $anchor : ''; + // 参数组装 + if (!empty($vars)) { + // 添加参数 + if (Config::get('url_common_param')) { + $vars = http_build_query($vars); + $url .= $suffix . '?' . $vars . $anchor; + } else { + $paramType = Config::get('url_param_type'); + foreach ($vars as $var => $val) { + if ('' !== trim($val)) { + if ($paramType) { + $url .= $depr . urlencode($val); + } else { + $url .= $depr . $var . $depr . urlencode($val); + } + } + } + $url .= $suffix . $anchor; + } + } else { + $url .= $suffix . $anchor; + } + // 检测域名 + $domain = self::parseDomain($url, $domain); + // URL组装 + $url = $domain . rtrim(self::$root ?: Request::instance()->root(), '/') . '/' . ltrim($url, '/'); + + self::$bindCheck = false; + return $url; + } + + // 直接解析URL地址 + protected static function parseUrl($url, &$domain) + { + $request = Request::instance(); + if (0 === strpos($url, '/')) { + // 直接作为路由地址解析 + $url = substr($url, 1); + } elseif (false !== strpos($url, '\\')) { + // 解析到类 + $url = ltrim(str_replace('\\', '/', $url), '/'); + } elseif (0 === strpos($url, '@')) { + // 解析到控制器 + $url = substr($url, 1); + } else { + // 解析到 模块/控制器/操作 + $module = $request->module(); + $domains = Route::rules('domain'); + if (true === $domain && 2 == substr_count($url, '/')) { + $current = $request->host(); + $match = []; + $pos = []; + foreach ($domains as $key => $item) { + if (isset($item['[bind]']) && 0 === strpos($url, $item['[bind]'][0])) { + $pos[$key] = strlen($item['[bind]'][0]) + 1; + $match[] = $key; + $module = ''; + } + } + if ($match) { + $domain = current($match); + foreach ($match as $item) { + if (0 === strpos($current, $item)) { + $domain = $item; + } + } + self::$bindCheck = true; + $url = substr($url, $pos[$domain]); + } + } elseif ($domain) { + if (isset($domains[$domain]['[bind]'][0])) { + $bindModule = $domains[$domain]['[bind]'][0]; + if ($bindModule && !in_array($bindModule[0], ['\\', '@'])) { + $module = ''; + } + } + } + $module = $module ? $module . '/' : ''; + + $controller = $request->controller(); + if ('' == $url) { + // 空字符串输出当前的 模块/控制器/操作 + $action = $request->action(); + } else { + $path = explode('/', $url); + $action = array_pop($path); + $controller = empty($path) ? $controller : array_pop($path); + $module = empty($path) ? $module : array_pop($path) . '/'; + } + if (Config::get('url_convert')) { + $action = strtolower($action); + $controller = Loader::parseName($controller); + } + $url = $module . $controller . '/' . $action; + } + return $url; + } + + // 检测域名 + protected static function parseDomain(&$url, $domain) + { + if (!$domain) { + return ''; + } + $request = Request::instance(); + $rootDomain = Config::get('url_domain_root'); + if (true === $domain) { + // 自动判断域名 + $domain = Config::get('app_host') ?: $request->host(); + + $domains = Route::rules('domain'); + if ($domains) { + $route_domain = array_keys($domains); + foreach ($route_domain as $domain_prefix) { + if (0 === strpos($domain_prefix, '*.') && strpos($domain, ltrim($domain_prefix, '*.')) !== false) { + foreach ($domains as $key => $rule) { + $rule = is_array($rule) ? $rule[0] : $rule; + if (is_string($rule) && false === strpos($key, '*') && 0 === strpos($url, $rule)) { + $url = ltrim($url, $rule); + $domain = $key; + // 生成对应子域名 + if (!empty($rootDomain)) { + $domain .= $rootDomain; + } + break; + } elseif (false !== strpos($key, '*')) { + if (!empty($rootDomain)) { + $domain .= $rootDomain; + } + break; + } + } + } + } + } + + } else { + if (empty($rootDomain)) { + $host = Config::get('app_host') ?: $request->host(); + $rootDomain = substr_count($host, '.') > 1 ? substr(strstr($host, '.'), 1) : $host; + } + if (substr_count($domain, '.') < 2 && !strpos($domain, $rootDomain)) { + $domain .= '.' . $rootDomain; + } + } + if (false !== strpos($domain, '://')) { + $scheme = ''; + } else { + $scheme = $request->isSsl() || Config::get('is_https') ? 'https://' : 'http://'; + } + return $scheme . $domain; + } + + // 解析URL后缀 + protected static function parseSuffix($suffix) + { + if ($suffix) { + $suffix = true === $suffix ? Config::get('url_html_suffix') : $suffix; + if ($pos = strpos($suffix, '|')) { + $suffix = substr($suffix, 0, $pos); + } + } + return (empty($suffix) || 0 === strpos($suffix, '.')) ? $suffix : '.' . $suffix; + } + + // 匹配路由地址 + public static function getRuleUrl($rule, &$vars = []) + { + foreach ($rule as $item) { + list($url, $pattern, $domain, $suffix) = $item; + if (empty($pattern)) { + return [rtrim($url, '$'), $domain, $suffix]; + } + $type = Config::get('url_common_param'); + foreach ($pattern as $key => $val) { + if (isset($vars[$key])) { + $url = str_replace(['[:' . $key . ']', '<' . $key . '?>', ':' . $key . '', '<' . $key . '>'], $type ? $vars[$key] : urlencode($vars[$key]), $url); + unset($vars[$key]); + $result = [$url, $domain, $suffix]; + } elseif (2 == $val) { + $url = str_replace(['/[:' . $key . ']', '[:' . $key . ']', '<' . $key . '?>'], '', $url); + $result = [$url, $domain, $suffix]; + } else { + break; + } + } + if (isset($result)) { + return $result; + } + } + return false; + } + + // 指定当前生成URL地址的root + public static function root($root) + { + self::$root = $root; + Request::instance()->root($root); + } +} diff --git a/thinkphp/library/think/Validate.php b/thinkphp/library/think/Validate.php new file mode 100644 index 0000000..784e1b2 --- /dev/null +++ b/thinkphp/library/think/Validate.php @@ -0,0 +1,1393 @@ + +// +---------------------------------------------------------------------- + +namespace think; + +use think\exception\ClassNotFoundException; + +class Validate +{ + // 实例 + protected static $instance; + + // 自定义的验证类型 + protected static $type = []; + + // 验证类型别名 + protected $alias = [ + '>' => 'gt', '>=' => 'egt', '<' => 'lt', '<=' => 'elt', '=' => 'eq', 'same' => 'eq', + ]; + + // 当前验证的规则 + protected $rule = []; + + // 验证提示信息 + protected $message = []; + // 验证字段描述 + protected $field = []; + + // 验证规则默认提示信息 + protected static $typeMsg = [ + 'require' => ':attribute require', + 'must' => ':attribute must', + 'number' => ':attribute must be numeric', + 'integer' => ':attribute must be integer', + 'float' => ':attribute must be float', + 'boolean' => ':attribute must be bool', + 'email' => ':attribute not a valid email address', + 'mobile' => ':attribute not a valid mobile', + 'array' => ':attribute must be a array', + 'accepted' => ':attribute must be yes,on or 1', + 'date' => ':attribute not a valid datetime', + 'file' => ':attribute not a valid file', + 'image' => ':attribute not a valid image', + 'alpha' => ':attribute must be alpha', + 'alphaNum' => ':attribute must be alpha-numeric', + 'alphaDash' => ':attribute must be alpha-numeric, dash, underscore', + 'activeUrl' => ':attribute not a valid domain or ip', + 'chs' => ':attribute must be chinese', + 'chsAlpha' => ':attribute must be chinese or alpha', + 'chsAlphaNum' => ':attribute must be chinese,alpha-numeric', + 'chsDash' => ':attribute must be chinese,alpha-numeric,underscore, dash', + 'url' => ':attribute not a valid url', + 'ip' => ':attribute not a valid ip', + 'dateFormat' => ':attribute must be dateFormat of :rule', + 'in' => ':attribute must be in :rule', + 'notIn' => ':attribute be notin :rule', + 'between' => ':attribute must between :1 - :2', + 'notBetween' => ':attribute not between :1 - :2', + 'length' => 'size of :attribute must be :rule', + 'max' => 'max size of :attribute must be :rule', + 'min' => 'min size of :attribute must be :rule', + 'after' => ':attribute cannot be less than :rule', + 'before' => ':attribute cannot exceed :rule', + 'afterWith' => ':attribute cannot be less than :rule', + 'beforeWith' => ':attribute cannot exceed :rule', + 'expire' => ':attribute not within :rule', + 'allowIp' => 'access IP is not allowed', + 'denyIp' => 'access IP denied', + 'confirm' => ':attribute out of accord with :2', + 'different' => ':attribute cannot be same with :2', + 'egt' => ':attribute must greater than or equal :rule', + 'gt' => ':attribute must greater than :rule', + 'elt' => ':attribute must less than or equal :rule', + 'lt' => ':attribute must less than :rule', + 'eq' => ':attribute must equal :rule', + 'unique' => ':attribute has exists', + 'regex' => ':attribute not conform to the rules', + 'method' => 'invalid Request method', + 'token' => 'invalid token', + 'fileSize' => 'filesize not match', + 'fileExt' => 'extensions to upload is not allowed', + 'fileMime' => 'mimetype to upload is not allowed', + ]; + + // 当前验证场景 + protected $currentScene = null; + + /** + * 内置正则验证规则 + * @var array + */ + protected $defaultRegex = [ + 'alpha' => '/^[A-Za-z]+$/', + 'alphaNum' => '/^[A-Za-z0-9]+$/', + 'alphaDash' => '/^[A-Za-z0-9\-\_]+$/', + 'chs' => '/^[\x{4e00}-\x{9fa5}\x{9fa6}-\x{9fef}\x{3400}-\x{4db5}\x{20000}-\x{2ebe0}]+$/u', + 'chsAlpha' => '/^[\x{4e00}-\x{9fa5}\x{9fa6}-\x{9fef}\x{3400}-\x{4db5}\x{20000}-\x{2ebe0}a-zA-Z]+$/u', + 'chsAlphaNum' => '/^[\x{4e00}-\x{9fa5}\x{9fa6}-\x{9fef}\x{3400}-\x{4db5}\x{20000}-\x{2ebe0}a-zA-Z0-9]+$/u', + 'chsDash' => '/^[\x{4e00}-\x{9fa5}\x{9fa6}-\x{9fef}\x{3400}-\x{4db5}\x{20000}-\x{2ebe0}a-zA-Z0-9\_\-]+$/u', + 'mobile' => '/^1[3-9]\d{9}$/', + 'idCard' => '/(^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$)|(^[1-9]\d{5}\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}$)/', + 'zip' => '/\d{6}/', + ]; + + // 正则表达式 regex = ['zip'=>'\d{6}',...] + protected $regex = []; + + // 验证场景 scene = ['edit'=>'name1,name2,...'] + protected $scene = []; + + // 验证失败错误信息 + protected $error = []; + + // 批量验证 + protected $batch = false; + + /** + * 构造函数 + * @access public + * @param array $rules 验证规则 + * @param array $message 验证提示信息 + * @param array $field 验证字段描述信息 + */ + public function __construct(array $rules = [], $message = [], $field = []) + { + $this->rule = array_merge($this->rule, $rules); + $this->message = array_merge($this->message, $message); + $this->field = array_merge($this->field, $field); + } + + /** + * 实例化验证 + * @access public + * @param array $rules 验证规则 + * @param array $message 验证提示信息 + * @param array $field 验证字段描述信息 + * @return Validate + */ + public static function make($rules = [], $message = [], $field = []) + { + if (is_null(self::$instance)) { + self::$instance = new self($rules, $message, $field); + } + return self::$instance; + } + + /** + * 添加字段验证规则 + * @access protected + * @param string|array $name 字段名称或者规则数组 + * @param mixed $rule 验证规则 + * @return Validate + */ + public function rule($name, $rule = '') + { + if (is_array($name)) { + $this->rule = array_merge($this->rule, $name); + } else { + $this->rule[$name] = $rule; + } + return $this; + } + + /** + * 注册验证(类型)规则 + * @access public + * @param string $type 验证规则类型 + * @param mixed $callback callback方法(或闭包) + * @return void + */ + public static function extend($type, $callback = null) + { + if (is_array($type)) { + self::$type = array_merge(self::$type, $type); + } else { + self::$type[$type] = $callback; + } + } + + /** + * 设置验证规则的默认提示信息 + * @access protected + * @param string|array $type 验证规则类型名称或者数组 + * @param string $msg 验证提示信息 + * @return void + */ + public static function setTypeMsg($type, $msg = null) + { + if (is_array($type)) { + self::$typeMsg = array_merge(self::$typeMsg, $type); + } else { + self::$typeMsg[$type] = $msg; + } + } + + /** + * 设置提示信息 + * @access public + * @param string|array $name 字段名称 + * @param string $message 提示信息 + * @return Validate + */ + public function message($name, $message = '') + { + if (is_array($name)) { + $this->message = array_merge($this->message, $name); + } else { + $this->message[$name] = $message; + } + return $this; + } + + /** + * 设置验证场景 + * @access public + * @param string|array $name 场景名或者场景设置数组 + * @param mixed $fields 要验证的字段 + * @return Validate + */ + public function scene($name, $fields = null) + { + if (is_array($name)) { + $this->scene = array_merge($this->scene, $name); + }if (is_null($fields)) { + // 设置当前场景 + $this->currentScene = $name; + } else { + // 设置验证场景 + $this->scene[$name] = $fields; + } + return $this; + } + + /** + * 判断是否存在某个验证场景 + * @access public + * @param string $name 场景名 + * @return bool + */ + public function hasScene($name) + { + return isset($this->scene[$name]); + } + + /** + * 设置批量验证 + * @access public + * @param bool $batch 是否批量验证 + * @return Validate + */ + public function batch($batch = true) + { + $this->batch = $batch; + return $this; + } + + /** + * 数据自动验证 + * @access public + * @param array $data 数据 + * @param mixed $rules 验证规则 + * @param string $scene 验证场景 + * @return bool + */ + public function check($data, $rules = [], $scene = '') + { + $this->error = []; + + if (empty($rules)) { + // 读取验证规则 + $rules = $this->rule; + } + + // 分析验证规则 + $scene = $this->getScene($scene); + if (is_array($scene)) { + // 处理场景验证字段 + $change = []; + $array = []; + foreach ($scene as $k => $val) { + if (is_numeric($k)) { + $array[] = $val; + } else { + $array[] = $k; + $change[$k] = $val; + } + } + } + + foreach ($rules as $key => $item) { + // field => rule1|rule2... field=>['rule1','rule2',...] + if (is_numeric($key)) { + // [field,rule1|rule2,msg1|msg2] + $key = $item[0]; + $rule = $item[1]; + if (isset($item[2])) { + $msg = is_string($item[2]) ? explode('|', $item[2]) : $item[2]; + } else { + $msg = []; + } + } else { + $rule = $item; + $msg = []; + } + if (strpos($key, '|')) { + // 字段|描述 用于指定属性名称 + list($key, $title) = explode('|', $key); + } else { + $title = isset($this->field[$key]) ? $this->field[$key] : $key; + } + + // 场景检测 + if (!empty($scene)) { + if ($scene instanceof \Closure && !call_user_func_array($scene, [$key, $data])) { + continue; + } elseif (is_array($scene)) { + if (!in_array($key, $array)) { + continue; + } elseif (isset($change[$key])) { + // 重载某个验证规则 + $rule = $change[$key]; + } + } + } + + // 获取数据 支持二维数组 + $value = $this->getDataValue($data, $key); + + // 字段验证 + if ($rule instanceof \Closure) { + // 匿名函数验证 支持传入当前字段和所有字段两个数据 + $result = call_user_func_array($rule, [$value, $data]); + } else { + $result = $this->checkItem($key, $value, $rule, $data, $title, $msg); + } + + if (true !== $result) { + // 没有返回true 则表示验证失败 + if (!empty($this->batch)) { + // 批量验证 + if (is_array($result)) { + $this->error = array_merge($this->error, $result); + } else { + $this->error[$key] = $result; + } + } else { + $this->error = $result; + return false; + } + } + } + return !empty($this->error) ? false : true; + } + + /** + * 根据验证规则验证数据 + * @access protected + * @param mixed $value 字段值 + * @param mixed $rules 验证规则 + * @return bool + */ + protected function checkRule($value, $rules) + { + if ($rules instanceof \Closure) { + return call_user_func_array($rules, [$value]); + } elseif (is_string($rules)) { + $rules = explode('|', $rules); + } + + foreach ($rules as $key => $rule) { + if ($rule instanceof \Closure) { + $result = call_user_func_array($rule, [$value]); + } else { + // 判断验证类型 + list($type, $rule) = $this->getValidateType($key, $rule); + + $callback = isset(self::$type[$type]) ? self::$type[$type] : [$this, $type]; + + $result = call_user_func_array($callback, [$value, $rule]); + } + + if (true !== $result) { + return $result; + } + } + + return true; + } + + /** + * 验证单个字段规则 + * @access protected + * @param string $field 字段名 + * @param mixed $value 字段值 + * @param mixed $rules 验证规则 + * @param array $data 数据 + * @param string $title 字段描述 + * @param array $msg 提示信息 + * @return mixed + */ + protected function checkItem($field, $value, $rules, $data, $title = '', $msg = []) + { + // 支持多规则验证 require|in:a,b,c|... 或者 ['require','in'=>'a,b,c',...] + if (is_string($rules)) { + $rules = explode('|', $rules); + } + $i = 0; + foreach ($rules as $key => $rule) { + if ($rule instanceof \Closure) { + $result = call_user_func_array($rule, [$value, $data]); + $info = is_numeric($key) ? '' : $key; + } else { + // 判断验证类型 + list($type, $rule, $info) = $this->getValidateType($key, $rule); + + // 如果不是require 有数据才会行验证 + if (0 === strpos($info, 'require') || (!is_null($value) && '' !== $value)) { + // 验证类型 + $callback = isset(self::$type[$type]) ? self::$type[$type] : [$this, $type]; + // 验证数据 + $result = call_user_func_array($callback, [$value, $rule, $data, $field, $title]); + } else { + $result = true; + } + } + + if (false === $result) { + // 验证失败 返回错误信息 + if (isset($msg[$i])) { + $message = $msg[$i]; + if (is_string($message) && strpos($message, '{%') === 0) { + $message = Lang::get(substr($message, 2, -1)); + } + } else { + $message = $this->getRuleMsg($field, $title, $info, $rule); + } + return $message; + } elseif (true !== $result) { + // 返回自定义错误信息 + if (is_string($result) && false !== strpos($result, ':')) { + $result = str_replace([':attribute', ':rule'], [$title, (string) $rule], $result); + } + return $result; + } + $i++; + } + return $result; + } + + /** + * 获取当前验证类型及规则 + * @access public + * @param mixed $key + * @param mixed $rule + * @return array + */ + protected function getValidateType($key, $rule) + { + // 判断验证类型 + if (!is_numeric($key)) { + return [$key, $rule, $key]; + } + + if (strpos($rule, ':')) { + list($type, $rule) = explode(':', $rule, 2); + if (isset($this->alias[$type])) { + // 判断别名 + $type = $this->alias[$type]; + } + $info = $type; + } elseif (method_exists($this, $rule)) { + $type = $rule; + $info = $rule; + $rule = ''; + } else { + $type = 'is'; + $info = $rule; + } + + return [$type, $rule, $info]; + } + + /** + * 验证是否和某个字段的值一致 + * @access protected + * @param mixed $value 字段值 + * @param mixed $rule 验证规则 + * @param array $data 数据 + * @param string $field 字段名 + * @return bool + */ + protected function confirm($value, $rule, $data, $field = '') + { + if ('' == $rule) { + if (strpos($field, '_confirm')) { + $rule = strstr($field, '_confirm', true); + } else { + $rule = $field . '_confirm'; + } + } + return $this->getDataValue($data, $rule) === $value; + } + + /** + * 验证是否和某个字段的值是否不同 + * @access protected + * @param mixed $value 字段值 + * @param mixed $rule 验证规则 + * @param array $data 数据 + * @return bool + */ + protected function different($value, $rule, $data) + { + return $this->getDataValue($data, $rule) != $value; + } + + /** + * 验证是否大于等于某个值 + * @access protected + * @param mixed $value 字段值 + * @param mixed $rule 验证规则 + * @param array $data 数据 + * @return bool + */ + protected function egt($value, $rule, $data) + { + $val = $this->getDataValue($data, $rule); + return !is_null($val) && $value >= $val; + } + + /** + * 验证是否大于某个值 + * @access protected + * @param mixed $value 字段值 + * @param mixed $rule 验证规则 + * @param array $data 数据 + * @return bool + */ + protected function gt($value, $rule, $data) + { + $val = $this->getDataValue($data, $rule); + return !is_null($val) && $value > $val; + } + + /** + * 验证是否小于等于某个值 + * @access protected + * @param mixed $value 字段值 + * @param mixed $rule 验证规则 + * @param array $data 数据 + * @return bool + */ + protected function elt($value, $rule, $data) + { + $val = $this->getDataValue($data, $rule); + return !is_null($val) && $value <= $val; + } + + /** + * 验证是否小于某个值 + * @access protected + * @param mixed $value 字段值 + * @param mixed $rule 验证规则 + * @param array $data 数据 + * @return bool + */ + protected function lt($value, $rule, $data) + { + $val = $this->getDataValue($data, $rule); + return !is_null($val) && $value < $val; + } + + /** + * 验证是否等于某个值 + * @access protected + * @param mixed $value 字段值 + * @param mixed $rule 验证规则 + * @return bool + */ + protected function eq($value, $rule) + { + return $value == $rule; + } + + /** + * 验证字段值是否为有效格式 + * @access protected + * @param mixed $value 字段值 + * @param string $rule 验证规则 + * @param array $data 验证数据 + * @return bool + */ + protected function is($value, $rule, $data = []) + { + switch ($rule) { + case 'require': + // 必须 + $result = !empty($value) || '0' == $value; + break; + case 'accepted': + // 接受 + $result = in_array($value, ['1', 'on', 'yes']); + break; + case 'date': + // 是否是一个有效日期 + $result = false !== strtotime($value); + break; + case 'alpha': + // 只允许字母 + $result = $this->regex($value, '/^[A-Za-z]+$/'); + break; + case 'alphaNum': + // 只允许字母和数字 + $result = $this->regex($value, '/^[A-Za-z0-9]+$/'); + break; + case 'alphaDash': + // 只允许字母、数字和下划线 破折号 + $result = $this->regex($value, '/^[A-Za-z0-9\-\_]+$/'); + break; + case 'chs': + // 只允许汉字 + $result = $this->regex($value, '/^[\x{4e00}-\x{9fa5}]+$/u'); + break; + case 'chsAlpha': + // 只允许汉字、字母 + $result = $this->regex($value, '/^[\x{4e00}-\x{9fa5}a-zA-Z]+$/u'); + break; + case 'chsAlphaNum': + // 只允许汉字、字母和数字 + $result = $this->regex($value, '/^[\x{4e00}-\x{9fa5}a-zA-Z0-9]+$/u'); + break; + case 'chsDash': + // 只允许汉字、字母、数字和下划线_及破折号- + $result = $this->regex($value, '/^[\x{4e00}-\x{9fa5}a-zA-Z0-9\_\-]+$/u'); + break; + case 'activeUrl': + // 是否为有效的网址 + $result = checkdnsrr($value); + break; + case 'ip': + // 是否为IP地址 + $result = $this->filter($value, [FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_IPV6]); + break; + case 'url': + // 是否为一个URL地址 + $result = $this->filter($value, FILTER_VALIDATE_URL); + break; + case 'float': + // 是否为float + $result = $this->filter($value, FILTER_VALIDATE_FLOAT); + break; + case 'number': + $result = is_numeric($value); + break; + case 'integer': + // 是否为整型 + $result = $this->filter($value, FILTER_VALIDATE_INT); + break; + case 'email': + // 是否为邮箱地址 + $result = $this->filter($value, FILTER_VALIDATE_EMAIL); + break; + case 'boolean': + // 是否为布尔值 + $result = in_array($value, [true, false, 0, 1, '0', '1'], true); + break; + case 'array': + // 是否为数组 + $result = is_array($value); + break; + case 'file': + $result = $value instanceof File; + break; + case 'image': + $result = $value instanceof File && in_array($this->getImageType($value->getRealPath()), [1, 2, 3, 6]); + break; + case 'token': + $result = $this->token($value, '__token__', $data); + break; + default: + if (isset(self::$type[$rule])) { + // 注册的验证规则 + $result = call_user_func_array(self::$type[$rule], [$value]); + } else { + // 正则验证 + $result = $this->regex($value, $rule); + } + } + return $result; + } + + // 判断图像类型 + protected function getImageType($image) + { + if (function_exists('exif_imagetype')) { + return exif_imagetype($image); + } else { + try { + $info = getimagesize($image); + return $info ? $info[2] : false; + } catch (\Exception $e) { + return false; + } + } + } + + /** + * 验证是否为合格的域名或者IP 支持A,MX,NS,SOA,PTR,CNAME,AAAA,A6, SRV,NAPTR,TXT 或者 ANY类型 + * @access protected + * @param mixed $value 字段值 + * @param mixed $rule 验证规则 + * @return bool + */ + protected function activeUrl($value, $rule) + { + if (!in_array($rule, ['A', 'MX', 'NS', 'SOA', 'PTR', 'CNAME', 'AAAA', 'A6', 'SRV', 'NAPTR', 'TXT', 'ANY'])) { + $rule = 'MX'; + } + return checkdnsrr($value, $rule); + } + + /** + * 验证是否有效IP + * @access protected + * @param mixed $value 字段值 + * @param mixed $rule 验证规则 ipv4 ipv6 + * @return bool + */ + protected function ip($value, $rule) + { + if (!in_array($rule, ['ipv4', 'ipv6'])) { + $rule = 'ipv4'; + } + return $this->filter($value, [FILTER_VALIDATE_IP, 'ipv6' == $rule ? FILTER_FLAG_IPV6 : FILTER_FLAG_IPV4]); + } + + /** + * 验证上传文件后缀 + * @access protected + * @param mixed $file 上传文件 + * @param mixed $rule 验证规则 + * @return bool + */ + protected function fileExt($file, $rule) + { + if (is_array($file)) { + foreach ($file as $item) { + if (!($item instanceof File) || !$item->checkExt($rule)) { + return false; + } + } + return true; + } elseif ($file instanceof File) { + return $file->checkExt($rule); + } else { + return false; + } + } + + /** + * 验证上传文件类型 + * @access protected + * @param mixed $file 上传文件 + * @param mixed $rule 验证规则 + * @return bool + */ + protected function fileMime($file, $rule) + { + if (is_array($file)) { + foreach ($file as $item) { + if (!($item instanceof File) || !$item->checkMime($rule)) { + return false; + } + } + return true; + } elseif ($file instanceof File) { + return $file->checkMime($rule); + } else { + return false; + } + } + + /** + * 验证上传文件大小 + * @access protected + * @param mixed $file 上传文件 + * @param mixed $rule 验证规则 + * @return bool + */ + protected function fileSize($file, $rule) + { + if (is_array($file)) { + foreach ($file as $item) { + if (!($item instanceof File) || !$item->checkSize($rule)) { + return false; + } + } + return true; + } elseif ($file instanceof File) { + return $file->checkSize($rule); + } else { + return false; + } + } + + /** + * 验证图片的宽高及类型 + * @access protected + * @param mixed $file 上传文件 + * @param mixed $rule 验证规则 + * @return bool + */ + protected function image($file, $rule) + { + if (!($file instanceof File)) { + return false; + } + if ($rule) { + $rule = explode(',', $rule); + list($width, $height, $type) = getimagesize($file->getRealPath()); + if (isset($rule[2])) { + $imageType = strtolower($rule[2]); + if ('jpeg' == $imageType) { + $imageType = 'jpg'; + } + if (image_type_to_extension($type, false) != $imageType) { + return false; + } + } + + list($w, $h) = $rule; + return $w == $width && $h == $height; + } else { + return in_array($this->getImageType($file->getRealPath()), [1, 2, 3, 6]); + } + } + + /** + * 验证请求类型 + * @access protected + * @param mixed $value 字段值 + * @param mixed $rule 验证规则 + * @return bool + */ + protected function method($value, $rule) + { + $method = Request::instance()->method(); + return strtoupper($rule) == $method; + } + + /** + * 验证时间和日期是否符合指定格式 + * @access protected + * @param mixed $value 字段值 + * @param mixed $rule 验证规则 + * @return bool + */ + protected function dateFormat($value, $rule) + { + $info = date_parse_from_format($rule, $value); + return 0 == $info['warning_count'] && 0 == $info['error_count']; + } + + /** + * 验证是否唯一 + * @access protected + * @param mixed $value 字段值 + * @param mixed $rule 验证规则 格式:数据表,字段名,排除ID,主键名 + * @param array $data 数据 + * @param string $field 验证字段名 + * @return bool + */ + protected function unique($value, $rule, $data, $field) + { + if (is_string($rule)) { + $rule = explode(',', $rule); + } + if (false !== strpos($rule[0], '\\')) { + // 指定模型类 + $db = new $rule[0]; + } else { + try { + $db = Loader::model($rule[0]); + } catch (ClassNotFoundException $e) { + $db = Db::name($rule[0]); + } + } + $key = isset($rule[1]) ? $rule[1] : $field; + + if (strpos($key, '^')) { + // 支持多个字段验证 + $fields = explode('^', $key); + foreach ($fields as $key) { + if (isset($data[$key])) { + $map[$key] = $data[$key]; + } + } + } elseif (strpos($key, '=')) { + parse_str($key, $map); + } elseif (isset($data[$field])) { + $map[$key] = $data[$field]; + } else { + $map = []; + } + + $pk = isset($rule[3]) ? $rule[3] : $db->getPk(); + if (is_string($pk)) { + if (isset($rule[2])) { + $map[$pk] = ['neq', $rule[2]]; + } elseif (isset($data[$pk])) { + $map[$pk] = ['neq', $data[$pk]]; + } + } + if ($db->where($map)->field($pk)->find()) { + return false; + } + return true; + } + + /** + * 使用行为类验证 + * @access protected + * @param mixed $value 字段值 + * @param mixed $rule 验证规则 + * @param array $data 数据 + * @return mixed + */ + protected function behavior($value, $rule, $data) + { + return Hook::exec($rule, '', $data); + } + + /** + * 使用filter_var方式验证 + * @access protected + * @param mixed $value 字段值 + * @param mixed $rule 验证规则 + * @return bool + */ + protected function filter($value, $rule) + { + if (is_string($rule) && strpos($rule, ',')) { + list($rule, $param) = explode(',', $rule); + } elseif (is_array($rule)) { + $param = $rule[1] ?? 0; + $rule = $rule[0]; + } else { + $param = 0; + } + return false !== filter_var($value, is_int($rule) ? $rule : filter_id($rule), $param); + } + + /** + * 验证某个字段等于某个值的时候必须 + * @access protected + * @param mixed $value 字段值 + * @param mixed $rule 验证规则 + * @param array $data 数据 + * @return bool + */ + protected function requireIf($value, $rule, $data) + { + list($field, $val) = explode(',', $rule); + if ($this->getDataValue($data, $field) == $val) { + return !empty($value) || '0' == $value; + } else { + return true; + } + } + + /** + * 通过回调方法验证某个字段是否必须 + * @access protected + * @param mixed $value 字段值 + * @param mixed $rule 验证规则 + * @param array $data 数据 + * @return bool + */ + protected function requireCallback($value, $rule, $data) + { + $result = call_user_func_array($rule, [$value, $data]); + if ($result) { + return !empty($value) || '0' == $value; + } else { + return true; + } + } + + /** + * 验证某个字段有值的情况下必须 + * @access protected + * @param mixed $value 字段值 + * @param mixed $rule 验证规则 + * @param array $data 数据 + * @return bool + */ + protected function requireWith($value, $rule, $data) + { + $val = $this->getDataValue($data, $rule); + if (!empty($val)) { + return !empty($value) || '0' == $value; + } else { + return true; + } + } + + /** + * 验证是否在范围内 + * @access protected + * @param mixed $value 字段值 + * @param mixed $rule 验证规则 + * @return bool + */ + protected function in($value, $rule) + { + return in_array($value, is_array($rule) ? $rule : explode(',', $rule)); + } + + /** + * 验证是否不在某个范围 + * @access protected + * @param mixed $value 字段值 + * @param mixed $rule 验证规则 + * @return bool + */ + protected function notIn($value, $rule) + { + return !in_array($value, is_array($rule) ? $rule : explode(',', $rule)); + } + + /** + * between验证数据 + * @access protected + * @param mixed $value 字段值 + * @param mixed $rule 验证规则 + * @return bool + */ + protected function between($value, $rule) + { + if (is_string($rule)) { + $rule = explode(',', $rule); + } + list($min, $max) = $rule; + return $value >= $min && $value <= $max; + } + + /** + * 使用notbetween验证数据 + * @access protected + * @param mixed $value 字段值 + * @param mixed $rule 验证规则 + * @return bool + */ + protected function notBetween($value, $rule) + { + if (is_string($rule)) { + $rule = explode(',', $rule); + } + list($min, $max) = $rule; + return $value < $min || $value > $max; + } + + /** + * 验证数据长度 + * @access protected + * @param mixed $value 字段值 + * @param mixed $rule 验证规则 + * @return bool + */ + protected function length($value, $rule) + { + if (is_array($value)) { + $length = count($value); + } elseif ($value instanceof File) { + $length = $value->getSize(); + } else { + $length = mb_strlen((string) $value); + } + + if (strpos($rule, ',')) { + // 长度区间 + list($min, $max) = explode(',', $rule); + return $length >= $min && $length <= $max; + } else { + // 指定长度 + return $length == $rule; + } + } + + /** + * 验证数据最大长度 + * @access protected + * @param mixed $value 字段值 + * @param mixed $rule 验证规则 + * @return bool + */ + protected function max($value, $rule) + { + if (is_array($value)) { + $length = count($value); + } elseif ($value instanceof File) { + $length = $value->getSize(); + } else { + $length = mb_strlen((string) $value); + } + return $length <= $rule; + } + + /** + * 验证数据最小长度 + * @access protected + * @param mixed $value 字段值 + * @param mixed $rule 验证规则 + * @return bool + */ + protected function min($value, $rule) + { + if (is_array($value)) { + $length = count($value); + } elseif ($value instanceof File) { + $length = $value->getSize(); + } else { + $length = mb_strlen((string) $value); + } + return $length >= $rule; + } + + /** + * 验证日期 + * @access protected + * @param mixed $value 字段值 + * @param mixed $rule 验证规则 + * @param array $data 数据 + * @return bool + */ + protected function after($value, $rule, $data) + { + return strtotime($value) >= strtotime($rule); + } + + /** + * 验证日期 + * @access protected + * @param mixed $value 字段值 + * @param mixed $rule 验证规则 + * @param array $data 数据 + * @return bool + */ + protected function before($value, $rule, $data) + { + return strtotime($value) <= strtotime($rule); + } + + /** + * 验证日期字段 + * @access protected + * @param mixed $value 字段值 + * @param mixed $rule 验证规则 + * @param array $data 数据 + * @return bool + */ + protected function afterWith($value, $rule, $data) + { + $rule = $this->getDataValue($data, $rule); + return !is_null($rule) && strtotime($value) >= strtotime($rule); + } + + /** + * 验证日期字段 + * @access protected + * @param mixed $value 字段值 + * @param mixed $rule 验证规则 + * @param array $data 数据 + * @return bool + */ + protected function beforeWith($value, $rule, $data) + { + $rule = $this->getDataValue($data, $rule); + return !is_null($rule) && strtotime($value) <= strtotime($rule); + } + + /** + * 验证有效期 + * @access protected + * @param mixed $value 字段值 + * @param mixed $rule 验证规则 + * @return bool + */ + protected function expire($value, $rule) + { + if (is_string($rule)) { + $rule = explode(',', $rule); + } + list($start, $end) = $rule; + if (!is_numeric($start)) { + $start = strtotime($start); + } + + if (!is_numeric($end)) { + $end = strtotime($end); + } + return $_SERVER['REQUEST_TIME'] >= $start && $_SERVER['REQUEST_TIME'] <= $end; + } + + /** + * 验证IP许可 + * @access protected + * @param string $value 字段值 + * @param mixed $rule 验证规则 + * @return mixed + */ + protected function allowIp($value, $rule) + { + return in_array($_SERVER['REMOTE_ADDR'], is_array($rule) ? $rule : explode(',', $rule)); + } + + /** + * 验证IP禁用 + * @access protected + * @param string $value 字段值 + * @param mixed $rule 验证规则 + * @return mixed + */ + protected function denyIp($value, $rule) + { + return !in_array($_SERVER['REMOTE_ADDR'], is_array($rule) ? $rule : explode(',', $rule)); + } + + /** + * 使用正则验证数据 + * @access protected + * @param mixed $value 字段值 + * @param mixed $rule 验证规则 正则规则或者预定义正则名 + * @return mixed + */ + protected function regex($value, $rule) + { + if (isset($this->regex[$rule])) { + $rule = $this->regex[$rule]; + } elseif (isset($this->defaultRegex[$rule])) { + $rule = $this->defaultRegex[$rule]; + } + + if (is_string($rule) && 0 !== strpos($rule, '/') && !preg_match('/\/[imsU]{0,4}$/', $rule)) { + // 不是正则表达式则两端补上/ + $rule = '/^' . $rule . '$/'; + } + return is_scalar($value) && 1 === preg_match($rule, (string) $value); + } + + /** + * 验证表单令牌 + * @access protected + * @param mixed $value 字段值 + * @param mixed $rule 验证规则 + * @param array $data 数据 + * @return bool + */ + protected function token($value, $rule, $data) + { + $rule = !empty($rule) ? $rule : '__token__'; + if (!isset($data[$rule]) || !Session::has($rule)) { + // 令牌数据无效 + return false; + } + + // 令牌验证 + if (isset($data[$rule]) && Session::get($rule) === $data[$rule]) { + // 防止重复提交 + Session::delete($rule); // 验证完成销毁session + return true; + } + // 开启TOKEN重置 + Session::delete($rule); + return false; + } + + // 获取错误信息 + public function getError() + { + return $this->error; + } + + /** + * 获取数据值 + * @access protected + * @param array $data 数据 + * @param string $key 数据标识 支持二维 + * @return mixed + */ + protected function getDataValue($data, $key) + { + if (is_numeric($key)) { + $value = $key; + } elseif (strpos($key, '.')) { + // 支持二维数组验证 + list($name1, $name2) = explode('.', $key); + $value = isset($data[$name1][$name2]) ? $data[$name1][$name2] : null; + } else { + $value = isset($data[$key]) ? $data[$key] : null; + } + return $value; + } + + /** + * 获取验证规则的错误提示信息 + * @access protected + * @param string $attribute 字段英文名 + * @param string $title 字段描述名 + * @param string $type 验证规则名称 + * @param mixed $rule 验证规则数据 + * @return string + */ + protected function getRuleMsg($attribute, $title, $type, $rule) + { + if (isset($this->message[$attribute . '.' . $type])) { + $msg = $this->message[$attribute . '.' . $type]; + } elseif (isset($this->message[$attribute][$type])) { + $msg = $this->message[$attribute][$type]; + } elseif (isset($this->message[$attribute])) { + $msg = $this->message[$attribute]; + } elseif (isset(self::$typeMsg[$type])) { + $msg = self::$typeMsg[$type]; + } elseif (0 === strpos($type, 'require')) { + $msg = self::$typeMsg['require']; + } else { + $msg = $title . Lang::get('not conform to the rules'); + } + + if (is_string($msg) && 0 === strpos($msg, '{%')) { + $msg = Lang::get(substr($msg, 2, -1)); + } elseif (Lang::has($msg)) { + $msg = Lang::get($msg); + } + + if (is_string($msg) && is_scalar($rule) && false !== strpos($msg, ':')) { + // 变量替换 + if (is_string($rule) && strpos($rule, ',')) { + $array = array_pad(explode(',', $rule), 3, ''); + } else { + $array = array_pad([], 3, ''); + } + $msg = str_replace( + [':attribute', ':rule', ':1', ':2', ':3'], + [$title, (string) $rule, $array[0], $array[1], $array[2]], + $msg); + } + return $msg; + } + + /** + * 获取数据验证的场景 + * @access protected + * @param string $scene 验证场景 + * @return array + */ + protected function getScene($scene = '') + { + if (empty($scene)) { + // 读取指定场景 + $scene = $this->currentScene; + } + + if (!empty($scene) && isset($this->scene[$scene])) { + // 如果设置了验证适用场景 + $scene = $this->scene[$scene]; + if (is_string($scene)) { + $scene = explode(',', $scene); + } + } else { + $scene = []; + } + return $scene; + } + + public static function __callStatic($method, $params) + { + $class = self::make(); + if (method_exists($class, $method)) { + return call_user_func_array([$class, $method], $params); + } else { + throw new \BadMethodCallException('method not exists:' . __CLASS__ . '->' . $method); + } + } +} diff --git a/thinkphp/library/think/View.php b/thinkphp/library/think/View.php new file mode 100644 index 0000000..ca2dadb --- /dev/null +++ b/thinkphp/library/think/View.php @@ -0,0 +1,239 @@ + +// +---------------------------------------------------------------------- + +namespace think; + +class View +{ + // 视图实例 + protected static $instance; + // 模板引擎实例 + public $engine; + // 模板变量 + protected $data = []; + // 用于静态赋值的模板变量 + protected static $var = []; + // 视图输出替换 + protected $replace = []; + + /** + * 构造函数 + * @access public + * @param array $engine 模板引擎参数 + * @param array $replace 字符串替换参数 + */ + public function __construct($engine = [], $replace = []) + { + // 初始化模板引擎 + $this->engine($engine); + // 基础替换字符串 + $request = Request::instance(); + $base = $request->root(); + $root = strpos($base, '.') ? ltrim(dirname($base), DS) : $base; + if ('' != $root) { + $root = '/' . ltrim($root, '/'); + } + $baseReplace = [ + '__ROOT__' => $root, + '__URL__' => $base . '/' . $request->module() . '/' . Loader::parseName($request->controller()), + '__STATIC__' => $root . '/static', + '__CSS__' => $root . '/static/css', + '__JS__' => $root . '/static/js', + ]; + $this->replace = array_merge($baseReplace, (array) $replace); + } + + /** + * 初始化视图 + * @access public + * @param array $engine 模板引擎参数 + * @param array $replace 字符串替换参数 + * @return object + */ + public static function instance($engine = [], $replace = []) + { + if (is_null(self::$instance)) { + self::$instance = new self($engine, $replace); + } + return self::$instance; + } + + /** + * 模板变量静态赋值 + * @access public + * @param mixed $name 变量名 + * @param mixed $value 变量值 + * @return void + */ + public static function share($name, $value = '') + { + if (is_array($name)) { + self::$var = array_merge(self::$var, $name); + } else { + self::$var[$name] = $value; + } + } + + /** + * 模板变量赋值 + * @access public + * @param mixed $name 变量名 + * @param mixed $value 变量值 + * @return $this + */ + public function assign($name, $value = '') + { + if (is_array($name)) { + $this->data = array_merge($this->data, $name); + } else { + $this->data[$name] = $value; + } + return $this; + } + + /** + * 设置当前模板解析的引擎 + * @access public + * @param array|string $options 引擎参数 + * @return $this + */ + public function engine($options = []) + { + if (is_string($options)) { + $type = $options; + $options = []; + } else { + $type = !empty($options['type']) ? $options['type'] : 'Think'; + } + + $class = false !== strpos($type, '\\') ? $type : '\\think\\view\\driver\\' . ucfirst($type); + if (isset($options['type'])) { + unset($options['type']); + } + $this->engine = new $class($options); + return $this; + } + + /** + * 配置模板引擎 + * @access private + * @param string|array $name 参数名 + * @param mixed $value 参数值 + * @return $this + */ + public function config($name, $value = null) + { + $this->engine->config($name, $value); + return $this; + } + + /** + * 解析和获取模板内容 用于输出 + * @param string $template 模板文件名或者内容 + * @param array $vars 模板输出变量 + * @param array $replace 替换内容 + * @param array $config 模板参数 + * @param bool $renderContent 是否渲染内容 + * @return string + * @throws Exception + */ + public function fetch($template = '', $vars = [], $replace = [], $config = [], $renderContent = false) + { + // 模板变量 + $vars = array_merge(self::$var, $this->data, $vars); + + // 页面缓存 + ob_start(); + ob_implicit_flush(0); + + // 渲染输出 + try { + $method = $renderContent ? 'display' : 'fetch'; + // 允许用户自定义模板的字符串替换 + $replace = array_merge($this->replace, $replace, (array) $this->engine->config('tpl_replace_string')); + $this->engine->config('tpl_replace_string', $replace); + $this->engine->$method($template, $vars, $config); + } catch (\Exception $e) { + ob_end_clean(); + throw $e; + } + + // 获取并清空缓存 + $content = ob_get_clean(); + // 内容过滤标签 + Hook::listen('view_filter', $content); + return $content; + } + + /** + * 视图内容替换 + * @access public + * @param string|array $content 被替换内容(支持批量替换) + * @param string $replace 替换内容 + * @return $this + */ + public function replace($content, $replace = '') + { + if (is_array($content)) { + $this->replace = array_merge($this->replace, $content); + } else { + $this->replace[$content] = $replace; + } + return $this; + } + + /** + * 渲染内容输出 + * @access public + * @param string $content 内容 + * @param array $vars 模板输出变量 + * @param array $replace 替换内容 + * @param array $config 模板参数 + * @return mixed + */ + public function display($content, $vars = [], $replace = [], $config = []) + { + return $this->fetch($content, $vars, $replace, $config, true); + } + + /** + * 模板变量赋值 + * @access public + * @param string $name 变量名 + * @param mixed $value 变量值 + */ + public function __set($name, $value) + { + $this->data[$name] = $value; + } + + /** + * 取得模板显示变量的值 + * @access protected + * @param string $name 模板变量 + * @return mixed + */ + public function __get($name) + { + return $this->data[$name]; + } + + /** + * 检测模板变量是否设置 + * @access public + * @param string $name 模板变量名 + * @return bool + */ + public function __isset($name) + { + return isset($this->data[$name]); + } +} diff --git a/thinkphp/library/think/cache/Driver.php b/thinkphp/library/think/cache/Driver.php new file mode 100644 index 0000000..07805e4 --- /dev/null +++ b/thinkphp/library/think/cache/Driver.php @@ -0,0 +1,231 @@ + +// +---------------------------------------------------------------------- + +namespace think\cache; + +/** + * 缓存基础类 + */ +abstract class Driver +{ + protected $handler = null; + protected $options = []; + protected $tag; + + /** + * 判断缓存是否存在 + * @access public + * @param string $name 缓存变量名 + * @return bool + */ + abstract public function has($name); + + /** + * 读取缓存 + * @access public + * @param string $name 缓存变量名 + * @param mixed $default 默认值 + * @return mixed + */ + abstract public function get($name, $default = false); + + /** + * 写入缓存 + * @access public + * @param string $name 缓存变量名 + * @param mixed $value 存储数据 + * @param int $expire 有效时间 0为永久 + * @return boolean + */ + abstract public function set($name, $value, $expire = null); + + /** + * 自增缓存(针对数值缓存) + * @access public + * @param string $name 缓存变量名 + * @param int $step 步长 + * @return false|int + */ + abstract public function inc($name, $step = 1); + + /** + * 自减缓存(针对数值缓存) + * @access public + * @param string $name 缓存变量名 + * @param int $step 步长 + * @return false|int + */ + abstract public function dec($name, $step = 1); + + /** + * 删除缓存 + * @access public + * @param string $name 缓存变量名 + * @return boolean + */ + abstract public function rm($name); + + /** + * 清除缓存 + * @access public + * @param string $tag 标签名 + * @return boolean + */ + abstract public function clear($tag = null); + + /** + * 获取实际的缓存标识 + * @access public + * @param string $name 缓存名 + * @return string + */ + protected function getCacheKey($name) + { + return $this->options['prefix'] . $name; + } + + /** + * 读取缓存并删除 + * @access public + * @param string $name 缓存变量名 + * @return mixed + */ + public function pull($name) + { + $result = $this->get($name, false); + if ($result) { + $this->rm($name); + return $result; + } else { + return; + } + } + + /** + * 如果不存在则写入缓存 + * @access public + * @param string $name 缓存变量名 + * @param mixed $value 存储数据 + * @param int $expire 有效时间 0为永久 + * @return mixed + */ + public function remember($name, $value, $expire = null) + { + if (!$this->has($name)) { + $time = time(); + while ($time + 5 > time() && $this->has($name . '_lock')) { + // 存在锁定则等待 + usleep(200000); + } + + try { + // 锁定 + $this->set($name . '_lock', true); + if ($value instanceof \Closure) { + $value = call_user_func($value); + } + $this->set($name, $value, $expire); + // 解锁 + $this->rm($name . '_lock'); + } catch (\Exception $e) { + // 解锁 + $this->rm($name . '_lock'); + throw $e; + } catch (\throwable $e) { + $this->rm($name . '_lock'); + throw $e; + } + } else { + $value = $this->get($name); + } + return $value; + } + + /** + * 缓存标签 + * @access public + * @param string $name 标签名 + * @param string|array $keys 缓存标识 + * @param bool $overlay 是否覆盖 + * @return $this + */ + public function tag($name, $keys = null, $overlay = false) + { + if (is_null($name)) { + + } elseif (is_null($keys)) { + $this->tag = $name; + } else { + $key = 'tag_' . md5($name); + if (is_string($keys)) { + $keys = explode(',', $keys); + } + $keys = array_map([$this, 'getCacheKey'], $keys); + if ($overlay) { + $value = $keys; + } else { + $value = array_unique(array_merge($this->getTagItem($name), $keys)); + } + $this->set($key, implode(',', $value), 0); + } + return $this; + } + + /** + * 更新标签 + * @access public + * @param string $name 缓存标识 + * @return void + */ + protected function setTagItem($name) + { + if ($this->tag) { + $key = 'tag_' . md5($this->tag); + $this->tag = null; + if ($this->has($key)) { + $value = explode(',', $this->get($key)); + $value[] = $name; + $value = implode(',', array_unique($value)); + } else { + $value = $name; + } + $this->set($key, $value, 0); + } + } + + /** + * 获取标签包含的缓存标识 + * @access public + * @param string $tag 缓存标签 + * @return array + */ + protected function getTagItem($tag) + { + $key = 'tag_' . md5($tag); + $value = $this->get($key); + if ($value) { + return array_filter(explode(',', $value)); + } else { + return []; + } + } + + /** + * 返回句柄对象,可执行其它高级方法 + * + * @access public + * @return object + */ + public function handler() + { + return $this->handler; + } +} diff --git a/thinkphp/library/think/cache/driver/File.php b/thinkphp/library/think/cache/driver/File.php new file mode 100644 index 0000000..fee6489 --- /dev/null +++ b/thinkphp/library/think/cache/driver/File.php @@ -0,0 +1,268 @@ + +// +---------------------------------------------------------------------- + +namespace think\cache\driver; + +use think\cache\Driver; + +/** + * 文件类型缓存类 + * @author liu21st + */ +class File extends Driver +{ + protected $options = [ + 'expire' => 0, + 'cache_subdir' => true, + 'prefix' => '', + 'path' => CACHE_PATH, + 'data_compress' => false, + ]; + + protected $expire; + + /** + * 构造函数 + * @param array $options + */ + public function __construct($options = []) + { + if (!empty($options)) { + $this->options = array_merge($this->options, $options); + } + if (substr($this->options['path'], -1) != DS) { + $this->options['path'] .= DS; + } + $this->init(); + } + + /** + * 初始化检查 + * @access private + * @return boolean + */ + private function init() + { + // 创建项目缓存目录 + if (!is_dir($this->options['path'])) { + if (mkdir($this->options['path'], 0755, true)) { + return true; + } + } + return false; + } + + /** + * 取得变量的存储文件名 + * @access protected + * @param string $name 缓存变量名 + * @param bool $auto 是否自动创建目录 + * @return string + */ + protected function getCacheKey($name, $auto = false) + { + $name = md5($name); + if ($this->options['cache_subdir']) { + // 使用子目录 + $name = substr($name, 0, 2) . DS . substr($name, 2); + } + if ($this->options['prefix']) { + $name = $this->options['prefix'] . DS . $name; + } + $filename = $this->options['path'] . $name . '.php'; + $dir = dirname($filename); + + if ($auto && !is_dir($dir)) { + mkdir($dir, 0755, true); + } + return $filename; + } + + /** + * 判断缓存是否存在 + * @access public + * @param string $name 缓存变量名 + * @return bool + */ + public function has($name) + { + return $this->get($name) ? true : false; + } + + /** + * 读取缓存 + * @access public + * @param string $name 缓存变量名 + * @param mixed $default 默认值 + * @return mixed + */ + public function get($name, $default = false) + { + $filename = $this->getCacheKey($name); + if (!is_file($filename)) { + return $default; + } + $content = file_get_contents($filename); + $this->expire = null; + if (false !== $content) { + $expire = (int) substr($content, 8, 12); + if (0 != $expire && time() > filemtime($filename) + $expire) { + return $default; + } + $this->expire = $expire; + $content = substr($content, 32); + if ($this->options['data_compress'] && function_exists('gzcompress')) { + //启用数据压缩 + $content = gzuncompress($content); + } + $content = unserialize($content); + return $content; + } else { + return $default; + } + } + + /** + * 写入缓存 + * @access public + * @param string $name 缓存变量名 + * @param mixed $value 存储数据 + * @param integer|\DateTime $expire 有效时间(秒) + * @return boolean + */ + public function set($name, $value, $expire = null) + { + if (is_null($expire)) { + $expire = $this->options['expire']; + } + if ($expire instanceof \DateTime) { + $expire = $expire->getTimestamp() - time(); + } + $filename = $this->getCacheKey($name, true); + if ($this->tag && !is_file($filename)) { + $first = true; + } + $data = serialize($value); + if ($this->options['data_compress'] && function_exists('gzcompress')) { + //数据压缩 + $data = gzcompress($data, 3); + } + $data = "\n" . $data; + $result = file_put_contents($filename, $data); + if ($result) { + isset($first) && $this->setTagItem($filename); + clearstatcache(); + return true; + } else { + return false; + } + } + + /** + * 自增缓存(针对数值缓存) + * @access public + * @param string $name 缓存变量名 + * @param int $step 步长 + * @return false|int + */ + public function inc($name, $step = 1) + { + if ($this->has($name)) { + $value = $this->get($name) + $step; + $expire = $this->expire; + } else { + $value = $step; + $expire = 0; + } + + return $this->set($name, $value, $expire) ? $value : false; + } + + /** + * 自减缓存(针对数值缓存) + * @access public + * @param string $name 缓存变量名 + * @param int $step 步长 + * @return false|int + */ + public function dec($name, $step = 1) + { + if ($this->has($name)) { + $value = $this->get($name) - $step; + $expire = $this->expire; + } else { + $value = -$step; + $expire = 0; + } + + return $this->set($name, $value, $expire) ? $value : false; + } + + /** + * 删除缓存 + * @access public + * @param string $name 缓存变量名 + * @return boolean + */ + public function rm($name) + { + $filename = $this->getCacheKey($name); + try { + return $this->unlink($filename); + } catch (\Exception $e) { + } + } + + /** + * 清除缓存 + * @access public + * @param string $tag 标签名 + * @return boolean + */ + public function clear($tag = null) + { + if ($tag) { + // 指定标签清除 + $keys = $this->getTagItem($tag); + foreach ($keys as $key) { + $this->unlink($key); + } + $this->rm('tag_' . md5($tag)); + return true; + } + $files = (array) glob($this->options['path'] . ($this->options['prefix'] ? $this->options['prefix'] . DS : '') . '*'); + foreach ($files as $path) { + if (is_dir($path)) { + $matches = glob($path . '/*.php'); + if (is_array($matches)) { + array_map('unlink', $matches); + } + rmdir($path); + } else { + unlink($path); + } + } + return true; + } + + /** + * 判断文件是否存在后,删除 + * @param $path + * @return bool + * @author byron sampson + * @return boolean + */ + private function unlink($path) + { + return is_file($path) && unlink($path); + } + +} diff --git a/thinkphp/library/think/cache/driver/Lite.php b/thinkphp/library/think/cache/driver/Lite.php new file mode 100644 index 0000000..8cbf08f --- /dev/null +++ b/thinkphp/library/think/cache/driver/Lite.php @@ -0,0 +1,187 @@ + +// +---------------------------------------------------------------------- + +namespace think\cache\driver; + +use think\cache\Driver; + +/** + * 文件类型缓存类 + * @author liu21st + */ +class Lite extends Driver +{ + protected $options = [ + 'prefix' => '', + 'path' => '', + 'expire' => 0, // 等于 10*365*24*3600(10年) + ]; + + /** + * 构造函数 + * @access public + * + * @param array $options + */ + public function __construct($options = []) + { + if (!empty($options)) { + $this->options = array_merge($this->options, $options); + } + if (substr($this->options['path'], -1) != DS) { + $this->options['path'] .= DS; + } + + } + + /** + * 取得变量的存储文件名 + * @access protected + * @param string $name 缓存变量名 + * @return string + */ + protected function getCacheKey($name) + { + return $this->options['path'] . $this->options['prefix'] . md5($name) . '.php'; + } + + /** + * 判断缓存是否存在 + * @access public + * @param string $name 缓存变量名 + * @return mixed + */ + public function has($name) + { + return $this->get($name) ? true : false; + } + + /** + * 读取缓存 + * @access public + * @param string $name 缓存变量名 + * @param mixed $default 默认值 + * @return mixed + */ + public function get($name, $default = false) + { + $filename = $this->getCacheKey($name); + if (is_file($filename)) { + // 判断是否过期 + $mtime = filemtime($filename); + if ($mtime < time()) { + // 清除已经过期的文件 + unlink($filename); + return $default; + } + return include $filename; + } else { + return $default; + } + } + + /** + * 写入缓存 + * @access public + * @param string $name 缓存变量名 + * @param mixed $value 存储数据 + * @param integer|\DateTime $expire 有效时间(秒) + * @return bool + */ + public function set($name, $value, $expire = null) + { + if (is_null($expire)) { + $expire = $this->options['expire']; + } + if ($expire instanceof \DateTime) { + $expire = $expire->getTimestamp(); + } else { + $expire = 0 === $expire ? 10 * 365 * 24 * 3600 : $expire; + $expire = time() + $expire; + } + $filename = $this->getCacheKey($name); + if ($this->tag && !is_file($filename)) { + $first = true; + } + $ret = file_put_contents($filename, ("setTagItem($filename); + touch($filename, $expire); + } + return $ret; + } + + /** + * 自增缓存(针对数值缓存) + * @access public + * @param string $name 缓存变量名 + * @param int $step 步长 + * @return false|int + */ + public function inc($name, $step = 1) + { + if ($this->has($name)) { + $value = $this->get($name) + $step; + } else { + $value = $step; + } + return $this->set($name, $value, 0) ? $value : false; + } + + /** + * 自减缓存(针对数值缓存) + * @access public + * @param string $name 缓存变量名 + * @param int $step 步长 + * @return false|int + */ + public function dec($name, $step = 1) + { + if ($this->has($name)) { + $value = $this->get($name) - $step; + } else { + $value = -$step; + } + return $this->set($name, $value, 0) ? $value : false; + } + + /** + * 删除缓存 + * @access public + * @param string $name 缓存变量名 + * @return boolean + */ + public function rm($name) + { + return unlink($this->getCacheKey($name)); + } + + /** + * 清除缓存 + * @access public + * @param string $tag 标签名 + * @return bool + */ + public function clear($tag = null) + { + if ($tag) { + // 指定标签清除 + $keys = $this->getTagItem($tag); + foreach ($keys as $key) { + unlink($key); + } + $this->rm('tag_' . md5($tag)); + return true; + } + array_map("unlink", glob($this->options['path'] . ($this->options['prefix'] ? $this->options['prefix'] . DS : '') . '*.php')); + } +} diff --git a/thinkphp/library/think/cache/driver/Memcache.php b/thinkphp/library/think/cache/driver/Memcache.php new file mode 100644 index 0000000..58703ea --- /dev/null +++ b/thinkphp/library/think/cache/driver/Memcache.php @@ -0,0 +1,177 @@ + +// +---------------------------------------------------------------------- + +namespace think\cache\driver; + +use think\cache\Driver; + +class Memcache extends Driver +{ + protected $options = [ + 'host' => '127.0.0.1', + 'port' => 11211, + 'expire' => 0, + 'timeout' => 0, // 超时时间(单位:毫秒) + 'persistent' => true, + 'prefix' => '', + ]; + + /** + * 构造函数 + * @param array $options 缓存参数 + * @access public + * @throws \BadFunctionCallException + */ + public function __construct($options = []) + { + if (!extension_loaded('memcache')) { + throw new \BadFunctionCallException('not support: memcache'); + } + if (!empty($options)) { + $this->options = array_merge($this->options, $options); + } + $this->handler = new \Memcache; + // 支持集群 + $hosts = explode(',', $this->options['host']); + $ports = explode(',', $this->options['port']); + if (empty($ports[0])) { + $ports[0] = 11211; + } + // 建立连接 + foreach ((array) $hosts as $i => $host) { + $port = isset($ports[$i]) ? $ports[$i] : $ports[0]; + $this->options['timeout'] > 0 ? + $this->handler->addServer($host, $port, $this->options['persistent'], 1, $this->options['timeout']) : + $this->handler->addServer($host, $port, $this->options['persistent'], 1); + } + } + + /** + * 判断缓存 + * @access public + * @param string $name 缓存变量名 + * @return bool + */ + public function has($name) + { + $key = $this->getCacheKey($name); + return false !== $this->handler->get($key); + } + + /** + * 读取缓存 + * @access public + * @param string $name 缓存变量名 + * @param mixed $default 默认值 + * @return mixed + */ + public function get($name, $default = false) + { + $result = $this->handler->get($this->getCacheKey($name)); + return false !== $result ? $result : $default; + } + + /** + * 写入缓存 + * @access public + * @param string $name 缓存变量名 + * @param mixed $value 存储数据 + * @param integer|\DateTime $expire 有效时间(秒) + * @return bool + */ + public function set($name, $value, $expire = null) + { + if (is_null($expire)) { + $expire = $this->options['expire']; + } + if ($expire instanceof \DateTime) { + $expire = $expire->getTimestamp() - time(); + } + if ($this->tag && !$this->has($name)) { + $first = true; + } + $key = $this->getCacheKey($name); + if ($this->handler->set($key, $value, 0, $expire)) { + isset($first) && $this->setTagItem($key); + return true; + } + return false; + } + + /** + * 自增缓存(针对数值缓存) + * @access public + * @param string $name 缓存变量名 + * @param int $step 步长 + * @return false|int + */ + public function inc($name, $step = 1) + { + $key = $this->getCacheKey($name); + if ($this->handler->get($key)) { + return $this->handler->increment($key, $step); + } + return $this->handler->set($key, $step); + } + + /** + * 自减缓存(针对数值缓存) + * @access public + * @param string $name 缓存变量名 + * @param int $step 步长 + * @return false|int + */ + public function dec($name, $step = 1) + { + $key = $this->getCacheKey($name); + $value = $this->handler->get($key) - $step; + $res = $this->handler->set($key, $value); + if (!$res) { + return false; + } else { + return $value; + } + } + + /** + * 删除缓存 + * @param string $name 缓存变量名 + * @param bool|false $ttl + * @return bool + */ + public function rm($name, $ttl = false) + { + $key = $this->getCacheKey($name); + return false === $ttl ? + $this->handler->delete($key) : + $this->handler->delete($key, $ttl); + } + + /** + * 清除缓存 + * @access public + * @param string $tag 标签名 + * @return bool + */ + public function clear($tag = null) + { + if ($tag) { + // 指定标签清除 + $keys = $this->getTagItem($tag); + foreach ($keys as $key) { + $this->handler->delete($key); + } + $this->rm('tag_' . md5($tag)); + return true; + } + return $this->handler->flush(); + } +} diff --git a/thinkphp/library/think/cache/driver/Memcached.php b/thinkphp/library/think/cache/driver/Memcached.php new file mode 100644 index 0000000..5aab5a3 --- /dev/null +++ b/thinkphp/library/think/cache/driver/Memcached.php @@ -0,0 +1,187 @@ + +// +---------------------------------------------------------------------- + +namespace think\cache\driver; + +use think\cache\Driver; + +class Memcached extends Driver +{ + protected $options = [ + 'host' => '127.0.0.1', + 'port' => 11211, + 'expire' => 0, + 'timeout' => 0, // 超时时间(单位:毫秒) + 'prefix' => '', + 'username' => '', //账号 + 'password' => '', //密码 + 'option' => [], + ]; + + /** + * 构造函数 + * @param array $options 缓存参数 + * @access public + */ + public function __construct($options = []) + { + if (!extension_loaded('memcached')) { + throw new \BadFunctionCallException('not support: memcached'); + } + if (!empty($options)) { + $this->options = array_merge($this->options, $options); + } + $this->handler = new \Memcached; + if (!empty($this->options['option'])) { + $this->handler->setOptions($this->options['option']); + } + // 设置连接超时时间(单位:毫秒) + if ($this->options['timeout'] > 0) { + $this->handler->setOption(\Memcached::OPT_CONNECT_TIMEOUT, $this->options['timeout']); + } + // 支持集群 + $hosts = explode(',', $this->options['host']); + $ports = explode(',', $this->options['port']); + if (empty($ports[0])) { + $ports[0] = 11211; + } + // 建立连接 + $servers = []; + foreach ((array) $hosts as $i => $host) { + $servers[] = [$host, (isset($ports[$i]) ? $ports[$i] : $ports[0]), 1]; + } + $this->handler->addServers($servers); + if ('' != $this->options['username']) { + $this->handler->setOption(\Memcached::OPT_BINARY_PROTOCOL, true); + $this->handler->setSaslAuthData($this->options['username'], $this->options['password']); + } + } + + /** + * 判断缓存 + * @access public + * @param string $name 缓存变量名 + * @return bool + */ + public function has($name) + { + $key = $this->getCacheKey($name); + return $this->handler->get($key) ? true : false; + } + + /** + * 读取缓存 + * @access public + * @param string $name 缓存变量名 + * @param mixed $default 默认值 + * @return mixed + */ + public function get($name, $default = false) + { + $result = $this->handler->get($this->getCacheKey($name)); + return false !== $result ? $result : $default; + } + + /** + * 写入缓存 + * @access public + * @param string $name 缓存变量名 + * @param mixed $value 存储数据 + * @param integer|\DateTime $expire 有效时间(秒) + * @return bool + */ + public function set($name, $value, $expire = null) + { + if (is_null($expire)) { + $expire = $this->options['expire']; + } + if ($expire instanceof \DateTime) { + $expire = $expire->getTimestamp() - time(); + } + if ($this->tag && !$this->has($name)) { + $first = true; + } + $key = $this->getCacheKey($name); + $expire = 0 == $expire ? 0 : $_SERVER['REQUEST_TIME'] + $expire; + if ($this->handler->set($key, $value, $expire)) { + isset($first) && $this->setTagItem($key); + return true; + } + return false; + } + + /** + * 自增缓存(针对数值缓存) + * @access public + * @param string $name 缓存变量名 + * @param int $step 步长 + * @return false|int + */ + public function inc($name, $step = 1) + { + $key = $this->getCacheKey($name); + if ($this->handler->get($key)) { + return $this->handler->increment($key, $step); + } + return $this->handler->set($key, $step); + } + + /** + * 自减缓存(针对数值缓存) + * @access public + * @param string $name 缓存变量名 + * @param int $step 步长 + * @return false|int + */ + public function dec($name, $step = 1) + { + $key = $this->getCacheKey($name); + $value = $this->handler->get($key) - $step; + $res = $this->handler->set($key, $value); + if (!$res) { + return false; + } else { + return $value; + } + } + + /** + * 删除缓存 + * @param string $name 缓存变量名 + * @param bool|false $ttl + * @return bool + */ + public function rm($name, $ttl = false) + { + $key = $this->getCacheKey($name); + return false === $ttl ? + $this->handler->delete($key) : + $this->handler->delete($key, $ttl); + } + + /** + * 清除缓存 + * @access public + * @param string $tag 标签名 + * @return bool + */ + public function clear($tag = null) + { + if ($tag) { + // 指定标签清除 + $keys = $this->getTagItem($tag); + $this->handler->deleteMulti($keys); + $this->rm('tag_' . md5($tag)); + return true; + } + return $this->handler->flush(); + } +} diff --git a/thinkphp/library/think/cache/driver/Redis.php b/thinkphp/library/think/cache/driver/Redis.php new file mode 100644 index 0000000..d7bf6d1 --- /dev/null +++ b/thinkphp/library/think/cache/driver/Redis.php @@ -0,0 +1,188 @@ + +// +---------------------------------------------------------------------- + +namespace think\cache\driver; + +use think\cache\Driver; + +/** + * Redis缓存驱动,适合单机部署、有前端代理实现高可用的场景,性能最好 + * 有需要在业务层实现读写分离、或者使用RedisCluster的需求,请使用Redisd驱动 + * + * 要求安装phpredis扩展:https://github.com/nicolasff/phpredis + * @author 尘缘 <130775@qq.com> + */ +class Redis extends Driver +{ + protected $options = [ + 'host' => '127.0.0.1', + 'port' => 6379, + 'password' => '', + 'select' => 0, + 'timeout' => 0, + 'expire' => 0, + 'persistent' => false, + 'prefix' => '', + ]; + + /** + * 构造函数 + * @param array $options 缓存参数 + * @access public + */ + public function __construct($options = []) + { + if (!extension_loaded('redis')) { + throw new \BadFunctionCallException('not support: redis'); + } + if (!empty($options)) { + $this->options = array_merge($this->options, $options); + } + $this->handler = new \Redis; + if ($this->options['persistent']) { + $this->handler->pconnect($this->options['host'], $this->options['port'], $this->options['timeout'], 'persistent_id_' . $this->options['select']); + } else { + $this->handler->connect($this->options['host'], $this->options['port'], $this->options['timeout']); + } + + if ('' != $this->options['password']) { + $this->handler->auth($this->options['password']); + } + + if (0 != $this->options['select']) { + $this->handler->select($this->options['select']); + } + } + + /** + * 判断缓存 + * @access public + * @param string $name 缓存变量名 + * @return bool + */ + public function has($name) + { + return (bool) $this->handler->exists($this->getCacheKey($name)); + } + + /** + * 读取缓存 + * @access public + * @param string $name 缓存变量名 + * @param mixed $default 默认值 + * @return mixed + */ + public function get($name, $default = false) + { + $value = $this->handler->get($this->getCacheKey($name)); + if (is_null($value) || false === $value) { + return $default; + } + + try { + $result = 0 === strpos($value, 'think_serialize:') ? unserialize(substr($value, 16)) : $value; + } catch (\Exception $e) { + $result = $default; + } + + return $result; + } + + /** + * 写入缓存 + * @access public + * @param string $name 缓存变量名 + * @param mixed $value 存储数据 + * @param integer|\DateTime $expire 有效时间(秒) + * @return boolean + */ + public function set($name, $value, $expire = null) + { + if (is_null($expire)) { + $expire = $this->options['expire']; + } + if ($expire instanceof \DateTime) { + $expire = $expire->getTimestamp() - time(); + } + if ($this->tag && !$this->has($name)) { + $first = true; + } + $key = $this->getCacheKey($name); + $value = is_scalar($value) ? $value : 'think_serialize:' . serialize($value); + if ($expire) { + $result = $this->handler->setex($key, $expire, $value); + } else { + $result = $this->handler->set($key, $value); + } + isset($first) && $this->setTagItem($key); + return $result; + } + + /** + * 自增缓存(针对数值缓存) + * @access public + * @param string $name 缓存变量名 + * @param int $step 步长 + * @return false|int + */ + public function inc($name, $step = 1) + { + $key = $this->getCacheKey($name); + + return $this->handler->incrby($key, $step); + } + + /** + * 自减缓存(针对数值缓存) + * @access public + * @param string $name 缓存变量名 + * @param int $step 步长 + * @return false|int + */ + public function dec($name, $step = 1) + { + $key = $this->getCacheKey($name); + + return $this->handler->decrby($key, $step); + } + + /** + * 删除缓存 + * @access public + * @param string $name 缓存变量名 + * @return boolean + */ + public function rm($name) + { + return $this->handler->del($this->getCacheKey($name)); + } + + /** + * 清除缓存 + * @access public + * @param string $tag 标签名 + * @return boolean + */ + public function clear($tag = null) + { + if ($tag) { + // 指定标签清除 + $keys = $this->getTagItem($tag); + foreach ($keys as $key) { + $this->handler->del($key); + } + $this->rm('tag_' . md5($tag)); + return true; + } + return $this->handler->flushDB(); + } + +} diff --git a/thinkphp/library/think/cache/driver/Sqlite.php b/thinkphp/library/think/cache/driver/Sqlite.php new file mode 100644 index 0000000..dc2ee05 --- /dev/null +++ b/thinkphp/library/think/cache/driver/Sqlite.php @@ -0,0 +1,199 @@ + +// +---------------------------------------------------------------------- + +namespace think\cache\driver; + +use think\cache\Driver; + +/** + * Sqlite缓存驱动 + * @author liu21st + */ +class Sqlite extends Driver +{ + protected $options = [ + 'db' => ':memory:', + 'table' => 'sharedmemory', + 'prefix' => '', + 'expire' => 0, + 'persistent' => false, + ]; + + /** + * 构造函数 + * @param array $options 缓存参数 + * @throws \BadFunctionCallException + * @access public + */ + public function __construct($options = []) + { + if (!extension_loaded('sqlite')) { + throw new \BadFunctionCallException('not support: sqlite'); + } + if (!empty($options)) { + $this->options = array_merge($this->options, $options); + } + $func = $this->options['persistent'] ? 'sqlite_popen' : 'sqlite_open'; + $this->handler = $func($this->options['db']); + } + + /** + * 获取实际的缓存标识 + * @access public + * @param string $name 缓存名 + * @return string + */ + protected function getCacheKey($name) + { + return $this->options['prefix'] . sqlite_escape_string($name); + } + + /** + * 判断缓存 + * @access public + * @param string $name 缓存变量名 + * @return bool + */ + public function has($name) + { + $name = $this->getCacheKey($name); + $sql = 'SELECT value FROM ' . $this->options['table'] . ' WHERE var=\'' . $name . '\' AND (expire=0 OR expire >' . $_SERVER['REQUEST_TIME'] . ') LIMIT 1'; + $result = sqlite_query($this->handler, $sql); + return sqlite_num_rows($result); + } + + /** + * 读取缓存 + * @access public + * @param string $name 缓存变量名 + * @param mixed $default 默认值 + * @return mixed + */ + public function get($name, $default = false) + { + $name = $this->getCacheKey($name); + $sql = 'SELECT value FROM ' . $this->options['table'] . ' WHERE var=\'' . $name . '\' AND (expire=0 OR expire >' . $_SERVER['REQUEST_TIME'] . ') LIMIT 1'; + $result = sqlite_query($this->handler, $sql); + if (sqlite_num_rows($result)) { + $content = sqlite_fetch_single($result); + if (function_exists('gzcompress')) { + //启用数据压缩 + $content = gzuncompress($content); + } + return unserialize($content); + } + return $default; + } + + /** + * 写入缓存 + * @access public + * @param string $name 缓存变量名 + * @param mixed $value 存储数据 + * @param integer|\DateTime $expire 有效时间(秒) + * @return boolean + */ + public function set($name, $value, $expire = null) + { + $name = $this->getCacheKey($name); + $value = sqlite_escape_string(serialize($value)); + if (is_null($expire)) { + $expire = $this->options['expire']; + } + if ($expire instanceof \DateTime) { + $expire = $expire->getTimestamp(); + } else { + $expire = (0 == $expire) ? 0 : (time() + $expire); //缓存有效期为0表示永久缓存 + } + if (function_exists('gzcompress')) { + //数据压缩 + $value = gzcompress($value, 3); + } + if ($this->tag) { + $tag = $this->tag; + $this->tag = null; + } else { + $tag = ''; + } + $sql = 'REPLACE INTO ' . $this->options['table'] . ' (var, value, expire, tag) VALUES (\'' . $name . '\', \'' . $value . '\', \'' . $expire . '\', \'' . $tag . '\')'; + if (sqlite_query($this->handler, $sql)) { + return true; + } + return false; + } + + /** + * 自增缓存(针对数值缓存) + * @access public + * @param string $name 缓存变量名 + * @param int $step 步长 + * @return false|int + */ + public function inc($name, $step = 1) + { + if ($this->has($name)) { + $value = $this->get($name) + $step; + } else { + $value = $step; + } + return $this->set($name, $value, 0) ? $value : false; + } + + /** + * 自减缓存(针对数值缓存) + * @access public + * @param string $name 缓存变量名 + * @param int $step 步长 + * @return false|int + */ + public function dec($name, $step = 1) + { + if ($this->has($name)) { + $value = $this->get($name) - $step; + } else { + $value = -$step; + } + return $this->set($name, $value, 0) ? $value : false; + } + + /** + * 删除缓存 + * @access public + * @param string $name 缓存变量名 + * @return boolean + */ + public function rm($name) + { + $name = $this->getCacheKey($name); + $sql = 'DELETE FROM ' . $this->options['table'] . ' WHERE var=\'' . $name . '\''; + sqlite_query($this->handler, $sql); + return true; + } + + /** + * 清除缓存 + * @access public + * @param string $tag 标签名 + * @return boolean + */ + public function clear($tag = null) + { + if ($tag) { + $name = sqlite_escape_string($tag); + $sql = 'DELETE FROM ' . $this->options['table'] . ' WHERE tag=\'' . $name . '\''; + sqlite_query($this->handler, $sql); + return true; + } + $sql = 'DELETE FROM ' . $this->options['table']; + sqlite_query($this->handler, $sql); + return true; + } +} diff --git a/thinkphp/library/think/cache/driver/Wincache.php b/thinkphp/library/think/cache/driver/Wincache.php new file mode 100644 index 0000000..03f8d35 --- /dev/null +++ b/thinkphp/library/think/cache/driver/Wincache.php @@ -0,0 +1,152 @@ + +// +---------------------------------------------------------------------- + +namespace think\cache\driver; + +use think\cache\Driver; + +/** + * Wincache缓存驱动 + * @author liu21st + */ +class Wincache extends Driver +{ + protected $options = [ + 'prefix' => '', + 'expire' => 0, + ]; + + /** + * 构造函数 + * @param array $options 缓存参数 + * @throws \BadFunctionCallException + * @access public + */ + public function __construct($options = []) + { + if (!function_exists('wincache_ucache_info')) { + throw new \BadFunctionCallException('not support: WinCache'); + } + if (!empty($options)) { + $this->options = array_merge($this->options, $options); + } + } + + /** + * 判断缓存 + * @access public + * @param string $name 缓存变量名 + * @return bool + */ + public function has($name) + { + $key = $this->getCacheKey($name); + return wincache_ucache_exists($key); + } + + /** + * 读取缓存 + * @access public + * @param string $name 缓存变量名 + * @param mixed $default 默认值 + * @return mixed + */ + public function get($name, $default = false) + { + $key = $this->getCacheKey($name); + return wincache_ucache_exists($key) ? wincache_ucache_get($key) : $default; + } + + /** + * 写入缓存 + * @access public + * @param string $name 缓存变量名 + * @param mixed $value 存储数据 + * @param integer|\DateTime $expire 有效时间(秒) + * @return boolean + */ + public function set($name, $value, $expire = null) + { + if (is_null($expire)) { + $expire = $this->options['expire']; + } + if ($expire instanceof \DateTime) { + $expire = $expire->getTimestamp() - time(); + } + $key = $this->getCacheKey($name); + if ($this->tag && !$this->has($name)) { + $first = true; + } + if (wincache_ucache_set($key, $value, $expire)) { + isset($first) && $this->setTagItem($key); + return true; + } + return false; + } + + /** + * 自增缓存(针对数值缓存) + * @access public + * @param string $name 缓存变量名 + * @param int $step 步长 + * @return false|int + */ + public function inc($name, $step = 1) + { + $key = $this->getCacheKey($name); + return wincache_ucache_inc($key, $step); + } + + /** + * 自减缓存(针对数值缓存) + * @access public + * @param string $name 缓存变量名 + * @param int $step 步长 + * @return false|int + */ + public function dec($name, $step = 1) + { + $key = $this->getCacheKey($name); + return wincache_ucache_dec($key, $step); + } + + /** + * 删除缓存 + * @access public + * @param string $name 缓存变量名 + * @return boolean + */ + public function rm($name) + { + return wincache_ucache_delete($this->getCacheKey($name)); + } + + /** + * 清除缓存 + * @access public + * @param string $tag 标签名 + * @return boolean + */ + public function clear($tag = null) + { + if ($tag) { + $keys = $this->getTagItem($tag); + foreach ($keys as $key) { + wincache_ucache_delete($key); + } + $this->rm('tag_' . md5($tag)); + return true; + } else { + return wincache_ucache_clear(); + } + } + +} diff --git a/thinkphp/library/think/cache/driver/Xcache.php b/thinkphp/library/think/cache/driver/Xcache.php new file mode 100644 index 0000000..4d94c03 --- /dev/null +++ b/thinkphp/library/think/cache/driver/Xcache.php @@ -0,0 +1,155 @@ + +// +---------------------------------------------------------------------- + +namespace think\cache\driver; + +use think\cache\Driver; + +/** + * Xcache缓存驱动 + * @author liu21st + */ +class Xcache extends Driver +{ + protected $options = [ + 'prefix' => '', + 'expire' => 0, + ]; + + /** + * 构造函数 + * @param array $options 缓存参数 + * @access public + * @throws \BadFunctionCallException + */ + public function __construct($options = []) + { + if (!function_exists('xcache_info')) { + throw new \BadFunctionCallException('not support: Xcache'); + } + if (!empty($options)) { + $this->options = array_merge($this->options, $options); + } + } + + /** + * 判断缓存 + * @access public + * @param string $name 缓存变量名 + * @return bool + */ + public function has($name) + { + $key = $this->getCacheKey($name); + return xcache_isset($key); + } + + /** + * 读取缓存 + * @access public + * @param string $name 缓存变量名 + * @param mixed $default 默认值 + * @return mixed + */ + public function get($name, $default = false) + { + $key = $this->getCacheKey($name); + return xcache_isset($key) ? xcache_get($key) : $default; + } + + /** + * 写入缓存 + * @access public + * @param string $name 缓存变量名 + * @param mixed $value 存储数据 + * @param integer|\DateTime $expire 有效时间(秒) + * @return boolean + */ + public function set($name, $value, $expire = null) + { + if (is_null($expire)) { + $expire = $this->options['expire']; + } + if ($expire instanceof \DateTime) { + $expire = $expire->getTimestamp() - time(); + } + if ($this->tag && !$this->has($name)) { + $first = true; + } + $key = $this->getCacheKey($name); + if (xcache_set($key, $value, $expire)) { + isset($first) && $this->setTagItem($key); + return true; + } + return false; + } + + /** + * 自增缓存(针对数值缓存) + * @access public + * @param string $name 缓存变量名 + * @param int $step 步长 + * @return false|int + */ + public function inc($name, $step = 1) + { + $key = $this->getCacheKey($name); + return xcache_inc($key, $step); + } + + /** + * 自减缓存(针对数值缓存) + * @access public + * @param string $name 缓存变量名 + * @param int $step 步长 + * @return false|int + */ + public function dec($name, $step = 1) + { + $key = $this->getCacheKey($name); + return xcache_dec($key, $step); + } + + /** + * 删除缓存 + * @access public + * @param string $name 缓存变量名 + * @return boolean + */ + public function rm($name) + { + return xcache_unset($this->getCacheKey($name)); + } + + /** + * 清除缓存 + * @access public + * @param string $tag 标签名 + * @return boolean + */ + public function clear($tag = null) + { + if ($tag) { + // 指定标签清除 + $keys = $this->getTagItem($tag); + foreach ($keys as $key) { + xcache_unset($key); + } + $this->rm('tag_' . md5($tag)); + return true; + } + if (function_exists('xcache_unset_by_prefix')) { + return xcache_unset_by_prefix($this->options['prefix']); + } else { + return false; + } + } +} diff --git a/thinkphp/library/think/config/driver/Ini.php b/thinkphp/library/think/config/driver/Ini.php new file mode 100644 index 0000000..bcd12b6 --- /dev/null +++ b/thinkphp/library/think/config/driver/Ini.php @@ -0,0 +1,24 @@ + +// +---------------------------------------------------------------------- + +namespace think\config\driver; + +class Ini +{ + public function parse($config) + { + if (is_file($config)) { + return parse_ini_file($config, true); + } else { + return parse_ini_string($config, true); + } + } +} diff --git a/thinkphp/library/think/config/driver/Json.php b/thinkphp/library/think/config/driver/Json.php new file mode 100644 index 0000000..479dcc8 --- /dev/null +++ b/thinkphp/library/think/config/driver/Json.php @@ -0,0 +1,24 @@ + +// +---------------------------------------------------------------------- + +namespace think\config\driver; + +class Json +{ + public function parse($config) + { + if (is_file($config)) { + $config = file_get_contents($config); + } + $result = json_decode($config, true); + return $result; + } +} diff --git a/thinkphp/library/think/config/driver/Xml.php b/thinkphp/library/think/config/driver/Xml.php new file mode 100644 index 0000000..1158519 --- /dev/null +++ b/thinkphp/library/think/config/driver/Xml.php @@ -0,0 +1,31 @@ + +// +---------------------------------------------------------------------- + +namespace think\config\driver; + +class Xml +{ + public function parse($config) + { + if (is_file($config)) { + $content = simplexml_load_file($config); + } else { + $content = simplexml_load_string($config); + } + $result = (array) $content; + foreach ($result as $key => $val) { + if (is_object($val)) { + $result[$key] = (array) $val; + } + } + return $result; + } +} diff --git a/thinkphp/library/think/console/Command.php b/thinkphp/library/think/console/Command.php new file mode 100644 index 0000000..d0caad2 --- /dev/null +++ b/thinkphp/library/think/console/Command.php @@ -0,0 +1,470 @@ + +// +---------------------------------------------------------------------- + +namespace think\console; + +use think\Console; +use think\console\input\Argument; +use think\console\input\Definition; +use think\console\input\Option; + +class Command +{ + + /** @var Console */ + private $console; + private $name; + private $aliases = []; + private $definition; + private $help; + private $description; + private $ignoreValidationErrors = false; + private $consoleDefinitionMerged = false; + private $consoleDefinitionMergedWithArgs = false; + private $code; + private $synopsis = []; + private $usages = []; + + /** @var Input */ + protected $input; + + /** @var Output */ + protected $output; + + /** + * 构造方法 + * @param string|null $name 命令名称,如果没有设置则比如在 configure() 里设置 + * @throws \LogicException + * @api + */ + public function __construct($name = null) + { + $this->definition = new Definition(); + + if (null !== $name) { + $this->setName($name); + } + + $this->configure(); + + if (!$this->name) { + throw new \LogicException(sprintf('The command defined in "%s" cannot have an empty name.', get_class($this))); + } + } + + /** + * 忽略验证错误 + */ + public function ignoreValidationErrors() + { + $this->ignoreValidationErrors = true; + } + + /** + * 设置控制台 + * @param Console $console + */ + public function setConsole(Console $console = null) + { + $this->console = $console; + } + + /** + * 获取控制台 + * @return Console + * @api + */ + public function getConsole() + { + return $this->console; + } + + /** + * 是否有效 + * @return bool + */ + public function isEnabled() + { + return true; + } + + /** + * 配置指令 + */ + protected function configure() + { + } + + /** + * 执行指令 + * @param Input $input + * @param Output $output + * @return null|int + * @throws \LogicException + * @see setCode() + */ + protected function execute(Input $input, Output $output) + { + throw new \LogicException('You must override the execute() method in the concrete command class.'); + } + + /** + * 用户验证 + * @param Input $input + * @param Output $output + */ + protected function interact(Input $input, Output $output) + { + } + + /** + * 初始化 + * @param Input $input An InputInterface instance + * @param Output $output An OutputInterface instance + */ + protected function initialize(Input $input, Output $output) + { + } + + /** + * 执行 + * @param Input $input + * @param Output $output + * @return int + * @throws \Exception + * @see setCode() + * @see execute() + */ + public function run(Input $input, Output $output) + { + $this->input = $input; + $this->output = $output; + + $this->getSynopsis(true); + $this->getSynopsis(false); + + $this->mergeConsoleDefinition(); + + try { + $input->bind($this->definition); + } catch (\Exception $e) { + if (!$this->ignoreValidationErrors) { + throw $e; + } + } + + $this->initialize($input, $output); + + if ($input->isInteractive()) { + $this->interact($input, $output); + } + + $input->validate(); + + if ($this->code) { + $statusCode = call_user_func($this->code, $input, $output); + } else { + $statusCode = $this->execute($input, $output); + } + + return is_numeric($statusCode) ? (int) $statusCode : 0; + } + + /** + * 设置执行代码 + * @param callable $code callable(InputInterface $input, OutputInterface $output) + * @return Command + * @throws \InvalidArgumentException + * @see execute() + */ + public function setCode(callable $code) + { + if (!is_callable($code)) { + throw new \InvalidArgumentException('Invalid callable provided to Command::setCode.'); + } + + if (PHP_VERSION_ID >= 50400 && $code instanceof \Closure) { + $r = new \ReflectionFunction($code); + if (null === $r->getClosureThis()) { + $code = \Closure::bind($code, $this); + } + } + + $this->code = $code; + + return $this; + } + + /** + * 合并参数定义 + * @param bool $mergeArgs + */ + public function mergeConsoleDefinition($mergeArgs = true) + { + if (null === $this->console + || (true === $this->consoleDefinitionMerged + && ($this->consoleDefinitionMergedWithArgs || !$mergeArgs)) + ) { + return; + } + + if ($mergeArgs) { + $currentArguments = $this->definition->getArguments(); + $this->definition->setArguments($this->console->getDefinition()->getArguments()); + $this->definition->addArguments($currentArguments); + } + + $this->definition->addOptions($this->console->getDefinition()->getOptions()); + + $this->consoleDefinitionMerged = true; + if ($mergeArgs) { + $this->consoleDefinitionMergedWithArgs = true; + } + } + + /** + * 设置参数定义 + * @param array|Definition $definition + * @return Command + * @api + */ + public function setDefinition($definition) + { + if ($definition instanceof Definition) { + $this->definition = $definition; + } else { + $this->definition->setDefinition($definition); + } + + $this->consoleDefinitionMerged = false; + + return $this; + } + + /** + * 获取参数定义 + * @return Definition + * @api + */ + public function getDefinition() + { + return $this->definition; + } + + /** + * 获取当前指令的参数定义 + * @return Definition + */ + public function getNativeDefinition() + { + return $this->getDefinition(); + } + + /** + * 添加参数 + * @param string $name 名称 + * @param int $mode 类型 + * @param string $description 描述 + * @param mixed $default 默认值 + * @return Command + */ + public function addArgument($name, $mode = null, $description = '', $default = null) + { + $this->definition->addArgument(new Argument($name, $mode, $description, $default)); + + return $this; + } + + /** + * 添加选项 + * @param string $name 选项名称 + * @param string $shortcut 别名 + * @param int $mode 类型 + * @param string $description 描述 + * @param mixed $default 默认值 + * @return Command + */ + public function addOption($name, $shortcut = null, $mode = null, $description = '', $default = null) + { + $this->definition->addOption(new Option($name, $shortcut, $mode, $description, $default)); + + return $this; + } + + /** + * 设置指令名称 + * @param string $name + * @return Command + * @throws \InvalidArgumentException + */ + public function setName($name) + { + $this->validateName($name); + + $this->name = $name; + + return $this; + } + + /** + * 获取指令名称 + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * 设置描述 + * @param string $description + * @return Command + */ + public function setDescription($description) + { + $this->description = $description; + + return $this; + } + + /** + * 获取描述 + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * 设置帮助信息 + * @param string $help + * @return Command + */ + public function setHelp($help) + { + $this->help = $help; + + return $this; + } + + /** + * 获取帮助信息 + * @return string + */ + public function getHelp() + { + return $this->help; + } + + /** + * 描述信息 + * @return string + */ + public function getProcessedHelp() + { + $name = $this->name; + + $placeholders = [ + '%command.name%', + '%command.full_name%', + ]; + $replacements = [ + $name, + $_SERVER['PHP_SELF'] . ' ' . $name, + ]; + + return str_replace($placeholders, $replacements, $this->getHelp()); + } + + /** + * 设置别名 + * @param string[] $aliases + * @return Command + * @throws \InvalidArgumentException + */ + public function setAliases($aliases) + { + if (!is_array($aliases) && !$aliases instanceof \Traversable) { + throw new \InvalidArgumentException('$aliases must be an array or an instance of \Traversable'); + } + + foreach ($aliases as $alias) { + $this->validateName($alias); + } + + $this->aliases = $aliases; + + return $this; + } + + /** + * 获取别名 + * @return array + */ + public function getAliases() + { + return $this->aliases; + } + + /** + * 获取简介 + * @param bool $short 是否简单的 + * @return string + */ + public function getSynopsis($short = false) + { + $key = $short ? 'short' : 'long'; + + if (!isset($this->synopsis[$key])) { + $this->synopsis[$key] = trim(sprintf('%s %s', $this->name, $this->definition->getSynopsis($short))); + } + + return $this->synopsis[$key]; + } + + /** + * 添加用法介绍 + * @param string $usage + * @return $this + */ + public function addUsage($usage) + { + if (0 !== strpos($usage, $this->name)) { + $usage = sprintf('%s %s', $this->name, $usage); + } + + $this->usages[] = $usage; + + return $this; + } + + /** + * 获取用法介绍 + * @return array + */ + public function getUsages() + { + return $this->usages; + } + + /** + * 验证指令名称 + * @param string $name + * @throws \InvalidArgumentException + */ + private function validateName($name) + { + if (!preg_match('/^[^\:]++(\:[^\:]++)*$/', $name)) { + throw new \InvalidArgumentException(sprintf('Command name "%s" is invalid.', $name)); + } + } +} diff --git a/thinkphp/library/think/console/Input.php b/thinkphp/library/think/console/Input.php new file mode 100644 index 0000000..2482dfd --- /dev/null +++ b/thinkphp/library/think/console/Input.php @@ -0,0 +1,464 @@ + +// +---------------------------------------------------------------------- + +namespace think\console; + +use think\console\input\Argument; +use think\console\input\Definition; +use think\console\input\Option; + +class Input +{ + + /** + * @var Definition + */ + protected $definition; + + /** + * @var Option[] + */ + protected $options = []; + + /** + * @var Argument[] + */ + protected $arguments = []; + + protected $interactive = true; + + private $tokens; + private $parsed; + + public function __construct($argv = null) + { + if (null === $argv) { + $argv = $_SERVER['argv']; + // 去除命令名 + array_shift($argv); + } + + $this->tokens = $argv; + + $this->definition = new Definition(); + } + + protected function setTokens(array $tokens) + { + $this->tokens = $tokens; + } + + /** + * 绑定实例 + * @param Definition $definition A InputDefinition instance + */ + public function bind(Definition $definition) + { + $this->arguments = []; + $this->options = []; + $this->definition = $definition; + + $this->parse(); + } + + /** + * 解析参数 + */ + protected function parse() + { + $parseOptions = true; + $this->parsed = $this->tokens; + while (null !== $token = array_shift($this->parsed)) { + if ($parseOptions && '' == $token) { + $this->parseArgument($token); + } elseif ($parseOptions && '--' == $token) { + $parseOptions = false; + } elseif ($parseOptions && 0 === strpos($token, '--')) { + $this->parseLongOption($token); + } elseif ($parseOptions && '-' === $token[0] && '-' !== $token) { + $this->parseShortOption($token); + } else { + $this->parseArgument($token); + } + } + } + + /** + * 解析短选项 + * @param string $token 当前的指令. + */ + private function parseShortOption($token) + { + $name = substr($token, 1); + + if (strlen($name) > 1) { + if ($this->definition->hasShortcut($name[0]) + && $this->definition->getOptionForShortcut($name[0])->acceptValue() + ) { + $this->addShortOption($name[0], substr($name, 1)); + } else { + $this->parseShortOptionSet($name); + } + } else { + $this->addShortOption($name, null); + } + } + + /** + * 解析短选项 + * @param string $name 当前指令 + * @throws \RuntimeException + */ + private function parseShortOptionSet($name) + { + $len = strlen($name); + for ($i = 0; $i < $len; ++$i) { + if (!$this->definition->hasShortcut($name[$i])) { + throw new \RuntimeException(sprintf('The "-%s" option does not exist.', $name[$i])); + } + + $option = $this->definition->getOptionForShortcut($name[$i]); + if ($option->acceptValue()) { + $this->addLongOption($option->getName(), $i === $len - 1 ? null : substr($name, $i + 1)); + + break; + } else { + $this->addLongOption($option->getName(), null); + } + } + } + + /** + * 解析完整选项 + * @param string $token 当前指令 + */ + private function parseLongOption($token) + { + $name = substr($token, 2); + + if (false !== $pos = strpos($name, '=')) { + $this->addLongOption(substr($name, 0, $pos), substr($name, $pos + 1)); + } else { + $this->addLongOption($name, null); + } + } + + /** + * 解析参数 + * @param string $token 当前指令 + * @throws \RuntimeException + */ + private function parseArgument($token) + { + $c = count($this->arguments); + + if ($this->definition->hasArgument($c)) { + $arg = $this->definition->getArgument($c); + + $this->arguments[$arg->getName()] = $arg->isArray() ? [$token] : $token; + + } elseif ($this->definition->hasArgument($c - 1) && $this->definition->getArgument($c - 1)->isArray()) { + $arg = $this->definition->getArgument($c - 1); + + $this->arguments[$arg->getName()][] = $token; + } else { + throw new \RuntimeException('Too many arguments.'); + } + } + + /** + * 添加一个短选项的值 + * @param string $shortcut 短名称 + * @param mixed $value 值 + * @throws \RuntimeException + */ + private function addShortOption($shortcut, $value) + { + if (!$this->definition->hasShortcut($shortcut)) { + throw new \RuntimeException(sprintf('The "-%s" option does not exist.', $shortcut)); + } + + $this->addLongOption($this->definition->getOptionForShortcut($shortcut)->getName(), $value); + } + + /** + * 添加一个完整选项的值 + * @param string $name 选项名 + * @param mixed $value 值 + * @throws \RuntimeException + */ + private function addLongOption($name, $value) + { + if (!$this->definition->hasOption($name)) { + throw new \RuntimeException(sprintf('The "--%s" option does not exist.', $name)); + } + + $option = $this->definition->getOption($name); + + if (false === $value) { + $value = null; + } + + if (null !== $value && !$option->acceptValue()) { + throw new \RuntimeException(sprintf('The "--%s" option does not accept a value.', $name, $value)); + } + + if (null === $value && $option->acceptValue() && count($this->parsed)) { + $next = array_shift($this->parsed); + if (isset($next[0]) && '-' !== $next[0]) { + $value = $next; + } elseif (empty($next)) { + $value = ''; + } else { + array_unshift($this->parsed, $next); + } + } + + if (null === $value) { + if ($option->isValueRequired()) { + throw new \RuntimeException(sprintf('The "--%s" option requires a value.', $name)); + } + + if (!$option->isArray()) { + $value = $option->isValueOptional() ? $option->getDefault() : true; + } + } + + if ($option->isArray()) { + $this->options[$name][] = $value; + } else { + $this->options[$name] = $value; + } + } + + /** + * 获取第一个参数 + * @return string|null + */ + public function getFirstArgument() + { + foreach ($this->tokens as $token) { + if ($token && '-' === $token[0]) { + continue; + } + + return $token; + } + return; + } + + /** + * 检查原始参数是否包含某个值 + * @param string|array $values 需要检查的值 + * @return bool + */ + public function hasParameterOption($values) + { + $values = (array) $values; + + foreach ($this->tokens as $token) { + foreach ($values as $value) { + if ($token === $value || 0 === strpos($token, $value . '=')) { + return true; + } + } + } + + return false; + } + + /** + * 获取原始选项的值 + * @param string|array $values 需要检查的值 + * @param mixed $default 默认值 + * @return mixed The option value + */ + public function getParameterOption($values, $default = false) + { + $values = (array) $values; + $tokens = $this->tokens; + + while (0 < count($tokens)) { + $token = array_shift($tokens); + + foreach ($values as $value) { + if ($token === $value || 0 === strpos($token, $value . '=')) { + if (false !== $pos = strpos($token, '=')) { + return substr($token, $pos + 1); + } + + return array_shift($tokens); + } + } + } + + return $default; + } + + /** + * 验证输入 + * @throws \RuntimeException + */ + public function validate() + { + if (count($this->arguments) < $this->definition->getArgumentRequiredCount()) { + throw new \RuntimeException('Not enough arguments.'); + } + } + + /** + * 检查输入是否是交互的 + * @return bool + */ + public function isInteractive() + { + return $this->interactive; + } + + /** + * 设置输入的交互 + * @param bool + */ + public function setInteractive($interactive) + { + $this->interactive = (bool) $interactive; + } + + /** + * 获取所有的参数 + * @return Argument[] + */ + public function getArguments() + { + return array_merge($this->definition->getArgumentDefaults(), $this->arguments); + } + + /** + * 根据名称获取参数 + * @param string $name 参数名 + * @return mixed + * @throws \InvalidArgumentException + */ + public function getArgument($name) + { + if (!$this->definition->hasArgument($name)) { + throw new \InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name)); + } + + return isset($this->arguments[$name]) ? $this->arguments[$name] : $this->definition->getArgument($name) + ->getDefault(); + } + + /** + * 设置参数的值 + * @param string $name 参数名 + * @param string $value 值 + * @throws \InvalidArgumentException + */ + public function setArgument($name, $value) + { + if (!$this->definition->hasArgument($name)) { + throw new \InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name)); + } + + $this->arguments[$name] = $value; + } + + /** + * 检查是否存在某个参数 + * @param string|int $name 参数名或位置 + * @return bool + */ + public function hasArgument($name) + { + return $this->definition->hasArgument($name); + } + + /** + * 获取所有的选项 + * @return Option[] + */ + public function getOptions() + { + return array_merge($this->definition->getOptionDefaults(), $this->options); + } + + /** + * 获取选项值 + * @param string $name 选项名称 + * @return mixed + * @throws \InvalidArgumentException + */ + public function getOption($name) + { + if (!$this->definition->hasOption($name)) { + throw new \InvalidArgumentException(sprintf('The "%s" option does not exist.', $name)); + } + + return isset($this->options[$name]) ? $this->options[$name] : $this->definition->getOption($name)->getDefault(); + } + + /** + * 设置选项值 + * @param string $name 选项名 + * @param string|bool $value 值 + * @throws \InvalidArgumentException + */ + public function setOption($name, $value) + { + if (!$this->definition->hasOption($name)) { + throw new \InvalidArgumentException(sprintf('The "%s" option does not exist.', $name)); + } + + $this->options[$name] = $value; + } + + /** + * 是否有某个选项 + * @param string $name 选项名 + * @return bool + */ + public function hasOption($name) + { + return $this->definition->hasOption($name) && isset($this->options[$name]); + } + + /** + * 转义指令 + * @param string $token + * @return string + */ + public function escapeToken($token) + { + return preg_match('{^[\w-]+$}', $token) ? $token : escapeshellarg($token); + } + + /** + * 返回传递给命令的参数的字符串 + * @return string + */ + public function __toString() + { + $tokens = array_map(function ($token) { + if (preg_match('{^(-[^=]+=)(.+)}', $token, $match)) { + return $match[1] . $this->escapeToken($match[2]); + } + + if ($token && '-' !== $token[0]) { + return $this->escapeToken($token); + } + + return $token; + }, $this->tokens); + + return implode(' ', $tokens); + } +} diff --git a/thinkphp/library/think/console/LICENSE b/thinkphp/library/think/console/LICENSE new file mode 100644 index 0000000..0abe056 --- /dev/null +++ b/thinkphp/library/think/console/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2004-2016 Fabien Potencier + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/thinkphp/library/think/console/Output.php b/thinkphp/library/think/console/Output.php new file mode 100644 index 0000000..65dc9fb --- /dev/null +++ b/thinkphp/library/think/console/Output.php @@ -0,0 +1,222 @@ + +// +---------------------------------------------------------------------- + +namespace think\console; + +use Exception; +use think\console\output\Ask; +use think\console\output\Descriptor; +use think\console\output\driver\Buffer; +use think\console\output\driver\Console; +use think\console\output\driver\Nothing; +use think\console\output\Question; +use think\console\output\question\Choice; +use think\console\output\question\Confirmation; + +/** + * Class Output + * @package think\console + * + * @see \think\console\output\driver\Console::setDecorated + * @method void setDecorated($decorated) + * + * @see \think\console\output\driver\Buffer::fetch + * @method string fetch() + * + * @method void info($message) + * @method void error($message) + * @method void comment($message) + * @method void warning($message) + * @method void highlight($message) + * @method void question($message) + */ +class Output +{ + const VERBOSITY_QUIET = 0; + const VERBOSITY_NORMAL = 1; + const VERBOSITY_VERBOSE = 2; + const VERBOSITY_VERY_VERBOSE = 3; + const VERBOSITY_DEBUG = 4; + + const OUTPUT_NORMAL = 0; + const OUTPUT_RAW = 1; + const OUTPUT_PLAIN = 2; + + private $verbosity = self::VERBOSITY_NORMAL; + + /** @var Buffer|Console|Nothing */ + private $handle = null; + + protected $styles = [ + 'info', + 'error', + 'comment', + 'question', + 'highlight', + 'warning' + ]; + + public function __construct($driver = 'console') + { + $class = '\\think\\console\\output\\driver\\' . ucwords($driver); + + $this->handle = new $class($this); + } + + public function ask(Input $input, $question, $default = null, $validator = null) + { + $question = new Question($question, $default); + $question->setValidator($validator); + + return $this->askQuestion($input, $question); + } + + public function askHidden(Input $input, $question, $validator = null) + { + $question = new Question($question); + + $question->setHidden(true); + $question->setValidator($validator); + + return $this->askQuestion($input, $question); + } + + public function confirm(Input $input, $question, $default = true) + { + return $this->askQuestion($input, new Confirmation($question, $default)); + } + + /** + * {@inheritdoc} + */ + public function choice(Input $input, $question, array $choices, $default = null) + { + if (null !== $default) { + $values = array_flip($choices); + $default = $values[$default]; + } + + return $this->askQuestion($input, new Choice($question, $choices, $default)); + } + + protected function askQuestion(Input $input, Question $question) + { + $ask = new Ask($input, $this, $question); + $answer = $ask->run(); + + if ($input->isInteractive()) { + $this->newLine(); + } + + return $answer; + } + + protected function block($style, $message) + { + $this->writeln("<{$style}>{$message}"); + } + + /** + * 输出空行 + * @param int $count + */ + public function newLine($count = 1) + { + $this->write(str_repeat(PHP_EOL, $count)); + } + + /** + * 输出信息并换行 + * @param string $messages + * @param int $type + */ + public function writeln($messages, $type = self::OUTPUT_NORMAL) + { + $this->write($messages, true, $type); + } + + /** + * 输出信息 + * @param string $messages + * @param bool $newline + * @param int $type + */ + public function write($messages, $newline = false, $type = self::OUTPUT_NORMAL) + { + $this->handle->write($messages, $newline, $type); + } + + public function renderException(\Exception $e) + { + $this->handle->renderException($e); + } + + /** + * {@inheritdoc} + */ + public function setVerbosity($level) + { + $this->verbosity = (int) $level; + } + + /** + * {@inheritdoc} + */ + public function getVerbosity() + { + return $this->verbosity; + } + + public function isQuiet() + { + return self::VERBOSITY_QUIET === $this->verbosity; + } + + public function isVerbose() + { + return self::VERBOSITY_VERBOSE <= $this->verbosity; + } + + public function isVeryVerbose() + { + return self::VERBOSITY_VERY_VERBOSE <= $this->verbosity; + } + + public function isDebug() + { + return self::VERBOSITY_DEBUG <= $this->verbosity; + } + + public function describe($object, array $options = []) + { + $descriptor = new Descriptor(); + $options = array_merge([ + 'raw_text' => false, + ], $options); + + $descriptor->describe($this, $object, $options); + } + + public function __call($method, $args) + { + if (in_array($method, $this->styles)) { + array_unshift($args, $method); + return call_user_func_array([$this, 'block'], $args); + } + + if ($this->handle && method_exists($this->handle, $method)) { + return call_user_func_array([$this->handle, $method], $args); + } else { + throw new Exception('method not exists:' . __CLASS__ . '->' . $method); + } + } + +} diff --git a/thinkphp/library/think/console/bin/README.md b/thinkphp/library/think/console/bin/README.md new file mode 100644 index 0000000..9acc52f --- /dev/null +++ b/thinkphp/library/think/console/bin/README.md @@ -0,0 +1 @@ +console 工具使用 hiddeninput.exe 在 windows 上隐藏密码输入,该二进制文件由第三方提供,相关源码和其他细节可以在 [Hidden Input](https://github.com/Seldaek/hidden-input) 找到。 diff --git a/thinkphp/library/think/console/bin/hiddeninput.exe b/thinkphp/library/think/console/bin/hiddeninput.exe new file mode 100644 index 0000000000000000000000000000000000000000..c8cf65e8d819e6e525121cf6b21f1c2429746038 GIT binary patch literal 9216 zcmeHNe{@sVeZR8hV88~S)=Hp|Mpn({rC^@)BwNOI{ERJXCYlx+k1K6PLHo z_e!z_fhOzeA3JTX&-Z@s{rFOgjEwBlqjr!)9f zjyHz`A+ni`!0Taby{Uj5Y>jQq(k5A+X})PLWAi|{IZbtc8n^^trM{GI=P_15U6d?l zJJ3PW8XjfHpR}6`k{&5@JcEeH_SqQoQbU62o2YS30W)p_t&Fjy*RXQCZt$gCf|ao| zx&3R}m6|-Lfi@pua=$26n(UlnWo$>K67*|+#(qL_An=?l0M02AhOSJDv3;~?1ORfw z76EdK#MpSHqACHLcnJLIYlCSiX4eS@Pr8rN)Xwz0dk7O*y^0_C(Yks2Kvg! z-d-fJ)F9@k?>)m(XqDKIe2OKfhCQde9fpO0ko24yn*4xzX7q+ze`Z*=aJgwV?D?73 zaJ8UkSk|NN>@-|mB*f`EIK7$ElgAB<7p&p`^Vuq$58#;?B^*Bz7&d$B#+AYUC z(^m|`7{lqx&b^5$;i`j|S!+u|lcaQplp_&Nb)!>r>vGh3wb!tW zLq6%bkSt8jO|(vWH>LiPV(Xkp%BiGhl1q!PXXNKVKE!>Y5cHc2%cJOJA{-&ZsSn`T z#8~TA#(HWH4m>uCd+kCMTFgMI*s*n3!iCOwEI`{vGcVhzDu!Lw%-Ea^JATtrF`q3`+#KvvYJ0vM~A}D#LOD zlw`4ncB0U*Jji=--Wz#>I&5?hy;MgYW2u91d8ob=7MWfY`u;7Xe-J{Qsb0=0p|SM2 zG|=~mERIj4?gi)Ew|{LIN#oAsh20k_khIYjJBBN6rrIJ=eQO=nE;rTnPSiaQS$1$# z+|JRh0!IbQIa*f1(TZ}QM;|WO0+jTy(e)ggN4>zqp2E>C>hGPLHjHBh--2%@{EZNE zbUk{<3MABX&20QwK{MxK8`1Vk>^%dO5i@VTfu>NG3$K4NC=hSPsj9UYy`rNO}sBnB9QdKdIk7G+2_amnWstdTYVg z7HgLJGC~XLZG`63GwH8PdO_+G(k6~?J8Wj5mQos#21kC4W#2)guQXI)!z^{@F)U)5 z*re+r(2dib3D4P~%Z6TL=$PIkpmm<_#isu%t=%DcIwNkJhMeJ|bpahHO%8h|y~Ccf zUg#xVk+dyu>Q1O7JZ~8KS>tqi0qK**X*y6yHM71`bT=kFZ=@E%oe2!Km1^2sa>v+onZ%x_>aOJF+N0{i~z|<(IzgT*{0PpQq}E zQpU35@bm;qI?t_znGI&5&4sZV>+%m}w$(4hSDvLk)l<{5XyMlnCl7C%AjM3XnWvVz z{NoFsX)JB)SoqABZxUa*Yq+^^(cbq4mL%^lO12c${z{pf+)|kTTI~nQywyYF6}6|8 zlsN9&{-vwTrTyu<5^90_AsIU-ID#ZG@6d%poU44<**%xVe?`uxf}_Mr$SLHLS|K_N zQnw>(Lr2U=%$-<2D~RSzbG)2W2u^KMDnFFE?GmmbQ)V)fty957F`4OvQ_25E68ITr z5?`suu`|v?r!y=gFOGj$%9IJ zuTP=&2GcnoZZ0qSe6YL-*-lg>Q#>?Ew`a=GDc4vI#<1sNdKn?n7iSj0Orl$-#FMFi zykr>X-Xvi>sVr;92+8*H!r|3L$#o~hXa0z>AmF=z z?|@FF;*S|S0yqsw0j>Z(3mX-HD!|{N-vYc9paC8Ld=|6?00!6(_%lERupO`&um*4k z0b~W>e*uhTe4;V;mq>(ox$9FB`wLt!*DKj~!aOh|fL&#Pg*b??tm%5~_6M#02wqeC zS~wO>TWGnSp^r<0&8f2V6W->w=C+p~daC5e5wNQM*(* z66^}b0(!q3)zq$mu&VnbR#nr3;h5DS*o7{y66=!#;Dy4$pd1ZH<6WEOi0oJ8SxRL* z*v-9@Z^2w%^S(w5dO{_9Duby%2RT~;ppxaE$l()x6&}>7Wcg=u_&>f`Vs8OJGTy{X z2HpG=ThJz<{%|4Qq-~ad0qcrc87n88DHpM(nypwXIkZn<{zIT$ul&BQ?{ApCAZtyr zs2YpNt@x(G*faTU*HCKnAk(G=Tl~>r1QK8LY~J8mFFGoN5iIkYSwlm4Lsj#g4dsE5 zU-4;*Kdh-zv!rT4N$O}Q&n)?v0-9Y)lRFz58^P-KtKonzrfQ1p@0V_10^0||cGRn9 zRG<-#_TEV2nn4{BOh{YVBR4e!V!D?0K%BAlQN!D%M#k1bHypiIHT)5tlj>p0Pp_;+ z!cqC-JIs@JRhB+#teGs$Cib_=(yjRo4OJg^YPg%58aJVsC(LQ?W6%pn!-#aMZwoPcopo^Rn6BE z3=c5&W5~pP(C(-2r;PnH-S0{F`runM0ERCf3rESX$+S(MKOXmKJL9zXF}9-lf^xUs z+bb)+P%L&gV@<4q{6w^xEJ>Y>TQFUeoz0o-yq)jUqww=?wjUO8Y{a5G;DJ0Jr!LL+ zWhgsLuzi&eDrGDn$2DJwpFfH-?SGWbr>qRb?v{P`_%)So)CQgzO^HQ%;y#tJ=knH4 z95jX;^bF#BiuTH^%-j}{9VrZD=R%Q%wselH^p>5 z7d>gWB-st&3Fj%Mt*|tR5iK3J=`xhs&G)I7E>`FO@o7L z@S$B!pYMuzz5DN@X!O4DPm5n@raPJn-Q#o*m*e^5lk$g?0esg%$;>g5QW-|;c=H2GM}bo2tW^D924wmOkrUbWxcQ# z#v6bP%Tdfe~jtCRzAL;-OahZ=#yvUixu2-9fD2j$*|YY`F?0wF-{a# ztr<&kZjZ+81}6ZESqtgW)8kP#s@VLTSUR{}6?U^R*x7RE3Rl&n=VnFFqg9Uqz1n@N9N|=9<4} zuJfy^+}|D9X&vm3MAdqmu0&UMd^=K>b1hLAm_E!$rZC2b;;T~Dl zI`Eo_yRY76uM})|6wk9->of(=9&4jLv5#p@OzS~Yl>@pG)^>6`R+KtL{<4ly4o9WiM!%p_pfROU354)e8PIeE z1_s?#;OX6waNvvb&UQRN(WLbR+}&b#jo&WY-LlwCX}Q*$jGuKYuOGoIoyR(>e}}ix z+t}Q^cEcC8Y{@h}>HmJ^gD!l@gzwHmiBKl26x_lZVZG2UY!`w;RJd122;US&geQdW z3Qq}R!gIo5;ka;0I4c-Jq5X6A6?VzK&c4y!ZXdAUYu{r}*!SBXw?Aor+J4-A(*COb zb^CwV-?3k`zi-cX*c`VzL`RLI(b4MgIrGN z%ojf`E*6)Gg1A9!7q^N##2zsss^V9~-Qt7d!{UDNZ^XY9pA^3@9ui*?e=7c5d`nD; z?}~R(p>y1Kw!>|X4ycYEAkcZa*n-R%y! zqi)Up756UpqwfE7=hfigw$k~G@25gaxF9UGTkV>C(7x1Rbx4jb#|}rxq0vQ!n-c#f J0sQ~1{4brj`U(I5 literal 0 HcmV?d00001 diff --git a/thinkphp/library/think/console/command/Build.php b/thinkphp/library/think/console/command/Build.php new file mode 100644 index 0000000..39806c3 --- /dev/null +++ b/thinkphp/library/think/console/command/Build.php @@ -0,0 +1,56 @@ + +// +---------------------------------------------------------------------- + +namespace think\console\command; + +use think\console\Command; +use think\console\Input; +use think\console\input\Option; +use think\console\Output; + +class Build extends Command +{ + + /** + * {@inheritdoc} + */ + protected function configure() + { + $this->setName('build') + ->setDefinition([ + new Option('config', null, Option::VALUE_OPTIONAL, "build.php path"), + new Option('module', null, Option::VALUE_OPTIONAL, "module name"), + ]) + ->setDescription('Build Application Dirs'); + } + + protected function execute(Input $input, Output $output) + { + if ($input->hasOption('module')) { + \think\Build::module($input->getOption('module')); + $output->writeln("Successed"); + return; + } + + if ($input->hasOption('config')) { + $build = include $input->getOption('config'); + } else { + $build = include APP_PATH . 'build.php'; + } + if (empty($build)) { + $output->writeln("Build Config Is Empty"); + return; + } + \think\Build::run($build); + $output->writeln("Successed"); + + } +} diff --git a/thinkphp/library/think/console/command/Clear.php b/thinkphp/library/think/console/command/Clear.php new file mode 100644 index 0000000..1b5102e --- /dev/null +++ b/thinkphp/library/think/console/command/Clear.php @@ -0,0 +1,63 @@ + +// +---------------------------------------------------------------------- +namespace think\console\command; + +use think\Cache; +use think\console\Command; +use think\console\Input; +use think\console\input\Argument; +use think\console\input\Option; +use think\console\Output; + +class Clear extends Command +{ + protected function configure() + { + // 指令配置 + $this + ->setName('clear') + ->addArgument('type', Argument::OPTIONAL, 'type to clear', null) + ->addOption('path', 'd', Option::VALUE_OPTIONAL, 'path to clear', null) + ->setDescription('Clear runtime file'); + } + + protected function execute(Input $input, Output $output) + { + $path = $input->getOption('path') ?: RUNTIME_PATH; + + $type = $input->getArgument('type'); + + if ($type == 'route') { + Cache::clear('route_check'); + } else { + if (is_dir($path)) { + $this->clearPath($path); + } + } + + $output->writeln("Clear Successed"); + } + + protected function clearPath($path) + { + $path = realpath($path) . DS; + $files = scandir($path); + if ($files) { + foreach ($files as $file) { + if ('.' != $file && '..' != $file && is_dir($path . $file)) { + $this->clearPath($path . $file); + } elseif ('.gitignore' != $file && is_file($path . $file)) { + unlink($path . $file); + } + } + } + } +} diff --git a/thinkphp/library/think/console/command/Help.php b/thinkphp/library/think/console/command/Help.php new file mode 100644 index 0000000..bae2c65 --- /dev/null +++ b/thinkphp/library/think/console/command/Help.php @@ -0,0 +1,69 @@ + +// +---------------------------------------------------------------------- + +namespace think\console\command; + +use think\console\Command; +use think\console\Input; +use think\console\input\Argument as InputArgument; +use think\console\input\Option as InputOption; +use think\console\Output; + +class Help extends Command +{ + + private $command; + + /** + * {@inheritdoc} + */ + protected function configure() + { + $this->ignoreValidationErrors(); + + $this->setName('help')->setDefinition([ + new InputArgument('command_name', InputArgument::OPTIONAL, 'The command name', 'help'), + new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw command help'), + ])->setDescription('Displays help for a command')->setHelp(<<%command.name% command displays help for a given command: + + php %command.full_name% list + +To display the list of available commands, please use the list command. +EOF + ); + } + + /** + * Sets the command. + * @param Command $command The command to set + */ + public function setCommand(Command $command) + { + $this->command = $command; + } + + /** + * {@inheritdoc} + */ + protected function execute(Input $input, Output $output) + { + if (null === $this->command) { + $this->command = $this->getConsole()->find($input->getArgument('command_name')); + } + + $output->describe($this->command, [ + 'raw_text' => $input->getOption('raw'), + ]); + + $this->command = null; + } +} diff --git a/thinkphp/library/think/console/command/Lists.php b/thinkphp/library/think/console/command/Lists.php new file mode 100644 index 0000000..084ddaa --- /dev/null +++ b/thinkphp/library/think/console/command/Lists.php @@ -0,0 +1,74 @@ + +// +---------------------------------------------------------------------- + +namespace think\console\command; + +use think\console\Command; +use think\console\Input; +use think\console\Output; +use think\console\input\Argument as InputArgument; +use think\console\input\Option as InputOption; +use think\console\input\Definition as InputDefinition; + +class Lists extends Command +{ + + /** + * {@inheritdoc} + */ + protected function configure() + { + $this->setName('list')->setDefinition($this->createDefinition())->setDescription('Lists commands')->setHelp(<<%command.name% command lists all commands: + + php %command.full_name% + +You can also display the commands for a specific namespace: + + php %command.full_name% test + +It's also possible to get raw list of commands (useful for embedding command runner): + + php %command.full_name% --raw +EOF + ); + } + + /** + * {@inheritdoc} + */ + public function getNativeDefinition() + { + return $this->createDefinition(); + } + + /** + * {@inheritdoc} + */ + protected function execute(Input $input, Output $output) + { + $output->describe($this->getConsole(), [ + 'raw_text' => $input->getOption('raw'), + 'namespace' => $input->getArgument('namespace'), + ]); + } + + /** + * {@inheritdoc} + */ + private function createDefinition() + { + return new InputDefinition([ + new InputArgument('namespace', InputArgument::OPTIONAL, 'The namespace name'), + new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw command list') + ]); + } +} diff --git a/thinkphp/library/think/console/command/Make.php b/thinkphp/library/think/console/command/Make.php new file mode 100644 index 0000000..d1daf34 --- /dev/null +++ b/thinkphp/library/think/console/command/Make.php @@ -0,0 +1,110 @@ + +// +---------------------------------------------------------------------- + +namespace think\console\command; + +use think\App; +use think\Config; +use think\console\Command; +use think\console\Input; +use think\console\input\Argument; +use think\console\Output; + +abstract class Make extends Command +{ + + protected $type; + + abstract protected function getStub(); + + protected function configure() + { + $this->addArgument('name', Argument::REQUIRED, "The name of the class"); + } + + protected function execute(Input $input, Output $output) + { + + $name = trim($input->getArgument('name')); + + $classname = $this->getClassName($name); + + $pathname = $this->getPathName($classname); + + if (is_file($pathname)) { + $output->writeln('' . $this->type . ' already exists!'); + return false; + } + + if (!is_dir(dirname($pathname))) { + mkdir(strtolower(dirname($pathname)), 0755, true); + } + + file_put_contents($pathname, $this->buildClass($classname)); + + $output->writeln('' . $this->type . ' created successfully.'); + + } + + protected function buildClass($name) + { + $stub = file_get_contents($this->getStub()); + + $namespace = trim(implode('\\', array_slice(explode('\\', $name), 0, -1)), '\\'); + + $class = str_replace($namespace . '\\', '', $name); + + return str_replace(['{%className%}', '{%namespace%}', '{%app_namespace%}'], [ + $class, + $namespace, + App::$namespace, + ], $stub); + + } + + protected function getPathName($name) + { + $name = str_replace(App::$namespace . '\\', '', $name); + + return APP_PATH . str_replace('\\', '/', $name) . '.php'; + } + + protected function getClassName($name) + { + $appNamespace = App::$namespace; + + if (strpos($name, $appNamespace . '\\') === 0) { + return $name; + } + + if (Config::get('app_multi_module')) { + if (strpos($name, '/')) { + list($module, $name) = explode('/', $name, 2); + } else { + $module = 'common'; + } + } else { + $module = null; + } + + if (strpos($name, '/') !== false) { + $name = str_replace('/', '\\', $name); + } + + return $this->getNamespace($appNamespace, $module) . '\\' . $name; + } + + protected function getNamespace($appNamespace, $module) + { + return $module ? ($appNamespace . '\\' . $module) : $appNamespace; + } + +} diff --git a/thinkphp/library/think/console/command/make/Controller.php b/thinkphp/library/think/console/command/make/Controller.php new file mode 100644 index 0000000..afa7be9 --- /dev/null +++ b/thinkphp/library/think/console/command/make/Controller.php @@ -0,0 +1,50 @@ + +// +---------------------------------------------------------------------- + +namespace think\console\command\make; + +use think\Config; +use think\console\command\Make; +use think\console\input\Option; + +class Controller extends Make +{ + + protected $type = "Controller"; + + protected function configure() + { + parent::configure(); + $this->setName('make:controller') + ->addOption('plain', null, Option::VALUE_NONE, 'Generate an empty controller class.') + ->setDescription('Create a new resource controller class'); + } + + protected function getStub() + { + if ($this->input->getOption('plain')) { + return __DIR__ . '/stubs/controller.plain.stub'; + } + + return __DIR__ . '/stubs/controller.stub'; + } + + protected function getClassName($name) + { + return parent::getClassName($name) . (Config::get('controller_suffix') ? ucfirst(Config::get('url_controller_layer')) : ''); + } + + protected function getNamespace($appNamespace, $module) + { + return parent::getNamespace($appNamespace, $module) . '\controller'; + } + +} diff --git a/thinkphp/library/think/console/command/make/Model.php b/thinkphp/library/think/console/command/make/Model.php new file mode 100644 index 0000000..d4e9b5d --- /dev/null +++ b/thinkphp/library/think/console/command/make/Model.php @@ -0,0 +1,36 @@ + +// +---------------------------------------------------------------------- + +namespace think\console\command\make; + +use think\console\command\Make; + +class Model extends Make +{ + protected $type = "Model"; + + protected function configure() + { + parent::configure(); + $this->setName('make:model') + ->setDescription('Create a new model class'); + } + + protected function getStub() + { + return __DIR__ . '/stubs/model.stub'; + } + + protected function getNamespace($appNamespace, $module) + { + return parent::getNamespace($appNamespace, $module) . '\model'; + } +} diff --git a/thinkphp/library/think/console/command/make/stubs/controller.plain.stub b/thinkphp/library/think/console/command/make/stubs/controller.plain.stub new file mode 100644 index 0000000..b7539dc --- /dev/null +++ b/thinkphp/library/think/console/command/make/stubs/controller.plain.stub @@ -0,0 +1,10 @@ + +// +---------------------------------------------------------------------- +namespace think\console\command\optimize; + +use think\App; +use think\Config; +use think\console\Command; +use think\console\Input; +use think\console\Output; + +class Autoload extends Command +{ + + protected function configure() + { + $this->setName('optimize:autoload') + ->setDescription('Optimizes PSR0 and PSR4 packages to be loaded with classmaps too, good for production.'); + } + + protected function execute(Input $input, Output $output) + { + + $classmapFile = << realpath(rtrim(APP_PATH)), + 'think\\' => LIB_PATH . 'think', + 'behavior\\' => LIB_PATH . 'behavior', + 'traits\\' => LIB_PATH . 'traits', + '' => realpath(rtrim(EXTEND_PATH)), + ]; + + $root_namespace = Config::get('root_namespace'); + foreach ($root_namespace as $namespace => $dir) { + $namespacesToScan[$namespace . '\\'] = realpath($dir); + } + + krsort($namespacesToScan); + $classMap = []; + foreach ($namespacesToScan as $namespace => $dir) { + + if (!is_dir($dir)) { + continue; + } + + $namespaceFilter = $namespace === '' ? null : $namespace; + $classMap = $this->addClassMapCode($dir, $namespaceFilter, $classMap); + } + + ksort($classMap); + foreach ($classMap as $class => $code) { + $classmapFile .= ' ' . var_export($class, true) . ' => ' . $code; + } + $classmapFile .= "];\n"; + + if (!is_dir(RUNTIME_PATH)) { + @mkdir(RUNTIME_PATH, 0755, true); + } + + file_put_contents(RUNTIME_PATH . 'classmap' . EXT, $classmapFile); + + $output->writeln('Succeed!'); + } + + protected function addClassMapCode($dir, $namespace, $classMap) + { + foreach ($this->createMap($dir, $namespace) as $class => $path) { + + $pathCode = $this->getPathCode($path) . ",\n"; + + if (!isset($classMap[$class])) { + $classMap[$class] = $pathCode; + } elseif ($classMap[$class] !== $pathCode && !preg_match('{/(test|fixture|example|stub)s?/}i', strtr($classMap[$class] . ' ' . $path, '\\', '/'))) { + $this->output->writeln( + 'Warning: Ambiguous class resolution, "' . $class . '"' . + ' was found in both "' . str_replace(["',\n"], [ + '', + ], $classMap[$class]) . '" and "' . $path . '", the first will be used.' + ); + } + } + return $classMap; + } + + protected function getPathCode($path) + { + + $baseDir = ''; + $libPath = $this->normalizePath(realpath(LIB_PATH)); + $appPath = $this->normalizePath(realpath(APP_PATH)); + $extendPath = $this->normalizePath(realpath(EXTEND_PATH)); + $rootPath = $this->normalizePath(realpath(ROOT_PATH)); + $path = $this->normalizePath($path); + + if ($libPath !== null && strpos($path, $libPath . '/') === 0) { + $path = substr($path, strlen(LIB_PATH)); + $baseDir = 'LIB_PATH'; + } elseif ($appPath !== null && strpos($path, $appPath . '/') === 0) { + $path = substr($path, strlen($appPath) + 1); + $baseDir = 'APP_PATH'; + } elseif ($extendPath !== null && strpos($path, $extendPath . '/') === 0) { + $path = substr($path, strlen($extendPath) + 1); + $baseDir = 'EXTEND_PATH'; + } elseif ($rootPath !== null && strpos($path, $rootPath . '/') === 0) { + $path = substr($path, strlen($rootPath) + 1); + $baseDir = 'ROOT_PATH'; + } + + if ($path !== false) { + $baseDir .= " . "; + } + + return $baseDir . (($path !== false) ? var_export($path, true) : ""); + } + + protected function normalizePath($path) + { + if ($path === false) { + return; + } + $parts = []; + $path = strtr($path, '\\', '/'); + $prefix = ''; + $absolute = false; + + if (preg_match('{^([0-9a-z]+:(?://(?:[a-z]:)?)?)}i', $path, $match)) { + $prefix = $match[1]; + $path = substr($path, strlen($prefix)); + } + + if (substr($path, 0, 1) === '/') { + $absolute = true; + $path = substr($path, 1); + } + + $up = false; + foreach (explode('/', $path) as $chunk) { + if ('..' === $chunk && ($absolute || $up)) { + array_pop($parts); + $up = !(empty($parts) || '..' === end($parts)); + } elseif ('.' !== $chunk && '' !== $chunk) { + $parts[] = $chunk; + $up = '..' !== $chunk; + } + } + + return $prefix . ($absolute ? '/' : '') . implode('/', $parts); + } + + protected function createMap($path, $namespace = null) + { + if (is_string($path)) { + if (is_file($path)) { + $path = [new \SplFileInfo($path)]; + } elseif (is_dir($path)) { + + $objects = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path), \RecursiveIteratorIterator::SELF_FIRST); + + $path = []; + + /** @var \SplFileInfo $object */ + foreach ($objects as $object) { + if ($object->isFile() && $object->getExtension() == 'php') { + $path[] = $object; + } + } + } else { + throw new \RuntimeException( + 'Could not scan for classes inside "' . $path . + '" which does not appear to be a file nor a folder' + ); + } + } + + $map = []; + + /** @var \SplFileInfo $file */ + foreach ($path as $file) { + $filePath = $file->getRealPath(); + + if (pathinfo($filePath, PATHINFO_EXTENSION) != 'php') { + continue; + } + + $classes = $this->findClasses($filePath); + + foreach ($classes as $class) { + if (null !== $namespace && 0 !== strpos($class, $namespace)) { + continue; + } + + if (!isset($map[$class])) { + $map[$class] = $filePath; + } elseif ($map[$class] !== $filePath && !preg_match('{/(test|fixture|example|stub)s?/}i', strtr($map[$class] . ' ' . $filePath, '\\', '/'))) { + $this->output->writeln( + 'Warning: Ambiguous class resolution, "' . $class . '"' . + ' was found in both "' . $map[$class] . '" and "' . $filePath . '", the first will be used.' + ); + } + } + } + + return $map; + } + + protected function findClasses($path) + { + $extraTypes = '|trait'; + + $contents = @php_strip_whitespace($path); + if (!$contents) { + if (!file_exists($path)) { + $message = 'File at "%s" does not exist, check your classmap definitions'; + } elseif (!is_readable($path)) { + $message = 'File at "%s" is not readable, check its permissions'; + } elseif ('' === trim(file_get_contents($path))) { + return []; + } else { + $message = 'File at "%s" could not be parsed as PHP, it may be binary or corrupted'; + } + $error = error_get_last(); + if (isset($error['message'])) { + $message .= PHP_EOL . 'The following message may be helpful:' . PHP_EOL . $error['message']; + } + throw new \RuntimeException(sprintf($message, $path)); + } + + if (!preg_match('{\b(?:class|interface' . $extraTypes . ')\s}i', $contents)) { + return []; + } + + // strip heredocs/nowdocs + $contents = preg_replace('{<<<\s*(\'?)(\w+)\\1(?:\r\n|\n|\r)(?:.*?)(?:\r\n|\n|\r)\\2(?=\r\n|\n|\r|;)}s', 'null', $contents); + // strip strings + $contents = preg_replace('{"[^"\\\\]*+(\\\\.[^"\\\\]*+)*+"|\'[^\'\\\\]*+(\\\\.[^\'\\\\]*+)*+\'}s', 'null', $contents); + // strip leading non-php code if needed + if (substr($contents, 0, 2) !== '.+<\?}s', '?>'); + if (false !== $pos && false === strpos(substr($contents, $pos), '])(?Pclass|interface' . $extraTypes . ') \s++ (?P[a-zA-Z_\x7f-\xff:][a-zA-Z0-9_\x7f-\xff:\-]*+) + | \b(?])(?Pnamespace) (?P\s++[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*+(?:\s*+\\\\\s*+[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*+)*+)? \s*+ [\{;] + ) + }ix', $contents, $matches); + + $classes = []; + $namespace = ''; + + for ($i = 0, $len = count($matches['type']); $i < $len; $i++) { + if (!empty($matches['ns'][$i])) { + $namespace = str_replace([' ', "\t", "\r", "\n"], '', $matches['nsname'][$i]) . '\\'; + } else { + $name = $matches['name'][$i]; + if ($name[0] === ':') { + $name = 'xhp' . substr(str_replace(['-', ':'], ['_', '__'], $name), 1); + } elseif ($matches['type'][$i] === 'enum') { + $name = rtrim($name, ':'); + } + $classes[] = ltrim($namespace . $name, '\\'); + } + } + + return $classes; + } + +} diff --git a/thinkphp/library/think/console/command/optimize/Config.php b/thinkphp/library/think/console/command/optimize/Config.php new file mode 100644 index 0000000..59c69a8 --- /dev/null +++ b/thinkphp/library/think/console/command/optimize/Config.php @@ -0,0 +1,93 @@ + +// +---------------------------------------------------------------------- +namespace think\console\command\optimize; + +use think\Config as ThinkConfig; +use think\console\Command; +use think\console\Input; +use think\console\input\Argument; +use think\console\Output; + +class Config extends Command +{ + /** @var Output */ + protected $output; + + protected function configure() + { + $this->setName('optimize:config') + ->addArgument('module', Argument::OPTIONAL, 'Build module config cache .') + ->setDescription('Build config and common file cache.'); + } + + protected function execute(Input $input, Output $output) + { + if ($input->getArgument('module')) { + $module = $input->getArgument('module') . DS; + } else { + $module = ''; + } + + $content = 'buildCacheContent($module); + + if (!is_dir(RUNTIME_PATH . $module)) { + @mkdir(RUNTIME_PATH . $module, 0755, true); + } + + file_put_contents(RUNTIME_PATH . $module . 'init' . EXT, $content); + + $output->writeln('Succeed!'); + } + + protected function buildCacheContent($module) + { + $content = ''; + $path = realpath(APP_PATH . $module) . DS; + + if ($module) { + // 加载模块配置 + $config = ThinkConfig::load(CONF_PATH . $module . 'config' . CONF_EXT); + + // 读取数据库配置文件 + $filename = CONF_PATH . $module . 'database' . CONF_EXT; + ThinkConfig::load($filename, 'database'); + + // 加载应用状态配置 + if ($config['app_status']) { + $config = ThinkConfig::load(CONF_PATH . $module . $config['app_status'] . CONF_EXT); + } + // 读取扩展配置文件 + if (is_dir(CONF_PATH . $module . 'extra')) { + $dir = CONF_PATH . $module . 'extra'; + $files = scandir($dir); + foreach ($files as $file) { + if (strpos($file, CONF_EXT)) { + $filename = $dir . DS . $file; + ThinkConfig::load($filename, pathinfo($file, PATHINFO_FILENAME)); + } + } + } + } + + // 加载行为扩展文件 + if (is_file(CONF_PATH . $module . 'tags' . EXT)) { + $content .= '\think\Hook::import(' . (var_export(include CONF_PATH . $module . 'tags' . EXT, true)) . ');' . PHP_EOL; + } + + // 加载公共文件 + if (is_file($path . 'common' . EXT)) { + $content .= substr(php_strip_whitespace($path . 'common' . EXT), 5) . PHP_EOL; + } + + $content .= '\think\Config::set(' . var_export(ThinkConfig::get(), true) . ');'; + return $content; + } +} diff --git a/thinkphp/library/think/console/command/optimize/Route.php b/thinkphp/library/think/console/command/optimize/Route.php new file mode 100644 index 0000000..6da1d9a --- /dev/null +++ b/thinkphp/library/think/console/command/optimize/Route.php @@ -0,0 +1,75 @@ + +// +---------------------------------------------------------------------- +namespace think\console\command\optimize; + +use think\console\Command; +use think\console\Input; +use think\console\Output; + +class Route extends Command +{ + /** @var Output */ + protected $output; + + protected function configure() + { + $this->setName('optimize:route') + ->setDescription('Build route cache.'); + } + + protected function execute(Input $input, Output $output) + { + + if (!is_dir(RUNTIME_PATH)) { + @mkdir(RUNTIME_PATH, 0755, true); + } + + file_put_contents(RUNTIME_PATH . 'route.php', $this->buildRouteCache()); + $output->writeln('Succeed!'); + } + + protected function buildRouteCache() + { + $files = \think\Config::get('route_config_file'); + foreach ($files as $file) { + if (is_file(CONF_PATH . $file . CONF_EXT)) { + $config = include CONF_PATH . $file . CONF_EXT; + if (is_array($config)) { + \think\Route::import($config); + } + } + } + $rules = \think\Route::rules(true); + array_walk_recursive($rules, [$this, 'buildClosure']); + $content = 'getStartLine(); + $endLine = $reflection->getEndLine(); + $file = $reflection->getFileName(); + $item = file($file); + $content = ''; + for ($i = $startLine - 1; $i <= $endLine - 1; $i++) { + $content .= $item[$i]; + } + $start = strpos($content, 'function'); + $end = strrpos($content, '}'); + $value = '[__start__' . substr($content, $start, $end - $start + 1) . '__end__]'; + } + } +} diff --git a/thinkphp/library/think/console/command/optimize/Schema.php b/thinkphp/library/think/console/command/optimize/Schema.php new file mode 100644 index 0000000..3353424 --- /dev/null +++ b/thinkphp/library/think/console/command/optimize/Schema.php @@ -0,0 +1,118 @@ + +// +---------------------------------------------------------------------- +namespace think\console\command\optimize; + +use think\App; +use think\console\Command; +use think\console\Input; +use think\console\input\Option; +use think\console\Output; +use think\Db; + +class Schema extends Command +{ + /** @var Output */ + protected $output; + + protected function configure() + { + $this->setName('optimize:schema') + ->addOption('config', null, Option::VALUE_REQUIRED, 'db config .') + ->addOption('db', null, Option::VALUE_REQUIRED, 'db name .') + ->addOption('table', null, Option::VALUE_REQUIRED, 'table name .') + ->addOption('module', null, Option::VALUE_REQUIRED, 'module name .') + ->setDescription('Build database schema cache.'); + } + + protected function execute(Input $input, Output $output) + { + if (!is_dir(RUNTIME_PATH . 'schema')) { + @mkdir(RUNTIME_PATH . 'schema', 0755, true); + } + $config = []; + if ($input->hasOption('config')) { + $config = $input->getOption('config'); + } + if ($input->hasOption('module')) { + $module = $input->getOption('module'); + // 读取模型 + $path = APP_PATH . $module . DS . 'model'; + $list = is_dir($path) ? scandir($path) : []; + $app = App::$namespace; + foreach ($list as $file) { + if (0 === strpos($file, '.')) { + continue; + } + $class = '\\' . $app . '\\' . $module . '\\model\\' . pathinfo($file, PATHINFO_FILENAME); + $this->buildModelSchema($class); + } + $output->writeln('Succeed!'); + return; + } elseif ($input->hasOption('table')) { + $table = $input->getOption('table'); + if (!strpos($table, '.')) { + $dbName = Db::connect($config)->getConfig('database'); + } + $tables[] = $table; + } elseif ($input->hasOption('db')) { + $dbName = $input->getOption('db'); + $tables = Db::connect($config)->getTables($dbName); + } elseif (!\think\Config::get('app_multi_module')) { + $app = App::$namespace; + $path = APP_PATH . 'model'; + $list = is_dir($path) ? scandir($path) : []; + foreach ($list as $file) { + if (0 === strpos($file, '.')) { + continue; + } + $class = '\\' . $app . '\\model\\' . pathinfo($file, PATHINFO_FILENAME); + $this->buildModelSchema($class); + } + $output->writeln('Succeed!'); + return; + } else { + $tables = Db::connect($config)->getTables(); + } + + $db = isset($dbName) ? $dbName . '.' : ''; + $this->buildDataBaseSchema($tables, $db, $config); + + $output->writeln('Succeed!'); + } + + protected function buildModelSchema($class) + { + $reflect = new \ReflectionClass($class); + if (!$reflect->isAbstract() && $reflect->isSubclassOf('\think\Model')) { + $table = $class::getTable(); + $dbName = $class::getConfig('database'); + $content = 'getFields($table); + $content .= var_export($info, true) . ';'; + file_put_contents(RUNTIME_PATH . 'schema' . DS . $dbName . '.' . $table . EXT, $content); + } + } + + protected function buildDataBaseSchema($tables, $db, $config) + { + if ('' == $db) { + $dbName = Db::connect($config)->getConfig('database') . '.'; + } else { + $dbName = $db; + } + foreach ($tables as $table) { + $content = 'getFields($db . $table); + $content .= var_export($info, true) . ';'; + file_put_contents(RUNTIME_PATH . 'schema' . DS . $dbName . $table . EXT, $content); + } + } +} diff --git a/thinkphp/library/think/console/input/Argument.php b/thinkphp/library/think/console/input/Argument.php new file mode 100644 index 0000000..16223bb --- /dev/null +++ b/thinkphp/library/think/console/input/Argument.php @@ -0,0 +1,115 @@ + +// +---------------------------------------------------------------------- + +namespace think\console\input; + +class Argument +{ + + const REQUIRED = 1; + const OPTIONAL = 2; + const IS_ARRAY = 4; + + private $name; + private $mode; + private $default; + private $description; + + /** + * 构造方法 + * @param string $name 参数名 + * @param int $mode 参数类型: self::REQUIRED 或者 self::OPTIONAL + * @param string $description 描述 + * @param mixed $default 默认值 (仅 self::OPTIONAL 类型有效) + * @throws \InvalidArgumentException + */ + public function __construct($name, $mode = null, $description = '', $default = null) + { + if (null === $mode) { + $mode = self::OPTIONAL; + } elseif (!is_int($mode) || $mode > 7 || $mode < 1) { + throw new \InvalidArgumentException(sprintf('Argument mode "%s" is not valid.', $mode)); + } + + $this->name = $name; + $this->mode = $mode; + $this->description = $description; + + $this->setDefault($default); + } + + /** + * 获取参数名 + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * 是否必须 + * @return bool + */ + public function isRequired() + { + return self::REQUIRED === (self::REQUIRED & $this->mode); + } + + /** + * 该参数是否接受数组 + * @return bool + */ + public function isArray() + { + return self::IS_ARRAY === (self::IS_ARRAY & $this->mode); + } + + /** + * 设置默认值 + * @param mixed $default 默认值 + * @throws \LogicException + */ + public function setDefault($default = null) + { + if (self::REQUIRED === $this->mode && null !== $default) { + throw new \LogicException('Cannot set a default value except for InputArgument::OPTIONAL mode.'); + } + + if ($this->isArray()) { + if (null === $default) { + $default = []; + } elseif (!is_array($default)) { + throw new \LogicException('A default value for an array argument must be an array.'); + } + } + + $this->default = $default; + } + + /** + * 获取默认值 + * @return mixed + */ + public function getDefault() + { + return $this->default; + } + + /** + * 获取描述 + * @return string + */ + public function getDescription() + { + return $this->description; + } +} diff --git a/thinkphp/library/think/console/input/Definition.php b/thinkphp/library/think/console/input/Definition.php new file mode 100644 index 0000000..c71977e --- /dev/null +++ b/thinkphp/library/think/console/input/Definition.php @@ -0,0 +1,375 @@ + +// +---------------------------------------------------------------------- + +namespace think\console\input; + +class Definition +{ + + /** + * @var Argument[] + */ + private $arguments; + + private $requiredCount; + private $hasAnArrayArgument = false; + private $hasOptional; + + /** + * @var Option[] + */ + private $options; + private $shortcuts; + + /** + * 构造方法 + * @param array $definition + * @api + */ + public function __construct(array $definition = []) + { + $this->setDefinition($definition); + } + + /** + * 设置指令的定义 + * @param array $definition 定义的数组 + */ + public function setDefinition(array $definition) + { + $arguments = []; + $options = []; + foreach ($definition as $item) { + if ($item instanceof Option) { + $options[] = $item; + } else { + $arguments[] = $item; + } + } + + $this->setArguments($arguments); + $this->setOptions($options); + } + + /** + * 设置参数 + * @param Argument[] $arguments 参数数组 + */ + public function setArguments($arguments = []) + { + $this->arguments = []; + $this->requiredCount = 0; + $this->hasOptional = false; + $this->hasAnArrayArgument = false; + $this->addArguments($arguments); + } + + /** + * 添加参数 + * @param Argument[] $arguments 参数数组 + * @api + */ + public function addArguments($arguments = []) + { + if (null !== $arguments) { + foreach ($arguments as $argument) { + $this->addArgument($argument); + } + } + } + + /** + * 添加一个参数 + * @param Argument $argument 参数 + * @throws \LogicException + */ + public function addArgument(Argument $argument) + { + if (isset($this->arguments[$argument->getName()])) { + throw new \LogicException(sprintf('An argument with name "%s" already exists.', $argument->getName())); + } + + if ($this->hasAnArrayArgument) { + throw new \LogicException('Cannot add an argument after an array argument.'); + } + + if ($argument->isRequired() && $this->hasOptional) { + throw new \LogicException('Cannot add a required argument after an optional one.'); + } + + if ($argument->isArray()) { + $this->hasAnArrayArgument = true; + } + + if ($argument->isRequired()) { + ++$this->requiredCount; + } else { + $this->hasOptional = true; + } + + $this->arguments[$argument->getName()] = $argument; + } + + /** + * 根据名称或者位置获取参数 + * @param string|int $name 参数名或者位置 + * @return Argument 参数 + * @throws \InvalidArgumentException + */ + public function getArgument($name) + { + if (!$this->hasArgument($name)) { + throw new \InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name)); + } + + $arguments = is_int($name) ? array_values($this->arguments) : $this->arguments; + + return $arguments[$name]; + } + + /** + * 根据名称或位置检查是否具有某个参数 + * @param string|int $name 参数名或者位置 + * @return bool + * @api + */ + public function hasArgument($name) + { + $arguments = is_int($name) ? array_values($this->arguments) : $this->arguments; + + return isset($arguments[$name]); + } + + /** + * 获取所有的参数 + * @return Argument[] 参数数组 + */ + public function getArguments() + { + return $this->arguments; + } + + /** + * 获取参数数量 + * @return int + */ + public function getArgumentCount() + { + return $this->hasAnArrayArgument ? PHP_INT_MAX : count($this->arguments); + } + + /** + * 获取必填的参数的数量 + * @return int + */ + public function getArgumentRequiredCount() + { + return $this->requiredCount; + } + + /** + * 获取参数默认值 + * @return array + */ + public function getArgumentDefaults() + { + $values = []; + foreach ($this->arguments as $argument) { + $values[$argument->getName()] = $argument->getDefault(); + } + + return $values; + } + + /** + * 设置选项 + * @param Option[] $options 选项数组 + */ + public function setOptions($options = []) + { + $this->options = []; + $this->shortcuts = []; + $this->addOptions($options); + } + + /** + * 添加选项 + * @param Option[] $options 选项数组 + * @api + */ + public function addOptions($options = []) + { + foreach ($options as $option) { + $this->addOption($option); + } + } + + /** + * 添加一个选项 + * @param Option $option 选项 + * @throws \LogicException + * @api + */ + public function addOption(Option $option) + { + if (isset($this->options[$option->getName()]) && !$option->equals($this->options[$option->getName()])) { + throw new \LogicException(sprintf('An option named "%s" already exists.', $option->getName())); + } + + if ($option->getShortcut()) { + foreach (explode('|', $option->getShortcut()) as $shortcut) { + if (isset($this->shortcuts[$shortcut]) + && !$option->equals($this->options[$this->shortcuts[$shortcut]]) + ) { + throw new \LogicException(sprintf('An option with shortcut "%s" already exists.', $shortcut)); + } + } + } + + $this->options[$option->getName()] = $option; + if ($option->getShortcut()) { + foreach (explode('|', $option->getShortcut()) as $shortcut) { + $this->shortcuts[$shortcut] = $option->getName(); + } + } + } + + /** + * 根据名称获取选项 + * @param string $name 选项名 + * @return Option + * @throws \InvalidArgumentException + * @api + */ + public function getOption($name) + { + if (!$this->hasOption($name)) { + throw new \InvalidArgumentException(sprintf('The "--%s" option does not exist.', $name)); + } + + return $this->options[$name]; + } + + /** + * 根据名称检查是否有这个选项 + * @param string $name 选项名 + * @return bool + * @api + */ + public function hasOption($name) + { + return isset($this->options[$name]); + } + + /** + * 获取所有选项 + * @return Option[] + * @api + */ + public function getOptions() + { + return $this->options; + } + + /** + * 根据名称检查某个选项是否有短名称 + * @param string $name 短名称 + * @return bool + */ + public function hasShortcut($name) + { + return isset($this->shortcuts[$name]); + } + + /** + * 根据短名称获取选项 + * @param string $shortcut 短名称 + * @return Option + */ + public function getOptionForShortcut($shortcut) + { + return $this->getOption($this->shortcutToName($shortcut)); + } + + /** + * 获取所有选项的默认值 + * @return array + */ + public function getOptionDefaults() + { + $values = []; + foreach ($this->options as $option) { + $values[$option->getName()] = $option->getDefault(); + } + + return $values; + } + + /** + * 根据短名称获取选项名 + * @param string $shortcut 短名称 + * @return string + * @throws \InvalidArgumentException + */ + private function shortcutToName($shortcut) + { + if (!isset($this->shortcuts[$shortcut])) { + throw new \InvalidArgumentException(sprintf('The "-%s" option does not exist.', $shortcut)); + } + + return $this->shortcuts[$shortcut]; + } + + /** + * 获取该指令的介绍 + * @param bool $short 是否简洁介绍 + * @return string + */ + public function getSynopsis($short = false) + { + $elements = []; + + if ($short && $this->getOptions()) { + $elements[] = '[options]'; + } elseif (!$short) { + foreach ($this->getOptions() as $option) { + $value = ''; + if ($option->acceptValue()) { + $value = sprintf(' %s%s%s', $option->isValueOptional() ? '[' : '', strtoupper($option->getName()), $option->isValueOptional() ? ']' : ''); + } + + $shortcut = $option->getShortcut() ? sprintf('-%s|', $option->getShortcut()) : ''; + $elements[] = sprintf('[%s--%s%s]', $shortcut, $option->getName(), $value); + } + } + + if (count($elements) && $this->getArguments()) { + $elements[] = '[--]'; + } + + foreach ($this->getArguments() as $argument) { + $element = '<' . $argument->getName() . '>'; + if (!$argument->isRequired()) { + $element = '[' . $element . ']'; + } elseif ($argument->isArray()) { + $element .= ' (' . $element . ')'; + } + + if ($argument->isArray()) { + $element .= '...'; + } + + $elements[] = $element; + } + + return implode(' ', $elements); + } +} diff --git a/thinkphp/library/think/console/input/Option.php b/thinkphp/library/think/console/input/Option.php new file mode 100644 index 0000000..e5707c9 --- /dev/null +++ b/thinkphp/library/think/console/input/Option.php @@ -0,0 +1,190 @@ + +// +---------------------------------------------------------------------- + +namespace think\console\input; + +class Option +{ + + const VALUE_NONE = 1; + const VALUE_REQUIRED = 2; + const VALUE_OPTIONAL = 4; + const VALUE_IS_ARRAY = 8; + + private $name; + private $shortcut; + private $mode; + private $default; + private $description; + + /** + * 构造方法 + * @param string $name 选项名 + * @param string|array $shortcut 短名称,多个用|隔开或者使用数组 + * @param int $mode 选项类型(可选类型为 self::VALUE_*) + * @param string $description 描述 + * @param mixed $default 默认值 (类型为 self::VALUE_REQUIRED 或者 self::VALUE_NONE 的时候必须为null) + * @throws \InvalidArgumentException + */ + public function __construct($name, $shortcut = null, $mode = null, $description = '', $default = null) + { + if (0 === strpos($name, '--')) { + $name = substr($name, 2); + } + + if (empty($name)) { + throw new \InvalidArgumentException('An option name cannot be empty.'); + } + + if (empty($shortcut)) { + $shortcut = null; + } + + if (null !== $shortcut) { + if (is_array($shortcut)) { + $shortcut = implode('|', $shortcut); + } + $shortcuts = preg_split('{(\|)-?}', ltrim($shortcut, '-')); + $shortcuts = array_filter($shortcuts); + $shortcut = implode('|', $shortcuts); + + if (empty($shortcut)) { + throw new \InvalidArgumentException('An option shortcut cannot be empty.'); + } + } + + if (null === $mode) { + $mode = self::VALUE_NONE; + } elseif (!is_int($mode) || $mode > 15 || $mode < 1) { + throw new \InvalidArgumentException(sprintf('Option mode "%s" is not valid.', $mode)); + } + + $this->name = $name; + $this->shortcut = $shortcut; + $this->mode = $mode; + $this->description = $description; + + if ($this->isArray() && !$this->acceptValue()) { + throw new \InvalidArgumentException('Impossible to have an option mode VALUE_IS_ARRAY if the option does not accept a value.'); + } + + $this->setDefault($default); + } + + /** + * 获取短名称 + * @return string + */ + public function getShortcut() + { + return $this->shortcut; + } + + /** + * 获取选项名 + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * 是否可以设置值 + * @return bool 类型不是 self::VALUE_NONE 的时候返回true,其他均返回false + */ + public function acceptValue() + { + return $this->isValueRequired() || $this->isValueOptional(); + } + + /** + * 是否必须 + * @return bool 类型是 self::VALUE_REQUIRED 的时候返回true,其他均返回false + */ + public function isValueRequired() + { + return self::VALUE_REQUIRED === (self::VALUE_REQUIRED & $this->mode); + } + + /** + * 是否可选 + * @return bool 类型是 self::VALUE_OPTIONAL 的时候返回true,其他均返回false + */ + public function isValueOptional() + { + return self::VALUE_OPTIONAL === (self::VALUE_OPTIONAL & $this->mode); + } + + /** + * 选项值是否接受数组 + * @return bool 类型是 self::VALUE_IS_ARRAY 的时候返回true,其他均返回false + */ + public function isArray() + { + return self::VALUE_IS_ARRAY === (self::VALUE_IS_ARRAY & $this->mode); + } + + /** + * 设置默认值 + * @param mixed $default 默认值 + * @throws \LogicException + */ + public function setDefault($default = null) + { + if (self::VALUE_NONE === (self::VALUE_NONE & $this->mode) && null !== $default) { + throw new \LogicException('Cannot set a default value when using InputOption::VALUE_NONE mode.'); + } + + if ($this->isArray()) { + if (null === $default) { + $default = []; + } elseif (!is_array($default)) { + throw new \LogicException('A default value for an array option must be an array.'); + } + } + + $this->default = $this->acceptValue() ? $default : false; + } + + /** + * 获取默认值 + * @return mixed + */ + public function getDefault() + { + return $this->default; + } + + /** + * 获取描述文字 + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * 检查所给选项是否是当前这个 + * @param Option $option + * @return bool + */ + public function equals(Option $option) + { + return $option->getName() === $this->getName() + && $option->getShortcut() === $this->getShortcut() + && $option->getDefault() === $this->getDefault() + && $option->isArray() === $this->isArray() + && $option->isValueRequired() === $this->isValueRequired() + && $option->isValueOptional() === $this->isValueOptional(); + } +} diff --git a/thinkphp/library/think/console/output/Ask.php b/thinkphp/library/think/console/output/Ask.php new file mode 100644 index 0000000..7304af9 --- /dev/null +++ b/thinkphp/library/think/console/output/Ask.php @@ -0,0 +1,340 @@ + +// +---------------------------------------------------------------------- + +namespace think\console\output; + +use think\console\Input; +use think\console\Output; +use think\console\output\question\Choice; +use think\console\output\question\Confirmation; + +class Ask +{ + private static $stty; + + private static $shell; + + /** @var Input */ + protected $input; + + /** @var Output */ + protected $output; + + /** @var Question */ + protected $question; + + public function __construct(Input $input, Output $output, Question $question) + { + $this->input = $input; + $this->output = $output; + $this->question = $question; + } + + public function run() + { + if (!$this->input->isInteractive()) { + return $this->question->getDefault(); + } + + if (!$this->question->getValidator()) { + return $this->doAsk(); + } + + $that = $this; + + $interviewer = function () use ($that) { + return $that->doAsk(); + }; + + return $this->validateAttempts($interviewer); + } + + protected function doAsk() + { + $this->writePrompt(); + + $inputStream = STDIN; + $autocomplete = $this->question->getAutocompleterValues(); + + if (null === $autocomplete || !$this->hasSttyAvailable()) { + $ret = false; + if ($this->question->isHidden()) { + try { + $ret = trim($this->getHiddenResponse($inputStream)); + } catch (\RuntimeException $e) { + if (!$this->question->isHiddenFallback()) { + throw $e; + } + } + } + + if (false === $ret) { + $ret = fgets($inputStream, 4096); + if (false === $ret) { + throw new \RuntimeException('Aborted'); + } + $ret = trim($ret); + } + } else { + $ret = trim($this->autocomplete($inputStream)); + } + + $ret = strlen($ret) > 0 ? $ret : $this->question->getDefault(); + + if ($normalizer = $this->question->getNormalizer()) { + return $normalizer($ret); + } + + return $ret; + } + + private function autocomplete($inputStream) + { + $autocomplete = $this->question->getAutocompleterValues(); + $ret = ''; + + $i = 0; + $ofs = -1; + $matches = $autocomplete; + $numMatches = count($matches); + + $sttyMode = shell_exec('stty -g'); + + shell_exec('stty -icanon -echo'); + + while (!feof($inputStream)) { + $c = fread($inputStream, 1); + + if ("\177" === $c) { + if (0 === $numMatches && 0 !== $i) { + --$i; + $this->output->write("\033[1D"); + } + + if ($i === 0) { + $ofs = -1; + $matches = $autocomplete; + $numMatches = count($matches); + } else { + $numMatches = 0; + } + + $ret = substr($ret, 0, $i); + } elseif ("\033" === $c) { + $c .= fread($inputStream, 2); + + if (isset($c[2]) && ('A' === $c[2] || 'B' === $c[2])) { + if ('A' === $c[2] && -1 === $ofs) { + $ofs = 0; + } + + if (0 === $numMatches) { + continue; + } + + $ofs += ('A' === $c[2]) ? -1 : 1; + $ofs = ($numMatches + $ofs) % $numMatches; + } + } elseif (ord($c) < 32) { + if ("\t" === $c || "\n" === $c) { + if ($numMatches > 0 && -1 !== $ofs) { + $ret = $matches[$ofs]; + $this->output->write(substr($ret, $i)); + $i = strlen($ret); + } + + if ("\n" === $c) { + $this->output->write($c); + break; + } + + $numMatches = 0; + } + + continue; + } else { + $this->output->write($c); + $ret .= $c; + ++$i; + + $numMatches = 0; + $ofs = 0; + + foreach ($autocomplete as $value) { + if (0 === strpos($value, $ret) && $i !== strlen($value)) { + $matches[$numMatches++] = $value; + } + } + } + + $this->output->write("\033[K"); + + if ($numMatches > 0 && -1 !== $ofs) { + $this->output->write("\0337"); + $this->output->highlight(substr($matches[$ofs], $i)); + $this->output->write("\0338"); + } + } + + shell_exec(sprintf('stty %s', $sttyMode)); + + return $ret; + } + + protected function getHiddenResponse($inputStream) + { + if ('\\' === DIRECTORY_SEPARATOR) { + $exe = __DIR__ . '/../bin/hiddeninput.exe'; + + $value = rtrim(shell_exec($exe)); + $this->output->writeln(''); + + if (isset($tmpExe)) { + unlink($tmpExe); + } + + return $value; + } + + if ($this->hasSttyAvailable()) { + $sttyMode = shell_exec('stty -g'); + + shell_exec('stty -echo'); + $value = fgets($inputStream, 4096); + shell_exec(sprintf('stty %s', $sttyMode)); + + if (false === $value) { + throw new \RuntimeException('Aborted'); + } + + $value = trim($value); + $this->output->writeln(''); + + return $value; + } + + if (false !== $shell = $this->getShell()) { + $readCmd = $shell === 'csh' ? 'set mypassword = $<' : 'read -r mypassword'; + $command = sprintf("/usr/bin/env %s -c 'stty -echo; %s; stty echo; echo \$mypassword'", $shell, $readCmd); + $value = rtrim(shell_exec($command)); + $this->output->writeln(''); + + return $value; + } + + throw new \RuntimeException('Unable to hide the response.'); + } + + protected function validateAttempts($interviewer) + { + /** @var \Exception $error */ + $error = null; + $attempts = $this->question->getMaxAttempts(); + while (null === $attempts || $attempts--) { + if (null !== $error) { + $this->output->error($error->getMessage()); + } + + try { + return call_user_func($this->question->getValidator(), $interviewer()); + } catch (\Exception $error) { + } + } + + throw $error; + } + + /** + * 显示问题的提示信息 + */ + protected function writePrompt() + { + $text = $this->question->getQuestion(); + $default = $this->question->getDefault(); + + switch (true) { + case null === $default: + $text = sprintf(' %s:', $text); + + break; + + case $this->question instanceof Confirmation: + $text = sprintf(' %s (yes/no) [%s]:', $text, $default ? 'yes' : 'no'); + + break; + + case $this->question instanceof Choice && $this->question->isMultiselect(): + $choices = $this->question->getChoices(); + $default = explode(',', $default); + + foreach ($default as $key => $value) { + $default[$key] = $choices[trim($value)]; + } + + $text = sprintf(' %s [%s]:', $text, implode(', ', $default)); + + break; + + case $this->question instanceof Choice: + $choices = $this->question->getChoices(); + $text = sprintf(' %s [%s]:', $text, $choices[$default]); + + break; + + default: + $text = sprintf(' %s [%s]:', $text, $default); + } + + $this->output->writeln($text); + + if ($this->question instanceof Choice) { + $width = max(array_map('strlen', array_keys($this->question->getChoices()))); + + foreach ($this->question->getChoices() as $key => $value) { + $this->output->writeln(sprintf(" [%-{$width}s] %s", $key, $value)); + } + } + + $this->output->write(' > '); + } + + private function getShell() + { + if (null !== self::$shell) { + return self::$shell; + } + + self::$shell = false; + + if (file_exists('/usr/bin/env')) { + $test = "/usr/bin/env %s -c 'echo OK' 2> /dev/null"; + foreach (['bash', 'zsh', 'ksh', 'csh'] as $sh) { + if ('OK' === rtrim(shell_exec(sprintf($test, $sh)))) { + self::$shell = $sh; + break; + } + } + } + + return self::$shell; + } + + private function hasSttyAvailable() + { + if (null !== self::$stty) { + return self::$stty; + } + + exec('stty 2>&1', $output, $exitcode); + + return self::$stty = $exitcode === 0; + } +} diff --git a/thinkphp/library/think/console/output/Descriptor.php b/thinkphp/library/think/console/output/Descriptor.php new file mode 100644 index 0000000..c2e38cf --- /dev/null +++ b/thinkphp/library/think/console/output/Descriptor.php @@ -0,0 +1,319 @@ + +// +---------------------------------------------------------------------- + +namespace think\console\output; + +use think\Console; +use think\console\Command; +use think\console\input\Argument as InputArgument; +use think\console\input\Definition as InputDefinition; +use think\console\input\Option as InputOption; +use think\console\Output; +use think\console\output\descriptor\Console as ConsoleDescription; + +class Descriptor +{ + + /** + * @var Output + */ + protected $output; + + /** + * {@inheritdoc} + */ + public function describe(Output $output, $object, array $options = []) + { + $this->output = $output; + + switch (true) { + case $object instanceof InputArgument: + $this->describeInputArgument($object, $options); + break; + case $object instanceof InputOption: + $this->describeInputOption($object, $options); + break; + case $object instanceof InputDefinition: + $this->describeInputDefinition($object, $options); + break; + case $object instanceof Command: + $this->describeCommand($object, $options); + break; + case $object instanceof Console: + $this->describeConsole($object, $options); + break; + default: + throw new \InvalidArgumentException(sprintf('Object of type "%s" is not describable.', get_class($object))); + } + } + + /** + * 输出内容 + * @param string $content + * @param bool $decorated + */ + protected function write($content, $decorated = false) + { + $this->output->write($content, false, $decorated ? Output::OUTPUT_NORMAL : Output::OUTPUT_RAW); + } + + /** + * 描述参数 + * @param InputArgument $argument + * @param array $options + * @return void + */ + protected function describeInputArgument(InputArgument $argument, array $options = []) + { + if (null !== $argument->getDefault() + && (!is_array($argument->getDefault()) + || count($argument->getDefault())) + ) { + $default = sprintf(' [default: %s]', $this->formatDefaultValue($argument->getDefault())); + } else { + $default = ''; + } + + $totalWidth = isset($options['total_width']) ? $options['total_width'] : strlen($argument->getName()); + $spacingWidth = $totalWidth - strlen($argument->getName()) + 2; + + $this->writeText(sprintf(" %s%s%s%s", $argument->getName(), str_repeat(' ', $spacingWidth), // + 17 = 2 spaces + + + 2 spaces + preg_replace('/\s*\R\s*/', PHP_EOL . str_repeat(' ', $totalWidth + 17), $argument->getDescription()), $default), $options); + } + + /** + * 描述选项 + * @param InputOption $option + * @param array $options + * @return void + */ + protected function describeInputOption(InputOption $option, array $options = []) + { + if ($option->acceptValue() && null !== $option->getDefault() + && (!is_array($option->getDefault()) + || count($option->getDefault())) + ) { + $default = sprintf(' [default: %s]', $this->formatDefaultValue($option->getDefault())); + } else { + $default = ''; + } + + $value = ''; + if ($option->acceptValue()) { + $value = '=' . strtoupper($option->getName()); + + if ($option->isValueOptional()) { + $value = '[' . $value . ']'; + } + } + + $totalWidth = isset($options['total_width']) ? $options['total_width'] : $this->calculateTotalWidthForOptions([$option]); + $synopsis = sprintf('%s%s', $option->getShortcut() ? sprintf('-%s, ', $option->getShortcut()) : ' ', sprintf('--%s%s', $option->getName(), $value)); + + $spacingWidth = $totalWidth - strlen($synopsis) + 2; + + $this->writeText(sprintf(" %s%s%s%s%s", $synopsis, str_repeat(' ', $spacingWidth), // + 17 = 2 spaces + + + 2 spaces + preg_replace('/\s*\R\s*/', "\n" . str_repeat(' ', $totalWidth + 17), $option->getDescription()), $default, $option->isArray() ? ' (multiple values allowed)' : ''), $options); + } + + /** + * 描述输入 + * @param InputDefinition $definition + * @param array $options + * @return void + */ + protected function describeInputDefinition(InputDefinition $definition, array $options = []) + { + $totalWidth = $this->calculateTotalWidthForOptions($definition->getOptions()); + foreach ($definition->getArguments() as $argument) { + $totalWidth = max($totalWidth, strlen($argument->getName())); + } + + if ($definition->getArguments()) { + $this->writeText('Arguments:', $options); + $this->writeText("\n"); + foreach ($definition->getArguments() as $argument) { + $this->describeInputArgument($argument, array_merge($options, ['total_width' => $totalWidth])); + $this->writeText("\n"); + } + } + + if ($definition->getArguments() && $definition->getOptions()) { + $this->writeText("\n"); + } + + if ($definition->getOptions()) { + $laterOptions = []; + + $this->writeText('Options:', $options); + foreach ($definition->getOptions() as $option) { + if ($option->getShortcut() && strlen($option->getShortcut()) > 1) { + $laterOptions[] = $option; + continue; + } + $this->writeText("\n"); + $this->describeInputOption($option, array_merge($options, ['total_width' => $totalWidth])); + } + foreach ($laterOptions as $option) { + $this->writeText("\n"); + $this->describeInputOption($option, array_merge($options, ['total_width' => $totalWidth])); + } + } + } + + /** + * 描述指令 + * @param Command $command + * @param array $options + * @return void + */ + protected function describeCommand(Command $command, array $options = []) + { + $command->getSynopsis(true); + $command->getSynopsis(false); + $command->mergeConsoleDefinition(false); + + $this->writeText('Usage:', $options); + foreach (array_merge([$command->getSynopsis(true)], $command->getAliases(), $command->getUsages()) as $usage) { + $this->writeText("\n"); + $this->writeText(' ' . $usage, $options); + } + $this->writeText("\n"); + + $definition = $command->getNativeDefinition(); + if ($definition->getOptions() || $definition->getArguments()) { + $this->writeText("\n"); + $this->describeInputDefinition($definition, $options); + $this->writeText("\n"); + } + + if ($help = $command->getProcessedHelp()) { + $this->writeText("\n"); + $this->writeText('Help:', $options); + $this->writeText("\n"); + $this->writeText(' ' . str_replace("\n", "\n ", $help), $options); + $this->writeText("\n"); + } + } + + /** + * 描述控制台 + * @param Console $console + * @param array $options + * @return void + */ + protected function describeConsole(Console $console, array $options = []) + { + $describedNamespace = isset($options['namespace']) ? $options['namespace'] : null; + $description = new ConsoleDescription($console, $describedNamespace); + + if (isset($options['raw_text']) && $options['raw_text']) { + $width = $this->getColumnWidth($description->getCommands()); + + foreach ($description->getCommands() as $command) { + $this->writeText(sprintf("%-{$width}s %s", $command->getName(), $command->getDescription()), $options); + $this->writeText("\n"); + } + } else { + if ('' != $help = $console->getHelp()) { + $this->writeText("$help\n\n", $options); + } + + $this->writeText("Usage:\n", $options); + $this->writeText(" command [options] [arguments]\n\n", $options); + + $this->describeInputDefinition(new InputDefinition($console->getDefinition()->getOptions()), $options); + + $this->writeText("\n"); + $this->writeText("\n"); + + $width = $this->getColumnWidth($description->getCommands()); + + if ($describedNamespace) { + $this->writeText(sprintf('Available commands for the "%s" namespace:', $describedNamespace), $options); + } else { + $this->writeText('Available commands:', $options); + } + + // add commands by namespace + foreach ($description->getNamespaces() as $namespace) { + if (!$describedNamespace && ConsoleDescription::GLOBAL_NAMESPACE !== $namespace['id']) { + $this->writeText("\n"); + $this->writeText(' ' . $namespace['id'] . '', $options); + } + + foreach ($namespace['commands'] as $name) { + $this->writeText("\n"); + $spacingWidth = $width - strlen($name); + $this->writeText(sprintf(" %s%s%s", $name, str_repeat(' ', $spacingWidth), $description->getCommand($name) + ->getDescription()), $options); + } + } + + $this->writeText("\n"); + } + } + + /** + * {@inheritdoc} + */ + private function writeText($content, array $options = []) + { + $this->write(isset($options['raw_text']) + && $options['raw_text'] ? strip_tags($content) : $content, isset($options['raw_output']) ? !$options['raw_output'] : true); + } + + /** + * 格式化 + * @param mixed $default + * @return string + */ + private function formatDefaultValue($default) + { + return json_encode($default, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); + } + + /** + * @param Command[] $commands + * @return int + */ + private function getColumnWidth(array $commands) + { + $width = 0; + foreach ($commands as $command) { + $width = strlen($command->getName()) > $width ? strlen($command->getName()) : $width; + } + + return $width + 2; + } + + /** + * @param InputOption[] $options + * @return int + */ + private function calculateTotalWidthForOptions($options) + { + $totalWidth = 0; + foreach ($options as $option) { + $nameLength = 4 + strlen($option->getName()) + 2; // - + shortcut + , + whitespace + name + -- + + if ($option->acceptValue()) { + $valueLength = 1 + strlen($option->getName()); // = + value + $valueLength += $option->isValueOptional() ? 2 : 0; // [ + ] + + $nameLength += $valueLength; + } + $totalWidth = max($totalWidth, $nameLength); + } + + return $totalWidth; + } +} diff --git a/thinkphp/library/think/console/output/Formatter.php b/thinkphp/library/think/console/output/Formatter.php new file mode 100644 index 0000000..f8bee55 --- /dev/null +++ b/thinkphp/library/think/console/output/Formatter.php @@ -0,0 +1,198 @@ + +// +---------------------------------------------------------------------- +namespace think\console\output; + +use think\console\output\formatter\Stack as StyleStack; +use think\console\output\formatter\Style; + +class Formatter +{ + + private $decorated = false; + private $styles = []; + private $styleStack; + + /** + * 转义 + * @param string $text + * @return string + */ + public static function escape($text) + { + return preg_replace('/([^\\\\]?)setStyle('error', new Style('white', 'red')); + $this->setStyle('info', new Style('green')); + $this->setStyle('comment', new Style('yellow')); + $this->setStyle('question', new Style('black', 'cyan')); + $this->setStyle('highlight', new Style('red')); + $this->setStyle('warning', new Style('black', 'yellow')); + + $this->styleStack = new StyleStack(); + } + + /** + * 设置外观标识 + * @param bool $decorated 是否美化文字 + */ + public function setDecorated($decorated) + { + $this->decorated = (bool) $decorated; + } + + /** + * 获取外观标识 + * @return bool + */ + public function isDecorated() + { + return $this->decorated; + } + + /** + * 添加一个新样式 + * @param string $name 样式名 + * @param Style $style 样式实例 + */ + public function setStyle($name, Style $style) + { + $this->styles[strtolower($name)] = $style; + } + + /** + * 是否有这个样式 + * @param string $name + * @return bool + */ + public function hasStyle($name) + { + return isset($this->styles[strtolower($name)]); + } + + /** + * 获取样式 + * @param string $name + * @return Style + * @throws \InvalidArgumentException + */ + public function getStyle($name) + { + if (!$this->hasStyle($name)) { + throw new \InvalidArgumentException(sprintf('Undefined style: %s', $name)); + } + + return $this->styles[strtolower($name)]; + } + + /** + * 使用所给的样式格式化文字 + * @param string $message 文字 + * @return string + */ + public function format($message) + { + $offset = 0; + $output = ''; + $tagRegex = '[a-z][a-z0-9_=;-]*'; + preg_match_all("#<(($tagRegex) | /($tagRegex)?)>#isx", $message, $matches, PREG_OFFSET_CAPTURE); + foreach ($matches[0] as $i => $match) { + $pos = $match[1]; + $text = $match[0]; + + if (0 != $pos && '\\' == $message[$pos - 1]) { + continue; + } + + $output .= $this->applyCurrentStyle(substr($message, $offset, $pos - $offset)); + $offset = $pos + strlen($text); + + if ($open = '/' != $text[1]) { + $tag = $matches[1][$i][0]; + } else { + $tag = isset($matches[3][$i][0]) ? $matches[3][$i][0] : ''; + } + + if (!$open && !$tag) { + // + $this->styleStack->pop(); + } elseif (false === $style = $this->createStyleFromString(strtolower($tag))) { + $output .= $this->applyCurrentStyle($text); + } elseif ($open) { + $this->styleStack->push($style); + } else { + $this->styleStack->pop($style); + } + } + + $output .= $this->applyCurrentStyle(substr($message, $offset)); + + return str_replace('\\<', '<', $output); + } + + /** + * @return StyleStack + */ + public function getStyleStack() + { + return $this->styleStack; + } + + /** + * 根据字符串创建新的样式实例 + * @param string $string + * @return Style|bool + */ + private function createStyleFromString($string) + { + if (isset($this->styles[$string])) { + return $this->styles[$string]; + } + + if (!preg_match_all('/([^=]+)=([^;]+)(;|$)/', strtolower($string), $matches, PREG_SET_ORDER)) { + return false; + } + + $style = new Style(); + foreach ($matches as $match) { + array_shift($match); + + if ('fg' == $match[0]) { + $style->setForeground($match[1]); + } elseif ('bg' == $match[0]) { + $style->setBackground($match[1]); + } else { + try { + $style->setOption($match[1]); + } catch (\InvalidArgumentException $e) { + return false; + } + } + } + + return $style; + } + + /** + * 从堆栈应用样式到文字 + * @param string $text 文字 + * @return string + */ + private function applyCurrentStyle($text) + { + return $this->isDecorated() && strlen($text) > 0 ? $this->styleStack->getCurrent()->apply($text) : $text; + } +} diff --git a/thinkphp/library/think/console/output/Question.php b/thinkphp/library/think/console/output/Question.php new file mode 100644 index 0000000..03975f2 --- /dev/null +++ b/thinkphp/library/think/console/output/Question.php @@ -0,0 +1,211 @@ + +// +---------------------------------------------------------------------- + +namespace think\console\output; + +class Question +{ + + private $question; + private $attempts; + private $hidden = false; + private $hiddenFallback = true; + private $autocompleterValues; + private $validator; + private $default; + private $normalizer; + + /** + * 构造方法 + * @param string $question 问题 + * @param mixed $default 默认答案 + */ + public function __construct($question, $default = null) + { + $this->question = $question; + $this->default = $default; + } + + /** + * 获取问题 + * @return string + */ + public function getQuestion() + { + return $this->question; + } + + /** + * 获取默认答案 + * @return mixed + */ + public function getDefault() + { + return $this->default; + } + + /** + * 是否隐藏答案 + * @return bool + */ + public function isHidden() + { + return $this->hidden; + } + + /** + * 隐藏答案 + * @param bool $hidden + * @return Question + */ + public function setHidden($hidden) + { + if ($this->autocompleterValues) { + throw new \LogicException('A hidden question cannot use the autocompleter.'); + } + + $this->hidden = (bool) $hidden; + + return $this; + } + + /** + * 不能被隐藏是否撤销 + * @return bool + */ + public function isHiddenFallback() + { + return $this->hiddenFallback; + } + + /** + * 设置不能被隐藏的时候的操作 + * @param bool $fallback + * @return Question + */ + public function setHiddenFallback($fallback) + { + $this->hiddenFallback = (bool) $fallback; + + return $this; + } + + /** + * 获取自动完成 + * @return null|array|\Traversable + */ + public function getAutocompleterValues() + { + return $this->autocompleterValues; + } + + /** + * 设置自动完成的值 + * @param null|array|\Traversable $values + * @return Question + * @throws \InvalidArgumentException + * @throws \LogicException + */ + public function setAutocompleterValues($values) + { + if (is_array($values) && $this->isAssoc($values)) { + $values = array_merge(array_keys($values), array_values($values)); + } + + if (null !== $values && !is_array($values)) { + if (!$values instanceof \Traversable || $values instanceof \Countable) { + throw new \InvalidArgumentException('Autocompleter values can be either an array, `null` or an object implementing both `Countable` and `Traversable` interfaces.'); + } + } + + if ($this->hidden) { + throw new \LogicException('A hidden question cannot use the autocompleter.'); + } + + $this->autocompleterValues = $values; + + return $this; + } + + /** + * 设置答案的验证器 + * @param null|callable $validator + * @return Question The current instance + */ + public function setValidator($validator) + { + $this->validator = $validator; + + return $this; + } + + /** + * 获取验证器 + * @return null|callable + */ + public function getValidator() + { + return $this->validator; + } + + /** + * 设置最大重试次数 + * @param null|int $attempts + * @return Question + * @throws \InvalidArgumentException + */ + public function setMaxAttempts($attempts) + { + if (null !== $attempts && $attempts < 1) { + throw new \InvalidArgumentException('Maximum number of attempts must be a positive value.'); + } + + $this->attempts = $attempts; + + return $this; + } + + /** + * 获取最大重试次数 + * @return null|int + */ + public function getMaxAttempts() + { + return $this->attempts; + } + + /** + * 设置响应的回调 + * @param string|\Closure $normalizer + * @return Question + */ + public function setNormalizer($normalizer) + { + $this->normalizer = $normalizer; + + return $this; + } + + /** + * 获取响应回调 + * The normalizer can ba a callable (a string), a closure or a class implementing __invoke. + * @return string|\Closure + */ + public function getNormalizer() + { + return $this->normalizer; + } + + protected function isAssoc($array) + { + return (bool) count(array_filter(array_keys($array), 'is_string')); + } +} diff --git a/thinkphp/library/think/console/output/descriptor/Console.php b/thinkphp/library/think/console/output/descriptor/Console.php new file mode 100644 index 0000000..4648b68 --- /dev/null +++ b/thinkphp/library/think/console/output/descriptor/Console.php @@ -0,0 +1,149 @@ + +// +---------------------------------------------------------------------- + +namespace think\console\output\descriptor; + +use think\Console as ThinkConsole; +use think\console\Command; + +class Console +{ + + const GLOBAL_NAMESPACE = '_global'; + + /** + * @var ThinkConsole + */ + private $console; + + /** + * @var null|string + */ + private $namespace; + + /** + * @var array + */ + private $namespaces; + + /** + * @var Command[] + */ + private $commands; + + /** + * @var Command[] + */ + private $aliases; + + /** + * 构造方法 + * @param ThinkConsole $console + * @param string|null $namespace + */ + public function __construct(ThinkConsole $console, $namespace = null) + { + $this->console = $console; + $this->namespace = $namespace; + } + + /** + * @return array + */ + public function getNamespaces() + { + if (null === $this->namespaces) { + $this->inspectConsole(); + } + + return $this->namespaces; + } + + /** + * @return Command[] + */ + public function getCommands() + { + if (null === $this->commands) { + $this->inspectConsole(); + } + + return $this->commands; + } + + /** + * @param string $name + * @return Command + * @throws \InvalidArgumentException + */ + public function getCommand($name) + { + if (!isset($this->commands[$name]) && !isset($this->aliases[$name])) { + throw new \InvalidArgumentException(sprintf('Command %s does not exist.', $name)); + } + + return isset($this->commands[$name]) ? $this->commands[$name] : $this->aliases[$name]; + } + + private function inspectConsole() + { + $this->commands = []; + $this->namespaces = []; + + $all = $this->console->all($this->namespace ? $this->console->findNamespace($this->namespace) : null); + foreach ($this->sortCommands($all) as $namespace => $commands) { + $names = []; + + /** @var Command $command */ + foreach ($commands as $name => $command) { + if (!$command->getName()) { + continue; + } + + if ($command->getName() === $name) { + $this->commands[$name] = $command; + } else { + $this->aliases[$name] = $command; + } + + $names[] = $name; + } + + $this->namespaces[$namespace] = ['id' => $namespace, 'commands' => $names]; + } + } + + /** + * @param array $commands + * @return array + */ + private function sortCommands(array $commands) + { + $namespacedCommands = []; + foreach ($commands as $name => $command) { + $key = $this->console->extractNamespace($name, 1); + if (!$key) { + $key = self::GLOBAL_NAMESPACE; + } + + $namespacedCommands[$key][$name] = $command; + } + ksort($namespacedCommands); + + foreach ($namespacedCommands as &$commandsSet) { + ksort($commandsSet); + } + // unset reference to keep scope clear + unset($commandsSet); + + return $namespacedCommands; + } +} diff --git a/thinkphp/library/think/console/output/driver/Buffer.php b/thinkphp/library/think/console/output/driver/Buffer.php new file mode 100644 index 0000000..c77a2ec --- /dev/null +++ b/thinkphp/library/think/console/output/driver/Buffer.php @@ -0,0 +1,52 @@ + +// +---------------------------------------------------------------------- + +namespace think\console\output\driver; + +use think\console\Output; + +class Buffer +{ + /** + * @var string + */ + private $buffer = ''; + + public function __construct(Output $output) + { + // do nothing + } + + public function fetch() + { + $content = $this->buffer; + $this->buffer = ''; + return $content; + } + + public function write($messages, $newline = false, $options = Output::OUTPUT_NORMAL) + { + $messages = (array) $messages; + + foreach ($messages as $message) { + $this->buffer .= $message; + } + if ($newline) { + $this->buffer .= "\n"; + } + } + + public function renderException(\Exception $e) + { + // do nothing + } + +} diff --git a/thinkphp/library/think/console/output/driver/Console.php b/thinkphp/library/think/console/output/driver/Console.php new file mode 100644 index 0000000..8f29fd0 --- /dev/null +++ b/thinkphp/library/think/console/output/driver/Console.php @@ -0,0 +1,373 @@ + +// +---------------------------------------------------------------------- + +namespace think\console\output\driver; + +use think\console\Output; +use think\console\output\Formatter; + +class Console +{ + + /** @var Resource */ + private $stdout; + + /** @var Formatter */ + private $formatter; + + private $terminalDimensions; + + /** @var Output */ + private $output; + + public function __construct(Output $output) + { + $this->output = $output; + $this->formatter = new Formatter(); + $this->stdout = $this->openOutputStream(); + $decorated = $this->hasColorSupport($this->stdout); + $this->formatter->setDecorated($decorated); + } + + public function getFormatter() + { + return $this->formatter; + } + + public function setDecorated($decorated) + { + $this->formatter->setDecorated($decorated); + } + + public function write($messages, $newline = false, $type = Output::OUTPUT_NORMAL, $stream = null) + { + if (Output::VERBOSITY_QUIET === $this->output->getVerbosity()) { + return; + } + + $messages = (array) $messages; + + foreach ($messages as $message) { + switch ($type) { + case Output::OUTPUT_NORMAL: + $message = $this->formatter->format($message); + break; + case Output::OUTPUT_RAW: + break; + case Output::OUTPUT_PLAIN: + $message = strip_tags($this->formatter->format($message)); + break; + default: + throw new \InvalidArgumentException(sprintf('Unknown output type given (%s)', $type)); + } + + $this->doWrite($message, $newline, $stream); + } + } + + public function renderException(\Exception $e) + { + $stderr = $this->openErrorStream(); + $decorated = $this->hasColorSupport($stderr); + $this->formatter->setDecorated($decorated); + + do { + $title = sprintf(' [%s] ', get_class($e)); + + $len = $this->stringWidth($title); + + $width = $this->getTerminalWidth() ? $this->getTerminalWidth() - 1 : PHP_INT_MAX; + + if (defined('HHVM_VERSION') && $width > 1 << 31) { + $width = 1 << 31; + } + $lines = []; + foreach (preg_split('/\r?\n/', $e->getMessage()) as $line) { + foreach ($this->splitStringByWidth($line, $width - 4) as $line) { + + $lineLength = $this->stringWidth(preg_replace('/\[[^m]*m/', '', $line)) + 4; + $lines[] = [$line, $lineLength]; + + $len = max($lineLength, $len); + } + } + + $messages = ['', '']; + $messages[] = $emptyLine = sprintf('%s', str_repeat(' ', $len)); + $messages[] = sprintf('%s%s', $title, str_repeat(' ', max(0, $len - $this->stringWidth($title)))); + foreach ($lines as $line) { + $messages[] = sprintf(' %s %s', $line[0], str_repeat(' ', $len - $line[1])); + } + $messages[] = $emptyLine; + $messages[] = ''; + $messages[] = ''; + + $this->write($messages, true, Output::OUTPUT_NORMAL, $stderr); + + if (Output::VERBOSITY_VERBOSE <= $this->output->getVerbosity()) { + $this->write('Exception trace:', true, Output::OUTPUT_NORMAL, $stderr); + + // exception related properties + $trace = $e->getTrace(); + array_unshift($trace, [ + 'function' => '', + 'file' => $e->getFile() !== null ? $e->getFile() : 'n/a', + 'line' => $e->getLine() !== null ? $e->getLine() : 'n/a', + 'args' => [], + ]); + + for ($i = 0, $count = count($trace); $i < $count; ++$i) { + $class = isset($trace[$i]['class']) ? $trace[$i]['class'] : ''; + $type = isset($trace[$i]['type']) ? $trace[$i]['type'] : ''; + $function = $trace[$i]['function']; + $file = isset($trace[$i]['file']) ? $trace[$i]['file'] : 'n/a'; + $line = isset($trace[$i]['line']) ? $trace[$i]['line'] : 'n/a'; + + $this->write(sprintf(' %s%s%s() at %s:%s', $class, $type, $function, $file, $line), true, Output::OUTPUT_NORMAL, $stderr); + } + + $this->write('', true, Output::OUTPUT_NORMAL, $stderr); + $this->write('', true, Output::OUTPUT_NORMAL, $stderr); + } + } while ($e = $e->getPrevious()); + + } + + /** + * 获取终端宽度 + * @return int|null + */ + protected function getTerminalWidth() + { + $dimensions = $this->getTerminalDimensions(); + + return $dimensions[0]; + } + + /** + * 获取终端高度 + * @return int|null + */ + protected function getTerminalHeight() + { + $dimensions = $this->getTerminalDimensions(); + + return $dimensions[1]; + } + + /** + * 获取当前终端的尺寸 + * @return array + */ + public function getTerminalDimensions() + { + if ($this->terminalDimensions) { + return $this->terminalDimensions; + } + + if ('\\' === DS) { + if (preg_match('/^(\d+)x\d+ \(\d+x(\d+)\)$/', trim(getenv('ANSICON')), $matches)) { + return [(int) $matches[1], (int) $matches[2]]; + } + if (preg_match('/^(\d+)x(\d+)$/', $this->getMode(), $matches)) { + return [(int) $matches[1], (int) $matches[2]]; + } + } + + if ($sttyString = $this->getSttyColumns()) { + if (preg_match('/rows.(\d+);.columns.(\d+);/i', $sttyString, $matches)) { + return [(int) $matches[2], (int) $matches[1]]; + } + if (preg_match('/;.(\d+).rows;.(\d+).columns/i', $sttyString, $matches)) { + return [(int) $matches[2], (int) $matches[1]]; + } + } + + return [null, null]; + } + + /** + * 获取stty列数 + * @return string + */ + private function getSttyColumns() + { + if (!function_exists('proc_open')) { + return; + } + + $descriptorspec = [1 => ['pipe', 'w'], 2 => ['pipe', 'w']]; + $process = proc_open('stty -a | grep columns', $descriptorspec, $pipes, null, null, ['suppress_errors' => true]); + if (is_resource($process)) { + $info = stream_get_contents($pipes[1]); + fclose($pipes[1]); + fclose($pipes[2]); + proc_close($process); + + return $info; + } + return; + } + + /** + * 获取终端模式 + * @return string x 或 null + */ + private function getMode() + { + if (!function_exists('proc_open')) { + return; + } + + $descriptorspec = [1 => ['pipe', 'w'], 2 => ['pipe', 'w']]; + $process = proc_open('mode CON', $descriptorspec, $pipes, null, null, ['suppress_errors' => true]); + if (is_resource($process)) { + $info = stream_get_contents($pipes[1]); + fclose($pipes[1]); + fclose($pipes[2]); + proc_close($process); + + if (preg_match('/--------+\r?\n.+?(\d+)\r?\n.+?(\d+)\r?\n/', $info, $matches)) { + return $matches[2] . 'x' . $matches[1]; + } + } + return; + } + + private function stringWidth($string) + { + if (!function_exists('mb_strwidth')) { + return strlen($string); + } + + if (false === $encoding = mb_detect_encoding($string)) { + return strlen($string); + } + + return mb_strwidth($string, $encoding); + } + + private function splitStringByWidth($string, $width) + { + if (!function_exists('mb_strwidth')) { + return str_split($string, $width); + } + + if (false === $encoding = mb_detect_encoding($string)) { + return str_split($string, $width); + } + + $utf8String = mb_convert_encoding($string, 'utf8', $encoding); + $lines = []; + $line = ''; + foreach (preg_split('//u', $utf8String) as $char) { + if (mb_strwidth($line . $char, 'utf8') <= $width) { + $line .= $char; + continue; + } + $lines[] = str_pad($line, $width); + $line = $char; + } + if (strlen($line)) { + $lines[] = count($lines) ? str_pad($line, $width) : $line; + } + + mb_convert_variables($encoding, 'utf8', $lines); + + return $lines; + } + + private function isRunningOS400() + { + $checks = [ + function_exists('php_uname') ? php_uname('s') : '', + getenv('OSTYPE'), + PHP_OS, + ]; + return false !== stripos(implode(';', $checks), 'OS400'); + } + + /** + * 当前环境是否支持写入控制台输出到stdout. + * + * @return bool + */ + protected function hasStdoutSupport() + { + return false === $this->isRunningOS400(); + } + + /** + * 当前环境是否支持写入控制台输出到stderr. + * + * @return bool + */ + protected function hasStderrSupport() + { + return false === $this->isRunningOS400(); + } + + /** + * @return resource + */ + private function openOutputStream() + { + if (!$this->hasStdoutSupport()) { + return fopen('php://output', 'w'); + } + return @fopen('php://stdout', 'w') ?: fopen('php://output', 'w'); + } + + /** + * @return resource + */ + private function openErrorStream() + { + return fopen($this->hasStderrSupport() ? 'php://stderr' : 'php://output', 'w'); + } + + /** + * 将消息写入到输出。 + * @param string $message 消息 + * @param bool $newline 是否另起一行 + * @param null $stream + */ + protected function doWrite($message, $newline, $stream = null) + { + if (null === $stream) { + $stream = $this->stdout; + } + if (false === @fwrite($stream, $message . ($newline ? PHP_EOL : ''))) { + throw new \RuntimeException('Unable to write output.'); + } + + fflush($stream); + } + + /** + * 是否支持着色 + * @param $stream + * @return bool + */ + protected function hasColorSupport($stream) + { + if (DIRECTORY_SEPARATOR === '\\') { + return + '10.0.10586' === PHP_WINDOWS_VERSION_MAJOR . '.' . PHP_WINDOWS_VERSION_MINOR . '.' . PHP_WINDOWS_VERSION_BUILD + || false !== getenv('ANSICON') + || 'ON' === getenv('ConEmuANSI') + || 'xterm' === getenv('TERM'); + } + + return function_exists('posix_isatty') && @posix_isatty($stream); + } + +} diff --git a/thinkphp/library/think/console/output/driver/Nothing.php b/thinkphp/library/think/console/output/driver/Nothing.php new file mode 100644 index 0000000..9a55f77 --- /dev/null +++ b/thinkphp/library/think/console/output/driver/Nothing.php @@ -0,0 +1,33 @@ + +// +---------------------------------------------------------------------- + +namespace think\console\output\driver; + +use think\console\Output; + +class Nothing +{ + + public function __construct(Output $output) + { + // do nothing + } + + public function write($messages, $newline = false, $options = Output::OUTPUT_NORMAL) + { + // do nothing + } + + public function renderException(\Exception $e) + { + // do nothing + } +} diff --git a/thinkphp/library/think/console/output/formatter/Stack.php b/thinkphp/library/think/console/output/formatter/Stack.php new file mode 100644 index 0000000..4864a3f --- /dev/null +++ b/thinkphp/library/think/console/output/formatter/Stack.php @@ -0,0 +1,116 @@ + +// +---------------------------------------------------------------------- + +namespace think\console\output\formatter; + +class Stack +{ + + /** + * @var Style[] + */ + private $styles; + + /** + * @var Style + */ + private $emptyStyle; + + /** + * 构造方法 + * @param Style|null $emptyStyle + */ + public function __construct(Style $emptyStyle = null) + { + $this->emptyStyle = $emptyStyle ?: new Style(); + $this->reset(); + } + + /** + * 重置堆栈 + */ + public function reset() + { + $this->styles = []; + } + + /** + * 推一个样式进入堆栈 + * @param Style $style + */ + public function push(Style $style) + { + $this->styles[] = $style; + } + + /** + * 从堆栈中弹出一个样式 + * @param Style|null $style + * @return Style + * @throws \InvalidArgumentException + */ + public function pop(Style $style = null) + { + if (empty($this->styles)) { + return $this->emptyStyle; + } + + if (null === $style) { + return array_pop($this->styles); + } + + /** + * @var int $index + * @var Style $stackedStyle + */ + foreach (array_reverse($this->styles, true) as $index => $stackedStyle) { + if ($style->apply('') === $stackedStyle->apply('')) { + $this->styles = array_slice($this->styles, 0, $index); + + return $stackedStyle; + } + } + + throw new \InvalidArgumentException('Incorrectly nested style tag found.'); + } + + /** + * 计算堆栈的当前样式。 + * @return Style + */ + public function getCurrent() + { + if (empty($this->styles)) { + return $this->emptyStyle; + } + + return $this->styles[count($this->styles) - 1]; + } + + /** + * @param Style $emptyStyle + * @return Stack + */ + public function setEmptyStyle(Style $emptyStyle) + { + $this->emptyStyle = $emptyStyle; + + return $this; + } + + /** + * @return Style + */ + public function getEmptyStyle() + { + return $this->emptyStyle; + } +} diff --git a/thinkphp/library/think/console/output/formatter/Style.php b/thinkphp/library/think/console/output/formatter/Style.php new file mode 100644 index 0000000..d9b0999 --- /dev/null +++ b/thinkphp/library/think/console/output/formatter/Style.php @@ -0,0 +1,189 @@ + +// +---------------------------------------------------------------------- + +namespace think\console\output\formatter; + +class Style +{ + + private static $availableForegroundColors = [ + 'black' => ['set' => 30, 'unset' => 39], + 'red' => ['set' => 31, 'unset' => 39], + 'green' => ['set' => 32, 'unset' => 39], + 'yellow' => ['set' => 33, 'unset' => 39], + 'blue' => ['set' => 34, 'unset' => 39], + 'magenta' => ['set' => 35, 'unset' => 39], + 'cyan' => ['set' => 36, 'unset' => 39], + 'white' => ['set' => 37, 'unset' => 39], + ]; + private static $availableBackgroundColors = [ + 'black' => ['set' => 40, 'unset' => 49], + 'red' => ['set' => 41, 'unset' => 49], + 'green' => ['set' => 42, 'unset' => 49], + 'yellow' => ['set' => 43, 'unset' => 49], + 'blue' => ['set' => 44, 'unset' => 49], + 'magenta' => ['set' => 45, 'unset' => 49], + 'cyan' => ['set' => 46, 'unset' => 49], + 'white' => ['set' => 47, 'unset' => 49], + ]; + private static $availableOptions = [ + 'bold' => ['set' => 1, 'unset' => 22], + 'underscore' => ['set' => 4, 'unset' => 24], + 'blink' => ['set' => 5, 'unset' => 25], + 'reverse' => ['set' => 7, 'unset' => 27], + 'conceal' => ['set' => 8, 'unset' => 28], + ]; + + private $foreground; + private $background; + private $options = []; + + /** + * 初始化输出的样式 + * @param string|null $foreground 字体颜色 + * @param string|null $background 背景色 + * @param array $options 格式 + * @api + */ + public function __construct($foreground = null, $background = null, array $options = []) + { + if (null !== $foreground) { + $this->setForeground($foreground); + } + if (null !== $background) { + $this->setBackground($background); + } + if (count($options)) { + $this->setOptions($options); + } + } + + /** + * 设置字体颜色 + * @param string|null $color 颜色名 + * @throws \InvalidArgumentException + * @api + */ + public function setForeground($color = null) + { + if (null === $color) { + $this->foreground = null; + + return; + } + + if (!isset(static::$availableForegroundColors[$color])) { + throw new \InvalidArgumentException(sprintf('Invalid foreground color specified: "%s". Expected one of (%s)', $color, implode(', ', array_keys(static::$availableForegroundColors)))); + } + + $this->foreground = static::$availableForegroundColors[$color]; + } + + /** + * 设置背景色 + * @param string|null $color 颜色名 + * @throws \InvalidArgumentException + * @api + */ + public function setBackground($color = null) + { + if (null === $color) { + $this->background = null; + + return; + } + + if (!isset(static::$availableBackgroundColors[$color])) { + throw new \InvalidArgumentException(sprintf('Invalid background color specified: "%s". Expected one of (%s)', $color, implode(', ', array_keys(static::$availableBackgroundColors)))); + } + + $this->background = static::$availableBackgroundColors[$color]; + } + + /** + * 设置字体格式 + * @param string $option 格式名 + * @throws \InvalidArgumentException When the option name isn't defined + * @api + */ + public function setOption($option) + { + if (!isset(static::$availableOptions[$option])) { + throw new \InvalidArgumentException(sprintf('Invalid option specified: "%s". Expected one of (%s)', $option, implode(', ', array_keys(static::$availableOptions)))); + } + + if (!in_array(static::$availableOptions[$option], $this->options)) { + $this->options[] = static::$availableOptions[$option]; + } + } + + /** + * 重置字体格式 + * @param string $option 格式名 + * @throws \InvalidArgumentException + */ + public function unsetOption($option) + { + if (!isset(static::$availableOptions[$option])) { + throw new \InvalidArgumentException(sprintf('Invalid option specified: "%s". Expected one of (%s)', $option, implode(', ', array_keys(static::$availableOptions)))); + } + + $pos = array_search(static::$availableOptions[$option], $this->options); + if (false !== $pos) { + unset($this->options[$pos]); + } + } + + /** + * 批量设置字体格式 + * @param array $options + */ + public function setOptions(array $options) + { + $this->options = []; + + foreach ($options as $option) { + $this->setOption($option); + } + } + + /** + * 应用样式到文字 + * @param string $text 文字 + * @return string + */ + public function apply($text) + { + $setCodes = []; + $unsetCodes = []; + + if (null !== $this->foreground) { + $setCodes[] = $this->foreground['set']; + $unsetCodes[] = $this->foreground['unset']; + } + if (null !== $this->background) { + $setCodes[] = $this->background['set']; + $unsetCodes[] = $this->background['unset']; + } + if (count($this->options)) { + foreach ($this->options as $option) { + $setCodes[] = $option['set']; + $unsetCodes[] = $option['unset']; + } + } + + if (0 === count($setCodes)) { + return $text; + } + + return sprintf("\033[%sm%s\033[%sm", implode(';', $setCodes), $text, implode(';', $unsetCodes)); + } +} diff --git a/thinkphp/library/think/console/output/question/Choice.php b/thinkphp/library/think/console/output/question/Choice.php new file mode 100644 index 0000000..f6760e5 --- /dev/null +++ b/thinkphp/library/think/console/output/question/Choice.php @@ -0,0 +1,163 @@ + +// +---------------------------------------------------------------------- + +namespace think\console\output\question; + +use think\console\output\Question; + +class Choice extends Question +{ + + private $choices; + private $multiselect = false; + private $prompt = ' > '; + private $errorMessage = 'Value "%s" is invalid'; + + /** + * 构造方法 + * @param string $question 问题 + * @param array $choices 选项 + * @param mixed $default 默认答案 + */ + public function __construct($question, array $choices, $default = null) + { + parent::__construct($question, $default); + + $this->choices = $choices; + $this->setValidator($this->getDefaultValidator()); + $this->setAutocompleterValues($choices); + } + + /** + * 可选项 + * @return array + */ + public function getChoices() + { + return $this->choices; + } + + /** + * 设置可否多选 + * @param bool $multiselect + * @return self + */ + public function setMultiselect($multiselect) + { + $this->multiselect = $multiselect; + $this->setValidator($this->getDefaultValidator()); + + return $this; + } + + public function isMultiselect() + { + return $this->multiselect; + } + + /** + * 获取提示 + * @return string + */ + public function getPrompt() + { + return $this->prompt; + } + + /** + * 设置提示 + * @param string $prompt + * @return self + */ + public function setPrompt($prompt) + { + $this->prompt = $prompt; + + return $this; + } + + /** + * 设置错误提示信息 + * @param string $errorMessage + * @return self + */ + public function setErrorMessage($errorMessage) + { + $this->errorMessage = $errorMessage; + $this->setValidator($this->getDefaultValidator()); + + return $this; + } + + /** + * 获取默认的验证方法 + * @return callable + */ + private function getDefaultValidator() + { + $choices = $this->choices; + $errorMessage = $this->errorMessage; + $multiselect = $this->multiselect; + $isAssoc = $this->isAssoc($choices); + + return function ($selected) use ($choices, $errorMessage, $multiselect, $isAssoc) { + // Collapse all spaces. + $selectedChoices = str_replace(' ', '', $selected); + + if ($multiselect) { + // Check for a separated comma values + if (!preg_match('/^[a-zA-Z0-9_-]+(?:,[a-zA-Z0-9_-]+)*$/', $selectedChoices, $matches)) { + throw new \InvalidArgumentException(sprintf($errorMessage, $selected)); + } + $selectedChoices = explode(',', $selectedChoices); + } else { + $selectedChoices = [$selected]; + } + + $multiselectChoices = []; + foreach ($selectedChoices as $value) { + $results = []; + foreach ($choices as $key => $choice) { + if ($choice === $value) { + $results[] = $key; + } + } + + if (count($results) > 1) { + throw new \InvalidArgumentException(sprintf('The provided answer is ambiguous. Value should be one of %s.', implode(' or ', $results))); + } + + $result = array_search($value, $choices); + + if (!$isAssoc) { + if (!empty($result)) { + $result = $choices[$result]; + } elseif (isset($choices[$value])) { + $result = $choices[$value]; + } + } elseif (empty($result) && array_key_exists($value, $choices)) { + $result = $value; + } + + if (empty($result)) { + throw new \InvalidArgumentException(sprintf($errorMessage, $value)); + } + array_push($multiselectChoices, $result); + } + + if ($multiselect) { + return $multiselectChoices; + } + + return current($multiselectChoices); + }; + } +} diff --git a/thinkphp/library/think/console/output/question/Confirmation.php b/thinkphp/library/think/console/output/question/Confirmation.php new file mode 100644 index 0000000..6598f9b --- /dev/null +++ b/thinkphp/library/think/console/output/question/Confirmation.php @@ -0,0 +1,57 @@ + +// +---------------------------------------------------------------------- + +namespace think\console\output\question; + +use think\console\output\Question; + +class Confirmation extends Question +{ + + private $trueAnswerRegex; + + /** + * 构造方法 + * @param string $question 问题 + * @param bool $default 默认答案 + * @param string $trueAnswerRegex 验证正则 + */ + public function __construct($question, $default = true, $trueAnswerRegex = '/^y/i') + { + parent::__construct($question, (bool) $default); + + $this->trueAnswerRegex = $trueAnswerRegex; + $this->setNormalizer($this->getDefaultNormalizer()); + } + + /** + * 获取默认的答案回调 + * @return callable + */ + private function getDefaultNormalizer() + { + $default = $this->getDefault(); + $regex = $this->trueAnswerRegex; + + return function ($answer) use ($default, $regex) { + if (is_bool($answer)) { + return $answer; + } + + $answerIsTrue = (bool) preg_match($regex, $answer); + if (false === $default) { + return $answer && $answerIsTrue; + } + + return !$answer || $answerIsTrue; + }; + } +} diff --git a/thinkphp/library/think/controller/Rest.php b/thinkphp/library/think/controller/Rest.php new file mode 100644 index 0000000..43ab2f6 --- /dev/null +++ b/thinkphp/library/think/controller/Rest.php @@ -0,0 +1,99 @@ + +// +---------------------------------------------------------------------- + +namespace think\controller; + +use think\App; +use think\Request; +use think\Response; + +abstract class Rest +{ + + protected $method; // 当前请求类型 + protected $type; // 当前资源类型 + // 输出类型 + protected $restMethodList = 'get|post|put|delete'; + protected $restDefaultMethod = 'get'; + protected $restTypeList = 'html|xml|json|rss'; + protected $restDefaultType = 'html'; + protected $restOutputType = [ // REST允许输出的资源类型列表 + 'xml' => 'application/xml', + 'json' => 'application/json', + 'html' => 'text/html', + ]; + + /** + * 构造函数 取得模板对象实例 + * @access public + */ + public function __construct() + { + // 资源类型检测 + $request = Request::instance(); + $ext = $request->ext(); + if ('' == $ext) { + // 自动检测资源类型 + $this->type = $request->type(); + } elseif (!preg_match('/(' . $this->restTypeList . ')$/i', $ext)) { + // 资源类型非法 则用默认资源类型访问 + $this->type = $this->restDefaultType; + } else { + $this->type = $ext; + } + // 请求方式检测 + $method = strtolower($request->method()); + if (!preg_match('/(' . $this->restMethodList . ')$/i', $method)) { + // 请求方式非法 则用默认请求方法 + $method = $this->restDefaultMethod; + } + $this->method = $method; + } + + /** + * REST 调用 + * @access public + * @param string $method 方法名 + * @return mixed + * @throws \Exception + */ + public function _empty($method) + { + if (method_exists($this, $method . '_' . $this->method . '_' . $this->type)) { + // RESTFul方法支持 + $fun = $method . '_' . $this->method . '_' . $this->type; + } elseif ($this->method == $this->restDefaultMethod && method_exists($this, $method . '_' . $this->type)) { + $fun = $method . '_' . $this->type; + } elseif ($this->type == $this->restDefaultType && method_exists($this, $method . '_' . $this->method)) { + $fun = $method . '_' . $this->method; + } + if (isset($fun)) { + return App::invokeMethod([$this, $fun]); + } else { + // 抛出异常 + throw new \Exception('error action :' . $method); + } + } + + /** + * 输出返回数据 + * @access protected + * @param mixed $data 要返回的数据 + * @param String $type 返回类型 JSON XML + * @param integer $code HTTP状态码 + * @return Response + */ + protected function response($data, $type = 'json', $code = 200) + { + return Response::create($data, $type)->code($code); + } + +} diff --git a/thinkphp/library/think/controller/Yar.php b/thinkphp/library/think/controller/Yar.php new file mode 100644 index 0000000..af4e9a1 --- /dev/null +++ b/thinkphp/library/think/controller/Yar.php @@ -0,0 +1,51 @@ + +// +---------------------------------------------------------------------- + +namespace think\controller; + +/** + * ThinkPHP Yar控制器类 + */ +abstract class Yar +{ + + /** + * 构造函数 + * @access public + */ + public function __construct() + { + //控制器初始化 + if (method_exists($this, '_initialize')) { + $this->_initialize(); + } + + //判断扩展是否存在 + if (!extension_loaded('yar')) { + throw new \Exception('not support yar'); + } + + //实例化Yar_Server + $server = new \Yar_Server($this); + // 启动server + $server->handle(); + } + + /** + * 魔术方法 有不存在的操作的时候执行 + * @access public + * @param string $method 方法名 + * @param array $args 参数 + * @return mixed + */ + public function __call($method, $args) + {} +} diff --git a/thinkphp/library/think/db/Builder.php b/thinkphp/library/think/db/Builder.php new file mode 100644 index 0000000..16480d3 --- /dev/null +++ b/thinkphp/library/think/db/Builder.php @@ -0,0 +1,905 @@ + +// +---------------------------------------------------------------------- + +namespace think\db; + +use PDO; +use think\Exception; + +abstract class Builder +{ + // connection对象实例 + protected $connection; + // 查询对象实例 + protected $query; + + // 数据库表达式 + protected $exp = ['eq' => '=', 'neq' => '<>', 'gt' => '>', 'egt' => '>=', 'lt' => '<', 'elt' => '<=', 'notlike' => 'NOT LIKE', 'not like' => 'NOT LIKE', 'like' => 'LIKE', 'in' => 'IN', 'exp' => 'EXP', 'notin' => 'NOT IN', 'not in' => 'NOT IN', 'between' => 'BETWEEN', 'not between' => 'NOT BETWEEN', 'notbetween' => 'NOT BETWEEN', 'exists' => 'EXISTS', 'notexists' => 'NOT EXISTS', 'not exists' => 'NOT EXISTS', 'null' => 'NULL', 'notnull' => 'NOT NULL', 'not null' => 'NOT NULL', '> time' => '> TIME', '< time' => '< TIME', '>= time' => '>= TIME', '<= time' => '<= TIME', 'between time' => 'BETWEEN TIME', 'not between time' => 'NOT BETWEEN TIME', 'notbetween time' => 'NOT BETWEEN TIME']; + + // SQL表达式 + protected $selectSql = 'SELECT%DISTINCT% %FIELD% FROM %TABLE%%FORCE%%JOIN%%WHERE%%GROUP%%HAVING%%UNION%%ORDER%%LIMIT%%LOCK%%COMMENT%'; + protected $insertSql = '%INSERT% INTO %TABLE% (%FIELD%) VALUES (%DATA%) %COMMENT%'; + protected $insertAllSql = '%INSERT% INTO %TABLE% (%FIELD%) %DATA% %COMMENT%'; + protected $updateSql = 'UPDATE %TABLE% SET %SET% %JOIN% %WHERE% %ORDER%%LIMIT% %LOCK%%COMMENT%'; + protected $deleteSql = 'DELETE FROM %TABLE% %USING% %JOIN% %WHERE% %ORDER%%LIMIT% %LOCK%%COMMENT%'; + + /** + * 构造函数 + * @access public + * @param Connection $connection 数据库连接对象实例 + * @param Query $query 数据库查询对象实例 + */ + public function __construct(Connection $connection, Query $query) + { + $this->connection = $connection; + $this->query = $query; + } + + /** + * 获取当前的连接对象实例 + * @access public + * @return Connection + */ + public function getConnection() + { + return $this->connection; + } + + /** + * 获取当前的Query对象实例 + * @access public + * @return Query + */ + public function getQuery() + { + return $this->query; + } + + /** + * 将SQL语句中的__TABLE_NAME__字符串替换成带前缀的表名(小写) + * @access protected + * @param string $sql sql语句 + * @return string + */ + protected function parseSqlTable($sql) + { + return $this->query->parseSqlTable($sql); + } + + /** + * 数据分析 + * @access protected + * @param array $data 数据 + * @param array $options 查询参数 + * @return array + * @throws Exception + */ + protected function parseData($data, $options) + { + if (empty($data)) { + return []; + } + + // 获取绑定信息 + $bind = $this->query->getFieldsBind($options['table']); + if ('*' == $options['field']) { + $fields = array_keys($bind); + } else { + $fields = $options['field']; + } + + $result = []; + foreach ($data as $key => $val) { + if ('*' != $options['field'] && !in_array($key, $fields, true)) { + continue; + } + + $item = $this->parseKey($key, $options, true); + if ($val instanceof Expression) { + $result[$item] = $val->getValue(); + continue; + } elseif (is_object($val) && method_exists($val, '__toString')) { + // 对象数据写入 + $val = $val->__toString(); + } + if (false === strpos($key, '.') && !in_array($key, $fields, true)) { + if ($options['strict']) { + throw new Exception('fields not exists:[' . $key . ']'); + } + } elseif (is_null($val)) { + $result[$item] = 'NULL'; + } elseif (is_array($val) && !empty($val)) { + switch (strtolower($val[0])) { + case 'inc': + $result[$item] = $item . '+' . floatval($val[1]); + break; + case 'dec': + $result[$item] = $item . '-' . floatval($val[1]); + break; + case 'exp': + throw new Exception('not support data:[' . $val[0] . ']'); + } + } elseif (is_scalar($val)) { + // 过滤非标量数据 + if (0 === strpos($val, ':') && $this->query->isBind(substr($val, 1))) { + $result[$item] = $val; + } else { + $key = str_replace('.', '_', $key); + $this->query->bind('data__' . $key, $val, isset($bind[$key]) ? $bind[$key] : PDO::PARAM_STR); + $result[$item] = ':data__' . $key; + } + } + } + return $result; + } + + /** + * 字段名分析 + * @access protected + * @param string $key + * @param array $options + * @return string + */ + protected function parseKey($key, $options = [], $strict = false) + { + return $key; + } + + /** + * value分析 + * @access protected + * @param mixed $value + * @param string $field + * @return string|array + */ + protected function parseValue($value, $field = '') + { + if (is_string($value)) { + $value = strpos($value, ':') === 0 && $this->query->isBind(substr($value, 1)) ? $value : $this->connection->quote($value); + } elseif (is_array($value)) { + $value = array_map([$this, 'parseValue'], $value); + } elseif (is_bool($value)) { + $value = $value ? '1' : '0'; + } elseif (is_null($value)) { + $value = 'null'; + } + return $value; + } + + /** + * field分析 + * @access protected + * @param mixed $fields + * @param array $options + * @return string + */ + protected function parseField($fields, $options = []) + { + if ('*' == $fields || empty($fields)) { + $fieldsStr = '*'; + } elseif (is_array($fields)) { + // 支持 'field1'=>'field2' 这样的字段别名定义 + $array = []; + foreach ($fields as $key => $field) { + if ($field instanceof Expression) { + $array[] = $field->getValue(); + } elseif (!is_numeric($key)) { + $array[] = $this->parseKey($key, $options) . ' AS ' . $this->parseKey($field, $options, true); + } else { + $array[] = $this->parseKey($field, $options); + } + } + $fieldsStr = implode(',', $array); + } + return $fieldsStr; + } + + /** + * table分析 + * @access protected + * @param mixed $tables + * @param array $options + * @return string + */ + protected function parseTable($tables, $options = []) + { + $item = []; + foreach ((array) $tables as $key => $table) { + if (!is_numeric($key)) { + $key = $this->parseSqlTable($key); + $item[] = $this->parseKey($key) . ' ' . (isset($options['alias'][$table]) ? $this->parseKey($options['alias'][$table]) : $this->parseKey($table)); + } else { + $table = $this->parseSqlTable($table); + if (isset($options['alias'][$table])) { + $item[] = $this->parseKey($table) . ' ' . $this->parseKey($options['alias'][$table]); + } else { + $item[] = $this->parseKey($table); + } + } + } + return implode(',', $item); + } + + /** + * where分析 + * @access protected + * @param mixed $where 查询条件 + * @param array $options 查询参数 + * @return string + */ + protected function parseWhere($where, $options) + { + $whereStr = $this->buildWhere($where, $options); + if (!empty($options['soft_delete'])) { + // 附加软删除条件 + list($field, $condition) = $options['soft_delete']; + + $binds = $this->query->getFieldsBind($options['table']); + $whereStr = $whereStr ? '( ' . $whereStr . ' ) AND ' : ''; + $whereStr = $whereStr . $this->parseWhereItem($field, $condition, '', $options, $binds); + } + return empty($whereStr) ? '' : ' WHERE ' . $whereStr; + } + + /** + * 生成查询条件SQL + * @access public + * @param mixed $where + * @param array $options + * @return string + */ + public function buildWhere($where, $options) + { + if (empty($where)) { + $where = []; + } + + if ($where instanceof Query) { + return $this->buildWhere($where->getOptions('where'), $options); + } + + $whereStr = ''; + $binds = $this->query->getFieldsBind($options['table']); + foreach ($where as $key => $val) { + $str = []; + foreach ($val as $field => $value) { + if ($value instanceof Expression) { + $str[] = ' ' . $key . ' ( ' . $value->getValue() . ' )'; + } elseif ($value instanceof \Closure) { + // 使用闭包查询 + $query = new Query($this->connection); + call_user_func_array($value, [ & $query]); + $whereClause = $this->buildWhere($query->getOptions('where'), $options); + if (!empty($whereClause)) { + $str[] = ' ' . $key . ' ( ' . $whereClause . ' )'; + } + } elseif (strpos($field, '|')) { + // 不同字段使用相同查询条件(OR) + $array = explode('|', $field); + $item = []; + foreach ($array as $k) { + $item[] = $this->parseWhereItem($k, $value, '', $options, $binds); + } + $str[] = ' ' . $key . ' ( ' . implode(' OR ', $item) . ' )'; + } elseif (strpos($field, '&')) { + // 不同字段使用相同查询条件(AND) + $array = explode('&', $field); + $item = []; + foreach ($array as $k) { + $item[] = $this->parseWhereItem($k, $value, '', $options, $binds); + } + $str[] = ' ' . $key . ' ( ' . implode(' AND ', $item) . ' )'; + } else { + // 对字段使用表达式查询 + $field = is_string($field) ? $field : ''; + $str[] = ' ' . $key . ' ' . $this->parseWhereItem($field, $value, $key, $options, $binds); + } + } + + $whereStr .= empty($whereStr) ? substr(implode(' ', $str), strlen($key) + 1) : implode(' ', $str); + } + + return $whereStr; + } + + // where子单元分析 + protected function parseWhereItem($field, $val, $rule = '', $options = [], $binds = [], $bindName = null) + { + // 字段分析 + $key = $field ? $this->parseKey($field, $options, true) : ''; + + // 查询规则和条件 + if (!is_array($val)) { + $val = is_null($val) ? ['null', ''] : ['=', $val]; + } + list($exp, $value) = $val; + + // 对一个字段使用多个查询条件 + if (is_array($exp)) { + $item = array_pop($val); + // 传入 or 或者 and + if (is_string($item) && in_array($item, ['AND', 'and', 'OR', 'or'])) { + $rule = $item; + } else { + array_push($val, $item); + } + foreach ($val as $k => $item) { + $bindName = 'where_' . str_replace('.', '_', $field) . '_' . $k; + $str[] = $this->parseWhereItem($field, $item, $rule, $options, $binds, $bindName); + } + return '( ' . implode(' ' . $rule . ' ', $str) . ' )'; + } + + // 检测操作符 + if (!in_array($exp, $this->exp)) { + $exp = strtolower($exp); + if (isset($this->exp[$exp])) { + $exp = $this->exp[$exp]; + } else { + throw new Exception('where express error:' . $exp); + } + } + $bindName = $bindName ?: 'where_' . $rule . '_' . str_replace(['.', '-'], '_', $field); + if (preg_match('/\W/', $bindName)) { + // 处理带非单词字符的字段名 + $bindName = md5($bindName); + } + + if ($value instanceof Expression) { + + } elseif (is_object($value) && method_exists($value, '__toString')) { + // 对象数据写入 + $value = $value->__toString(); + } + + $bindType = isset($binds[$field]) ? $binds[$field] : PDO::PARAM_STR; + if (is_scalar($value) && array_key_exists($field, $binds) && !in_array($exp, ['EXP', 'NOT NULL', 'NULL', 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN']) && strpos($exp, 'TIME') === false) { + if (strpos($value, ':') !== 0 || !$this->query->isBind(substr($value, 1))) { + if ($this->query->isBind($bindName)) { + $bindName .= '_' . str_replace('.', '_', uniqid('', true)); + } + $this->query->bind($bindName, $value, $bindType); + $value = ':' . $bindName; + } + } + + $whereStr = ''; + if (in_array($exp, ['=', '<>', '>', '>=', '<', '<='])) { + // 比较运算 + if ($value instanceof \Closure) { + $whereStr .= $key . ' ' . $exp . ' ' . $this->parseClosure($value); + } else { + $whereStr .= $key . ' ' . $exp . ' ' . $this->parseValue($value, $field); + } + } elseif ('LIKE' == $exp || 'NOT LIKE' == $exp) { + // 模糊匹配 + if (is_array($value)) { + foreach ($value as $item) { + $array[] = $key . ' ' . $exp . ' ' . $this->parseValue($item, $field); + } + $logic = isset($val[2]) ? $val[2] : 'AND'; + $whereStr .= '(' . implode(' ' . strtoupper($logic) . ' ', $array) . ')'; + } else { + $whereStr .= $key . ' ' . $exp . ' ' . $this->parseValue($value, $field); + } + } elseif ('EXP' == $exp) { + // 表达式查询 + if ($value instanceof Expression) { + $whereStr .= '( ' . $key . ' ' . $value->getValue() . ' )'; + } else { + throw new Exception('where express error:' . $exp); + } + } elseif (in_array($exp, ['NOT NULL', 'NULL'])) { + // NULL 查询 + $whereStr .= $key . ' IS ' . $exp; + } elseif (in_array($exp, ['NOT IN', 'IN'])) { + // IN 查询 + if ($value instanceof \Closure) { + $whereStr .= $key . ' ' . $exp . ' ' . $this->parseClosure($value); + } else { + $value = array_unique(is_array($value) ? $value : explode(',', $value)); + if (array_key_exists($field, $binds)) { + $bind = []; + $array = []; + $i = 0; + foreach ($value as $v) { + $i++; + if ($this->query->isBind($bindName . '_in_' . $i)) { + $bindKey = $bindName . '_in_' . uniqid() . '_' . $i; + } else { + $bindKey = $bindName . '_in_' . $i; + } + $bind[$bindKey] = [$v, $bindType]; + $array[] = ':' . $bindKey; + } + $this->query->bind($bind); + $zone = implode(',', $array); + } else { + $zone = implode(',', $this->parseValue($value, $field)); + } + $whereStr .= $key . ' ' . $exp . ' (' . (empty($zone) ? "''" : $zone) . ')'; + } + } elseif (in_array($exp, ['NOT BETWEEN', 'BETWEEN'])) { + // BETWEEN 查询 + $data = is_array($value) ? $value : explode(',', $value); + if (array_key_exists($field, $binds)) { + if ($this->query->isBind($bindName . '_between_1')) { + $bindKey1 = $bindName . '_between_1' . uniqid(); + $bindKey2 = $bindName . '_between_2' . uniqid(); + } else { + $bindKey1 = $bindName . '_between_1'; + $bindKey2 = $bindName . '_between_2'; + } + $bind = [ + $bindKey1 => [$data[0], $bindType], + $bindKey2 => [$data[1], $bindType], + ]; + $this->query->bind($bind); + $between = ':' . $bindKey1 . ' AND :' . $bindKey2; + } else { + $between = $this->parseValue($data[0], $field) . ' AND ' . $this->parseValue($data[1], $field); + } + $whereStr .= $key . ' ' . $exp . ' ' . $between; + } elseif (in_array($exp, ['NOT EXISTS', 'EXISTS'])) { + // EXISTS 查询 + if ($value instanceof \Closure) { + $whereStr .= $exp . ' ' . $this->parseClosure($value); + } else { + $whereStr .= $exp . ' (' . $value . ')'; + } + } elseif (in_array($exp, ['< TIME', '> TIME', '<= TIME', '>= TIME'])) { + $whereStr .= $key . ' ' . substr($exp, 0, 2) . ' ' . $this->parseDateTime($value, $field, $options, $bindName, $bindType); + } elseif (in_array($exp, ['BETWEEN TIME', 'NOT BETWEEN TIME'])) { + if (is_string($value)) { + $value = explode(',', $value); + } + + $whereStr .= $key . ' ' . substr($exp, 0, -4) . $this->parseDateTime($value[0], $field, $options, $bindName . '_between_1', $bindType) . ' AND ' . $this->parseDateTime($value[1], $field, $options, $bindName . '_between_2', $bindType); + } + return $whereStr; + } + + // 执行闭包子查询 + protected function parseClosure($call, $show = true) + { + $query = new Query($this->connection); + call_user_func_array($call, [ & $query]); + return $query->buildSql($show); + } + + /** + * 日期时间条件解析 + * @access protected + * @param string $value + * @param string $key + * @param array $options + * @param string $bindName + * @param integer $bindType + * @return string + */ + protected function parseDateTime($value, $key, $options = [], $bindName = null, $bindType = null) + { + // 获取时间字段类型 + if (strpos($key, '.')) { + list($table, $key) = explode('.', $key); + if (isset($options['alias']) && $pos = array_search($table, $options['alias'])) { + $table = $pos; + } + } else { + $table = $options['table']; + } + $type = $this->query->getTableInfo($table, 'type'); + if (isset($type[$key])) { + $info = $type[$key]; + } + if (isset($info)) { + if (is_string($value)) { + $value = strtotime($value) ?: $value; + } + + if (preg_match('/(datetime|timestamp)/is', $info)) { + // 日期及时间戳类型 + $value = date('Y-m-d H:i:s', $value); + } elseif (preg_match('/(date)/is', $info)) { + // 日期及时间戳类型 + $value = date('Y-m-d', $value); + } + } + $bindName = $bindName ?: $key; + + if ($this->query->isBind($bindName)) { + $bindName .= '_' . str_replace('.', '_', uniqid('', true)); + } + + $this->query->bind($bindName, $value, $bindType); + return ':' . $bindName; + } + + /** + * limit分析 + * @access protected + * @param mixed $limit + * @return string + */ + protected function parseLimit($limit) + { + return (!empty($limit) && false === strpos($limit, '(')) ? ' LIMIT ' . $limit . ' ' : ''; + } + + /** + * join分析 + * @access protected + * @param array $join + * @param array $options 查询条件 + * @return string + */ + protected function parseJoin($join, & $options = []) + { + $joinStr = ''; + if (!empty($join)) { + foreach ($join as $item) { + list($table, $type, $on) = $item; + if (is_array($table)) { + $origin = key($table); + if ($origin && $origin != $table[$origin]) { + $options['alias'][$origin] = $table[$origin]; + } + } + $condition = []; + foreach ((array) $on as $val) { + if ($val instanceof Expression) { + $condition[] = $val->getValue(); + } elseif (strpos($val, '=')) { + list($val1, $val2) = explode('=', $val, 2); + $condition[] = $this->parseKey($val1, $options) . '=' . $this->parseKey($val2, $options); + } else { + $condition[] = $val; + } + } + + $table = $this->parseTable($table, $options); + $joinStr .= ' ' . $type . ' JOIN ' . $table . ' ON ' . implode(' AND ', $condition); + } + } + return $joinStr; + } + + /** + * order分析 + * @access protected + * @param mixed $order + * @param array $options 查询条件 + * @return string + */ + protected function parseOrder($order, $options = []) + { + if (empty($order)) { + return ''; + } + + $array = []; + foreach ($order as $key => $val) { + if ($val instanceof Expression) { + $array[] = $val->getValue(); + } elseif ('[rand]' == $val) { + $array[] = $this->parseRand(); + } else { + if (is_numeric($key)) { + list($key, $sort) = explode(' ', strpos($val, ' ') ? $val : $val . ' '); + } else { + $sort = $val; + } + $sort = strtoupper($sort); + $sort = in_array($sort, ['ASC', 'DESC'], true) ? ' ' . $sort : ''; + $array[] = $this->parseKey($key, $options, true) . $sort; + } + } + $order = implode(',', $array); + + return !empty($order) ? ' ORDER BY ' . $order : ''; + } + + /** + * group分析 + * @access protected + * @param mixed $group + * @return string + */ + protected function parseGroup($group) + { + return !empty($group) ? ' GROUP BY ' . $this->parseKey($group) : ''; + } + + /** + * having分析 + * @access protected + * @param string $having + * @return string + */ + protected function parseHaving($having) + { + return !empty($having) ? ' HAVING ' . $having : ''; + } + + /** + * comment分析 + * @access protected + * @param string $comment + * @return string + */ + protected function parseComment($comment) + { + if (false !== strpos($comment, '*/')) { + $comment = strstr($comment, '*/', true); + } + return !empty($comment) ? ' /* ' . $comment . ' */' : ''; + } + + /** + * distinct分析 + * @access protected + * @param mixed $distinct + * @return string + */ + protected function parseDistinct($distinct) + { + return !empty($distinct) ? ' DISTINCT ' : ''; + } + + /** + * union分析 + * @access protected + * @param mixed $union + * @return string + */ + protected function parseUnion($union) + { + if (empty($union)) { + return ''; + } + $type = $union['type']; + unset($union['type']); + foreach ($union as $u) { + if ($u instanceof \Closure) { + $sql[] = $type . ' ' . $this->parseClosure($u); + } elseif (is_string($u)) { + $sql[] = $type . ' ( ' . $this->parseSqlTable($u) . ' )'; + } + } + return ' ' . implode(' ', $sql); + } + + /** + * index分析,可在操作链中指定需要强制使用的索引 + * @access protected + * @param mixed $index + * @return string + */ + protected function parseForce($index) + { + if (empty($index)) { + return ''; + } + + return sprintf(" FORCE INDEX ( %s ) ", is_array($index) ? implode(',', $index) : $index); + } + + /** + * 设置锁机制 + * @access protected + * @param bool|string $lock + * @return string + */ + protected function parseLock($lock = false) + { + if (is_bool($lock)) { + return $lock ? ' FOR UPDATE ' : ''; + } elseif (is_string($lock)) { + return ' ' . trim($lock) . ' '; + } + } + + /** + * 生成查询SQL + * @access public + * @param array $options 表达式 + * @return string + */ + public function select($options = []) + { + $sql = str_replace( + ['%TABLE%', '%DISTINCT%', '%FIELD%', '%JOIN%', '%WHERE%', '%GROUP%', '%HAVING%', '%ORDER%', '%LIMIT%', '%UNION%', '%LOCK%', '%COMMENT%', '%FORCE%'], + [ + $this->parseTable($options['table'], $options), + $this->parseDistinct($options['distinct']), + $this->parseField($options['field'], $options), + $this->parseJoin($options['join'], $options), + $this->parseWhere($options['where'], $options), + $this->parseGroup($options['group']), + $this->parseHaving($options['having']), + $this->parseOrder($options['order'], $options), + $this->parseLimit($options['limit']), + $this->parseUnion($options['union']), + $this->parseLock($options['lock']), + $this->parseComment($options['comment']), + $this->parseForce($options['force']), + ], $this->selectSql); + return $sql; + } + + /** + * 生成insert SQL + * @access public + * @param array $data 数据 + * @param array $options 表达式 + * @param bool $replace 是否replace + * @return string + */ + public function insert(array $data, $options = [], $replace = false) + { + // 分析并处理数据 + $data = $this->parseData($data, $options); + if (empty($data)) { + return 0; + } + $fields = array_keys($data); + $values = array_values($data); + + $sql = str_replace( + ['%INSERT%', '%TABLE%', '%FIELD%', '%DATA%', '%COMMENT%'], + [ + $replace ? 'REPLACE' : 'INSERT', + $this->parseTable($options['table'], $options), + implode(' , ', $fields), + implode(' , ', $values), + $this->parseComment($options['comment']), + ], $this->insertSql); + + return $sql; + } + + /** + * 生成insertall SQL + * @access public + * @param array $dataSet 数据集 + * @param array $options 表达式 + * @param bool $replace 是否replace + * @return string + * @throws Exception + */ + public function insertAll($dataSet, $options = [], $replace = false) + { + // 获取合法的字段 + if ('*' == $options['field']) { + $fields = array_keys($this->query->getFieldsType($options['table'])); + } else { + $fields = $options['field']; + } + + foreach ($dataSet as $data) { + foreach ($data as $key => $val) { + if (!in_array($key, $fields, true)) { + if ($options['strict']) { + throw new Exception('fields not exists:[' . $key . ']'); + } + unset($data[$key]); + } elseif (is_null($val)) { + $data[$key] = 'NULL'; + } elseif (is_scalar($val)) { + $data[$key] = $this->parseValue($val, $key); + } elseif (is_object($val) && method_exists($val, '__toString')) { + // 对象数据写入 + $data[$key] = $val->__toString(); + } else { + // 过滤掉非标量数据 + unset($data[$key]); + } + } + $value = array_values($data); + $values[] = 'SELECT ' . implode(',', $value); + + if (!isset($insertFields)) { + $insertFields = array_keys($data); + } + } + + foreach ($insertFields as $field) { + $fields[] = $this->parseKey($field, $options, true); + } + + return str_replace( + ['%INSERT%', '%TABLE%', '%FIELD%', '%DATA%', '%COMMENT%'], + [ + $replace ? 'REPLACE' : 'INSERT', + $this->parseTable($options['table'], $options), + implode(' , ', $insertFields), + implode(' UNION ALL ', $values), + $this->parseComment($options['comment']), + ], $this->insertAllSql); + } + + /** + * 生成select insert SQL + * @access public + * @param array $fields 数据 + * @param string $table 数据表 + * @param array $options 表达式 + * @return string + */ + public function selectInsert($fields, $table, $options) + { + if (is_string($fields)) { + $fields = explode(',', $fields); + } + + $fields = array_map([$this, 'parseKey'], $fields); + $sql = 'INSERT INTO ' . $this->parseTable($table, $options) . ' (' . implode(',', $fields) . ') ' . $this->select($options); + return $sql; + } + + /** + * 生成update SQL + * @access public + * @param array $data 数据 + * @param array $options 表达式 + * @return string + */ + public function update($data, $options) + { + $table = $this->parseTable($options['table'], $options); + $data = $this->parseData($data, $options); + if (empty($data)) { + return ''; + } + foreach ($data as $key => $val) { + $set[] = $key . '=' . $val; + } + + $sql = str_replace( + ['%TABLE%', '%SET%', '%JOIN%', '%WHERE%', '%ORDER%', '%LIMIT%', '%LOCK%', '%COMMENT%'], + [ + $this->parseTable($options['table'], $options), + implode(',', $set), + $this->parseJoin($options['join'], $options), + $this->parseWhere($options['where'], $options), + $this->parseOrder($options['order'], $options), + $this->parseLimit($options['limit']), + $this->parseLock($options['lock']), + $this->parseComment($options['comment']), + ], $this->updateSql); + + return $sql; + } + + /** + * 生成delete SQL + * @access public + * @param array $options 表达式 + * @return string + */ + public function delete($options) + { + $sql = str_replace( + ['%TABLE%', '%USING%', '%JOIN%', '%WHERE%', '%ORDER%', '%LIMIT%', '%LOCK%', '%COMMENT%'], + [ + $this->parseTable($options['table'], $options), + !empty($options['using']) ? ' USING ' . $this->parseTable($options['using'], $options) . ' ' : '', + $this->parseJoin($options['join'], $options), + $this->parseWhere($options['where'], $options), + $this->parseOrder($options['order'], $options), + $this->parseLimit($options['limit']), + $this->parseLock($options['lock']), + $this->parseComment($options['comment']), + ], $this->deleteSql); + + return $sql; + } +} diff --git a/thinkphp/library/think/db/Connection.php b/thinkphp/library/think/db/Connection.php new file mode 100644 index 0000000..578cc8f --- /dev/null +++ b/thinkphp/library/think/db/Connection.php @@ -0,0 +1,1059 @@ + +// +---------------------------------------------------------------------- + +namespace think\db; + +use PDO; +use PDOStatement; +use think\Db; +use think\db\exception\BindParamException; +use think\Debug; +use think\Exception; +use think\exception\PDOException; +use think\Log; + +/** + * Class Connection + * @package think + * @method Query table(string $table) 指定数据表(含前缀) + * @method Query name(string $name) 指定数据表(不含前缀) + * + */ +abstract class Connection +{ + + /** @var PDOStatement PDO操作实例 */ + protected $PDOStatement; + + /** @var string 当前SQL指令 */ + protected $queryStr = ''; + // 返回或者影响记录数 + protected $numRows = 0; + // 事务指令数 + protected $transTimes = 0; + // 错误信息 + protected $error = ''; + + /** @var PDO[] 数据库连接ID 支持多个连接 */ + protected $links = []; + + /** @var PDO 当前连接ID */ + protected $linkID; + protected $linkRead; + protected $linkWrite; + + // 查询结果类型 + protected $fetchType = PDO::FETCH_ASSOC; + // 字段属性大小写 + protected $attrCase = PDO::CASE_LOWER; + // 监听回调 + protected static $event = []; + // 使用Builder类 + protected $builder; + // 数据库连接参数配置 + protected $config = [ + // 数据库类型 + 'type' => '', + // 服务器地址 + 'hostname' => '', + // 数据库名 + 'database' => '', + // 用户名 + 'username' => '', + // 密码 + 'password' => '', + // 端口 + 'hostport' => '', + // 连接dsn + 'dsn' => '', + // 数据库连接参数 + 'params' => [], + // 数据库编码默认采用utf8 + 'charset' => 'utf8', + // 数据库表前缀 + 'prefix' => '', + // 数据库调试模式 + 'debug' => false, + // 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器) + 'deploy' => 0, + // 数据库读写是否分离 主从式有效 + 'rw_separate' => false, + // 读写分离后 主服务器数量 + 'master_num' => 1, + // 指定从服务器序号 + 'slave_no' => '', + // 模型写入后自动读取主服务器 + 'read_master' => false, + // 是否严格检查字段是否存在 + 'fields_strict' => true, + // 数据返回类型 + 'result_type' => PDO::FETCH_ASSOC, + // 数据集返回类型 + 'resultset_type' => 'array', + // 自动写入时间戳字段 + 'auto_timestamp' => false, + // 时间字段取出后的默认时间格式 + 'datetime_format' => 'Y-m-d H:i:s', + // 是否需要进行SQL性能分析 + 'sql_explain' => false, + // Builder类 + 'builder' => '', + // Query类 + 'query' => '\\think\\db\\Query', + // 是否需要断线重连 + 'break_reconnect' => false, + ]; + + // PDO连接参数 + protected $params = [ + PDO::ATTR_CASE => PDO::CASE_NATURAL, + PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, + PDO::ATTR_ORACLE_NULLS => PDO::NULL_NATURAL, + PDO::ATTR_STRINGIFY_FETCHES => false, + PDO::ATTR_EMULATE_PREPARES => false, + ]; + + // 绑定参数 + protected $bind = []; + + /** + * 构造函数 读取数据库配置信息 + * @access public + * @param array $config 数据库配置数组 + */ + public function __construct(array $config = []) + { + if (!empty($config)) { + $this->config = array_merge($this->config, $config); + } + } + + /** + * 获取新的查询对象 + * @access protected + * @return Query + */ + protected function getQuery() + { + $class = $this->config['query']; + return new $class($this); + } + + /** + * 获取当前连接器类对应的Builder类 + * @access public + * @return string + */ + public function getBuilder() + { + if (!empty($this->builder)) { + return $this->builder; + } else { + return $this->getConfig('builder') ?: '\\think\\db\\builder\\' . ucfirst($this->getConfig('type')); + } + } + + /** + * 调用Query类的查询方法 + * @access public + * @param string $method 方法名称 + * @param array $args 调用参数 + * @return mixed + */ + public function __call($method, $args) + { + return call_user_func_array([$this->getQuery(), $method], $args); + } + + /** + * 解析pdo连接的dsn信息 + * @access protected + * @param array $config 连接信息 + * @return string + */ + abstract protected function parseDsn($config); + + /** + * 取得数据表的字段信息 + * @access public + * @param string $tableName + * @return array + */ + abstract public function getFields($tableName); + + /** + * 取得数据库的表信息 + * @access public + * @param string $dbName + * @return array + */ + abstract public function getTables($dbName); + + /** + * SQL性能分析 + * @access protected + * @param string $sql + * @return array + */ + abstract protected function getExplain($sql); + + /** + * 对返数据表字段信息进行大小写转换出来 + * @access public + * @param array $info 字段信息 + * @return array + */ + public function fieldCase($info) + { + // 字段大小写转换 + switch ($this->attrCase) { + case PDO::CASE_LOWER: + $info = array_change_key_case($info); + break; + case PDO::CASE_UPPER: + $info = array_change_key_case($info, CASE_UPPER); + break; + case PDO::CASE_NATURAL: + default: + // 不做转换 + } + return $info; + } + + /** + * 获取数据库的配置参数 + * @access public + * @param string $config 配置名称 + * @return mixed + */ + public function getConfig($config = '') + { + return $config ? $this->config[$config] : $this->config; + } + + /** + * 设置数据库的配置参数 + * @access public + * @param string|array $config 配置名称 + * @param mixed $value 配置值 + * @return void + */ + public function setConfig($config, $value = '') + { + if (is_array($config)) { + $this->config = array_merge($this->config, $config); + } else { + $this->config[$config] = $value; + } + } + + /** + * 连接数据库方法 + * @access public + * @param array $config 连接参数 + * @param integer $linkNum 连接序号 + * @param array|bool $autoConnection 是否自动连接主数据库(用于分布式) + * @return PDO + * @throws Exception + */ + public function connect(array $config = [], $linkNum = 0, $autoConnection = false) + { + if (!isset($this->links[$linkNum])) { + if (!$config) { + $config = $this->config; + } else { + $config = array_merge($this->config, $config); + } + // 连接参数 + if (isset($config['params']) && is_array($config['params'])) { + $params = $config['params'] + $this->params; + } else { + $params = $this->params; + } + // 记录当前字段属性大小写设置 + $this->attrCase = $params[PDO::ATTR_CASE]; + + // 数据返回类型 + if (isset($config['result_type'])) { + $this->fetchType = $config['result_type']; + } + try { + if (empty($config['dsn'])) { + $config['dsn'] = $this->parseDsn($config); + } + if ($config['debug']) { + $startTime = microtime(true); + } + $this->links[$linkNum] = new PDO($config['dsn'], $config['username'], $config['password'], $params); + if ($config['debug']) { + // 记录数据库连接信息 + Log::record('[ DB ] CONNECT:[ UseTime:' . number_format(microtime(true) - $startTime, 6) . 's ] ' . $config['dsn'], 'sql'); + } + } catch (\PDOException $e) { + if ($autoConnection) { + Log::record($e->getMessage(), 'error'); + return $this->connect($autoConnection, $linkNum); + } else { + throw $e; + } + } + } + return $this->links[$linkNum]; + } + + /** + * 释放查询结果 + * @access public + */ + public function free() + { + $this->PDOStatement = null; + } + + /** + * 获取PDO对象 + * @access public + * @return \PDO|false + */ + public function getPdo() + { + if (!$this->linkID) { + return false; + } else { + return $this->linkID; + } + } + + /** + * 执行查询 返回数据集 + * @access public + * @param string $sql sql指令 + * @param array $bind 参数绑定 + * @param bool $master 是否在主服务器读操作 + * @param bool $pdo 是否返回PDO对象 + * @return mixed + * @throws PDOException + * @throws \Exception + */ + public function query($sql, $bind = [], $master = false, $pdo = false) + { + $this->initConnect($master); + if (!$this->linkID) { + return false; + } + + // 记录SQL语句 + $this->queryStr = $sql; + if ($bind) { + $this->bind = $bind; + } + + Db::$queryTimes++; + try { + // 调试开始 + $this->debug(true); + + // 预处理 + $this->PDOStatement = $this->linkID->prepare($sql); + + // 是否为存储过程调用 + $procedure = in_array(strtolower(substr(trim($sql), 0, 4)), ['call', 'exec']); + // 参数绑定 + if ($procedure) { + $this->bindParam($bind); + } else { + $this->bindValue($bind); + } + // 执行查询 + $this->PDOStatement->execute(); + // 调试结束 + $this->debug(false, '', $master); + // 返回结果集 + return $this->getResult($pdo, $procedure); + } catch (\PDOException $e) { + if ($this->isBreak($e)) { + return $this->close()->query($sql, $bind, $master, $pdo); + } + throw new PDOException($e, $this->config, $this->getLastsql()); + } catch (\Throwable $e) { + if ($this->isBreak($e)) { + return $this->close()->query($sql, $bind, $master, $pdo); + } + throw $e; + } catch (\Exception $e) { + if ($this->isBreak($e)) { + return $this->close()->query($sql, $bind, $master, $pdo); + } + throw $e; + } + } + + /** + * 执行语句 + * @access public + * @param string $sql sql指令 + * @param array $bind 参数绑定 + * @param Query $query 查询对象 + * @return int + * @throws PDOException + * @throws \Exception + */ + public function execute($sql, $bind = [], Query $query = null) + { + $this->initConnect(true); + if (!$this->linkID) { + return false; + } + + // 记录SQL语句 + $this->queryStr = $sql; + if ($bind) { + $this->bind = $bind; + } + + Db::$executeTimes++; + try { + // 调试开始 + $this->debug(true); + + // 预处理 + $this->PDOStatement = $this->linkID->prepare($sql); + + // 是否为存储过程调用 + $procedure = in_array(strtolower(substr(trim($sql), 0, 4)), ['call', 'exec']); + // 参数绑定 + if ($procedure) { + $this->bindParam($bind); + } else { + $this->bindValue($bind); + } + // 执行语句 + $this->PDOStatement->execute(); + // 调试结束 + $this->debug(false, '', true); + + if ($query && !empty($this->config['deploy']) && !empty($this->config['read_master'])) { + $query->readMaster(); + } + + $this->numRows = $this->PDOStatement->rowCount(); + return $this->numRows; + } catch (\PDOException $e) { + if ($this->isBreak($e)) { + return $this->close()->execute($sql, $bind, $query); + } + throw new PDOException($e, $this->config, $this->getLastsql()); + } catch (\Throwable $e) { + if ($this->isBreak($e)) { + return $this->close()->execute($sql, $bind, $query); + } + throw $e; + } catch (\Exception $e) { + if ($this->isBreak($e)) { + return $this->close()->execute($sql, $bind, $query); + } + throw $e; + } + } + + /** + * 根据参数绑定组装最终的SQL语句 便于调试 + * @access public + * @param string $sql 带参数绑定的sql语句 + * @param array $bind 参数绑定列表 + * @return string + */ + public function getRealSql($sql, array $bind = []) + { + if (is_array($sql)) { + $sql = implode(';', $sql); + } + + foreach ($bind as $key => $val) { + $value = is_array($val) ? $val[0] : $val; + $type = is_array($val) ? $val[1] : PDO::PARAM_STR; + if (PDO::PARAM_STR == $type) { + $value = $this->quote($value); + } elseif (PDO::PARAM_INT == $type) { + $value = (float) $value; + } + // 判断占位符 + $sql = is_numeric($key) ? + substr_replace($sql, $value, strpos($sql, '?'), 1) : + str_replace( + [':' . $key . ')', ':' . $key . ',', ':' . $key . ' ', ':' . $key . PHP_EOL], + [$value . ')', $value . ',', $value . ' ', $value . PHP_EOL], + $sql . ' '); + } + return rtrim($sql); + } + + /** + * 参数绑定 + * 支持 ['name'=>'value','id'=>123] 对应命名占位符 + * 或者 ['value',123] 对应问号占位符 + * @access public + * @param array $bind 要绑定的参数列表 + * @return void + * @throws BindParamException + */ + protected function bindValue(array $bind = []) + { + foreach ($bind as $key => $val) { + // 占位符 + $param = is_numeric($key) ? $key + 1 : ':' . $key; + if (is_array($val)) { + if (PDO::PARAM_INT == $val[1] && '' === $val[0]) { + $val[0] = 0; + } + $result = $this->PDOStatement->bindValue($param, $val[0], $val[1]); + } else { + $result = $this->PDOStatement->bindValue($param, $val); + } + if (!$result) { + throw new BindParamException( + "Error occurred when binding parameters '{$param}'", + $this->config, + $this->getLastsql(), + $bind + ); + } + } + } + + /** + * 存储过程的输入输出参数绑定 + * @access public + * @param array $bind 要绑定的参数列表 + * @return void + * @throws BindParamException + */ + protected function bindParam($bind) + { + foreach ($bind as $key => $val) { + $param = is_numeric($key) ? $key + 1 : ':' . $key; + if (is_array($val)) { + array_unshift($val, $param); + $result = call_user_func_array([$this->PDOStatement, 'bindParam'], $val); + } else { + $result = $this->PDOStatement->bindValue($param, $val); + } + if (!$result) { + $param = array_shift($val); + throw new BindParamException( + "Error occurred when binding parameters '{$param}'", + $this->config, + $this->getLastsql(), + $bind + ); + } + } + } + + /** + * 获得数据集数组 + * @access protected + * @param bool $pdo 是否返回PDOStatement + * @param bool $procedure 是否存储过程 + * @return PDOStatement|array + */ + protected function getResult($pdo = false, $procedure = false) + { + if ($pdo) { + // 返回PDOStatement对象处理 + return $this->PDOStatement; + } + if ($procedure) { + // 存储过程返回结果 + return $this->procedure(); + } + $result = $this->PDOStatement->fetchAll($this->fetchType); + $this->numRows = count($result); + return $result; + } + + /** + * 获得存储过程数据集 + * @access protected + * @return array + */ + protected function procedure() + { + $item = []; + do { + $result = $this->getResult(); + if ($result) { + $item[] = $result; + } + } while ($this->PDOStatement->nextRowset()); + $this->numRows = count($item); + return $item; + } + + /** + * 执行数据库事务 + * @access public + * @param callable $callback 数据操作方法回调 + * @return mixed + * @throws PDOException + * @throws \Exception + * @throws \Throwable + */ + public function transaction($callback) + { + $this->startTrans(); + try { + $result = null; + if (is_callable($callback)) { + $result = call_user_func_array($callback, [$this]); + } + $this->commit(); + return $result; + } catch (\Exception $e) { + $this->rollback(); + throw $e; + } catch (\Throwable $e) { + $this->rollback(); + throw $e; + } + } + + /** + * 启动事务 + * @access public + * @return bool|mixed + * @throws \Exception + */ + public function startTrans() + { + $this->initConnect(true); + if (!$this->linkID) { + return false; + } + + ++$this->transTimes; + try { + if (1 == $this->transTimes) { + $this->linkID->beginTransaction(); + } elseif ($this->transTimes > 1 && $this->supportSavepoint()) { + $this->linkID->exec( + $this->parseSavepoint('trans' . $this->transTimes) + ); + } + + } catch (\Exception $e) { + if ($this->isBreak($e)) { + --$this->transTimes; + return $this->close()->startTrans(); + } + throw $e; + } catch (\Error $e) { + if ($this->isBreak($e)) { + --$this->transTimes; + return $this->close()->startTrans(); + } + throw $e; + } + } + + /** + * 用于非自动提交状态下面的查询提交 + * @access public + * @return void + * @throws PDOException + */ + public function commit() + { + $this->initConnect(true); + + if (1 == $this->transTimes) { + $this->linkID->commit(); + } + + --$this->transTimes; + } + + /** + * 事务回滚 + * @access public + * @return void + * @throws PDOException + */ + public function rollback() + { + $this->initConnect(true); + + if (1 == $this->transTimes) { + $this->linkID->rollBack(); + } elseif ($this->transTimes > 1 && $this->supportSavepoint()) { + $this->linkID->exec( + $this->parseSavepointRollBack('trans' . $this->transTimes) + ); + } + + $this->transTimes = max(0, $this->transTimes - 1); + } + + /** + * 是否支持事务嵌套 + * @return bool + */ + protected function supportSavepoint() + { + return false; + } + + /** + * 生成定义保存点的SQL + * @param $name + * @return string + */ + protected function parseSavepoint($name) + { + return 'SAVEPOINT ' . $name; + } + + /** + * 生成回滚到保存点的SQL + * @param $name + * @return string + */ + protected function parseSavepointRollBack($name) + { + return 'ROLLBACK TO SAVEPOINT ' . $name; + } + + /** + * 批处理执行SQL语句 + * 批处理的指令都认为是execute操作 + * @access public + * @param array $sqlArray SQL批处理指令 + * @return boolean + */ + public function batchQuery($sqlArray = [], $bind = [], Query $query = null) + { + if (!is_array($sqlArray)) { + return false; + } + // 自动启动事务支持 + $this->startTrans(); + try { + foreach ($sqlArray as $sql) { + $this->execute($sql, $bind, $query); + } + // 提交事务 + $this->commit(); + } catch (\Exception $e) { + $this->rollback(); + throw $e; + } + + return true; + } + + /** + * 获得查询次数 + * @access public + * @param boolean $execute 是否包含所有查询 + * @return integer + */ + public function getQueryTimes($execute = false) + { + return $execute ? Db::$queryTimes + Db::$executeTimes : Db::$queryTimes; + } + + /** + * 获得执行次数 + * @access public + * @return integer + */ + public function getExecuteTimes() + { + return Db::$executeTimes; + } + + /** + * 关闭数据库(或者重新连接) + * @access public + * @return $this + */ + public function close() + { + $this->linkID = null; + $this->linkWrite = null; + $this->linkRead = null; + $this->links = []; + // 释放查询 + $this->free(); + return $this; + } + + /** + * 是否断线 + * @access protected + * @param \PDOException|\Exception $e 异常对象 + * @return bool + */ + protected function isBreak($e) + { + if (!$this->config['break_reconnect']) { + return false; + } + + $info = [ + 'server has gone away', + 'no connection to the server', + 'Lost connection', + 'is dead or not enabled', + 'Error while sending', + 'decryption failed or bad record mac', + 'server closed the connection unexpectedly', + 'SSL connection has been closed unexpectedly', + 'Error writing data to the connection', + 'Resource deadlock avoided', + 'failed with errno', + ]; + + $error = $e->getMessage(); + + foreach ($info as $msg) { + if (false !== stripos($error, $msg)) { + return true; + } + } + return false; + } + + /** + * 获取最近一次查询的sql语句 + * @access public + * @return string + */ + public function getLastSql() + { + return $this->getRealSql($this->queryStr, $this->bind); + } + + /** + * 获取最近插入的ID + * @access public + * @param string $sequence 自增序列名 + * @return string + */ + public function getLastInsID($sequence = null) + { + return $this->linkID->lastInsertId($sequence); + } + + /** + * 获取返回或者影响的记录数 + * @access public + * @return integer + */ + public function getNumRows() + { + return $this->numRows; + } + + /** + * 获取最近的错误信息 + * @access public + * @return string + */ + public function getError() + { + if ($this->PDOStatement) { + $error = $this->PDOStatement->errorInfo(); + $error = $error[1] . ':' . $error[2]; + } else { + $error = ''; + } + if ('' != $this->queryStr) { + $error .= "\n [ SQL语句 ] : " . $this->getLastsql(); + } + return $error; + } + + /** + * SQL指令安全过滤 + * @access public + * @param string $str SQL字符串 + * @param bool $master 是否主库查询 + * @return string + */ + public function quote($str, $master = true) + { + $this->initConnect($master); + return $this->linkID ? $this->linkID->quote($str) : $str; + } + + /** + * 数据库调试 记录当前SQL及分析性能 + * @access protected + * @param boolean $start 调试开始标记 true 开始 false 结束 + * @param string $sql 执行的SQL语句 留空自动获取 + * @param boolean $master 主从标记 + * @return void + */ + protected function debug($start, $sql = '', $master = false) + { + if (!empty($this->config['debug'])) { + // 开启数据库调试模式 + if ($start) { + Debug::remark('queryStartTime', 'time'); + } else { + // 记录操作结束时间 + Debug::remark('queryEndTime', 'time'); + $runtime = Debug::getRangeTime('queryStartTime', 'queryEndTime'); + $sql = $sql ?: $this->getLastsql(); + $result = []; + // SQL性能分析 + if ($this->config['sql_explain'] && 0 === stripos(trim($sql), 'select')) { + $result = $this->getExplain($sql); + } + // SQL监听 + $this->trigger($sql, $runtime, $result, $master); + } + } + } + + /** + * 监听SQL执行 + * @access public + * @param callable $callback 回调方法 + * @return void + */ + public function listen($callback) + { + self::$event[] = $callback; + } + + /** + * 触发SQL事件 + * @access protected + * @param string $sql SQL语句 + * @param float $runtime SQL运行时间 + * @param mixed $explain SQL分析 + * @param bool $master 主从标记 + * @return void + */ + protected function trigger($sql, $runtime, $explain = [], $master = false) + { + if (!empty(self::$event)) { + foreach (self::$event as $callback) { + if (is_callable($callback)) { + call_user_func_array($callback, [$sql, $runtime, $explain, $master]); + } + } + } else { + // 未注册监听则记录到日志中 + if ($this->config['deploy']) { + // 分布式记录当前操作的主从 + $master = $master ? 'master|' : 'slave|'; + } else { + $master = ''; + } + + Log::record('[ SQL ] ' . $sql . ' [ ' . $master . 'RunTime:' . $runtime . 's ]', 'sql'); + if (!empty($explain)) { + Log::record('[ EXPLAIN : ' . var_export($explain, true) . ' ]', 'sql'); + } + } + } + + /** + * 初始化数据库连接 + * @access protected + * @param boolean $master 是否主服务器 + * @return void + */ + protected function initConnect($master = true) + { + if (!empty($this->config['deploy'])) { + // 采用分布式数据库 + if ($master || $this->transTimes) { + if (!$this->linkWrite) { + $this->linkWrite = $this->multiConnect(true); + } + $this->linkID = $this->linkWrite; + } else { + if (!$this->linkRead) { + $this->linkRead = $this->multiConnect(false); + } + $this->linkID = $this->linkRead; + } + } elseif (!$this->linkID) { + // 默认单数据库 + $this->linkID = $this->connect(); + } + } + + /** + * 连接分布式服务器 + * @access protected + * @param boolean $master 主服务器 + * @return PDO + */ + protected function multiConnect($master = false) + { + $_config = []; + // 分布式数据库配置解析 + foreach (['username', 'password', 'hostname', 'hostport', 'database', 'dsn', 'charset'] as $name) { + $_config[$name] = explode(',', $this->config[$name]); + } + + // 主服务器序号 + $m = floor(mt_rand(0, $this->config['master_num'] - 1)); + + if ($this->config['rw_separate']) { + // 主从式采用读写分离 + if ($master) // 主服务器写入 + { + $r = $m; + } elseif (is_numeric($this->config['slave_no'])) { + // 指定服务器读 + $r = $this->config['slave_no']; + } else { + // 读操作连接从服务器 每次随机连接的数据库 + $r = floor(mt_rand($this->config['master_num'], count($_config['hostname']) - 1)); + } + } else { + // 读写操作不区分服务器 每次随机连接的数据库 + $r = floor(mt_rand(0, count($_config['hostname']) - 1)); + } + $dbMaster = false; + if ($m != $r) { + $dbMaster = []; + foreach (['username', 'password', 'hostname', 'hostport', 'database', 'dsn', 'charset'] as $name) { + $dbMaster[$name] = isset($_config[$name][$m]) ? $_config[$name][$m] : $_config[$name][0]; + } + } + $dbConfig = []; + foreach (['username', 'password', 'hostname', 'hostport', 'database', 'dsn', 'charset'] as $name) { + $dbConfig[$name] = isset($_config[$name][$r]) ? $_config[$name][$r] : $_config[$name][0]; + } + return $this->connect($dbConfig, $r, $r == $m ? false : $dbMaster); + } + + /** + * 析构方法 + * @access public + */ + public function __destruct() + { + // 释放查询 + if ($this->PDOStatement) { + $this->free(); + } + // 关闭连接 + $this->close(); + } +} diff --git a/thinkphp/library/think/db/Expression.php b/thinkphp/library/think/db/Expression.php new file mode 100644 index 0000000..f1b92ab --- /dev/null +++ b/thinkphp/library/think/db/Expression.php @@ -0,0 +1,48 @@ + +// +---------------------------------------------------------------------- + +namespace think\db; + +class Expression +{ + /** + * 查询表达式 + * + * @var string + */ + protected $value; + + /** + * 创建一个查询表达式 + * + * @param string $value + * @return void + */ + public function __construct($value) + { + $this->value = $value; + } + + /** + * 获取表达式 + * + * @return string + */ + public function getValue() + { + return $this->value; + } + + public function __toString() + { + return (string) $this->value; + } +} diff --git a/thinkphp/library/think/db/Query.php b/thinkphp/library/think/db/Query.php new file mode 100644 index 0000000..4aa74eb --- /dev/null +++ b/thinkphp/library/think/db/Query.php @@ -0,0 +1,3046 @@ + +// +---------------------------------------------------------------------- + +namespace think\db; + +use PDO; +use think\App; +use think\Cache; +use think\Collection; +use think\Config; +use think\Db; +use think\db\exception\BindParamException; +use think\db\exception\DataNotFoundException; +use think\db\exception\ModelNotFoundException; +use think\Exception; +use think\exception\DbException; +use think\exception\PDOException; +use think\Loader; +use think\Model; +use think\model\Relation; +use think\model\relation\OneToOne; +use think\Paginator; + +class Query +{ + // 数据库Connection对象实例 + protected $connection; + // 数据库Builder对象实例 + protected $builder; + // 当前模型类名称 + protected $model; + // 当前数据表名称(含前缀) + protected $table = ''; + // 当前数据表名称(不含前缀) + protected $name = ''; + // 当前数据表主键 + protected $pk; + // 当前数据表前缀 + protected $prefix = ''; + // 查询参数 + protected $options = []; + // 参数绑定 + protected $bind = []; + // 数据表信息 + protected static $info = []; + // 回调事件 + private static $event = []; + // 读取主库 + protected static $readMaster = []; + + /** + * 构造函数 + * @access public + * @param Connection $connection 数据库对象实例 + * @param Model $model 模型对象 + */ + public function __construct(Connection $connection = null, $model = null) + { + $this->connection = $connection ?: Db::connect([], true); + $this->prefix = $this->connection->getConfig('prefix'); + $this->model = $model; + // 设置当前连接的Builder对象 + $this->setBuilder(); + } + + /** + * 利用__call方法实现一些特殊的Model方法 + * @access public + * @param string $method 方法名称 + * @param array $args 调用参数 + * @return mixed + * @throws DbException + * @throws Exception + */ + public function __call($method, $args) + { + if (strtolower(substr($method, 0, 5)) == 'getby') { + // 根据某个字段获取记录 + $field = Loader::parseName(substr($method, 5)); + $where[$field] = $args[0]; + return $this->where($where)->find(); + } elseif (strtolower(substr($method, 0, 10)) == 'getfieldby') { + // 根据某个字段获取记录的某个值 + $name = Loader::parseName(substr($method, 10)); + $where[$name] = $args[0]; + return $this->where($where)->value($args[1]); + } elseif ($this->model && method_exists($this->model, 'scope' . $method)) { + // 动态调用命名范围 + $method = 'scope' . $method; + array_unshift($args, $this); + + call_user_func_array([$this->model, $method], $args); + return $this; + } else { + throw new Exception('method not exist:' . __CLASS__ . '->' . $method); + } + } + + /** + * 获取当前的数据库Connection对象 + * @access public + * @return Connection + */ + public function getConnection() + { + return $this->connection; + } + + /** + * 切换当前的数据库连接 + * @access public + * @param mixed $config + * @return $this + */ + public function connect($config) + { + $this->connection = Db::connect($config); + $this->setBuilder(); + $this->prefix = $this->connection->getConfig('prefix'); + return $this; + } + + /** + * 设置当前的数据库Builder对象 + * @access protected + * @return void + */ + protected function setBuilder() + { + $class = $this->connection->getBuilder(); + $this->builder = new $class($this->connection, $this); + } + + /** + * 获取当前的模型对象实例 + * @access public + * @return Model|null + */ + public function getModel() + { + return $this->model; + } + + /** + * 设置后续从主库读取数据 + * @access public + * @param bool $allTable + * @return void + */ + public function readMaster($allTable = false) + { + if ($allTable) { + $table = '*'; + } else { + $table = isset($this->options['table']) ? $this->options['table'] : $this->getTable(); + } + + static::$readMaster[$table] = true; + + return $this; + } + + /** + * 获取当前的builder实例对象 + * @access public + * @return Builder + */ + public function getBuilder() + { + return $this->builder; + } + + /** + * 指定默认的数据表名(不含前缀) + * @access public + * @param string $name + * @return $this + */ + public function name($name) + { + $this->name = $name; + return $this; + } + + /** + * 指定默认数据表名(含前缀) + * @access public + * @param string $table 表名 + * @return $this + */ + public function setTable($table) + { + $this->table = $table; + return $this; + } + + /** + * 得到当前或者指定名称的数据表 + * @access public + * @param string $name + * @return string + */ + public function getTable($name = '') + { + if ($name || empty($this->table)) { + $name = $name ?: $this->name; + $tableName = $this->prefix; + if ($name) { + $tableName .= Loader::parseName($name); + } + } else { + $tableName = $this->table; + } + return $tableName; + } + + /** + * 将SQL语句中的__TABLE_NAME__字符串替换成带前缀的表名(小写) + * @access public + * @param string $sql sql语句 + * @return string + */ + public function parseSqlTable($sql) + { + if (false !== strpos($sql, '__')) { + $prefix = $this->prefix; + $sql = preg_replace_callback("/__([A-Z0-9_-]+)__/sU", function ($match) use ($prefix) { + return $prefix . strtolower($match[1]); + }, $sql); + } + return $sql; + } + + /** + * 执行查询 返回数据集 + * @access public + * @param string $sql sql指令 + * @param array $bind 参数绑定 + * @param boolean $master 是否在主服务器读操作 + * @param bool|string $class 指定返回的数据集对象 + * @return mixed + * @throws BindParamException + * @throws PDOException + */ + public function query($sql, $bind = [], $master = false, $class = false) + { + return $this->connection->query($sql, $bind, $master, $class); + } + + /** + * 执行语句 + * @access public + * @param string $sql sql指令 + * @param array $bind 参数绑定 + * @return int + * @throws BindParamException + * @throws PDOException + */ + public function execute($sql, $bind = []) + { + return $this->connection->execute($sql, $bind, $this); + } + + /** + * 获取最近插入的ID + * @access public + * @param string $sequence 自增序列名 + * @return string + */ + public function getLastInsID($sequence = null) + { + return $this->connection->getLastInsID($sequence); + } + + /** + * 获取最近一次查询的sql语句 + * @access public + * @return string + */ + public function getLastSql() + { + return $this->connection->getLastSql(); + } + + /** + * 执行数据库事务 + * @access public + * @param callable $callback 数据操作方法回调 + * @return mixed + */ + public function transaction($callback) + { + return $this->connection->transaction($callback); + } + + /** + * 启动事务 + * @access public + * @return void + */ + public function startTrans() + { + $this->connection->startTrans(); + } + + /** + * 用于非自动提交状态下面的查询提交 + * @access public + * @return void + * @throws PDOException + */ + public function commit() + { + $this->connection->commit(); + } + + /** + * 事务回滚 + * @access public + * @return void + * @throws PDOException + */ + public function rollback() + { + $this->connection->rollback(); + } + + /** + * 批处理执行SQL语句 + * 批处理的指令都认为是execute操作 + * @access public + * @param array $sql SQL批处理指令 + * @return boolean + */ + public function batchQuery($sql = [], $bind = []) + { + return $this->connection->batchQuery($sql, $bind); + } + + /** + * 获取数据库的配置参数 + * @access public + * @param string $name 参数名称 + * @return boolean + */ + public function getConfig($name = '') + { + return $this->connection->getConfig($name); + } + + /** + * 得到分表的的数据表名 + * @access public + * @param array $data 操作的数据 + * @param string $field 分表依据的字段 + * @param array $rule 分表规则 + * @return string + */ + public function getPartitionTableName($data, $field, $rule = []) + { + // 对数据表进行分区 + if ($field && isset($data[$field])) { + $value = $data[$field]; + $type = $rule['type']; + switch ($type) { + case 'id': + // 按照id范围分表 + $step = $rule['expr']; + $seq = floor($value / $step) + 1; + break; + case 'year': + // 按照年份分表 + if (!is_numeric($value)) { + $value = strtotime($value); + } + $seq = date('Y', $value) - $rule['expr'] + 1; + break; + case 'mod': + // 按照id的模数分表 + $seq = ($value % $rule['num']) + 1; + break; + case 'md5': + // 按照md5的序列分表 + $seq = (ord(substr(md5($value), 0, 1)) % $rule['num']) + 1; + break; + default: + if (function_exists($type)) { + // 支持指定函数哈希 + $seq = (ord(substr($type($value), 0, 1)) % $rule['num']) + 1; + } else { + // 按照字段的首字母的值分表 + $seq = (ord($value[0]) % $rule['num']) + 1; + } + } + return $this->getTable() . '_' . $seq; + } else { + // 当设置的分表字段不在查询条件或者数据中 + // 进行联合查询,必须设定 partition['num'] + $tableName = []; + for ($i = 0; $i < $rule['num']; $i++) { + $tableName[] = 'SELECT * FROM ' . $this->getTable() . '_' . ($i + 1); + } + + $tableName = '( ' . implode(" UNION ", $tableName) . ') AS ' . $this->name; + return $tableName; + } + } + + /** + * 得到某个字段的值 + * @access public + * @param string $field 字段名 + * @param mixed $default 默认值 + * @param bool $force 强制转为数字类型 + * @return mixed + */ + public function value($field, $default = null, $force = false) + { + $result = false; + if (empty($this->options['fetch_sql']) && !empty($this->options['cache'])) { + // 判断查询缓存 + $cache = $this->options['cache']; + if (empty($this->options['table'])) { + $this->options['table'] = $this->getTable(); + } + $key = is_string($cache['key']) ? $cache['key'] : md5($this->connection->getConfig('database') . '.' . $field . serialize($this->options) . serialize($this->bind)); + $result = Cache::get($key); + } + if (false === $result) { + if (isset($this->options['field'])) { + unset($this->options['field']); + } + $pdo = $this->field($field)->limit(1)->getPdo(); + if (is_string($pdo)) { + // 返回SQL语句 + return $pdo; + } + + $result = $pdo->fetchColumn(); + if ($force) { + $result = (float) $result; + } + + if (isset($cache) && false !== $result) { + // 缓存数据 + $this->cacheData($key, $result, $cache); + } + } else { + // 清空查询条件 + $this->options = []; + } + return false !== $result ? $result : $default; + } + + /** + * 得到某个列的数组 + * @access public + * @param string $field 字段名 多个字段用逗号分隔 + * @param string $key 索引 + * @return array + */ + public function column($field, $key = '') + { + $result = false; + if (empty($this->options['fetch_sql']) && !empty($this->options['cache'])) { + // 判断查询缓存 + $cache = $this->options['cache']; + if (empty($this->options['table'])) { + $this->options['table'] = $this->getTable(); + } + $guid = is_string($cache['key']) ? $cache['key'] : md5($this->connection->getConfig('database') . '.' . $field . serialize($this->options) . serialize($this->bind)); + $result = Cache::get($guid); + } + if (false === $result) { + $result = []; + if (isset($this->options['field'])) { + unset($this->options['field']); + } + if (is_null($field)) { + $field = '*'; + } elseif ($key && '*' != $field) { + $field = $key . ',' . $field; + } + $pdo = $this->field($field)->getPdo(); + if (is_string($pdo)) { + // 返回SQL语句 + return $pdo; + } + if (1 == $pdo->columnCount()) { + $result = $pdo->fetchAll(PDO::FETCH_COLUMN); + } else { + $resultSet = $pdo->fetchAll(PDO::FETCH_ASSOC); + if ($resultSet) { + $fields = array_keys($resultSet[0]); + $count = count($fields); + $key1 = array_shift($fields); + $key2 = $fields ? array_shift($fields) : ''; + $key = $key ?: $key1; + if (strpos($key, '.')) { + list($alias, $key) = explode('.', $key); + } + foreach ($resultSet as $val) { + if ($count > 2) { + $result[$val[$key]] = $val; + } elseif (2 == $count) { + $result[$val[$key]] = $val[$key2]; + } elseif (1 == $count) { + $result[$val[$key]] = $val[$key1]; + } + } + } else { + $result = []; + } + } + if (isset($cache) && isset($guid)) { + // 缓存数据 + $this->cacheData($guid, $result, $cache); + } + } else { + // 清空查询条件 + $this->options = []; + } + return $result; + } + + /** + * COUNT查询 + * @access public + * @param string $field 字段名 + * @return integer|string + */ + public function count($field = '*') + { + if (isset($this->options['group'])) { + if (!preg_match('/^[\w\.\*]+$/', $field)) { + throw new Exception('not support data:' . $field); + } + // 支持GROUP + $options = $this->getOptions(); + $subSql = $this->options($options)->field('count(' . $field . ')')->bind($this->bind)->buildSql(); + + $count = $this->table([$subSql => '_group_count_'])->value('COUNT(*) AS tp_count', 0, true); + } else { + $count = $this->aggregate('COUNT', $field, true); + } + + return is_string($count) ? $count : (int) $count; + + } + + /** + * 聚合查询 + * @access public + * @param string $aggregate 聚合方法 + * @param string $field 字段名 + * @param bool $force 强制转为数字类型 + * @return mixed + */ + public function aggregate($aggregate, $field, $force = false) + { + if (0 === stripos($field, 'DISTINCT ')) { + list($distinct, $field) = explode(' ', $field); + } + + if (!preg_match('/^[\w\.\+\-\*]+$/', $field)) { + throw new Exception('not support data:' . $field); + } + + $result = $this->value($aggregate . '(' . (!empty($distinct) ? 'DISTINCT ' : '') . $field . ') AS tp_' . strtolower($aggregate), 0, $force); + + return $result; + } + + /** + * SUM查询 + * @access public + * @param string $field 字段名 + * @return float|int + */ + public function sum($field) + { + return $this->aggregate('SUM', $field, true); + } + + /** + * MIN查询 + * @access public + * @param string $field 字段名 + * @param bool $force 强制转为数字类型 + * @return mixed + */ + public function min($field, $force = true) + { + return $this->aggregate('MIN', $field, $force); + } + + /** + * MAX查询 + * @access public + * @param string $field 字段名 + * @param bool $force 强制转为数字类型 + * @return mixed + */ + public function max($field, $force = true) + { + return $this->aggregate('MAX', $field, $force); + } + + /** + * AVG查询 + * @access public + * @param string $field 字段名 + * @return float|int + */ + public function avg($field) + { + return $this->aggregate('AVG', $field, true); + } + + /** + * 设置记录的某个字段值 + * 支持使用数据库字段和方法 + * @access public + * @param string|array $field 字段名 + * @param mixed $value 字段值 + * @return integer + */ + public function setField($field, $value = '') + { + if (is_array($field)) { + $data = $field; + } else { + $data[$field] = $value; + } + return $this->update($data); + } + + /** + * 字段值(延迟)增长 + * @access public + * @param string $field 字段名 + * @param integer $step 增长值 + * @param integer $lazyTime 延时时间(s) + * @return integer|true + * @throws Exception + */ + public function setInc($field, $step = 1, $lazyTime = 0) + { + $condition = !empty($this->options['where']) ? $this->options['where'] : []; + if (empty($condition)) { + // 没有条件不做任何更新 + throw new Exception('no data to update'); + } + if ($lazyTime > 0) { + // 延迟写入 + $guid = md5($this->getTable() . '_' . $field . '_' . serialize($condition) . serialize($this->bind)); + $step = $this->lazyWrite('inc', $guid, $step, $lazyTime); + if (false === $step) { + // 清空查询条件 + $this->options = []; + return true; + } + } + return $this->setField($field, ['inc', $step]); + } + + /** + * 字段值(延迟)减少 + * @access public + * @param string $field 字段名 + * @param integer $step 减少值 + * @param integer $lazyTime 延时时间(s) + * @return integer|true + * @throws Exception + */ + public function setDec($field, $step = 1, $lazyTime = 0) + { + $condition = !empty($this->options['where']) ? $this->options['where'] : []; + if (empty($condition)) { + // 没有条件不做任何更新 + throw new Exception('no data to update'); + } + if ($lazyTime > 0) { + // 延迟写入 + $guid = md5($this->getTable() . '_' . $field . '_' . serialize($condition) . serialize($this->bind)); + $step = $this->lazyWrite('dec', $guid, $step, $lazyTime); + if (false === $step) { + // 清空查询条件 + $this->options = []; + return true; + } + return $this->setField($field, ['inc', $step]); + } + return $this->setField($field, ['dec', $step]); + } + + /** + * 延时更新检查 返回false表示需要延时 + * 否则返回实际写入的数值 + * @access protected + * @param string $type 自增或者自减 + * @param string $guid 写入标识 + * @param integer $step 写入步进值 + * @param integer $lazyTime 延时时间(s) + * @return false|integer + */ + protected function lazyWrite($type, $guid, $step, $lazyTime) + { + if (!Cache::has($guid . '_time')) { + // 计时开始 + Cache::set($guid . '_time', $_SERVER['REQUEST_TIME'], 0); + Cache::$type($guid, $step); + } elseif ($_SERVER['REQUEST_TIME'] > Cache::get($guid . '_time') + $lazyTime) { + // 删除缓存 + $value = Cache::$type($guid, $step); + Cache::rm($guid); + Cache::rm($guid . '_time'); + return 0 === $value ? false : $value; + } else { + // 更新缓存 + Cache::$type($guid, $step); + } + return false; + } + + /** + * 查询SQL组装 join + * @access public + * @param mixed $join 关联的表名 + * @param mixed $condition 条件 + * @param string $type JOIN类型 + * @return $this + */ + public function join($join, $condition = null, $type = 'INNER') + { + if (empty($condition)) { + // 如果为组数,则循环调用join + foreach ($join as $key => $value) { + if (is_array($value) && 2 <= count($value)) { + $this->join($value[0], $value[1], isset($value[2]) ? $value[2] : $type); + } + } + } else { + $table = $this->getJoinTable($join); + + $this->options['join'][] = [$table, strtoupper($type), $condition]; + } + return $this; + } + + /** + * 获取Join表名及别名 支持 + * ['prefix_table或者子查询'=>'alias'] 'prefix_table alias' 'table alias' + * @access public + * @param array|string $join + * @return array|string + */ + protected function getJoinTable($join, &$alias = null) + { + // 传入的表名为数组 + if (is_array($join)) { + $table = $join; + $alias = array_shift($join); + } else { + $join = trim($join); + if (false !== strpos($join, '(')) { + // 使用子查询 + $table = $join; + } else { + $prefix = $this->prefix; + if (strpos($join, ' ')) { + // 使用别名 + list($table, $alias) = explode(' ', $join); + } else { + $table = $join; + if (false === strpos($join, '.') && 0 !== strpos($join, '__')) { + $alias = $join; + } + } + if ($prefix && false === strpos($table, '.') && 0 !== strpos($table, $prefix) && 0 !== strpos($table, '__')) { + $table = $this->getTable($table); + } + } + if (isset($alias) && $table != $alias) { + $table = [$table => $alias]; + } + } + return $table; + } + + /** + * 查询SQL组装 union + * @access public + * @param mixed $union + * @param boolean $all + * @return $this + */ + public function union($union, $all = false) + { + $this->options['union']['type'] = $all ? 'UNION ALL' : 'UNION'; + + if (is_array($union)) { + $this->options['union'] = array_merge($this->options['union'], $union); + } else { + $this->options['union'][] = $union; + } + return $this; + } + + /** + * 指定查询字段 支持字段排除和指定数据表 + * @access public + * @param mixed $field + * @param boolean $except 是否排除 + * @param string $tableName 数据表名 + * @param string $prefix 字段前缀 + * @param string $alias 别名前缀 + * @return $this + */ + public function field($field, $except = false, $tableName = '', $prefix = '', $alias = '') + { + if (empty($field)) { + return $this; + } elseif ($field instanceof Expression) { + $this->options['field'][] = $field; + return $this; + } + + if (is_string($field)) { + if (preg_match('/[\<\'\"\(]/', $field)) { + return $this->fieldRaw($field); + } + $field = array_map('trim', explode(',', $field)); + } + if (true === $field) { + // 获取全部字段 + $fields = $this->getTableInfo($tableName ?: (isset($this->options['table']) ? $this->options['table'] : ''), 'fields'); + $field = $fields ?: ['*']; + } elseif ($except) { + // 字段排除 + $fields = $this->getTableInfo($tableName ?: (isset($this->options['table']) ? $this->options['table'] : ''), 'fields'); + $field = $fields ? array_diff($fields, $field) : $field; + } + if ($tableName) { + // 添加统一的前缀 + $prefix = $prefix ?: $tableName; + foreach ($field as $key => $val) { + if (is_numeric($key)) { + $val = $prefix . '.' . $val . ($alias ? ' AS ' . $alias . $val : ''); + } + $field[$key] = $val; + } + } + + if (isset($this->options['field'])) { + $field = array_merge((array) $this->options['field'], $field); + } + $this->options['field'] = array_unique($field); + return $this; + } + + /** + * 表达式方式指定查询字段 + * @access public + * @param string $field 字段名 + * @param array $bind 参数绑定 + * @return $this + */ + public function fieldRaw($field, array $bind = []) + { + $this->options['field'][] = $this->raw($field); + + if ($bind) { + $this->bind($bind); + } + + return $this; + } + + /** + * 设置数据 + * @access public + * @param mixed $field 字段名或者数据 + * @param mixed $value 字段值 + * @return $this + */ + public function data($field, $value = null) + { + if (is_array($field)) { + $this->options['data'] = isset($this->options['data']) ? array_merge($this->options['data'], $field) : $field; + } else { + $this->options['data'][$field] = $value; + } + return $this; + } + + /** + * 字段值增长 + * @access public + * @param string|array $field 字段名 + * @param integer $step 增长值 + * @return $this + */ + public function inc($field, $step = 1) + { + $fields = is_string($field) ? explode(',', $field) : $field; + foreach ($fields as $field) { + $this->data($field, ['inc', $step]); + } + return $this; + } + + /** + * 字段值减少 + * @access public + * @param string|array $field 字段名 + * @param integer $step 增长值 + * @return $this + */ + public function dec($field, $step = 1) + { + $fields = is_string($field) ? explode(',', $field) : $field; + foreach ($fields as $field) { + $this->data($field, ['dec', $step]); + } + return $this; + } + + /** + * 使用表达式设置数据 + * @access public + * @param string $field 字段名 + * @param string $value 字段值 + * @return $this + */ + public function exp($field, $value) + { + $this->data($field, $this->raw($value)); + return $this; + } + + /** + * 使用表达式设置数据 + * @access public + * @param mixed $value 表达式 + * @return Expression + */ + public function raw($value) + { + return new Expression($value); + } + + /** + * 指定JOIN查询字段 + * @access public + * @param string|array $table 数据表 + * @param string|array $field 查询字段 + * @param mixed $on JOIN条件 + * @param string $type JOIN类型 + * @return $this + */ + public function view($join, $field = true, $on = null, $type = 'INNER') + { + $this->options['view'] = true; + if (is_array($join) && key($join) === 0) { + foreach ($join as $key => $val) { + $this->view($val[0], $val[1], isset($val[2]) ? $val[2] : null, isset($val[3]) ? $val[3] : 'INNER'); + } + } else { + $fields = []; + $table = $this->getJoinTable($join, $alias); + + if (true === $field) { + $fields = $alias . '.*'; + } else { + if (is_string($field)) { + $field = explode(',', $field); + } + foreach ($field as $key => $val) { + if (is_numeric($key)) { + $fields[] = $alias . '.' . $val; + $this->options['map'][$val] = $alias . '.' . $val; + } else { + if (preg_match('/[,=\.\'\"\(\s]/', $key)) { + $name = $key; + } else { + $name = $alias . '.' . $key; + } + $fields[$name] = $val; + $this->options['map'][$val] = $name; + } + } + } + $this->field($fields); + if ($on) { + $this->join($table, $on, $type); + } else { + $this->table($table); + } + } + return $this; + } + + /** + * 设置分表规则 + * @access public + * @param array $data 操作的数据 + * @param string $field 分表依据的字段 + * @param array $rule 分表规则 + * @return $this + */ + public function partition($data, $field, $rule = []) + { + $this->options['table'] = $this->getPartitionTableName($data, $field, $rule); + return $this; + } + + /** + * 指定AND查询条件 + * @access public + * @param mixed $field 查询字段 + * @param mixed $op 查询表达式 + * @param mixed $condition 查询条件 + * @return $this + */ + public function where($field, $op = null, $condition = null) + { + $param = func_get_args(); + array_shift($param); + $this->parseWhereExp('AND', $field, $op, $condition, $param); + return $this; + } + + /** + * 指定OR查询条件 + * @access public + * @param mixed $field 查询字段 + * @param mixed $op 查询表达式 + * @param mixed $condition 查询条件 + * @return $this + */ + public function whereOr($field, $op = null, $condition = null) + { + $param = func_get_args(); + array_shift($param); + $this->parseWhereExp('OR', $field, $op, $condition, $param); + return $this; + } + + /** + * 指定XOR查询条件 + * @access public + * @param mixed $field 查询字段 + * @param mixed $op 查询表达式 + * @param mixed $condition 查询条件 + * @return $this + */ + public function whereXor($field, $op = null, $condition = null) + { + $param = func_get_args(); + array_shift($param); + $this->parseWhereExp('XOR', $field, $op, $condition, $param); + return $this; + } + + /** + * 指定表达式查询条件 + * @access public + * @param string $where 查询条件 + * @param array $bind 参数绑定 + * @param string $logic 查询逻辑 and or xor + * @return $this + */ + public function whereRaw($where, $bind = [], $logic = 'AND') + { + $this->options['where'][$logic][] = $this->raw($where); + + if ($bind) { + $this->bind($bind); + } + + return $this; + } + + /** + * 指定表达式查询条件 OR + * @access public + * @param string $where 查询条件 + * @param array $bind 参数绑定 + * @return $this + */ + public function whereOrRaw($where, $bind = []) + { + return $this->whereRaw($where, $bind, 'OR'); + } + + /** + * 指定Null查询条件 + * @access public + * @param mixed $field 查询字段 + * @param string $logic 查询逻辑 and or xor + * @return $this + */ + public function whereNull($field, $logic = 'AND') + { + $this->parseWhereExp($logic, $field, 'null', null, [], true); + return $this; + } + + /** + * 指定NotNull查询条件 + * @access public + * @param mixed $field 查询字段 + * @param string $logic 查询逻辑 and or xor + * @return $this + */ + public function whereNotNull($field, $logic = 'AND') + { + $this->parseWhereExp($logic, $field, 'notnull', null, [], true); + return $this; + } + + /** + * 指定Exists查询条件 + * @access public + * @param mixed $condition 查询条件 + * @param string $logic 查询逻辑 and or xor + * @return $this + */ + public function whereExists($condition, $logic = 'AND') + { + $this->options['where'][strtoupper($logic)][] = ['exists', $condition]; + return $this; + } + + /** + * 指定NotExists查询条件 + * @access public + * @param mixed $condition 查询条件 + * @param string $logic 查询逻辑 and or xor + * @return $this + */ + public function whereNotExists($condition, $logic = 'AND') + { + $this->options['where'][strtoupper($logic)][] = ['not exists', $condition]; + return $this; + } + + /** + * 指定In查询条件 + * @access public + * @param mixed $field 查询字段 + * @param mixed $condition 查询条件 + * @param string $logic 查询逻辑 and or xor + * @return $this + */ + public function whereIn($field, $condition, $logic = 'AND') + { + $this->parseWhereExp($logic, $field, 'in', $condition, [], true); + return $this; + } + + /** + * 指定NotIn查询条件 + * @access public + * @param mixed $field 查询字段 + * @param mixed $condition 查询条件 + * @param string $logic 查询逻辑 and or xor + * @return $this + */ + public function whereNotIn($field, $condition, $logic = 'AND') + { + $this->parseWhereExp($logic, $field, 'not in', $condition, [], true); + return $this; + } + + /** + * 指定Like查询条件 + * @access public + * @param mixed $field 查询字段 + * @param mixed $condition 查询条件 + * @param string $logic 查询逻辑 and or xor + * @return $this + */ + public function whereLike($field, $condition, $logic = 'AND') + { + $this->parseWhereExp($logic, $field, 'like', $condition, [], true); + return $this; + } + + /** + * 指定NotLike查询条件 + * @access public + * @param mixed $field 查询字段 + * @param mixed $condition 查询条件 + * @param string $logic 查询逻辑 and or xor + * @return $this + */ + public function whereNotLike($field, $condition, $logic = 'AND') + { + $this->parseWhereExp($logic, $field, 'not like', $condition, [], true); + return $this; + } + + /** + * 指定Between查询条件 + * @access public + * @param mixed $field 查询字段 + * @param mixed $condition 查询条件 + * @param string $logic 查询逻辑 and or xor + * @return $this + */ + public function whereBetween($field, $condition, $logic = 'AND') + { + $this->parseWhereExp($logic, $field, 'between', $condition, [], true); + return $this; + } + + /** + * 指定NotBetween查询条件 + * @access public + * @param mixed $field 查询字段 + * @param mixed $condition 查询条件 + * @param string $logic 查询逻辑 and or xor + * @return $this + */ + public function whereNotBetween($field, $condition, $logic = 'AND') + { + $this->parseWhereExp($logic, $field, 'not between', $condition, [], true); + return $this; + } + + /** + * 指定Exp查询条件 + * @access public + * @param mixed $field 查询字段 + * @param mixed $condition 查询条件 + * @param string $logic 查询逻辑 and or xor + * @return $this + */ + public function whereExp($field, $condition, $logic = 'AND') + { + $this->parseWhereExp($logic, $field, 'exp', $this->raw($condition), [], true); + return $this; + } + + /** + * 设置软删除字段及条件 + * @access public + * @param false|string $field 查询字段 + * @param mixed $condition 查询条件 + * @return $this + */ + public function useSoftDelete($field, $condition = null) + { + if ($field) { + $this->options['soft_delete'] = [$field, $condition ?: ['null', '']]; + } + return $this; + } + + /** + * 分析查询表达式 + * @access public + * @param string $logic 查询逻辑 and or xor + * @param string|array|\Closure $field 查询字段 + * @param mixed $op 查询表达式 + * @param mixed $condition 查询条件 + * @param array $param 查询参数 + * @param bool $strict 严格模式 + * @return void + */ + protected function parseWhereExp($logic, $field, $op, $condition, $param = [], $strict = false) + { + $logic = strtoupper($logic); + if ($field instanceof \Closure) { + $this->options['where'][$logic][] = is_string($op) ? [$op, $field] : $field; + return; + } + + if (is_string($field) && !empty($this->options['via']) && !strpos($field, '.')) { + $field = $this->options['via'] . '.' . $field; + } + + if ($field instanceof Expression) { + return $this->whereRaw($field, is_array($op) ? $op : []); + } elseif ($strict) { + // 使用严格模式查询 + $where[$field] = [$op, $condition]; + + // 记录一个字段多次查询条件 + $this->options['multi'][$logic][$field][] = $where[$field]; + } elseif (is_string($field) && preg_match('/[,=\>\<\'\"\(\s]/', $field)) { + $where[] = ['exp', $this->raw($field)]; + if (is_array($op)) { + // 参数绑定 + $this->bind($op); + } + } elseif (is_null($op) && is_null($condition)) { + if (is_array($field)) { + // 数组批量查询 + $where = $field; + foreach ($where as $k => $val) { + $this->options['multi'][$logic][$k][] = $val; + } + } elseif ($field && is_string($field)) { + // 字符串查询 + $where[$field] = ['null', '']; + $this->options['multi'][$logic][$field][] = $where[$field]; + } + } elseif (is_array($op)) { + $where[$field] = $param; + } elseif (in_array(strtolower($op), ['null', 'notnull', 'not null'])) { + // null查询 + $where[$field] = [$op, '']; + + $this->options['multi'][$logic][$field][] = $where[$field]; + } elseif (is_null($condition)) { + // 字段相等查询 + $where[$field] = ['eq', $op]; + + $this->options['multi'][$logic][$field][] = $where[$field]; + } else { + if ('exp' == strtolower($op)) { + $where[$field] = ['exp', $this->raw($condition)]; + // 参数绑定 + if (isset($param[2]) && is_array($param[2])) { + $this->bind($param[2]); + } + } else { + $where[$field] = [$op, $condition]; + } + // 记录一个字段多次查询条件 + $this->options['multi'][$logic][$field][] = $where[$field]; + } + + if (!empty($where)) { + if (!isset($this->options['where'][$logic])) { + $this->options['where'][$logic] = []; + } + if (is_string($field) && $this->checkMultiField($field, $logic)) { + $where[$field] = $this->options['multi'][$logic][$field]; + } elseif (is_array($field)) { + foreach ($field as $key => $val) { + if ($this->checkMultiField($key, $logic)) { + $where[$key] = $this->options['multi'][$logic][$key]; + } + } + } + $this->options['where'][$logic] = array_merge($this->options['where'][$logic], $where); + } + } + + /** + * 检查是否存在一个字段多次查询条件 + * @access public + * @param string $field 查询字段 + * @param string $logic 查询逻辑 and or xor + * @return bool + */ + private function checkMultiField($field, $logic) + { + return isset($this->options['multi'][$logic][$field]) && count($this->options['multi'][$logic][$field]) > 1; + } + + /** + * 去除某个查询条件 + * @access public + * @param string $field 查询字段 + * @param string $logic 查询逻辑 and or xor + * @return $this + */ + public function removeWhereField($field, $logic = 'AND') + { + $logic = strtoupper($logic); + if (isset($this->options['where'][$logic][$field])) { + unset($this->options['where'][$logic][$field]); + unset($this->options['multi'][$logic][$field]); + } + return $this; + } + + /** + * 去除查询参数 + * @access public + * @param string|bool $option 参数名 true 表示去除所有参数 + * @return $this + */ + public function removeOption($option = true) + { + if (true === $option) { + $this->options = []; + } elseif (is_string($option) && isset($this->options[$option])) { + unset($this->options[$option]); + } + return $this; + } + + /** + * 指定查询数量 + * @access public + * @param mixed $offset 起始位置 + * @param mixed $length 查询数量 + * @return $this + */ + public function limit($offset, $length = null) + { + if (is_null($length) && strpos($offset, ',')) { + list($offset, $length) = explode(',', $offset); + } + $this->options['limit'] = intval($offset) . ($length ? ',' . intval($length) : ''); + return $this; + } + + /** + * 指定分页 + * @access public + * @param mixed $page 页数 + * @param mixed $listRows 每页数量 + * @return $this + */ + public function page($page, $listRows = null) + { + if (is_null($listRows) && strpos($page, ',')) { + list($page, $listRows) = explode(',', $page); + } + $this->options['page'] = [intval($page), intval($listRows)]; + return $this; + } + + /** + * 分页查询 + * @param int|array $listRows 每页数量 数组表示配置参数 + * @param int|bool $simple 是否简洁模式或者总记录数 + * @param array $config 配置参数 + * page:当前页, + * path:url路径, + * query:url额外参数, + * fragment:url锚点, + * var_page:分页变量, + * list_rows:每页数量 + * type:分页类名 + * @return \think\Paginator + * @throws DbException + */ + public function paginate($listRows = null, $simple = false, $config = []) + { + if (is_int($simple)) { + $total = $simple; + $simple = false; + } + if (is_array($listRows)) { + $config = array_merge(Config::get('paginate'), $listRows); + $listRows = $config['list_rows']; + } else { + $config = array_merge(Config::get('paginate'), $config); + $listRows = $listRows ?: $config['list_rows']; + } + + /** @var Paginator $class */ + $class = false !== strpos($config['type'], '\\') ? $config['type'] : '\\think\\paginator\\driver\\' . ucwords($config['type']); + $page = isset($config['page']) ? (int) $config['page'] : call_user_func([ + $class, + 'getCurrentPage', + ], $config['var_page']); + + $page = $page < 1 ? 1 : $page; + + $config['path'] = isset($config['path']) ? $config['path'] : call_user_func([$class, 'getCurrentPath']); + + if (!isset($total) && !$simple) { + $options = $this->getOptions(); + + unset($this->options['order'], $this->options['limit'], $this->options['page'], $this->options['field']); + + $bind = $this->bind; + $total = $this->count(); + $results = $this->options($options)->bind($bind)->page($page, $listRows)->select(); + } elseif ($simple) { + $results = $this->limit(($page - 1) * $listRows, $listRows + 1)->select(); + $total = null; + } else { + $results = $this->page($page, $listRows)->select(); + } + return $class::make($results, $listRows, $page, $total, $simple, $config); + } + + /** + * 指定当前操作的数据表 + * @access public + * @param mixed $table 表名 + * @return $this + */ + public function table($table) + { + if (is_string($table)) { + if (strpos($table, ')')) { + // 子查询 + } elseif (strpos($table, ',')) { + $tables = explode(',', $table); + $table = []; + foreach ($tables as $item) { + list($item, $alias) = explode(' ', trim($item)); + if ($alias) { + $this->alias([$item => $alias]); + $table[$item] = $alias; + } else { + $table[] = $item; + } + } + } elseif (strpos($table, ' ')) { + list($table, $alias) = explode(' ', $table); + + $table = [$table => $alias]; + $this->alias($table); + } + } else { + $tables = $table; + $table = []; + foreach ($tables as $key => $val) { + if (is_numeric($key)) { + $table[] = $val; + } else { + $this->alias([$key => $val]); + $table[$key] = $val; + } + } + } + $this->options['table'] = $table; + return $this; + } + + /** + * USING支持 用于多表删除 + * @access public + * @param mixed $using + * @return $this + */ + public function using($using) + { + $this->options['using'] = $using; + return $this; + } + + /** + * 指定排序 order('id','desc') 或者 order(['id'=>'desc','create_time'=>'desc']) + * @access public + * @param string|array $field 排序字段 + * @param string $order 排序 + * @return $this + */ + public function order($field, $order = null) + { + if (empty($field)) { + return $this; + } elseif ($field instanceof Expression) { + $this->options['order'][] = $field; + return $this; + } + + if (is_string($field)) { + if (!empty($this->options['via'])) { + $field = $this->options['via'] . '.' . $field; + } + if (strpos($field, ',')) { + $field = array_map('trim', explode(',', $field)); + } else { + $field = empty($order) ? $field : [$field => $order]; + } + } elseif (!empty($this->options['via'])) { + foreach ($field as $key => $val) { + if (is_numeric($key)) { + $field[$key] = $this->options['via'] . '.' . $val; + } else { + $field[$this->options['via'] . '.' . $key] = $val; + unset($field[$key]); + } + } + } + if (!isset($this->options['order'])) { + $this->options['order'] = []; + } + if (is_array($field)) { + $this->options['order'] = array_merge($this->options['order'], $field); + } else { + $this->options['order'][] = $field; + } + + return $this; + } + + /** + * 表达式方式指定Field排序 + * @access public + * @param string $field 排序字段 + * @param array $bind 参数绑定 + * @return $this + */ + public function orderRaw($field, array $bind = []) + { + $this->options['order'][] = $this->raw($field); + + if ($bind) { + $this->bind($bind); + } + + return $this; + } + + /** + * 查询缓存 + * @access public + * @param mixed $key 缓存key + * @param integer|\DateTime $expire 缓存有效期 + * @param string $tag 缓存标签 + * @return $this + */ + public function cache($key = true, $expire = null, $tag = null) + { + // 增加快捷调用方式 cache(10) 等同于 cache(true, 10) + if ($key instanceof \DateTime || (is_numeric($key) && is_null($expire))) { + $expire = $key; + $key = true; + } + + if (false !== $key) { + $this->options['cache'] = ['key' => $key, 'expire' => $expire, 'tag' => $tag]; + } + return $this; + } + + /** + * 指定group查询 + * @access public + * @param string $group GROUP + * @return $this + */ + public function group($group) + { + $this->options['group'] = $group; + return $this; + } + + /** + * 指定having查询 + * @access public + * @param string $having having + * @return $this + */ + public function having($having) + { + $this->options['having'] = $having; + return $this; + } + + /** + * 指定查询lock + * @access public + * @param bool|string $lock 是否lock + * @return $this + */ + public function lock($lock = false) + { + $this->options['lock'] = $lock; + $this->options['master'] = true; + return $this; + } + + /** + * 指定distinct查询 + * @access public + * @param string $distinct 是否唯一 + * @return $this + */ + public function distinct($distinct) + { + $this->options['distinct'] = $distinct; + return $this; + } + + /** + * 指定数据表别名 + * @access public + * @param mixed $alias 数据表别名 + * @return $this + */ + public function alias($alias) + { + if (is_array($alias)) { + foreach ($alias as $key => $val) { + if (false !== strpos($key, '__')) { + $table = $this->parseSqlTable($key); + } else { + $table = $key; + } + $this->options['alias'][$table] = $val; + } + } else { + if (isset($this->options['table'])) { + $table = is_array($this->options['table']) ? key($this->options['table']) : $this->options['table']; + if (false !== strpos($table, '__')) { + $table = $this->parseSqlTable($table); + } + } else { + $table = $this->getTable(); + } + + $this->options['alias'][$table] = $alias; + } + return $this; + } + + /** + * 指定强制索引 + * @access public + * @param string $force 索引名称 + * @return $this + */ + public function force($force) + { + $this->options['force'] = $force; + return $this; + } + + /** + * 查询注释 + * @access public + * @param string $comment 注释 + * @return $this + */ + public function comment($comment) + { + $this->options['comment'] = $comment; + return $this; + } + + /** + * 获取执行的SQL语句 + * @access public + * @param boolean $fetch 是否返回sql + * @return $this + */ + public function fetchSql($fetch = true) + { + $this->options['fetch_sql'] = $fetch; + return $this; + } + + /** + * 不主动获取数据集 + * @access public + * @param bool $pdo 是否返回 PDOStatement 对象 + * @return $this + */ + public function fetchPdo($pdo = true) + { + $this->options['fetch_pdo'] = $pdo; + return $this; + } + + /** + * 设置从主服务器读取数据 + * @access public + * @return $this + */ + public function master() + { + $this->options['master'] = true; + return $this; + } + + /** + * 设置是否严格检查字段名 + * @access public + * @param bool $strict 是否严格检查字段 + * @return $this + */ + public function strict($strict = true) + { + $this->options['strict'] = $strict; + return $this; + } + + /** + * 设置查询数据不存在是否抛出异常 + * @access public + * @param bool $fail 数据不存在是否抛出异常 + * @return $this + */ + public function failException($fail = true) + { + $this->options['fail'] = $fail; + return $this; + } + + /** + * 设置自增序列名 + * @access public + * @param string $sequence 自增序列名 + * @return $this + */ + public function sequence($sequence = null) + { + $this->options['sequence'] = $sequence; + return $this; + } + + /** + * 指定数据表主键 + * @access public + * @param string $pk 主键 + * @return $this + */ + public function pk($pk) + { + $this->pk = $pk; + return $this; + } + + /** + * 查询日期或者时间 + * @access public + * @param string $field 日期字段名 + * @param string|array $op 比较运算符或者表达式 + * @param string|array $range 比较范围 + * @return $this + */ + public function whereTime($field, $op, $range = null) + { + if (is_null($range)) { + if (is_array($op)) { + $range = $op; + } else { + // 使用日期表达式 + switch (strtolower($op)) { + case 'today': + case 'd': + $range = ['today', 'tomorrow']; + break; + case 'week': + case 'w': + $range = ['this week 00:00:00', 'next week 00:00:00']; + break; + case 'month': + case 'm': + $range = ['first Day of this month 00:00:00', 'first Day of next month 00:00:00']; + break; + case 'year': + case 'y': + $range = ['this year 1/1', 'next year 1/1']; + break; + case 'yesterday': + $range = ['yesterday', 'today']; + break; + case 'last week': + $range = ['last week 00:00:00', 'this week 00:00:00']; + break; + case 'last month': + $range = ['first Day of last month 00:00:00', 'first Day of this month 00:00:00']; + break; + case 'last year': + $range = ['last year 1/1', 'this year 1/1']; + break; + default: + $range = $op; + } + } + $op = is_array($range) ? 'between' : '>'; + } + $this->where($field, strtolower($op) . ' time', $range); + return $this; + } + + /** + * 获取数据表信息 + * @access public + * @param mixed $tableName 数据表名 留空自动获取 + * @param string $fetch 获取信息类型 包括 fields type bind pk + * @return mixed + */ + public function getTableInfo($tableName = '', $fetch = '') + { + if (!$tableName) { + $tableName = $this->getTable(); + } + if (is_array($tableName)) { + $tableName = key($tableName) ?: current($tableName); + } + + if (strpos($tableName, ',')) { + // 多表不获取字段信息 + return false; + } else { + $tableName = $this->parseSqlTable($tableName); + } + + // 修正子查询作为表名的问题 + if (strpos($tableName, ')')) { + return []; + } + + list($guid) = explode(' ', $tableName); + $db = $this->getConfig('database'); + if (!isset(self::$info[$db . '.' . $guid])) { + if (!strpos($guid, '.')) { + $schema = $db . '.' . $guid; + } else { + $schema = $guid; + } + // 读取缓存 + if (!App::$debug && is_file(RUNTIME_PATH . 'schema/' . $schema . '.php')) { + $info = include RUNTIME_PATH . 'schema/' . $schema . '.php'; + } else { + $info = $this->connection->getFields($guid); + } + $fields = array_keys($info); + $bind = $type = []; + foreach ($info as $key => $val) { + // 记录字段类型 + $type[$key] = $val['type']; + $bind[$key] = $this->getFieldBindType($val['type']); + if (!empty($val['primary'])) { + $pk[] = $key; + } + } + if (isset($pk)) { + // 设置主键 + $pk = count($pk) > 1 ? $pk : $pk[0]; + } else { + $pk = null; + } + self::$info[$db . '.' . $guid] = ['fields' => $fields, 'type' => $type, 'bind' => $bind, 'pk' => $pk]; + } + return $fetch ? self::$info[$db . '.' . $guid][$fetch] : self::$info[$db . '.' . $guid]; + } + + /** + * 获取当前数据表的主键 + * @access public + * @param string|array $options 数据表名或者查询参数 + * @return string|array + */ + public function getPk($options = '') + { + if (!empty($this->pk)) { + $pk = $this->pk; + } else { + $pk = $this->getTableInfo(is_array($options) && isset($options['table']) ? $options['table'] : $options, 'pk'); + } + return $pk; + } + + // 获取当前数据表字段信息 + public function getTableFields($table = '') + { + return $this->getTableInfo($table ?: $this->getOptions('table'), 'fields'); + } + + // 获取当前数据表字段类型 + public function getFieldsType($table = '') + { + return $this->getTableInfo($table ?: $this->getOptions('table'), 'type'); + } + + // 获取当前数据表绑定信息 + public function getFieldsBind($table = '') + { + $types = $this->getFieldsType($table); + $bind = []; + if ($types) { + foreach ($types as $key => $type) { + $bind[$key] = $this->getFieldBindType($type); + } + } + return $bind; + } + + /** + * 获取字段绑定类型 + * @access public + * @param string $type 字段类型 + * @return integer + */ + protected function getFieldBindType($type) + { + if (0 === strpos($type, 'set') || 0 === strpos($type, 'enum')) { + $bind = PDO::PARAM_STR; + } elseif (preg_match('/(int|double|float|decimal|real|numeric|serial|bit)/is', $type)) { + $bind = PDO::PARAM_INT; + } elseif (preg_match('/bool/is', $type)) { + $bind = PDO::PARAM_BOOL; + } else { + $bind = PDO::PARAM_STR; + } + return $bind; + } + + /** + * 参数绑定 + * @access public + * @param mixed $key 参数名 + * @param mixed $value 绑定变量值 + * @param integer $type 绑定类型 + * @return $this + */ + public function bind($key, $value = false, $type = PDO::PARAM_STR) + { + if (is_array($key)) { + $this->bind = array_merge($this->bind, $key); + } else { + $this->bind[$key] = [$value, $type]; + } + return $this; + } + + /** + * 检测参数是否已经绑定 + * @access public + * @param string $key 参数名 + * @return bool + */ + public function isBind($key) + { + return isset($this->bind[$key]); + } + + /** + * 查询参数赋值 + * @access protected + * @param array $options 表达式参数 + * @return $this + */ + protected function options(array $options) + { + $this->options = $options; + return $this; + } + + /** + * 获取当前的查询参数 + * @access public + * @param string $name 参数名 + * @return mixed + */ + public function getOptions($name = '') + { + if ('' === $name) { + return $this->options; + } else { + return isset($this->options[$name]) ? $this->options[$name] : null; + } + } + + /** + * 设置关联查询JOIN预查询 + * @access public + * @param string|array $with 关联方法名称 + * @return $this + */ + public function with($with) + { + if (empty($with)) { + return $this; + } + + if (is_string($with)) { + $with = explode(',', $with); + } + + $first = true; + + /** @var Model $class */ + $class = $this->model; + foreach ($with as $key => $relation) { + $subRelation = ''; + $closure = false; + if ($relation instanceof \Closure) { + // 支持闭包查询过滤关联条件 + $closure = $relation; + $relation = $key; + $with[$key] = $key; + } elseif (is_array($relation)) { + $subRelation = $relation; + $relation = $key; + } elseif (is_string($relation) && strpos($relation, '.')) { + $with[$key] = $relation; + list($relation, $subRelation) = explode('.', $relation, 2); + } + + /** @var Relation $model */ + $relation = Loader::parseName($relation, 1, false); + $model = $class->$relation(); + if ($model instanceof OneToOne && 0 == $model->getEagerlyType()) { + $model->eagerly($this, $relation, $subRelation, $closure, $first); + $first = false; + } elseif ($closure) { + $with[$key] = $closure; + } + } + $this->via(); + if (isset($this->options['with'])) { + $this->options['with'] = array_merge($this->options['with'], $with); + } else { + $this->options['with'] = $with; + } + return $this; + } + + /** + * 关联统计 + * @access public + * @param string|array $relation 关联方法名 + * @param bool $subQuery 是否使用子查询 + * @return $this + */ + public function withCount($relation, $subQuery = true) + { + if (!$subQuery) { + $this->options['with_count'] = $relation; + } else { + $relations = is_string($relation) ? explode(',', $relation) : $relation; + if (!isset($this->options['field'])) { + $this->field('*'); + } + foreach ($relations as $key => $relation) { + $closure = $name = null; + if ($relation instanceof \Closure) { + $closure = $relation; + $relation = $key; + } elseif (!is_int($key)) { + $name = $relation; + $relation = $key; + } + $relation = Loader::parseName($relation, 1, false); + + $count = '(' . $this->model->$relation()->getRelationCountQuery($closure, $name) . ')'; + + if (empty($name)) { + $name = Loader::parseName($relation) . '_count'; + } + + $this->field([$count => $name]); + } + } + return $this; + } + + /** + * 关联预加载中 获取关联指定字段值 + * example: + * Model::with(['relation' => function($query){ + * $query->withField("id,name"); + * }]) + * + * @param string | array $field 指定获取的字段 + * @return $this + */ + public function withField($field) + { + $this->options['with_field'] = $field; + return $this; + } + + /** + * 设置当前字段添加的表别名 + * @access public + * @param string $via + * @return $this + */ + public function via($via = '') + { + $this->options['via'] = $via; + return $this; + } + + /** + * 设置关联查询 + * @access public + * @param string|array $relation 关联名称 + * @return $this + */ + public function relation($relation) + { + if (empty($relation)) { + return $this; + } + if (is_string($relation)) { + $relation = explode(',', $relation); + } + if (isset($this->options['relation'])) { + $this->options['relation'] = array_merge($this->options['relation'], $relation); + } else { + $this->options['relation'] = $relation; + } + return $this; + } + + /** + * 把主键值转换为查询条件 支持复合主键 + * @access public + * @param array|string $data 主键数据 + * @param mixed $options 表达式参数 + * @return void + * @throws Exception + */ + protected function parsePkWhere($data, &$options) + { + $pk = $this->getPk($options); + // 获取当前数据表 + $table = is_array($options['table']) ? key($options['table']) : $options['table']; + if (!empty($options['alias'][$table])) { + $alias = $options['alias'][$table]; + } + if (is_string($pk)) { + $key = isset($alias) ? $alias . '.' . $pk : $pk; + // 根据主键查询 + if (is_array($data)) { + $where[$key] = isset($data[$pk]) ? $data[$pk] : ['in', $data]; + } else { + $where[$key] = strpos($data, ',') ? ['IN', $data] : $data; + } + } elseif (is_array($pk) && is_array($data) && !empty($data)) { + // 根据复合主键查询 + foreach ($pk as $key) { + if (isset($data[$key])) { + $attr = isset($alias) ? $alias . '.' . $key : $key; + $where[$attr] = $data[$key]; + } else { + throw new Exception('miss complex primary data'); + } + } + } + + if (!empty($where)) { + if (isset($options['where']['AND'])) { + $options['where']['AND'] = array_merge($options['where']['AND'], $where); + } else { + $options['where']['AND'] = $where; + } + } + return; + } + + /** + * 插入记录 + * @access public + * @param mixed $data 数据 + * @param boolean $replace 是否replace + * @param boolean $getLastInsID 返回自增主键 + * @param string $sequence 自增序列名 + * @return integer|string + */ + public function insert(array $data = [], $replace = false, $getLastInsID = false, $sequence = null) + { + // 分析查询表达式 + $options = $this->parseExpress(); + $data = array_merge($options['data'], $data); + // 生成SQL语句 + $sql = $this->builder->insert($data, $options, $replace); + // 获取参数绑定 + $bind = $this->getBind(); + if ($options['fetch_sql']) { + // 获取实际执行的SQL语句 + return $this->connection->getRealSql($sql, $bind); + } + + // 执行操作 + $result = 0 === $sql ? 0 : $this->execute($sql, $bind, $this); + if ($result) { + $sequence = $sequence ?: (isset($options['sequence']) ? $options['sequence'] : null); + $lastInsId = $this->getLastInsID($sequence); + if ($lastInsId) { + $pk = $this->getPk($options); + if (is_string($pk)) { + $data[$pk] = $lastInsId; + } + } + $options['data'] = $data; + $this->trigger('after_insert', $options); + + if ($getLastInsID) { + return $lastInsId; + } + } + return $result; + } + + /** + * 插入记录并获取自增ID + * @access public + * @param mixed $data 数据 + * @param boolean $replace 是否replace + * @param string $sequence 自增序列名 + * @return integer|string + */ + public function insertGetId(array $data, $replace = false, $sequence = null) + { + return $this->insert($data, $replace, true, $sequence); + } + + /** + * 批量插入记录 + * @access public + * @param mixed $dataSet 数据集 + * @param boolean $replace 是否replace + * @param integer $limit 每次写入数据限制 + * @return integer|string + */ + public function insertAll(array $dataSet, $replace = false, $limit = null) + { + // 分析查询表达式 + $options = $this->parseExpress(); + if (!is_array(reset($dataSet))) { + return false; + } + + // 生成SQL语句 + if (is_null($limit)) { + $sql = $this->builder->insertAll($dataSet, $options, $replace); + } else { + $array = array_chunk($dataSet, $limit, true); + foreach ($array as $item) { + $sql[] = $this->builder->insertAll($item, $options, $replace); + } + } + + // 获取参数绑定 + $bind = $this->getBind(); + if ($options['fetch_sql']) { + // 获取实际执行的SQL语句 + return $this->connection->getRealSql($sql, $bind); + } elseif (is_array($sql)) { + // 执行操作 + return $this->batchQuery($sql, $bind, $this); + } else { + // 执行操作 + return $this->execute($sql, $bind, $this); + } + } + + /** + * 通过Select方式插入记录 + * @access public + * @param string $fields 要插入的数据表字段名 + * @param string $table 要插入的数据表名 + * @return integer|string + * @throws PDOException + */ + public function selectInsert($fields, $table) + { + // 分析查询表达式 + $options = $this->parseExpress(); + // 生成SQL语句 + $table = $this->parseSqlTable($table); + $sql = $this->builder->selectInsert($fields, $table, $options); + // 获取参数绑定 + $bind = $this->getBind(); + if ($options['fetch_sql']) { + // 获取实际执行的SQL语句 + return $this->connection->getRealSql($sql, $bind); + } else { + // 执行操作 + return $this->execute($sql, $bind, $this); + } + } + + /** + * 更新记录 + * @access public + * @param mixed $data 数据 + * @return integer|string + * @throws Exception + * @throws PDOException + */ + public function update(array $data = []) + { + $options = $this->parseExpress(); + $data = array_merge($options['data'], $data); + $pk = $this->getPk($options); + if (isset($options['cache']) && is_string($options['cache']['key'])) { + $key = $options['cache']['key']; + } + + if (empty($options['where'])) { + // 如果存在主键数据 则自动作为更新条件 + if (is_string($pk) && isset($data[$pk])) { + $where[$pk] = $data[$pk]; + if (!isset($key)) { + $key = 'think:' . $options['table'] . '|' . $data[$pk]; + } + unset($data[$pk]); + } elseif (is_array($pk)) { + // 增加复合主键支持 + foreach ($pk as $field) { + if (isset($data[$field])) { + $where[$field] = $data[$field]; + } else { + // 如果缺少复合主键数据则不执行 + throw new Exception('miss complex primary data'); + } + unset($data[$field]); + } + } + if (!isset($where)) { + // 如果没有任何更新条件则不执行 + throw new Exception('miss update condition'); + } else { + $options['where']['AND'] = $where; + } + } elseif (!isset($key) && is_string($pk) && isset($options['where']['AND'][$pk])) { + $key = $this->getCacheKey($options['where']['AND'][$pk], $options, $this->bind); + } + + // 生成UPDATE SQL语句 + $sql = $this->builder->update($data, $options); + // 获取参数绑定 + $bind = $this->getBind(); + if ($options['fetch_sql']) { + // 获取实际执行的SQL语句 + return $this->connection->getRealSql($sql, $bind); + } else { + // 检测缓存 + if (isset($key) && Cache::get($key)) { + // 删除缓存 + Cache::rm($key); + } elseif (!empty($options['cache']['tag'])) { + Cache::clear($options['cache']['tag']); + } + // 执行操作 + $result = '' == $sql ? 0 : $this->execute($sql, $bind, $this); + if ($result) { + if (is_string($pk) && isset($where[$pk])) { + $data[$pk] = $where[$pk]; + } elseif (is_string($pk) && isset($key) && strpos($key, '|')) { + list($a, $val) = explode('|', $key); + $data[$pk] = $val; + } + $options['data'] = $data; + $this->trigger('after_update', $options); + } + return $result; + } + } + + /** + * 执行查询但只返回PDOStatement对象 + * @access public + * @return \PDOStatement|string + */ + public function getPdo() + { + // 分析查询表达式 + $options = $this->parseExpress(); + // 生成查询SQL + $sql = $this->builder->select($options); + // 获取参数绑定 + $bind = $this->getBind(); + if ($options['fetch_sql']) { + // 获取实际执行的SQL语句 + return $this->connection->getRealSql($sql, $bind); + } + // 执行查询操作 + return $this->query($sql, $bind, $options['master'], true); + } + + /** + * 查找记录 + * @access public + * @param array|string|Query|\Closure $data + * @return Collection|false|\PDOStatement|string + * @throws DbException + * @throws ModelNotFoundException + * @throws DataNotFoundException + */ + public function select($data = null) + { + if ($data instanceof Query) { + return $data->select(); + } elseif ($data instanceof \Closure) { + call_user_func_array($data, [ & $this]); + $data = null; + } + // 分析查询表达式 + $options = $this->parseExpress(); + + if (false === $data) { + // 用于子查询 不查询只返回SQL + $options['fetch_sql'] = true; + } elseif (!is_null($data)) { + // 主键条件分析 + $this->parsePkWhere($data, $options); + } + + $resultSet = false; + if (empty($options['fetch_sql']) && !empty($options['cache'])) { + // 判断查询缓存 + $cache = $options['cache']; + unset($options['cache']); + $key = is_string($cache['key']) ? $cache['key'] : md5($this->connection->getConfig('database') . '.' . serialize($options) . serialize($this->bind)); + $resultSet = Cache::get($key); + } + if (false === $resultSet) { + // 生成查询SQL + $sql = $this->builder->select($options); + // 获取参数绑定 + $bind = $this->getBind(); + if ($options['fetch_sql']) { + // 获取实际执行的SQL语句 + return $this->connection->getRealSql($sql, $bind); + } + + $options['data'] = $data; + if ($resultSet = $this->trigger('before_select', $options)) { + } else { + // 执行查询操作 + $resultSet = $this->query($sql, $bind, $options['master'], $options['fetch_pdo']); + + if ($resultSet instanceof \PDOStatement) { + // 返回PDOStatement对象 + return $resultSet; + } + } + + if (isset($cache) && false !== $resultSet) { + // 缓存数据集 + $this->cacheData($key, $resultSet, $cache); + } + } + + // 数据列表读取后的处理 + if (!empty($this->model)) { + // 生成模型对象 + if (count($resultSet) > 0) { + foreach ($resultSet as $key => $result) { + /** @var Model $model */ + $model = $this->model->newInstance($result); + $model->isUpdate(true); + + // 关联查询 + if (!empty($options['relation'])) { + $model->relationQuery($options['relation']); + } + // 关联统计 + if (!empty($options['with_count'])) { + $model->relationCount($model, $options['with_count']); + } + $resultSet[$key] = $model; + } + if (!empty($options['with'])) { + // 预载入 + $model->eagerlyResultSet($resultSet, $options['with']); + } + // 模型数据集转换 + $resultSet = $model->toCollection($resultSet); + } else { + $resultSet = $this->model->toCollection($resultSet); + } + } elseif ('collection' == $this->connection->getConfig('resultset_type')) { + // 返回Collection对象 + $resultSet = new Collection($resultSet); + } + // 返回结果处理 + if (!empty($options['fail']) && count($resultSet) == 0) { + $this->throwNotFound($options); + } + return $resultSet; + } + + /** + * 缓存数据 + * @access public + * @param string $key 缓存标识 + * @param mixed $data 缓存数据 + * @param array $config 缓存参数 + */ + protected function cacheData($key, $data, $config = []) + { + if (isset($config['tag'])) { + Cache::tag($config['tag'])->set($key, $data, $config['expire']); + } else { + Cache::set($key, $data, $config['expire']); + } + } + + /** + * 生成缓存标识 + * @access public + * @param mixed $value 缓存数据 + * @param array $options 缓存参数 + * @param array $bind 绑定参数 + * @return string + */ + protected function getCacheKey($value, $options, $bind = []) + { + if (is_scalar($value)) { + $data = $value; + } elseif (is_array($value) && is_string($value[0]) && 'eq' == strtolower($value[0])) { + $data = $value[1]; + } + $prefix = $this->connection->getConfig('database') . '.'; + + if (isset($data)) { + return 'think:' . $prefix . (is_array($options['table']) ? key($options['table']) : $options['table']) . '|' . $data; + } + + try { + return md5($prefix . serialize($options) . serialize($bind)); + } catch (\Exception $e) { + throw new Exception('closure not support cache(true)'); + } + } + + /** + * 查找单条记录 + * @access public + * @param array|string|Query|\Closure $data + * @return array|false|\PDOStatement|string|Model + * @throws DbException + * @throws ModelNotFoundException + * @throws DataNotFoundException + */ + public function find($data = null) + { + if ($data instanceof Query) { + return $data->find(); + } elseif ($data instanceof \Closure) { + call_user_func_array($data, [ & $this]); + $data = null; + } + // 分析查询表达式 + $options = $this->parseExpress(); + $pk = $this->getPk($options); + if (!is_null($data)) { + // AR模式分析主键条件 + $this->parsePkWhere($data, $options); + } elseif (!empty($options['cache']) && true === $options['cache']['key'] && is_string($pk) && isset($options['where']['AND'][$pk])) { + $key = $this->getCacheKey($options['where']['AND'][$pk], $options, $this->bind); + } + + $options['limit'] = 1; + $result = false; + if (empty($options['fetch_sql']) && !empty($options['cache'])) { + // 判断查询缓存 + $cache = $options['cache']; + if (true === $cache['key'] && !is_null($data) && !is_array($data)) { + $key = 'think:' . $this->connection->getConfig('database') . '.' . (is_array($options['table']) ? key($options['table']) : $options['table']) . '|' . $data; + } elseif (is_string($cache['key'])) { + $key = $cache['key']; + } elseif (!isset($key)) { + $key = md5($this->connection->getConfig('database') . '.' . serialize($options) . serialize($this->bind)); + } + $result = Cache::get($key); + } + if (false === $result) { + // 生成查询SQL + $sql = $this->builder->select($options); + // 获取参数绑定 + $bind = $this->getBind(); + if ($options['fetch_sql']) { + // 获取实际执行的SQL语句 + return $this->connection->getRealSql($sql, $bind); + } + if (is_string($pk)) { + if (!is_array($data)) { + if (isset($key) && strpos($key, '|')) { + list($a, $val) = explode('|', $key); + $item[$pk] = $val; + } else { + $item[$pk] = $data; + } + $data = $item; + } + } + $options['data'] = $data; + // 事件回调 + if ($result = $this->trigger('before_find', $options)) { + } else { + // 执行查询 + $resultSet = $this->query($sql, $bind, $options['master'], $options['fetch_pdo']); + + if ($resultSet instanceof \PDOStatement) { + // 返回PDOStatement对象 + return $resultSet; + } + $result = isset($resultSet[0]) ? $resultSet[0] : null; + } + + if (isset($cache) && $result) { + // 缓存数据 + $this->cacheData($key, $result, $cache); + } + } + + // 数据处理 + if (!empty($result)) { + if (!empty($this->model)) { + // 返回模型对象 + $result = $this->model->newInstance($result); + $result->isUpdate(true, isset($options['where']['AND']) ? $options['where']['AND'] : null); + // 关联查询 + if (!empty($options['relation'])) { + $result->relationQuery($options['relation']); + } + // 预载入查询 + if (!empty($options['with'])) { + $result->eagerlyResult($result, $options['with']); + } + // 关联统计 + if (!empty($options['with_count'])) { + $result->relationCount($result, $options['with_count']); + } + } + } elseif (!empty($options['fail'])) { + $this->throwNotFound($options); + } + return $result; + } + + /** + * 查询失败 抛出异常 + * @access public + * @param array $options 查询参数 + * @throws ModelNotFoundException + * @throws DataNotFoundException + */ + protected function throwNotFound($options = []) + { + if (!empty($this->model)) { + $class = get_class($this->model); + throw new ModelNotFoundException('model data Not Found:' . $class, $class, $options); + } else { + $table = is_array($options['table']) ? key($options['table']) : $options['table']; + throw new DataNotFoundException('table data not Found:' . $table, $table, $options); + } + } + + /** + * 查找多条记录 如果不存在则抛出异常 + * @access public + * @param array|string|Query|\Closure $data + * @return array|\PDOStatement|string|Model + * @throws DbException + * @throws ModelNotFoundException + * @throws DataNotFoundException + */ + public function selectOrFail($data = null) + { + return $this->failException(true)->select($data); + } + + /** + * 查找单条记录 如果不存在则抛出异常 + * @access public + * @param array|string|Query|\Closure $data + * @return array|\PDOStatement|string|Model + * @throws DbException + * @throws ModelNotFoundException + * @throws DataNotFoundException + */ + public function findOrFail($data = null) + { + return $this->failException(true)->find($data); + } + + /** + * 分批数据返回处理 + * @access public + * @param integer $count 每次处理的数据数量 + * @param callable $callback 处理回调方法 + * @param string $column 分批处理的字段名 + * @param string $order 排序规则 + * @return boolean + * @throws \LogicException + */ + public function chunk($count, $callback, $column = null, $order = 'asc') + { + $options = $this->getOptions(); + if (empty($options['table'])) { + $options['table'] = $this->getTable(); + } + $column = $column ?: $this->getPk($options); + + if (isset($options['order'])) { + if (App::$debug) { + throw new \LogicException('chunk not support call order'); + } + unset($options['order']); + } + $bind = $this->bind; + if (is_array($column)) { + $times = 1; + $query = $this->options($options)->page($times, $count); + } else { + if (strpos($column, '.')) { + list($alias, $key) = explode('.', $column); + } else { + $key = $column; + } + $query = $this->options($options)->limit($count); + } + $resultSet = $query->order($column, $order)->select(); + + while (count($resultSet) > 0) { + if ($resultSet instanceof Collection) { + $resultSet = $resultSet->all(); + } + + if (false === call_user_func($callback, $resultSet)) { + return false; + } + + if (is_array($column)) { + $times++; + $query = $this->options($options)->page($times, $count); + } else { + $end = end($resultSet); + $lastId = is_array($end) ? $end[$key] : $end->getData($key); + $query = $this->options($options) + ->limit($count) + ->where($column, 'asc' == strtolower($order) ? '>' : '<', $lastId); + } + + $resultSet = $query->bind($bind)->order($column, $order)->select(); + } + + return true; + } + + /** + * 获取绑定的参数 并清空 + * @access public + * @return array + */ + public function getBind() + { + $bind = $this->bind; + $this->bind = []; + return $bind; + } + + /** + * 创建子查询SQL + * @access public + * @param bool $sub + * @return string + * @throws DbException + */ + public function buildSql($sub = true) + { + return $sub ? '( ' . $this->select(false) . ' )' : $this->select(false); + } + + /** + * 删除记录 + * @access public + * @param mixed $data 表达式 true 表示强制删除 + * @return int + * @throws Exception + * @throws PDOException + */ + public function delete($data = null) + { + // 分析查询表达式 + $options = $this->parseExpress(); + $pk = $this->getPk($options); + if (isset($options['cache']) && is_string($options['cache']['key'])) { + $key = $options['cache']['key']; + } + + if (!is_null($data) && true !== $data) { + if (!isset($key) && !is_array($data)) { + // 缓存标识 + $key = 'think:' . $options['table'] . '|' . $data; + } + // AR模式分析主键条件 + $this->parsePkWhere($data, $options); + } elseif (!isset($key) && is_string($pk) && isset($options['where']['AND'][$pk])) { + $key = $this->getCacheKey($options['where']['AND'][$pk], $options, $this->bind); + } + + if (true !== $data && empty($options['where'])) { + // 如果条件为空 不进行删除操作 除非设置 1=1 + throw new Exception('delete without condition'); + } + // 生成删除SQL语句 + $sql = $this->builder->delete($options); + // 获取参数绑定 + $bind = $this->getBind(); + if ($options['fetch_sql']) { + // 获取实际执行的SQL语句 + return $this->connection->getRealSql($sql, $bind); + } + + // 检测缓存 + if (isset($key) && Cache::get($key)) { + // 删除缓存 + Cache::rm($key); + } elseif (!empty($options['cache']['tag'])) { + Cache::clear($options['cache']['tag']); + } + // 执行操作 + $result = $this->execute($sql, $bind, $this); + if ($result) { + if (!is_array($data) && is_string($pk) && isset($key) && strpos($key, '|')) { + list($a, $val) = explode('|', $key); + $item[$pk] = $val; + $data = $item; + } + $options['data'] = $data; + $this->trigger('after_delete', $options); + } + return $result; + } + + /** + * 分析表达式(可用于查询或者写入操作) + * @access protected + * @return array + */ + protected function parseExpress() + { + $options = $this->options; + + // 获取数据表 + if (empty($options['table'])) { + $options['table'] = $this->getTable(); + } + + if (!isset($options['where'])) { + $options['where'] = []; + } elseif (isset($options['view'])) { + // 视图查询条件处理 + foreach (['AND', 'OR'] as $logic) { + if (isset($options['where'][$logic])) { + foreach ($options['where'][$logic] as $key => $val) { + if (array_key_exists($key, $options['map'])) { + $options['where'][$logic][$options['map'][$key]] = $val; + unset($options['where'][$logic][$key]); + } + } + } + } + + if (isset($options['order'])) { + // 视图查询排序处理 + if (is_string($options['order'])) { + $options['order'] = explode(',', $options['order']); + } + foreach ($options['order'] as $key => $val) { + if (is_numeric($key)) { + if (strpos($val, ' ')) { + list($field, $sort) = explode(' ', $val); + if (array_key_exists($field, $options['map'])) { + $options['order'][$options['map'][$field]] = $sort; + unset($options['order'][$key]); + } + } elseif (array_key_exists($val, $options['map'])) { + $options['order'][$options['map'][$val]] = 'asc'; + unset($options['order'][$key]); + } + } elseif (array_key_exists($key, $options['map'])) { + $options['order'][$options['map'][$key]] = $val; + unset($options['order'][$key]); + } + } + } + } + + if (!isset($options['field'])) { + $options['field'] = '*'; + } + + if (!isset($options['data'])) { + $options['data'] = []; + } + + if (!isset($options['strict'])) { + $options['strict'] = $this->getConfig('fields_strict'); + } + + foreach (['master', 'lock', 'fetch_pdo', 'fetch_sql', 'distinct'] as $name) { + if (!isset($options[$name])) { + $options[$name] = false; + } + } + + if (isset(static::$readMaster['*']) || (is_string($options['table']) && isset(static::$readMaster[$options['table']]))) { + $options['master'] = true; + } + + foreach (['join', 'union', 'group', 'having', 'limit', 'order', 'force', 'comment'] as $name) { + if (!isset($options[$name])) { + $options[$name] = ''; + } + } + + if (isset($options['page'])) { + // 根据页数计算limit + list($page, $listRows) = $options['page']; + $page = $page > 0 ? $page : 1; + $listRows = $listRows > 0 ? $listRows : (is_numeric($options['limit']) ? $options['limit'] : 20); + $offset = $listRows * ($page - 1); + $options['limit'] = $offset . ',' . $listRows; + } + + $this->options = []; + return $options; + } + + /** + * 注册回调方法 + * @access public + * @param string $event 事件名 + * @param callable $callback 回调方法 + * @return void + */ + public static function event($event, $callback) + { + self::$event[$event] = $callback; + } + + /** + * 触发事件 + * @access protected + * @param string $event 事件名 + * @param mixed $params 额外参数 + * @return bool + */ + protected function trigger($event, $params = []) + { + $result = false; + if (isset(self::$event[$event])) { + $callback = self::$event[$event]; + $result = call_user_func_array($callback, [$params, $this]); + } + return $result; + } +} diff --git a/thinkphp/library/think/db/builder/Mysql.php b/thinkphp/library/think/db/builder/Mysql.php new file mode 100644 index 0000000..be2af71 --- /dev/null +++ b/thinkphp/library/think/db/builder/Mysql.php @@ -0,0 +1,137 @@ + +// +---------------------------------------------------------------------- + +namespace think\db\builder; + +use think\db\Builder; +use think\Exception; + +/** + * mysql数据库驱动 + */ +class Mysql extends Builder +{ + + protected $insertAllSql = '%INSERT% INTO %TABLE% (%FIELD%) VALUES %DATA% %COMMENT%'; + protected $updateSql = 'UPDATE %TABLE% %JOIN% SET %SET% %WHERE% %ORDER%%LIMIT% %LOCK%%COMMENT%'; + + /** + * 生成insertall SQL + * @access public + * @param array $dataSet 数据集 + * @param array $options 表达式 + * @param bool $replace 是否replace + * @return string + * @throws Exception + */ + public function insertAll($dataSet, $options = [], $replace = false) + { + // 获取合法的字段 + if ('*' == $options['field']) { + $fields = array_keys($this->query->getFieldsType($options['table'])); + } else { + $fields = $options['field']; + } + + foreach ($dataSet as $data) { + foreach ($data as $key => $val) { + if (!in_array($key, $fields, true)) { + if ($options['strict']) { + throw new Exception('fields not exists:[' . $key . ']'); + } + unset($data[$key]); + } elseif (is_null($val)) { + $data[$key] = 'NULL'; + } elseif (is_scalar($val)) { + $data[$key] = $this->parseValue($val, $key); + } elseif (is_object($val) && method_exists($val, '__toString')) { + // 对象数据写入 + $data[$key] = $val->__toString(); + } else { + // 过滤掉非标量数据 + unset($data[$key]); + } + } + $value = array_values($data); + $values[] = '( ' . implode(',', $value) . ' )'; + + if (!isset($insertFields)) { + $insertFields = array_map([$this, 'parseKey'], array_keys($data)); + } + } + + return str_replace( + ['%INSERT%', '%TABLE%', '%FIELD%', '%DATA%', '%COMMENT%'], + [ + $replace ? 'REPLACE' : 'INSERT', + $this->parseTable($options['table'], $options), + implode(' , ', $insertFields), + implode(' , ', $values), + $this->parseComment($options['comment']), + ], $this->insertAllSql); + } + + /** + * 字段和表名处理 + * @access protected + * @param mixed $key + * @param array $options + * @return string + */ + protected function parseKey($key, $options = [], $strict = false) + { + if (is_numeric($key)) { + return $key; + } elseif ($key instanceof Expression) { + return $key->getValue(); + } + + $key = trim($key); + if (strpos($key, '$.') && false === strpos($key, '(')) { + // JSON字段支持 + list($field, $name) = explode('$.', $key); + return 'json_extract(' . $field . ', \'$.' . $name . '\')'; + } elseif (strpos($key, '.') && !preg_match('/[,\'\"\(\)`\s]/', $key)) { + list($table, $key) = explode('.', $key, 2); + if ('__TABLE__' == $table) { + $table = $this->query->getTable(); + } + if (isset($options['alias'][$table])) { + $table = $options['alias'][$table]; + } + } + + if ($strict && !preg_match('/^[\w\.\*]+$/', $key)) { + throw new Exception('not support data:' . $key); + } + if ('*' != $key && ($strict || !preg_match('/[,\'\"\*\(\)`.\s]/', $key))) { + $key = '`' . $key . '`'; + } + if (isset($table)) { + if (strpos($table, '.')) { + $table = str_replace('.', '`.`', $table); + } + $key = '`' . $table . '`.' . $key; + } + return $key; + } + + /** + * 随机排序 + * @access protected + * @return string + */ + protected function parseRand() + { + return 'rand()'; + } + +} diff --git a/thinkphp/library/think/db/builder/Pgsql.php b/thinkphp/library/think/db/builder/Pgsql.php new file mode 100644 index 0000000..acc2289 --- /dev/null +++ b/thinkphp/library/think/db/builder/Pgsql.php @@ -0,0 +1,89 @@ + +// +---------------------------------------------------------------------- + +namespace think\db\builder; + +use think\db\Builder; + +/** + * Pgsql数据库驱动 + */ +class Pgsql extends Builder +{ + protected $insertSql = 'INSERT INTO %TABLE% (%FIELD%) VALUES (%DATA%) %COMMENT%'; + protected $insertAllSql = 'INSERT INTO %TABLE% (%FIELD%) %DATA% %COMMENT%'; + + /** + * limit分析 + * @access protected + * @param mixed $limit + * @return string + */ + public function parseLimit($limit) + { + $limitStr = ''; + if (!empty($limit)) { + $limit = explode(',', $limit); + if (count($limit) > 1) { + $limitStr .= ' LIMIT ' . $limit[1] . ' OFFSET ' . $limit[0] . ' '; + } else { + $limitStr .= ' LIMIT ' . $limit[0] . ' '; + } + } + return $limitStr; + } + + /** + * 字段和表名处理 + * @access protected + * @param mixed $key + * @param array $options + * @return string + */ + protected function parseKey($key, $options = [], $strict = false) + { + if (is_numeric($key)) { + return $key; + } elseif ($key instanceof Expression) { + return $key->getValue(); + } + + $key = trim($key); + if (strpos($key, '$.') && false === strpos($key, '(')) { + // JSON字段支持 + list($field, $name) = explode('$.', $key); + $key = $field . '->>\'' . $name . '\''; + } elseif (strpos($key, '.')) { + list($table, $key) = explode('.', $key, 2); + if ('__TABLE__' == $table) { + $table = $this->query->getTable(); + } + if (isset($options['alias'][$table])) { + $table = $options['alias'][$table]; + } + } + if (isset($table)) { + $key = $table . '.' . $key; + } + return $key; + } + + /** + * 随机排序 + * @access protected + * @return string + */ + protected function parseRand() + { + return 'RANDOM()'; + } + +} diff --git a/thinkphp/library/think/db/builder/Sqlite.php b/thinkphp/library/think/db/builder/Sqlite.php new file mode 100644 index 0000000..c727f04 --- /dev/null +++ b/thinkphp/library/think/db/builder/Sqlite.php @@ -0,0 +1,82 @@ + +// +---------------------------------------------------------------------- + +namespace think\db\builder; + +use think\db\Builder; + +/** + * Sqlite数据库驱动 + */ +class Sqlite extends Builder +{ + + /** + * limit + * @access public + * @param string $limit + * @return string + */ + public function parseLimit($limit) + { + $limitStr = ''; + if (!empty($limit)) { + $limit = explode(',', $limit); + if (count($limit) > 1) { + $limitStr .= ' LIMIT ' . $limit[1] . ' OFFSET ' . $limit[0] . ' '; + } else { + $limitStr .= ' LIMIT ' . $limit[0] . ' '; + } + } + return $limitStr; + } + + /** + * 随机排序 + * @access protected + * @return string + */ + protected function parseRand() + { + return 'RANDOM()'; + } + + /** + * 字段和表名处理 + * @access protected + * @param mixed $key + * @param array $options + * @return string + */ + protected function parseKey($key, $options = [], $strict = false) + { + if (is_numeric($key)) { + return $key; + } elseif ($key instanceof Expression) { + return $key->getValue(); + } + + $key = trim($key); + if (strpos($key, '.')) { + list($table, $key) = explode('.', $key, 2); + if ('__TABLE__' == $table) { + $table = $this->query->getTable(); + } + if (isset($options['alias'][$table])) { + $table = $options['alias'][$table]; + } + } + if (isset($table)) { + $key = $table . '.' . $key; + } + return $key; + } +} diff --git a/thinkphp/library/think/db/builder/Sqlsrv.php b/thinkphp/library/think/db/builder/Sqlsrv.php new file mode 100644 index 0000000..dc425d9 --- /dev/null +++ b/thinkphp/library/think/db/builder/Sqlsrv.php @@ -0,0 +1,137 @@ + +// +---------------------------------------------------------------------- + +namespace think\db\builder; + +use think\db\Builder; +use think\db\Expression; + +/** + * Sqlsrv数据库驱动 + */ +class Sqlsrv extends Builder +{ + protected $selectSql = 'SELECT T1.* FROM (SELECT thinkphp.*, ROW_NUMBER() OVER (%ORDER%) AS ROW_NUMBER FROM (SELECT %DISTINCT% %FIELD% FROM %TABLE%%JOIN%%WHERE%%GROUP%%HAVING%) AS thinkphp) AS T1 %LIMIT%%COMMENT%'; + protected $selectInsertSql = 'SELECT %DISTINCT% %FIELD% FROM %TABLE%%JOIN%%WHERE%%GROUP%%HAVING%'; + protected $updateSql = 'UPDATE %TABLE% SET %SET% FROM %TABLE% %JOIN% %WHERE% %LIMIT% %LOCK%%COMMENT%'; + protected $deleteSql = 'DELETE FROM %TABLE% %USING% FROM %TABLE% %JOIN% %WHERE% %LIMIT% %LOCK%%COMMENT%'; + protected $insertSql = 'INSERT INTO %TABLE% (%FIELD%) VALUES (%DATA%) %COMMENT%'; + protected $insertAllSql = 'INSERT INTO %TABLE% (%FIELD%) %DATA% %COMMENT%'; + + /** + * order分析 + * @access protected + * @param mixed $order + * @param array $options + * @return string + */ + protected function parseOrder($order, $options = []) + { + if (empty($order)) { + return ' ORDER BY rand()'; + } + + $array = []; + foreach ($order as $key => $val) { + if ($val instanceof Expression) { + $array[] = $val->getValue(); + } elseif (is_numeric($key)) { + if (false === strpos($val, '(')) { + $array[] = $this->parseKey($val, $options); + } elseif ('[rand]' == $val) { + $array[] = $this->parseRand(); + } else { + $array[] = $val; + } + } else { + $sort = in_array(strtolower(trim($val)), ['asc', 'desc'], true) ? ' ' . $val : ''; + $array[] = $this->parseKey($key, $options, true) . ' ' . $sort; + } + } + + return ' ORDER BY ' . implode(',', $array); + } + + /** + * 随机排序 + * @access protected + * @return string + */ + protected function parseRand() + { + return 'rand()'; + } + + /** + * 字段和表名处理 + * @access protected + * @param mixed $key + * @param array $options + * @return string + */ + protected function parseKey($key, $options = [], $strict = false) + { + if (is_numeric($key)) { + return $key; + } elseif ($key instanceof Expression) { + return $key->getValue(); + } + $key = trim($key); + if (strpos($key, '.') && !preg_match('/[,\'\"\(\)\[\s]/', $key)) { + list($table, $key) = explode('.', $key, 2); + if ('__TABLE__' == $table) { + $table = $this->query->getTable(); + } + if (isset($options['alias'][$table])) { + $table = $options['alias'][$table]; + } + } + + if ($strict && !preg_match('/^[\w\.\*]+$/', $key)) { + throw new Exception('not support data:' . $key); + } + if ('*' != $key && ($strict || !preg_match('/[,\'\"\*\(\)\[.\s]/', $key))) { + $key = '[' . $key . ']'; + } + if (isset($table)) { + $key = '[' . $table . '].' . $key; + } + return $key; + } + + /** + * limit + * @access protected + * @param mixed $limit + * @return string + */ + protected function parseLimit($limit) + { + if (empty($limit)) { + return ''; + } + + $limit = explode(',', $limit); + if (count($limit) > 1) { + $limitStr = '(T1.ROW_NUMBER BETWEEN ' . $limit[0] . ' + 1 AND ' . $limit[0] . ' + ' . $limit[1] . ')'; + } else { + $limitStr = '(T1.ROW_NUMBER BETWEEN 1 AND ' . $limit[0] . ")"; + } + return 'WHERE ' . $limitStr; + } + + public function selectInsert($fields, $table, $options) + { + $this->selectSql = $this->selectInsertSql; + return parent::selectInsert($fields, $table, $options); + } + +} diff --git a/thinkphp/library/think/db/connector/Mysql.php b/thinkphp/library/think/db/connector/Mysql.php new file mode 100644 index 0000000..be1a85c --- /dev/null +++ b/thinkphp/library/think/db/connector/Mysql.php @@ -0,0 +1,126 @@ + +// +---------------------------------------------------------------------- + +namespace think\db\connector; + +use PDO; +use think\db\Connection; +use think\Log; + +/** + * mysql数据库驱动 + */ +class Mysql extends Connection +{ + + protected $builder = '\\think\\db\\builder\\Mysql'; + + /** + * 解析pdo连接的dsn信息 + * @access protected + * @param array $config 连接信息 + * @return string + */ + protected function parseDsn($config) + { + if (!empty($config['socket'])) { + $dsn = 'mysql:unix_socket=' . $config['socket']; + } elseif (!empty($config['hostport'])) { + $dsn = 'mysql:host=' . $config['hostname'] . ';port=' . $config['hostport']; + } else { + $dsn = 'mysql:host=' . $config['hostname']; + } + $dsn .= ';dbname=' . $config['database']; + + if (!empty($config['charset'])) { + $dsn .= ';charset=' . $config['charset']; + } + return $dsn; + } + + /** + * 取得数据表的字段信息 + * @access public + * @param string $tableName + * @return array + */ + public function getFields($tableName) + { + list($tableName) = explode(' ', $tableName); + if (false === strpos($tableName, '`')) { + if (strpos($tableName, '.')) { + $tableName = str_replace('.', '`.`', $tableName); + } + $tableName = '`' . $tableName . '`'; + } + $sql = 'SHOW COLUMNS FROM ' . $tableName; + $pdo = $this->query($sql, [], false, true); + $result = $pdo->fetchAll(PDO::FETCH_ASSOC); + $info = []; + if ($result) { + foreach ($result as $key => $val) { + $val = array_change_key_case($val); + $info[$val['field']] = [ + 'name' => $val['field'], + 'type' => $val['type'], + 'notnull' => (bool) ('' === $val['null']), // not null is empty, null is yes + 'default' => $val['default'], + 'primary' => (strtolower($val['key']) == 'pri'), + 'autoinc' => (strtolower($val['extra']) == 'auto_increment'), + ]; + } + } + return $this->fieldCase($info); + } + + /** + * 取得数据库的表信息 + * @access public + * @param string $dbName + * @return array + */ + public function getTables($dbName = '') + { + $sql = !empty($dbName) ? 'SHOW TABLES FROM ' . $dbName : 'SHOW TABLES '; + $pdo = $this->query($sql, [], false, true); + $result = $pdo->fetchAll(PDO::FETCH_ASSOC); + $info = []; + foreach ($result as $key => $val) { + $info[$key] = current($val); + } + return $info; + } + + /** + * SQL性能分析 + * @access protected + * @param string $sql + * @return array + */ + protected function getExplain($sql) + { + $pdo = $this->linkID->query("EXPLAIN " . $sql); + $result = $pdo->fetch(PDO::FETCH_ASSOC); + $result = array_change_key_case($result); + if (isset($result['extra'])) { + if (strpos($result['extra'], 'filesort') || strpos($result['extra'], 'temporary')) { + Log::record('SQL:' . $this->queryStr . '[' . $result['extra'] . ']', 'warn'); + } + } + return $result; + } + + protected function supportSavepoint() + { + return true; + } + +} diff --git a/thinkphp/library/think/db/connector/Pgsql.php b/thinkphp/library/think/db/connector/Pgsql.php new file mode 100644 index 0000000..bbcf576 --- /dev/null +++ b/thinkphp/library/think/db/connector/Pgsql.php @@ -0,0 +1,103 @@ + +// +---------------------------------------------------------------------- + +namespace think\db\connector; + +use PDO; +use think\db\Connection; + +/** + * Pgsql数据库驱动 + */ +class Pgsql extends Connection +{ + protected $builder = '\\think\\db\\builder\\Pgsql'; + + /** + * 解析pdo连接的dsn信息 + * @access protected + * @param array $config 连接信息 + * @return string + */ + protected function parseDsn($config) + { + $dsn = 'pgsql:dbname=' . $config['database'] . ';host=' . $config['hostname']; + if (!empty($config['hostport'])) { + $dsn .= ';port=' . $config['hostport']; + } + return $dsn; + } + + /** + * 取得数据表的字段信息 + * @access public + * @param string $tableName + * @return array + */ + public function getFields($tableName) + { + + list($tableName) = explode(' ', $tableName); + $sql = 'select fields_name as "field",fields_type as "type",fields_not_null as "null",fields_key_name as "key",fields_default as "default",fields_default as "extra" from table_msg(\'' . $tableName . '\');'; + + $pdo = $this->query($sql, [], false, true); + $result = $pdo->fetchAll(PDO::FETCH_ASSOC); + $info = []; + if ($result) { + foreach ($result as $key => $val) { + $val = array_change_key_case($val); + $info[$val['field']] = [ + 'name' => $val['field'], + 'type' => $val['type'], + 'notnull' => (bool) ('' !== $val['null']), + 'default' => $val['default'], + 'primary' => !empty($val['key']), + 'autoinc' => (0 === strpos($val['extra'], 'nextval(')), + ]; + } + } + return $this->fieldCase($info); + } + + /** + * 取得数据库的表信息 + * @access public + * @param string $dbName + * @return array + */ + public function getTables($dbName = '') + { + $sql = "select tablename as Tables_in_test from pg_tables where schemaname ='public'"; + $pdo = $this->query($sql, [], false, true); + $result = $pdo->fetchAll(PDO::FETCH_ASSOC); + $info = []; + foreach ($result as $key => $val) { + $info[$key] = current($val); + } + return $info; + } + + /** + * SQL性能分析 + * @access protected + * @param string $sql + * @return array + */ + protected function getExplain($sql) + { + return []; + } + + protected function supportSavepoint() + { + return true; + } +} diff --git a/thinkphp/library/think/db/connector/Sqlite.php b/thinkphp/library/think/db/connector/Sqlite.php new file mode 100644 index 0000000..c4e3a72 --- /dev/null +++ b/thinkphp/library/think/db/connector/Sqlite.php @@ -0,0 +1,104 @@ + +// +---------------------------------------------------------------------- + +namespace think\db\connector; + +use PDO; +use think\db\Connection; + +/** + * Sqlite数据库驱动 + */ +class Sqlite extends Connection +{ + + protected $builder = '\\think\\db\\builder\\Sqlite'; + + /** + * 解析pdo连接的dsn信息 + * @access protected + * @param array $config 连接信息 + * @return string + */ + protected function parseDsn($config) + { + $dsn = 'sqlite:' . $config['database']; + return $dsn; + } + + /** + * 取得数据表的字段信息 + * @access public + * @param string $tableName + * @return array + */ + public function getFields($tableName) + { + list($tableName) = explode(' ', $tableName); + $sql = 'PRAGMA table_info( ' . $tableName . ' )'; + + $pdo = $this->query($sql, [], false, true); + $result = $pdo->fetchAll(PDO::FETCH_ASSOC); + $info = []; + if ($result) { + foreach ($result as $key => $val) { + $val = array_change_key_case($val); + $info[$val['name']] = [ + 'name' => $val['name'], + 'type' => $val['type'], + 'notnull' => 1 === $val['notnull'], + 'default' => $val['dflt_value'], + 'primary' => '1' == $val['pk'], + 'autoinc' => '1' == $val['pk'], + ]; + } + } + return $this->fieldCase($info); + } + + /** + * 取得数据库的表信息 + * @access public + * @param string $dbName + * @return array + */ + public function getTables($dbName = '') + { + + $sql = "SELECT name FROM sqlite_master WHERE type='table' " + . "UNION ALL SELECT name FROM sqlite_temp_master " + . "WHERE type='table' ORDER BY name"; + + $pdo = $this->query($sql, [], false, true); + $result = $pdo->fetchAll(PDO::FETCH_ASSOC); + $info = []; + foreach ($result as $key => $val) { + $info[$key] = current($val); + } + return $info; + } + + /** + * SQL性能分析 + * @access protected + * @param string $sql + * @return array + */ + protected function getExplain($sql) + { + return []; + } + + protected function supportSavepoint() + { + return true; + } +} diff --git a/thinkphp/library/think/db/connector/Sqlsrv.php b/thinkphp/library/think/db/connector/Sqlsrv.php new file mode 100644 index 0000000..35c6600 --- /dev/null +++ b/thinkphp/library/think/db/connector/Sqlsrv.php @@ -0,0 +1,125 @@ + +// +---------------------------------------------------------------------- + +namespace think\db\connector; + +use PDO; +use think\db\Connection; + +/** + * Sqlsrv数据库驱动 + */ +class Sqlsrv extends Connection +{ + // PDO连接参数 + protected $params = [ + PDO::ATTR_CASE => PDO::CASE_NATURAL, + PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, + PDO::ATTR_STRINGIFY_FETCHES => false, + ]; + protected $builder = '\\think\\db\\builder\\Sqlsrv'; + /** + * 解析pdo连接的dsn信息 + * @access protected + * @param array $config 连接信息 + * @return string + */ + protected function parseDsn($config) + { + $dsn = 'sqlsrv:Database=' . $config['database'] . ';Server=' . $config['hostname']; + if (!empty($config['hostport'])) { + $dsn .= ',' . $config['hostport']; + } + return $dsn; + } + + /** + * 取得数据表的字段信息 + * @access public + * @param string $tableName + * @return array + */ + public function getFields($tableName) + { + list($tableName) = explode(' ', $tableName); + $tableNames = explode('.', $tableName); + $tableName = isset($tableNames[1]) ? $tableNames[1] : $tableNames[0]; + + $sql = "SELECT column_name, data_type, column_default, is_nullable + FROM information_schema.tables AS t + JOIN information_schema.columns AS c + ON t.table_catalog = c.table_catalog + AND t.table_schema = c.table_schema + AND t.table_name = c.table_name + WHERE t.table_name = '$tableName'"; + + $pdo = $this->query($sql, [], false, true); + $result = $pdo->fetchAll(PDO::FETCH_ASSOC); + $info = []; + if ($result) { + foreach ($result as $key => $val) { + $val = array_change_key_case($val); + $info[$val['column_name']] = [ + 'name' => $val['column_name'], + 'type' => $val['data_type'], + 'notnull' => (bool) ('' === $val['is_nullable']), // not null is empty, null is yes + 'default' => $val['column_default'], + 'primary' => false, + 'autoinc' => false, + ]; + } + } + $sql = "SELECT column_name FROM information_schema.key_column_usage WHERE table_name='$tableName'"; + // 调试开始 + $this->debug(true); + $pdo = $this->linkID->query($sql); + // 调试结束 + $this->debug(false, $sql); + $result = $pdo->fetch(PDO::FETCH_ASSOC); + if ($result) { + $info[$result['column_name']]['primary'] = true; + } + return $this->fieldCase($info); + } + + /** + * 取得数据表的字段信息 + * @access public + * @param string $dbName + * @return array + */ + public function getTables($dbName = '') + { + $sql = "SELECT TABLE_NAME + FROM INFORMATION_SCHEMA.TABLES + WHERE TABLE_TYPE = 'BASE TABLE' + "; + + $pdo = $this->query($sql, [], false, true); + $result = $pdo->fetchAll(PDO::FETCH_ASSOC); + $info = []; + foreach ($result as $key => $val) { + $info[$key] = current($val); + } + return $info; + } + + /** + * SQL性能分析 + * @access protected + * @param string $sql + * @return array + */ + protected function getExplain($sql) + { + return []; + } +} diff --git a/thinkphp/library/think/db/connector/pgsql.sql b/thinkphp/library/think/db/connector/pgsql.sql new file mode 100644 index 0000000..e1a09a3 --- /dev/null +++ b/thinkphp/library/think/db/connector/pgsql.sql @@ -0,0 +1,117 @@ +CREATE OR REPLACE FUNCTION pgsql_type(a_type varchar) RETURNS varchar AS +$BODY$ +DECLARE + v_type varchar; +BEGIN + IF a_type='int8' THEN + v_type:='bigint'; + ELSIF a_type='int4' THEN + v_type:='integer'; + ELSIF a_type='int2' THEN + v_type:='smallint'; + ELSIF a_type='bpchar' THEN + v_type:='char'; + ELSE + v_type:=a_type; + END IF; + RETURN v_type; +END; +$BODY$ +LANGUAGE PLPGSQL; + +CREATE TYPE "public"."tablestruct" AS ( + "fields_key_name" varchar(100), + "fields_name" VARCHAR(200), + "fields_type" VARCHAR(20), + "fields_length" BIGINT, + "fields_not_null" VARCHAR(10), + "fields_default" VARCHAR(500), + "fields_comment" VARCHAR(1000) +); + +CREATE OR REPLACE FUNCTION "public"."table_msg" (a_schema_name varchar, a_table_name varchar) RETURNS SETOF "public"."tablestruct" AS +$body$ +DECLARE + v_ret tablestruct; + v_oid oid; + v_sql varchar; + v_rec RECORD; + v_key varchar; +BEGIN + SELECT + pg_class.oid INTO v_oid + FROM + pg_class + INNER JOIN pg_namespace ON (pg_class.relnamespace = pg_namespace.oid AND lower(pg_namespace.nspname) = a_schema_name) + WHERE + pg_class.relname=a_table_name; + IF NOT FOUND THEN + RETURN; + END IF; + + v_sql=' + SELECT + pg_attribute.attname AS fields_name, + pg_attribute.attnum AS fields_index, + pgsql_type(pg_type.typname::varchar) AS fields_type, + pg_attribute.atttypmod-4 as fields_length, + CASE WHEN pg_attribute.attnotnull THEN ''not null'' + ELSE '''' + END AS fields_not_null, + pg_attrdef.adsrc AS fields_default, + pg_description.description AS fields_comment + FROM + pg_attribute + INNER JOIN pg_class ON pg_attribute.attrelid = pg_class.oid + INNER JOIN pg_type ON pg_attribute.atttypid = pg_type.oid + LEFT OUTER JOIN pg_attrdef ON pg_attrdef.adrelid = pg_class.oid AND pg_attrdef.adnum = pg_attribute.attnum + LEFT OUTER JOIN pg_description ON pg_description.objoid = pg_class.oid AND pg_description.objsubid = pg_attribute.attnum + WHERE + pg_attribute.attnum > 0 + AND attisdropped <> ''t'' + AND pg_class.oid = ' || v_oid || ' + ORDER BY pg_attribute.attnum' ; + + FOR v_rec IN EXECUTE v_sql LOOP + v_ret.fields_name=v_rec.fields_name; + v_ret.fields_type=v_rec.fields_type; + IF v_rec.fields_length > 0 THEN + v_ret.fields_length:=v_rec.fields_length; + ELSE + v_ret.fields_length:=NULL; + END IF; + v_ret.fields_not_null=v_rec.fields_not_null; + v_ret.fields_default=v_rec.fields_default; + v_ret.fields_comment=v_rec.fields_comment; + SELECT constraint_name INTO v_key FROM information_schema.key_column_usage WHERE table_schema=a_schema_name AND table_name=a_table_name AND column_name=v_rec.fields_name; + IF FOUND THEN + v_ret.fields_key_name=v_key; + ELSE + v_ret.fields_key_name=''; + END IF; + RETURN NEXT v_ret; + END LOOP; + RETURN ; +END; +$body$ +LANGUAGE 'plpgsql' VOLATILE CALLED ON NULL INPUT SECURITY INVOKER; + +COMMENT ON FUNCTION "public"."table_msg"(a_schema_name varchar, a_table_name varchar) +IS '获得表信息'; + +---重载一个函数 +CREATE OR REPLACE FUNCTION "public"."table_msg" (a_table_name varchar) RETURNS SETOF "public"."tablestruct" AS +$body$ +DECLARE + v_ret tablestruct; +BEGIN + FOR v_ret IN SELECT * FROM table_msg('public',a_table_name) LOOP + RETURN NEXT v_ret; + END LOOP; + RETURN; +END; +$body$ +LANGUAGE 'plpgsql' VOLATILE CALLED ON NULL INPUT SECURITY INVOKER; + +COMMENT ON FUNCTION "public"."table_msg"(a_table_name varchar) +IS '获得表信息'; \ No newline at end of file diff --git a/thinkphp/library/think/db/exception/BindParamException.php b/thinkphp/library/think/db/exception/BindParamException.php new file mode 100644 index 0000000..4ed1954 --- /dev/null +++ b/thinkphp/library/think/db/exception/BindParamException.php @@ -0,0 +1,35 @@ + +// +---------------------------------------------------------------------- + +namespace think\db\exception; + +use think\exception\DbException; + +/** + * PDO参数绑定异常 + */ +class BindParamException extends DbException +{ + + /** + * BindParamException constructor. + * @param string $message + * @param array $config + * @param string $sql + * @param array $bind + * @param int $code + */ + public function __construct($message, $config, $sql, $bind, $code = 10502) + { + $this->setData('Bind Param', $bind); + parent::__construct($message, $config, $sql, $code); + } +} diff --git a/thinkphp/library/think/db/exception/DataNotFoundException.php b/thinkphp/library/think/db/exception/DataNotFoundException.php new file mode 100644 index 0000000..f2542ac --- /dev/null +++ b/thinkphp/library/think/db/exception/DataNotFoundException.php @@ -0,0 +1,43 @@ + +// +---------------------------------------------------------------------- + +namespace think\db\exception; + +use think\exception\DbException; + +class DataNotFoundException extends DbException +{ + protected $table; + + /** + * DbException constructor. + * @param string $message + * @param string $table + * @param array $config + */ + public function __construct($message, $table = '', array $config = []) + { + $this->message = $message; + $this->table = $table; + + $this->setData('Database Config', $config); + } + + /** + * 获取数据表名 + * @access public + * @return string + */ + public function getTable() + { + return $this->table; + } +} diff --git a/thinkphp/library/think/db/exception/ModelNotFoundException.php b/thinkphp/library/think/db/exception/ModelNotFoundException.php new file mode 100644 index 0000000..6e5f930 --- /dev/null +++ b/thinkphp/library/think/db/exception/ModelNotFoundException.php @@ -0,0 +1,43 @@ + +// +---------------------------------------------------------------------- + +namespace think\db\exception; + +use think\exception\DbException; + +class ModelNotFoundException extends DbException +{ + protected $model; + + /** + * 构造方法 + * @param string $message + * @param string $model + */ + public function __construct($message, $model = '', array $config = []) + { + $this->message = $message; + $this->model = $model; + + $this->setData('Database Config', $config); + } + + /** + * 获取模型类名 + * @access public + * @return string + */ + public function getModel() + { + return $this->model; + } + +} diff --git a/thinkphp/library/think/debug/Console.php b/thinkphp/library/think/debug/Console.php new file mode 100644 index 0000000..c17911b --- /dev/null +++ b/thinkphp/library/think/debug/Console.php @@ -0,0 +1,160 @@ + +// +---------------------------------------------------------------------- + +namespace think\debug; + +use think\Cache; +use think\Config; +use think\Db; +use think\Debug; +use think\Request; +use think\Response; + +/** + * 浏览器调试输出 + */ +class Console +{ + protected $config = [ + 'trace_tabs' => ['base' => '基本', 'file' => '文件', 'info' => '流程', 'notice|error' => '错误', 'sql' => 'SQL', 'debug|log' => '调试'], + ]; + + // 实例化并传入参数 + public function __construct($config = []) + { + if (is_array($config)) { + $this->config = array_merge($this->config, $config); + } + } + + /** + * 调试输出接口 + * @access public + * @param Response $response Response对象 + * @param array $log 日志信息 + * @return bool + */ + public function output(Response $response, array $log = []) + { + $request = Request::instance(); + $contentType = $response->getHeader('Content-Type'); + $accept = $request->header('accept'); + if (strpos($accept, 'application/json') === 0 || $request->isAjax()) { + return false; + } elseif (!empty($contentType) && strpos($contentType, 'html') === false) { + return false; + } + // 获取基本信息 + $runtime = number_format(microtime(true) - THINK_START_TIME, 10); + $reqs = $runtime > 0 ? number_format(1 / $runtime, 2) : '∞'; + $mem = number_format((memory_get_usage() - THINK_START_MEM) / 1024, 2); + + if (isset($_SERVER['HTTP_HOST'])) { + $uri = $_SERVER['SERVER_PROTOCOL'] . ' ' . $_SERVER['REQUEST_METHOD'] . ' : ' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; + } else { + $uri = 'cmd:' . implode(' ', $_SERVER['argv']); + } + + // 页面Trace信息 + $base = [ + '请求信息' => date('Y-m-d H:i:s', $_SERVER['REQUEST_TIME']) . ' ' . $uri, + '运行时间' => number_format($runtime, 6) . 's [ 吞吐率:' . $reqs . 'req/s ] 内存消耗:' . $mem . 'kb 文件加载:' . count(get_included_files()), + '查询信息' => Db::$queryTimes . ' queries ' . Db::$executeTimes . ' writes ', + '缓存信息' => Cache::$readTimes . ' reads,' . Cache::$writeTimes . ' writes', + '配置加载' => count(Config::get()), + ]; + + if (session_id()) { + $base['会话信息'] = 'SESSION_ID=' . session_id(); + } + + $info = Debug::getFile(true); + + // 页面Trace信息 + $trace = []; + foreach ($this->config['trace_tabs'] as $name => $title) { + $name = strtolower($name); + switch ($name) { + case 'base': // 基本信息 + $trace[$title] = $base; + break; + case 'file': // 文件信息 + $trace[$title] = $info; + break; + default: // 调试信息 + if (strpos($name, '|')) { + // 多组信息 + $names = explode('|', $name); + $result = []; + foreach ($names as $name) { + $result = array_merge($result, isset($log[$name]) ? $log[$name] : []); + } + $trace[$title] = $result; + } else { + $trace[$title] = isset($log[$name]) ? $log[$name] : ''; + } + } + } + + //输出到控制台 + $lines = ''; + foreach ($trace as $type => $msg) { + $lines .= $this->console($type, $msg); + } + $js = << +{$lines} + +JS; + return $js; + } + + protected function console($type, $msg) + { + $type = strtolower($type); + $trace_tabs = array_values($this->config['trace_tabs']); + $line[] = ($type == $trace_tabs[0] || '调试' == $type || '错误' == $type) + ? "console.group('{$type}');" + : "console.groupCollapsed('{$type}');"; + + foreach ((array) $msg as $key => $m) { + switch ($type) { + case '调试': + $var_type = gettype($m); + if (in_array($var_type, ['array', 'string'])) { + $line[] = "console.log(" . json_encode($m) . ");"; + } else { + $line[] = "console.log(" . json_encode(var_export($m, 1)) . ");"; + } + break; + case '错误': + $msg = str_replace("\n", '\n', json_encode($m)); + $style = 'color:#F4006B;font-size:14px;'; + $line[] = "console.error(\"%c{$msg}\", \"{$style}\");"; + break; + case 'sql': + $msg = str_replace("\n", '\n', $m); + $style = "color:#009bb4;"; + $line[] = "console.log(\"%c{$msg}\", \"{$style}\");"; + break; + default: + $m = is_string($key) ? $key . ' ' . $m : $key + 1 . ' ' . $m; + $msg = json_encode($m); + $line[] = "console.log({$msg});"; + break; + } + } + $line[] = "console.groupEnd();"; + return implode(PHP_EOL, $line); + } + +} diff --git a/thinkphp/library/think/debug/Html.php b/thinkphp/library/think/debug/Html.php new file mode 100644 index 0000000..b6be7ad --- /dev/null +++ b/thinkphp/library/think/debug/Html.php @@ -0,0 +1,111 @@ + +// +---------------------------------------------------------------------- + +namespace think\debug; + +use think\Cache; +use think\Config; +use think\Db; +use think\Debug; +use think\Request; +use think\Response; + +/** + * 页面Trace调试 + */ +class Html +{ + protected $config = [ + 'trace_file' => '', + 'trace_tabs' => ['base' => '基本', 'file' => '文件', 'info' => '流程', 'notice|error' => '错误', 'sql' => 'SQL', 'debug|log' => '调试'], + ]; + + // 实例化并传入参数 + public function __construct(array $config = []) + { + $this->config['trace_file'] = THINK_PATH . 'tpl/page_trace.tpl'; + $this->config = array_merge($this->config, $config); + } + + /** + * 调试输出接口 + * @access public + * @param Response $response Response对象 + * @param array $log 日志信息 + * @return bool + */ + public function output(Response $response, array $log = []) + { + $request = Request::instance(); + $contentType = $response->getHeader('Content-Type'); + $accept = $request->header('accept'); + if (strpos($accept, 'application/json') === 0 || $request->isAjax()) { + return false; + } elseif (!empty($contentType) && strpos($contentType, 'html') === false) { + return false; + } + // 获取基本信息 + $runtime = number_format(microtime(true) - THINK_START_TIME, 10, '.', ''); + $reqs = $runtime > 0 ? number_format(1 / $runtime, 2) : '∞'; + $mem = number_format((memory_get_usage() - THINK_START_MEM) / 1024, 2); + + // 页面Trace信息 + if (isset($_SERVER['HTTP_HOST'])) { + $uri = $_SERVER['SERVER_PROTOCOL'] . ' ' . $_SERVER['REQUEST_METHOD'] . ' : ' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; + } else { + $uri = 'cmd:' . implode(' ', $_SERVER['argv']); + } + $base = [ + '请求信息' => date('Y-m-d H:i:s', $_SERVER['REQUEST_TIME']) . ' ' . $uri, + '运行时间' => number_format($runtime, 6) . 's [ 吞吐率:' . $reqs . 'req/s ] 内存消耗:' . $mem . 'kb 文件加载:' . count(get_included_files()), + '查询信息' => Db::$queryTimes . ' queries ' . Db::$executeTimes . ' writes ', + '缓存信息' => Cache::$readTimes . ' reads,' . Cache::$writeTimes . ' writes', + '配置加载' => count(Config::get()), + ]; + + if (session_id()) { + $base['会话信息'] = 'SESSION_ID=' . session_id(); + } + + $info = Debug::getFile(true); + + // 页面Trace信息 + $trace = []; + foreach ($this->config['trace_tabs'] as $name => $title) { + $name = strtolower($name); + switch ($name) { + case 'base': // 基本信息 + $trace[$title] = $base; + break; + case 'file': // 文件信息 + $trace[$title] = $info; + break; + default: // 调试信息 + if (strpos($name, '|')) { + // 多组信息 + $names = explode('|', $name); + $result = []; + foreach ($names as $name) { + $result = array_merge($result, isset($log[$name]) ? $log[$name] : []); + } + $trace[$title] = $result; + } else { + $trace[$title] = isset($log[$name]) ? $log[$name] : ''; + } + } + } + // 调用Trace页面模板 + ob_start(); + include $this->config['trace_file']; + return ob_get_clean(); + } + +} diff --git a/thinkphp/library/think/exception/ClassNotFoundException.php b/thinkphp/library/think/exception/ClassNotFoundException.php new file mode 100644 index 0000000..eb22e73 --- /dev/null +++ b/thinkphp/library/think/exception/ClassNotFoundException.php @@ -0,0 +1,32 @@ + +// +---------------------------------------------------------------------- + +namespace think\exception; + +class ClassNotFoundException extends \RuntimeException +{ + protected $class; + public function __construct($message, $class = '') + { + $this->message = $message; + $this->class = $class; + } + + /** + * 获取类名 + * @access public + * @return string + */ + public function getClass() + { + return $this->class; + } +} diff --git a/thinkphp/library/think/exception/DbException.php b/thinkphp/library/think/exception/DbException.php new file mode 100644 index 0000000..0ae80ad --- /dev/null +++ b/thinkphp/library/think/exception/DbException.php @@ -0,0 +1,43 @@ + +// +---------------------------------------------------------------------- + +namespace think\exception; + +use think\Exception; + +/** + * Database相关异常处理类 + */ +class DbException extends Exception +{ + /** + * DbException constructor. + * @param string $message + * @param array $config + * @param string $sql + * @param int $code + */ + public function __construct($message, array $config, $sql, $code = 10500) + { + $this->message = $message; + $this->code = $code; + + $this->setData('Database Status', [ + 'Error Code' => $code, + 'Error Message' => $message, + 'Error SQL' => $sql, + ]); + + unset($config['username'], $config['password']); + $this->setData('Database Config', $config); + } + +} diff --git a/thinkphp/library/think/exception/ErrorException.php b/thinkphp/library/think/exception/ErrorException.php new file mode 100644 index 0000000..b3a9a30 --- /dev/null +++ b/thinkphp/library/think/exception/ErrorException.php @@ -0,0 +1,57 @@ + +// +---------------------------------------------------------------------- + +namespace think\exception; + +use think\Exception; + +/** + * ThinkPHP错误异常 + * 主要用于封装 set_error_handler 和 register_shutdown_function 得到的错误 + * 除开从 think\Exception 继承的功能 + * 其他和PHP系统\ErrorException功能基本一样 + */ +class ErrorException extends Exception +{ + /** + * 用于保存错误级别 + * @var integer + */ + protected $severity; + + /** + * 错误异常构造函数 + * @param integer $severity 错误级别 + * @param string $message 错误详细信息 + * @param string $file 出错文件路径 + * @param integer $line 出错行号 + * @param array $context 错误上下文,会包含错误触发处作用域内所有变量的数组 + */ + public function __construct($severity, $message, $file, $line, array $context = []) + { + $this->severity = $severity; + $this->message = $message; + $this->file = $file; + $this->line = $line; + $this->code = 0; + + empty($context) || $this->setData('Error Context', $context); + } + + /** + * 获取错误级别 + * @return integer 错误级别 + */ + final public function getSeverity() + { + return $this->severity; + } +} diff --git a/thinkphp/library/think/exception/Handle.php b/thinkphp/library/think/exception/Handle.php new file mode 100644 index 0000000..f523db0 --- /dev/null +++ b/thinkphp/library/think/exception/Handle.php @@ -0,0 +1,282 @@ + +// +---------------------------------------------------------------------- + +namespace think\exception; + +use Exception; +use think\App; +use think\Config; +use think\console\Output; +use think\Lang; +use think\Log; +use think\Response; + +class Handle +{ + protected $render; + protected $ignoreReport = [ + '\\think\\exception\\HttpException', + ]; + + public function setRender($render) + { + $this->render = $render; + } + + /** + * Report or log an exception. + * + * @param \Exception $exception + * @return void + */ + public function report(Exception $exception) + { + if (!$this->isIgnoreReport($exception)) { + // 收集异常数据 + if (App::$debug) { + $data = [ + 'file' => $exception->getFile(), + 'line' => $exception->getLine(), + 'message' => $this->getMessage($exception), + 'code' => $this->getCode($exception), + ]; + $log = "[{$data['code']}]{$data['message']}[{$data['file']}:{$data['line']}]"; + } else { + $data = [ + 'code' => $this->getCode($exception), + 'message' => $this->getMessage($exception), + ]; + $log = "[{$data['code']}]{$data['message']}"; + } + + if (Config::get('record_trace')) { + $log .= "\r\n" . $exception->getTraceAsString(); + } + + Log::record($log, 'error'); + } + } + + protected function isIgnoreReport(Exception $exception) + { + foreach ($this->ignoreReport as $class) { + if ($exception instanceof $class) { + return true; + } + } + return false; + } + + /** + * Render an exception into an HTTP response. + * + * @param \Exception $e + * @return Response + */ + public function render(Exception $e) + { + if ($this->render && $this->render instanceof \Closure) { + $result = call_user_func_array($this->render, [$e]); + if ($result) { + return $result; + } + } + + if ($e instanceof HttpException) { + return $this->renderHttpException($e); + } else { + return $this->convertExceptionToResponse($e); + } + } + + /** + * @param Output $output + * @param Exception $e + */ + public function renderForConsole(Output $output, Exception $e) + { + if (App::$debug) { + $output->setVerbosity(Output::VERBOSITY_DEBUG); + } + $output->renderException($e); + } + + /** + * @param HttpException $e + * @return Response + */ + protected function renderHttpException(HttpException $e) + { + $status = $e->getStatusCode(); + $template = Config::get('http_exception_template'); + if (!App::$debug && !empty($template[$status])) { + return Response::create($template[$status], 'view', $status)->assign(['e' => $e]); + } else { + return $this->convertExceptionToResponse($e); + } + } + + /** + * @param Exception $exception + * @return Response + */ + protected function convertExceptionToResponse(Exception $exception) + { + // 收集异常数据 + if (App::$debug) { + // 调试模式,获取详细的错误信息 + $data = [ + 'name' => get_class($exception), + 'file' => $exception->getFile(), + 'line' => $exception->getLine(), + 'message' => $this->getMessage($exception), + 'trace' => $exception->getTrace(), + 'code' => $this->getCode($exception), + 'source' => $this->getSourceCode($exception), + 'datas' => $this->getExtendData($exception), + 'tables' => [ + 'GET Data' => $_GET, + 'POST Data' => $_POST, + 'Files' => $_FILES, + 'Cookies' => $_COOKIE, + 'Session' => isset($_SESSION) ? $_SESSION : [], + 'Server/Request Data' => $_SERVER, + 'Environment Variables' => $_ENV, + 'ThinkPHP Constants' => $this->getConst(), + ], + ]; + } else { + // 部署模式仅显示 Code 和 Message + $data = [ + 'code' => $this->getCode($exception), + 'message' => $this->getMessage($exception), + ]; + + if (!Config::get('show_error_msg')) { + // 不显示详细错误信息 + $data['message'] = Config::get('error_message'); + } + } + + //保留一层 + while (ob_get_level() > 1) { + ob_end_clean(); + } + + $data['echo'] = ob_get_clean(); + + ob_start(); + extract($data); + include Config::get('exception_tmpl'); + // 获取并清空缓存 + $content = ob_get_clean(); + $response = new Response($content, 'html'); + + if ($exception instanceof HttpException) { + $statusCode = $exception->getStatusCode(); + $response->header($exception->getHeaders()); + } + + if (!isset($statusCode)) { + $statusCode = 500; + } + $response->code($statusCode); + return $response; + } + + /** + * 获取错误编码 + * ErrorException则使用错误级别作为错误编码 + * @param \Exception $exception + * @return integer 错误编码 + */ + protected function getCode(Exception $exception) + { + $code = $exception->getCode(); + if (!$code && $exception instanceof ErrorException) { + $code = $exception->getSeverity(); + } + return $code; + } + + /** + * 获取错误信息 + * ErrorException则使用错误级别作为错误编码 + * @param \Exception $exception + * @return string 错误信息 + */ + protected function getMessage(Exception $exception) + { + $message = $exception->getMessage(); + if (IS_CLI) { + return $message; + } + + if (strpos($message, ':')) { + $name = strstr($message, ':', true); + $message = Lang::has($name) ? Lang::get($name) . strstr($message, ':') : $message; + } elseif (strpos($message, ',')) { + $name = strstr($message, ',', true); + $message = Lang::has($name) ? Lang::get($name) . ':' . substr(strstr($message, ','), 1) : $message; + } elseif (Lang::has($message)) { + $message = Lang::get($message); + } + return $message; + } + + /** + * 获取出错文件内容 + * 获取错误的前9行和后9行 + * @param \Exception $exception + * @return array 错误文件内容 + */ + protected function getSourceCode(Exception $exception) + { + // 读取前9行和后9行 + $line = $exception->getLine(); + $first = ($line - 9 > 0) ? $line - 9 : 1; + + try { + $contents = file($exception->getFile()); + $source = [ + 'first' => $first, + 'source' => array_slice($contents, $first - 1, 19), + ]; + } catch (Exception $e) { + $source = []; + } + return $source; + } + + /** + * 获取异常扩展信息 + * 用于非调试模式html返回类型显示 + * @param \Exception $exception + * @return array 异常类定义的扩展数据 + */ + protected function getExtendData(Exception $exception) + { + $data = []; + if ($exception instanceof \think\Exception) { + $data = $exception->getData(); + } + return $data; + } + + /** + * 获取常量列表 + * @return array 常量列表 + */ + private static function getConst() + { + return get_defined_constants(true)['user']; + } +} diff --git a/thinkphp/library/think/exception/HttpException.php b/thinkphp/library/think/exception/HttpException.php new file mode 100644 index 0000000..01a27fc --- /dev/null +++ b/thinkphp/library/think/exception/HttpException.php @@ -0,0 +1,36 @@ + +// +---------------------------------------------------------------------- + +namespace think\exception; + +class HttpException extends \RuntimeException +{ + private $statusCode; + private $headers; + + public function __construct($statusCode, $message = null, \Exception $previous = null, array $headers = [], $code = 0) + { + $this->statusCode = $statusCode; + $this->headers = $headers; + + parent::__construct($message, $code, $previous); + } + + public function getStatusCode() + { + return $this->statusCode; + } + + public function getHeaders() + { + return $this->headers; + } +} diff --git a/thinkphp/library/think/exception/HttpResponseException.php b/thinkphp/library/think/exception/HttpResponseException.php new file mode 100644 index 0000000..5297286 --- /dev/null +++ b/thinkphp/library/think/exception/HttpResponseException.php @@ -0,0 +1,33 @@ + +// +---------------------------------------------------------------------- + +namespace think\exception; + +use think\Response; + +class HttpResponseException extends \RuntimeException +{ + /** + * @var Response + */ + protected $response; + + public function __construct(Response $response) + { + $this->response = $response; + } + + public function getResponse() + { + return $this->response; + } + +} diff --git a/thinkphp/library/think/exception/PDOException.php b/thinkphp/library/think/exception/PDOException.php new file mode 100644 index 0000000..044f82a --- /dev/null +++ b/thinkphp/library/think/exception/PDOException.php @@ -0,0 +1,39 @@ + +// +---------------------------------------------------------------------- + +namespace think\exception; + +/** + * PDO异常处理类 + * 重新封装了系统的\PDOException类 + */ +class PDOException extends DbException +{ + /** + * PDOException constructor. + * @param \PDOException $exception + * @param array $config + * @param string $sql + * @param int $code + */ + public function __construct(\PDOException $exception, array $config, $sql, $code = 10501) + { + $error = $exception->errorInfo; + + $this->setData('PDO Error Info', [ + 'SQLSTATE' => $error[0], + 'Driver Error Code' => isset($error[1]) ? $error[1] : 0, + 'Driver Error Message' => isset($error[2]) ? $error[2] : '', + ]); + + parent::__construct($exception->getMessage(), $config, $sql, $code); + } +} diff --git a/thinkphp/library/think/exception/RouteNotFoundException.php b/thinkphp/library/think/exception/RouteNotFoundException.php new file mode 100644 index 0000000..d22e3a6 --- /dev/null +++ b/thinkphp/library/think/exception/RouteNotFoundException.php @@ -0,0 +1,22 @@ + +// +---------------------------------------------------------------------- + +namespace think\exception; + +class RouteNotFoundException extends HttpException +{ + + public function __construct() + { + parent::__construct(404, 'Route Not Found'); + } + +} diff --git a/thinkphp/library/think/exception/TemplateNotFoundException.php b/thinkphp/library/think/exception/TemplateNotFoundException.php new file mode 100644 index 0000000..4202069 --- /dev/null +++ b/thinkphp/library/think/exception/TemplateNotFoundException.php @@ -0,0 +1,33 @@ + +// +---------------------------------------------------------------------- + +namespace think\exception; + +class TemplateNotFoundException extends \RuntimeException +{ + protected $template; + + public function __construct($message, $template = '') + { + $this->message = $message; + $this->template = $template; + } + + /** + * 获取模板文件 + * @access public + * @return string + */ + public function getTemplate() + { + return $this->template; + } +} diff --git a/thinkphp/library/think/exception/ThrowableError.php b/thinkphp/library/think/exception/ThrowableError.php new file mode 100644 index 0000000..87b6b9d --- /dev/null +++ b/thinkphp/library/think/exception/ThrowableError.php @@ -0,0 +1,47 @@ + +// +---------------------------------------------------------------------- + +namespace think\exception; + +class ThrowableError extends \ErrorException +{ + public function __construct(\Throwable $e) + { + + if ($e instanceof \ParseError) { + $message = 'Parse error: ' . $e->getMessage(); + $severity = E_PARSE; + } elseif ($e instanceof \TypeError) { + $message = 'Type error: ' . $e->getMessage(); + $severity = E_RECOVERABLE_ERROR; + } else { + $message = 'Fatal error: ' . $e->getMessage(); + $severity = E_ERROR; + } + + parent::__construct( + $message, + $e->getCode(), + $severity, + $e->getFile(), + $e->getLine() + ); + + $this->setTrace($e->getTrace()); + } + + protected function setTrace($trace) + { + $traceReflector = new \ReflectionProperty('Exception', 'trace'); + $traceReflector->setAccessible(true); + $traceReflector->setValue($this, $trace); + } +} diff --git a/thinkphp/library/think/exception/ValidateException.php b/thinkphp/library/think/exception/ValidateException.php new file mode 100644 index 0000000..b368416 --- /dev/null +++ b/thinkphp/library/think/exception/ValidateException.php @@ -0,0 +1,33 @@ + +// +---------------------------------------------------------------------- + +namespace think\exception; + +class ValidateException extends \RuntimeException +{ + protected $error; + + public function __construct($error) + { + $this->error = $error; + $this->message = is_array($error) ? implode("\n\r", $error) : $error; + } + + /** + * 获取验证错误信息 + * @access public + * @return array|string + */ + public function getError() + { + return $this->error; + } +} diff --git a/thinkphp/library/think/log/driver/File.php b/thinkphp/library/think/log/driver/File.php new file mode 100644 index 0000000..bace4c2 --- /dev/null +++ b/thinkphp/library/think/log/driver/File.php @@ -0,0 +1,272 @@ + +// +---------------------------------------------------------------------- + +namespace think\log\driver; + +use think\App; +use think\Request; + +/** + * 本地化调试输出到文件 + */ +class File +{ + protected $config = [ + 'time_format' => ' c ', + 'single' => false, + 'file_size' => 2097152, + 'path' => LOG_PATH, + 'apart_level' => [], + 'max_files' => 0, + 'json' => false, + ]; + + // 实例化并传入参数 + public function __construct($config = []) + { + if (is_array($config)) { + $this->config = array_merge($this->config, $config); + } + } + + /** + * 日志写入接口 + * @access public + * @param array $log 日志信息 + * @param bool $append 是否追加请求信息 + * @return bool + */ + public function save(array $log = [], $append = false) + { + $destination = $this->getMasterLogFile(); + + $path = dirname($destination); + !is_dir($path) && mkdir($path, 0755, true); + + $info = []; + foreach ($log as $type => $val) { + + foreach ($val as $msg) { + if (!is_string($msg)) { + $msg = var_export($msg, true); + } + + $info[$type][] = $this->config['json'] ? $msg : '[ ' . $type . ' ] ' . $msg; + } + + if (!$this->config['json'] && (true === $this->config['apart_level'] || in_array($type, $this->config['apart_level']))) { + // 独立记录的日志级别 + $filename = $this->getApartLevelFile($path, $type); + + $this->write($info[$type], $filename, true, $append); + unset($info[$type]); + } + } + + if ($info) { + return $this->write($info, $destination, false, $append); + } + + return true; + } + + /** + * 获取主日志文件名 + * @access public + * @return string + */ + protected function getMasterLogFile() + { + $cli = PHP_SAPI == 'cli' ? '_cli' : ''; + if ($this->config['single']) { + $name = is_string($this->config['single']) ? $this->config['single'] : 'single'; + $destination = $this->config['path'] . $name . $cli . '.log'; + } else { + if ($this->config['max_files']) { + $filename = date('Ymd') . $cli . '.log'; + $files = glob($this->config['path'] . '*.log'); + + try { + if (count($files) > $this->config['max_files']) { + unlink($files[0]); + } + } catch (\Exception $e) { + } + } else { + $filename = date('Ym') . DIRECTORY_SEPARATOR . date('d') . $cli . '.log'; + } + + $destination = $this->config['path'] . $filename; + } + + return $destination; + } + + /** + * 获取独立日志文件名 + * @access public + * @param string $path 日志目录 + * @param string $type 日志类型 + * @return string + */ + protected function getApartLevelFile($path, $type) + { + $cli = PHP_SAPI == 'cli' ? '_cli' : ''; + + if ($this->config['single']) { + $name = is_string($this->config['single']) ? $this->config['single'] : 'single'; + } elseif ($this->config['max_files']) { + $name = date('Ymd'); + } else { + $name = date('d'); + } + + return $path . DIRECTORY_SEPARATOR . $name . '_' . $type . $cli . '.log'; + } + + /** + * 日志写入 + * @access protected + * @param array $message 日志信息 + * @param string $destination 日志文件 + * @param bool $apart 是否独立文件写入 + * @param bool $append 是否追加请求信息 + * @return bool + */ + protected function write($message, $destination, $apart = false, $append = false) + { + // 检测日志文件大小,超过配置大小则备份日志文件重新生成 + $this->checkLogSize($destination); + + // 日志信息封装 + $info['timestamp'] = date($this->config['time_format']); + + foreach ($message as $type => $msg) { + $msg = is_array($msg) ? implode("\r\n", $msg) : $msg; + if (PHP_SAPI == 'cli') { + $info['msg'] = $msg; + $info['type'] = $type; + } else { + $info[$type] = $msg; + } + } + + if (PHP_SAPI == 'cli') { + $message = $this->parseCliLog($info); + } else { + // 添加调试日志 + $this->getDebugLog($info, $append, $apart); + + $message = $this->parseLog($info); + } + + return error_log($message, 3, $destination); + } + + /** + * 检查日志文件大小并自动生成备份文件 + * @access protected + * @param string $destination 日志文件 + * @return void + */ + protected function checkLogSize($destination) + { + if (is_file($destination) && floor($this->config['file_size']) <= filesize($destination)) { + try { + rename($destination, dirname($destination) . DIRECTORY_SEPARATOR . time() . '-' . basename($destination)); + } catch (\Exception $e) { + } + } + } + + /** + * CLI日志解析 + * @access protected + * @param array $info 日志信息 + * @return string + */ + protected function parseCliLog($info) + { + if ($this->config['json']) { + $message = json_encode($info, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . "\r\n"; + } else { + $now = $info['timestamp']; + unset($info['timestamp']); + + $message = implode("\r\n", $info); + + $message = "[{$now}]" . $message . "\r\n"; + } + + return $message; + } + + /** + * 解析日志 + * @access protected + * @param array $info 日志信息 + * @return string + */ + protected function parseLog($info) + { + $request = Request::instance(); + $requestInfo = [ + 'ip' => $request->ip(), + 'method' => $request->method(), + 'host' => $request->host(), + 'uri' => $request->url(), + ]; + + if ($this->config['json']) { + $info = $requestInfo + $info; + return json_encode($info, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . "\r\n"; + } + + array_unshift($info, "---------------------------------------------------------------\r\n[{$info['timestamp']}] {$requestInfo['ip']} {$requestInfo['method']} {$requestInfo['host']}{$requestInfo['uri']}"); + unset($info['timestamp']); + + return implode("\r\n", $info) . "\r\n"; + } + + protected function getDebugLog(&$info, $append, $apart) + { + if (App::$debug && $append) { + + if ($this->config['json']) { + // 获取基本信息 + $runtime = round(microtime(true) - THINK_START_TIME, 10); + $reqs = $runtime > 0 ? number_format(1 / $runtime, 2) : '∞'; + + $memory_use = number_format((memory_get_usage() - THINK_START_MEM) / 1024, 2); + + $info = [ + 'runtime' => number_format($runtime, 6) . 's', + 'reqs' => $reqs . 'req/s', + 'memory' => $memory_use . 'kb', + 'file' => count(get_included_files()), + ] + $info; + + } elseif (!$apart) { + // 增加额外的调试信息 + $runtime = round(microtime(true) - THINK_START_TIME, 10); + $reqs = $runtime > 0 ? number_format(1 / $runtime, 2) : '∞'; + + $memory_use = number_format((memory_get_usage() - THINK_START_MEM) / 1024, 2); + + $time_str = '[运行时间:' . number_format($runtime, 6) . 's] [吞吐率:' . $reqs . 'req/s]'; + $memory_str = ' [内存消耗:' . $memory_use . 'kb]'; + $file_load = ' [文件加载:' . count(get_included_files()) . ']'; + + array_unshift($info, $time_str . $memory_str . $file_load); + } + } + } +} diff --git a/thinkphp/library/think/log/driver/Socket.php b/thinkphp/library/think/log/driver/Socket.php new file mode 100644 index 0000000..4f62915 --- /dev/null +++ b/thinkphp/library/think/log/driver/Socket.php @@ -0,0 +1,250 @@ + +// +---------------------------------------------------------------------- + +namespace think\log\driver; + +use think\App; + +/** + * github: https://github.com/luofei614/SocketLog + * @author luofei614 + */ +class Socket +{ + public $port = 1116; //SocketLog 服务的http的端口号 + + protected $config = [ + // socket服务器地址 + 'host' => 'localhost', + // 是否显示加载的文件列表 + 'show_included_files' => false, + // 日志强制记录到配置的client_id + 'force_client_ids' => [], + // 限制允许读取日志的client_id + 'allow_client_ids' => [], + ]; + + protected $css = [ + 'sql' => 'color:#009bb4;', + 'sql_warn' => 'color:#009bb4;font-size:14px;', + 'error' => 'color:#f4006b;font-size:14px;', + 'page' => 'color:#40e2ff;background:#171717;', + 'big' => 'font-size:20px;color:red;', + ]; + + protected $allowForceClientIds = []; //配置强制推送且被授权的client_id + + /** + * 构造函数 + * @param array $config 缓存参数 + * @access public + */ + public function __construct(array $config = []) + { + if (!empty($config)) { + $this->config = array_merge($this->config, $config); + } + } + + /** + * 调试输出接口 + * @access public + * @param array $log 日志信息 + * @return bool + */ + public function save(array $log = [], $append = false) + { + if (!$this->check()) { + return false; + } + $trace = []; + if (App::$debug) { + $runtime = round(microtime(true) - THINK_START_TIME, 10); + $reqs = $runtime > 0 ? number_format(1 / $runtime, 2) : '∞'; + $time_str = ' [运行时间:' . number_format($runtime, 6) . 's][吞吐率:' . $reqs . 'req/s]'; + $memory_use = number_format((memory_get_usage() - THINK_START_MEM) / 1024, 2); + $memory_str = ' [内存消耗:' . $memory_use . 'kb]'; + $file_load = ' [文件加载:' . count(get_included_files()) . ']'; + + if (isset($_SERVER['HTTP_HOST'])) { + $current_uri = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; + } else { + $current_uri = 'cmd:' . implode(' ', $_SERVER['argv']); + } + // 基本信息 + $trace[] = [ + 'type' => 'group', + 'msg' => $current_uri . $time_str . $memory_str . $file_load, + 'css' => $this->css['page'], + ]; + } + + foreach ($log as $type => $val) { + $trace[] = [ + 'type' => 'groupCollapsed', + 'msg' => '[ ' . $type . ' ]', + 'css' => isset($this->css[$type]) ? $this->css[$type] : '', + ]; + foreach ($val as $msg) { + if (!is_string($msg)) { + $msg = var_export($msg, true); + } + $trace[] = [ + 'type' => 'log', + 'msg' => $msg, + 'css' => '', + ]; + } + $trace[] = [ + 'type' => 'groupEnd', + 'msg' => '', + 'css' => '', + ]; + } + + if ($this->config['show_included_files']) { + $trace[] = [ + 'type' => 'groupCollapsed', + 'msg' => '[ file ]', + 'css' => '', + ]; + $trace[] = [ + 'type' => 'log', + 'msg' => implode("\n", get_included_files()), + 'css' => '', + ]; + $trace[] = [ + 'type' => 'groupEnd', + 'msg' => '', + 'css' => '', + ]; + } + + $trace[] = [ + 'type' => 'groupEnd', + 'msg' => '', + 'css' => '', + ]; + + $tabid = $this->getClientArg('tabid'); + if (!$client_id = $this->getClientArg('client_id')) { + $client_id = ''; + } + + if (!empty($this->allowForceClientIds)) { + //强制推送到多个client_id + foreach ($this->allowForceClientIds as $force_client_id) { + $client_id = $force_client_id; + $this->sendToClient($tabid, $client_id, $trace, $force_client_id); + } + } else { + $this->sendToClient($tabid, $client_id, $trace, ''); + } + return true; + } + + /** + * 发送给指定客户端 + * @author Zjmainstay + * @param $tabid + * @param $client_id + * @param $logs + * @param $force_client_id + */ + protected function sendToClient($tabid, $client_id, $logs, $force_client_id) + { + $logs = [ + 'tabid' => $tabid, + 'client_id' => $client_id, + 'logs' => $logs, + 'force_client_id' => $force_client_id, + ]; + $msg = @json_encode($logs); + $address = '/' . $client_id; //将client_id作为地址, server端通过地址判断将日志发布给谁 + $this->send($this->config['host'], $msg, $address); + } + + protected function check() + { + $tabid = $this->getClientArg('tabid'); + //是否记录日志的检查 + if (!$tabid && !$this->config['force_client_ids']) { + return false; + } + //用户认证 + $allow_client_ids = $this->config['allow_client_ids']; + if (!empty($allow_client_ids)) { + //通过数组交集得出授权强制推送的client_id + $this->allowForceClientIds = array_intersect($allow_client_ids, $this->config['force_client_ids']); + if (!$tabid && count($this->allowForceClientIds)) { + return true; + } + + $client_id = $this->getClientArg('client_id'); + if (!in_array($client_id, $allow_client_ids)) { + return false; + } + } else { + $this->allowForceClientIds = $this->config['force_client_ids']; + } + return true; + } + + protected function getClientArg($name) + { + static $args = []; + + $key = 'HTTP_USER_AGENT'; + + if (isset($_SERVER['HTTP_SOCKETLOG'])) { + $key = 'HTTP_SOCKETLOG'; + } + + if (!isset($_SERVER[$key])) { + return; + } + if (empty($args)) { + if (!preg_match('/SocketLog\((.*?)\)/', $_SERVER[$key], $match)) { + $args = ['tabid' => null]; + return; + } + parse_str($match[1], $args); + } + if (isset($args[$name])) { + return $args[$name]; + } + return; + } + + /** + * @param string $host - $host of socket server + * @param string $message - 发送的消息 + * @param string $address - 地址 + * @return bool + */ + protected function send($host, $message = '', $address = '/') + { + $url = 'http://' . $host . ':' . $this->port . $address; + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $url); + curl_setopt($ch, CURLOPT_POST, true); + curl_setopt($ch, CURLOPT_POSTFIELDS, $message); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 1); + curl_setopt($ch, CURLOPT_TIMEOUT, 10); + $headers = [ + "Content-Type: application/json;charset=UTF-8", + ]; + curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); //设置header + return curl_exec($ch); + } + +} diff --git a/thinkphp/library/think/log/driver/Test.php b/thinkphp/library/think/log/driver/Test.php new file mode 100644 index 0000000..7f66338 --- /dev/null +++ b/thinkphp/library/think/log/driver/Test.php @@ -0,0 +1,30 @@ + +// +---------------------------------------------------------------------- + +namespace think\log\driver; + +/** + * 模拟测试输出 + */ +class Test +{ + /** + * 日志写入接口 + * @access public + * @param array $log 日志信息 + * @return bool + */ + public function save(array $log = []) + { + return true; + } + +} diff --git a/thinkphp/library/think/model/Collection.php b/thinkphp/library/think/model/Collection.php new file mode 100644 index 0000000..0406533 --- /dev/null +++ b/thinkphp/library/think/model/Collection.php @@ -0,0 +1,79 @@ + +// +---------------------------------------------------------------------- + +namespace think\model; + +use think\Collection as BaseCollection; +use think\Model; + +class Collection extends BaseCollection +{ + /** + * 延迟预载入关联查询 + * @access public + * @param mixed $relation 关联 + * @return $this + */ + public function load($relation) + { + $item = current($this->items); + $item->eagerlyResultSet($this->items, $relation); + return $this; + } + + /** + * 设置需要隐藏的输出属性 + * @access public + * @param array $hidden 属性列表 + * @param bool $override 是否覆盖 + * @return $this + */ + public function hidden($hidden = [], $override = false) + { + $this->each(function ($model) use ($hidden, $override) { + /** @var Model $model */ + $model->hidden($hidden, $override); + }); + return $this; + } + + /** + * 设置需要输出的属性 + * @param array $visible + * @param bool $override 是否覆盖 + * @return $this + */ + public function visible($visible = [], $override = false) + { + $this->each(function ($model) use ($visible, $override) { + /** @var Model $model */ + $model->visible($visible, $override); + }); + return $this; + } + + /** + * 设置需要追加的输出属性 + * @access public + * @param array $append 属性列表 + * @param bool $override 是否覆盖 + * @return $this + */ + public function append($append = [], $override = false) + { + $this->each(function ($model) use ($append, $override) { + /** @var Model $model */ + $model && $model->append($append, $override); + }); + return $this; + } + +} diff --git a/thinkphp/library/think/model/Merge.php b/thinkphp/library/think/model/Merge.php new file mode 100644 index 0000000..4a9da81 --- /dev/null +++ b/thinkphp/library/think/model/Merge.php @@ -0,0 +1,322 @@ + +// +---------------------------------------------------------------------- + +namespace think\model; + +use think\Db; +use think\db\Query; +use think\Model; + +class Merge extends Model +{ + + protected $relationModel = []; // HAS ONE 关联的模型列表 + protected $fk = ''; // 外键名 默认为主表名_id + protected $mapFields = []; // 需要处理的模型映射字段,避免混淆 array( id => 'user.id' ) + + /** + * 构造函数 + * @access public + * @param array|object $data 数据 + */ + public function __construct($data = []) + { + parent::__construct($data); + + // 设置默认外键名 仅支持单一外键 + if (empty($this->fk)) { + $this->fk = strtolower($this->name) . '_id'; + } + } + + /** + * 查找单条记录 + * @access public + * @param mixed $data 主键值或者查询条件(闭包) + * @param string|array $with 关联预查询 + * @param bool $cache 是否缓存 + * @return \think\Model + */ + public static function get($data = null, $with = [], $cache = false) + { + $query = self::parseQuery($data, $with, $cache); + $query = self::attachQuery($query); + return $query->find($data); + } + + /** + * 附加查询表达式 + * @access protected + * @param \think\db\Query $query 查询对象 + * @return \think\db\Query + */ + protected static function attachQuery($query) + { + $class = new static(); + $master = $class->name; + $fields = self::getModelField($query, $master, '', $class->mapFields, $class->field); + $query->alias($master)->field($fields); + + foreach ($class->relationModel as $key => $model) { + $name = is_int($key) ? $model : $key; + $table = is_int($key) ? $query->getTable($name) : $model; + $query->join($table . ' ' . $name, $name . '.' . $class->fk . '=' . $master . '.' . $class->getPk()); + $fields = self::getModelField($query, $name, $table, $class->mapFields, $class->field); + $query->field($fields); + } + return $query; + } + + /** + * 获取关联模型的字段 并解决混淆 + * @access protected + * @param \think\db\Query $query 查询对象 + * @param string $name 模型名称 + * @param string $table 关联表名称 + * @param array $map 字段映射 + * @param array $fields 查询字段 + * @return array + */ + protected static function getModelField($query, $name, $table = '', $map = [], $fields = []) + { + // 获取模型的字段信息 + $fields = $fields ?: $query->getTableInfo($table, 'fields'); + $array = []; + foreach ($fields as $field) { + if ($key = array_search($name . '.' . $field, $map)) { + // 需要处理映射字段 + $array[] = $name . '.' . $field . ' AS ' . $key; + } else { + $array[] = $field; + } + } + return $array; + } + + /** + * 查找所有记录 + * @access public + * @param mixed $data 主键列表或者查询条件(闭包) + * @param array|string $with 关联预查询 + * @param bool $cache + * @return array|false|string + */ + public static function all($data = null, $with = [], $cache = false) + { + $query = self::parseQuery($data, $with, $cache); + $query = self::attachQuery($query); + return $query->select($data); + } + + /** + * 处理写入的模型数据 + * @access public + * @param string $model 模型名称 + * @param array $data 数据 + * @return array + */ + protected function parseData($model, $data) + { + $item = []; + foreach ($data as $key => $val) { + if ($this->fk != $key && array_key_exists($key, $this->mapFields)) { + list($name, $key) = explode('.', $this->mapFields[$key]); + if ($model == $name) { + $item[$key] = $val; + } + } else { + $item[$key] = $val; + } + } + return $item; + } + + /** + * 保存模型数据 以及关联数据 + * @access public + * @param mixed $data 数据 + * @param array $where 更新条件 + * @param string $sequence 自增序列名 + * @return false|int + * @throws \Exception + */ + public function save($data = [], $where = [], $sequence = null) + { + if (!empty($data)) { + // 数据自动验证 + if (!$this->validateData($data)) { + return false; + } + // 数据对象赋值 + foreach ($data as $key => $value) { + $this->setAttr($key, $value, $data); + } + if (!empty($where)) { + $this->isUpdate = true; + } + } + + // 数据自动完成 + $this->autoCompleteData($this->auto); + + // 自动写入更新时间 + if ($this->autoWriteTimestamp && $this->updateTime && !isset($this->data[$this->updateTime])) { + $this->setAttr($this->updateTime, null); + } + + // 事件回调 + if (false === $this->trigger('before_write', $this)) { + return false; + } + + $db = $this->db(); + $db->startTrans(); + $pk = $this->getPk(); + try { + if ($this->isUpdate) { + // 自动写入 + $this->autoCompleteData($this->update); + + if (false === $this->trigger('before_update', $this)) { + return false; + } + + if (empty($where) && !empty($this->updateWhere)) { + $where = $this->updateWhere; + } + + // 获取有更新的数据 + $data = $this->getChangedData(); + // 保留主键数据 + foreach ($this->data as $key => $val) { + if ($this->isPk($key)) { + $data[$key] = $val; + } + } + // 处理模型数据 + $data = $this->parseData($this->name, $data); + if (is_string($pk) && isset($data[$pk])) { + if (!isset($where[$pk])) { + unset($where); + $where[$pk] = $data[$pk]; + } + unset($data[$pk]); + } + // 写入主表数据 + $result = $db->strict(false)->where($where)->update($data); + + // 写入附表数据 + foreach ($this->relationModel as $key => $model) { + $name = is_int($key) ? $model : $key; + $table = is_int($key) ? $db->getTable($model) : $model; + // 处理关联模型数据 + $data = $this->parseData($name, $data); + if (Db::table($table)->strict(false)->where($this->fk, $this->data[$this->getPk()])->update($data)) { + $result = 1; + } + } + + // 新增回调 + $this->trigger('after_update', $this); + } else { + // 自动写入 + $this->autoCompleteData($this->insert); + + // 自动写入创建时间 + if ($this->autoWriteTimestamp && $this->createTime && !isset($this->data[$this->createTime])) { + $this->setAttr($this->createTime, null); + } + + if (false === $this->trigger('before_insert', $this)) { + return false; + } + + // 处理模型数据 + $data = $this->parseData($this->name, $this->data); + // 写入主表数据 + $result = $db->name($this->name)->strict(false)->insert($data); + if ($result) { + $insertId = $db->getLastInsID($sequence); + // 写入外键数据 + if ($insertId) { + if (is_string($pk)) { + $this->data[$pk] = $insertId; + } + $this->data[$this->fk] = $insertId; + } + + // 写入附表数据 + $source = $this->data; + if ($insertId && is_string($pk) && isset($source[$pk]) && $this->fk != $pk) { + unset($source[$pk]); + } + foreach ($this->relationModel as $key => $model) { + $name = is_int($key) ? $model : $key; + $table = is_int($key) ? $db->getTable($model) : $model; + // 处理关联模型数据 + $data = $this->parseData($name, $source); + Db::table($table)->strict(false)->insert($data); + } + } + // 标记为更新 + $this->isUpdate = true; + // 新增回调 + $this->trigger('after_insert', $this); + } + $db->commit(); + // 写入回调 + $this->trigger('after_write', $this); + + $this->origin = $this->data; + return $result; + } catch (\Exception $e) { + $db->rollback(); + throw $e; + } + } + + /** + * 删除当前的记录 并删除关联数据 + * @access public + * @return int + * @throws \Exception + */ + public function delete() + { + if (false === $this->trigger('before_delete', $this)) { + return false; + } + + $db = $this->db(); + $db->startTrans(); + try { + $result = $db->delete($this->data); + if ($result) { + // 获取主键数据 + $pk = $this->data[$this->getPk()]; + + // 删除关联数据 + foreach ($this->relationModel as $key => $model) { + $table = is_int($key) ? $db->getTable($model) : $model; + $query = new Query; + $query->table($table)->where($this->fk, $pk)->delete(); + } + } + $this->trigger('after_delete', $this); + $db->commit(); + return $result; + } catch (\Exception $e) { + $db->rollback(); + throw $e; + } + } + +} diff --git a/thinkphp/library/think/model/Pivot.php b/thinkphp/library/think/model/Pivot.php new file mode 100644 index 0000000..13525cd --- /dev/null +++ b/thinkphp/library/think/model/Pivot.php @@ -0,0 +1,42 @@ + +// +---------------------------------------------------------------------- + +namespace think\model; + +use think\Model; + +class Pivot extends Model +{ + + /** @var Model */ + public $parent; + + protected $autoWriteTimestamp = false; + + /** + * 架构函数 + * @access public + * @param array|object $data 数据 + * @param Model $parent 上级模型 + * @param string $table 中间数据表名 + */ + public function __construct($data = [], Model $parent = null, $table = '') + { + $this->parent = $parent; + + if (is_null($this->name)) { + $this->name = $table; + } + + parent::__construct($data); + } + +} diff --git a/thinkphp/library/think/model/Relation.php b/thinkphp/library/think/model/Relation.php new file mode 100644 index 0000000..25fe88d --- /dev/null +++ b/thinkphp/library/think/model/Relation.php @@ -0,0 +1,155 @@ + +// +---------------------------------------------------------------------- + +namespace think\model; + +use think\db\Query; +use think\Exception; +use think\Model; + +/** + * Class Relation + * @package think\model + * + * @mixin Query + */ +abstract class Relation +{ + // 父模型对象 + protected $parent; + /** @var Model 当前关联的模型类 */ + protected $model; + /** @var Query 关联模型查询对象 */ + protected $query; + // 关联表外键 + protected $foreignKey; + // 关联表主键 + protected $localKey; + // 基础查询 + protected $baseQuery; + // 是否为自关联 + protected $selfRelation; + + /** + * 获取关联的所属模型 + * @access public + * @return Model + */ + public function getParent() + { + return $this->parent; + } + + /** + * 获取当前的关联模型对象实例 + * @access public + * @return Model + */ + public function getModel() + { + return $this->query->getModel(); + } + + /** + * 获取关联的查询对象 + * @access public + * @return Query + */ + public function getQuery() + { + return $this->query; + } + + /** + * 设置当前关联为自关联 + * @access public + * @param bool $self 是否自关联 + * @return $this + */ + public function selfRelation($self = true) + { + $this->selfRelation = $self; + return $this; + } + + /** + * 当前关联是否为自关联 + * @access public + * @return bool + */ + public function isSelfRelation() + { + return $this->selfRelation; + } + + /** + * 封装关联数据集 + * @access public + * @param array $resultSet 数据集 + * @return mixed + */ + protected function resultSetBuild($resultSet) + { + return (new $this->model)->toCollection($resultSet); + } + + protected function getQueryFields($model) + { + $fields = $this->query->getOptions('field'); + return $this->getRelationQueryFields($fields, $model); + } + + protected function getRelationQueryFields($fields, $model) + { + if ($fields) { + + if (is_string($fields)) { + $fields = explode(',', $fields); + } + + foreach ($fields as &$field) { + if (false === strpos($field, '.')) { + $field = $model . '.' . $field; + } + } + } else { + $fields = $model . '.*'; + } + + return $fields; + } + + /** + * 执行基础查询(仅执行一次) + * @access protected + * @return void + */ + protected function baseQuery() + {} + + public function __call($method, $args) + { + if ($this->query) { + // 执行基础查询 + $this->baseQuery(); + + $result = call_user_func_array([$this->query, $method], $args); + if ($result instanceof Query) { + return $this; + } else { + $this->baseQuery = false; + return $result; + } + } else { + throw new Exception('method not exists:' . __CLASS__ . '->' . $method); + } + } +} diff --git a/thinkphp/library/think/model/relation/BelongsTo.php b/thinkphp/library/think/model/relation/BelongsTo.php new file mode 100644 index 0000000..c1cbab9 --- /dev/null +++ b/thinkphp/library/think/model/relation/BelongsTo.php @@ -0,0 +1,243 @@ + +// +---------------------------------------------------------------------- + +namespace think\model\relation; + +use think\db\Query; +use think\Loader; +use think\Model; + +class BelongsTo extends OneToOne +{ + /** + * 构造函数 + * @access public + * @param Model $parent 上级模型对象 + * @param string $model 模型名 + * @param string $foreignKey 关联外键 + * @param string $localKey 关联主键 + * @param string $joinType JOIN类型 + * @param string $relation 关联名 + */ + public function __construct(Model $parent, $model, $foreignKey, $localKey, $joinType = 'INNER', $relation = null) + { + $this->parent = $parent; + $this->model = $model; + $this->foreignKey = $foreignKey; + $this->localKey = $localKey; + $this->joinType = $joinType; + $this->query = (new $model)->db(); + $this->relation = $relation; + } + + /** + * 延迟获取关联数据 + * @param string $subRelation 子关联名 + * @param \Closure $closure 闭包查询条件 + * @access public + * @return array|false|\PDOStatement|string|Model + */ + public function getRelation($subRelation = '', $closure = null) + { + $foreignKey = $this->foreignKey; + if ($closure) { + call_user_func_array($closure, [ & $this->query]); + } + $relationModel = $this->query + ->removeWhereField($this->localKey) + ->where($this->localKey, $this->parent->$foreignKey) + ->relation($subRelation) + ->find(); + + if ($relationModel) { + $relationModel->setParent(clone $this->parent); + } + + return $relationModel; + } + + /** + * 根据关联条件查询当前模型 + * @access public + * @param string $operator 比较操作符 + * @param integer $count 个数 + * @param string $id 关联表的统计字段 + * @return Query + */ + public function has($operator = '>=', $count = 1, $id = '*') + { + return $this->parent; + } + + /** + * 根据关联条件查询当前模型 + * @access public + * @param mixed $where 查询条件(数组或者闭包) + * @param mixed $fields 字段 + * @return Query + */ + public function hasWhere($where = [], $fields = null) + { + $table = $this->query->getTable(); + $model = basename(str_replace('\\', '/', get_class($this->parent))); + $relation = basename(str_replace('\\', '/', $this->model)); + + if (is_array($where)) { + foreach ($where as $key => $val) { + if (false === strpos($key, '.')) { + $where[$relation . '.' . $key] = $val; + unset($where[$key]); + } + } + } + $fields = $this->getRelationQueryFields($fields, $model); + + return $this->parent->db()->alias($model) + ->field($fields) + ->join([$table => $relation], $model . '.' . $this->foreignKey . '=' . $relation . '.' . $this->localKey, $this->joinType) + ->where($where); + } + + /** + * 预载入关联查询(数据集) + * @access public + * @param array $resultSet 数据集 + * @param string $relation 当前关联名 + * @param string $subRelation 子关联名 + * @param \Closure $closure 闭包 + * @return void + */ + protected function eagerlySet(&$resultSet, $relation, $subRelation, $closure) + { + $localKey = $this->localKey; + $foreignKey = $this->foreignKey; + + $range = []; + foreach ($resultSet as $result) { + // 获取关联外键列表 + if (isset($result->$foreignKey)) { + $range[] = $result->$foreignKey; + } + } + + if (!empty($range)) { + $this->query->removeWhereField($localKey); + $data = $this->eagerlyWhere($this->query, [ + $localKey => [ + 'in', + $range, + ], + ], $localKey, $relation, $subRelation, $closure); + // 关联属性名 + $attr = Loader::parseName($relation); + // 关联数据封装 + foreach ($resultSet as $result) { + // 关联模型 + if (!isset($data[$result->$foreignKey])) { + $relationModel = null; + } else { + $relationModel = $data[$result->$foreignKey]; + $relationModel->setParent(clone $result); + $relationModel->isUpdate(true); + } + + if (!empty($this->bindAttr)) { + // 绑定关联属性 + $this->bindAttr($relationModel, $result, $this->bindAttr); + } else { + // 设置关联属性 + $result->setRelation($attr, $relationModel); + } + } + } + } + + /** + * 预载入关联查询(数据) + * @access public + * @param Model $result 数据对象 + * @param string $relation 当前关联名 + * @param string $subRelation 子关联名 + * @param \Closure $closure 闭包 + * @return void + */ + protected function eagerlyOne(&$result, $relation, $subRelation, $closure) + { + $localKey = $this->localKey; + $foreignKey = $this->foreignKey; + $this->query->removeWhereField($localKey); + $data = $this->eagerlyWhere($this->query, [$localKey => $result->$foreignKey], $localKey, $relation, $subRelation, $closure); + // 关联模型 + if (!isset($data[$result->$foreignKey])) { + $relationModel = null; + } else { + $relationModel = $data[$result->$foreignKey]; + $relationModel->setParent(clone $result); + $relationModel->isUpdate(true); + } + if (!empty($this->bindAttr)) { + // 绑定关联属性 + $this->bindAttr($relationModel, $result, $this->bindAttr); + } else { + // 设置关联属性 + $result->setRelation(Loader::parseName($relation), $relationModel); + } + } + + /** + * 添加关联数据 + * @access public + * @param Model $model 关联模型对象 + * @return Model + */ + public function associate($model) + { + $foreignKey = $this->foreignKey; + $pk = $model->getPk(); + + $this->parent->setAttr($foreignKey, $model->$pk); + $this->parent->save(); + + return $this->parent->setRelation($this->relation, $model); + } + + /** + * 注销关联数据 + * @access public + * @return Model + */ + public function dissociate() + { + $foreignKey = $this->foreignKey; + + $this->parent->setAttr($foreignKey, null); + $this->parent->save(); + + return $this->parent->setRelation($this->relation, null); + } + + /** + * 执行基础查询(仅执行一次) + * @access protected + * @return void + */ + protected function baseQuery() + { + if (empty($this->baseQuery)) { + if (isset($this->parent->{$this->foreignKey})) { + // 关联查询带入关联条件 + $this->query->where($this->localKey, '=', $this->parent->{$this->foreignKey}); + } + + $this->baseQuery = true; + } + } +} diff --git a/thinkphp/library/think/model/relation/BelongsToMany.php b/thinkphp/library/think/model/relation/BelongsToMany.php new file mode 100644 index 0000000..a41c45c --- /dev/null +++ b/thinkphp/library/think/model/relation/BelongsToMany.php @@ -0,0 +1,644 @@ + +// +---------------------------------------------------------------------- + +namespace think\model\relation; + +use think\Collection; +use think\Db; +use think\db\Query; +use think\Exception; +use think\Loader; +use think\Model; +use think\model\Pivot; +use think\model\Relation; +use think\Paginator; + +class BelongsToMany extends Relation +{ + // 中间表表名 + protected $middle; + // 中间表模型名称 + protected $pivotName; + // 中间表模型对象 + protected $pivot; + // 中间表数据名称 + protected $pivotDataName = 'pivot'; + + /** + * 构造函数 + * @access public + * @param Model $parent 上级模型对象 + * @param string $model 模型名 + * @param string $table 中间表名 + * @param string $foreignKey 关联模型外键 + * @param string $localKey 当前模型关联键 + */ + public function __construct(Model $parent, $model, $table, $foreignKey, $localKey) + { + $this->parent = $parent; + $this->model = $model; + $this->foreignKey = $foreignKey; + $this->localKey = $localKey; + if (false !== strpos($table, '\\')) { + $this->pivotName = $table; + $this->middle = basename(str_replace('\\', '/', $table)); + } else { + $this->middle = $table; + } + $this->query = (new $model)->db(); + $this->pivot = $this->newPivot(); + + if ('think\model\Pivot' == get_class($this->pivot)) { + $this->pivot->name($this->middle); + } + } + + /** + * 设置中间表模型 + * @param $pivot + * @return $this + */ + public function pivot($pivot) + { + $this->pivotName = $pivot; + return $this; + } + + /** + * 设置中间表数据名称 + * @access public + * @param string $name + * @return $this + */ + public function pivotDataName($name) + { + $this->pivotDataName = $name; + return $this; + } + + /** + * 获取中间表更新条件 + * @param $data + * @return array + */ + protected function getUpdateWhere($data) + { + return [ + $this->localKey => $data[$this->localKey], + $this->foreignKey => $data[$this->foreignKey], + ]; + } + + /** + * 实例化中间表模型 + * @param array $data + * @param bool $isUpdate + * @return Pivot + * @throws Exception + */ + protected function newPivot($data = [], $isUpdate = false) + { + $class = $this->pivotName ?: '\\think\\model\\Pivot'; + $pivot = new $class($data, $this->parent, $this->middle); + if ($pivot instanceof Pivot) { + return $isUpdate ? $pivot->isUpdate(true, $this->getUpdateWhere($data)) : $pivot; + } else { + throw new Exception('pivot model must extends: \think\model\Pivot'); + } + } + + /** + * 合成中间表模型 + * @param array|Collection|Paginator $models + */ + protected function hydratePivot($models) + { + foreach ($models as $model) { + $pivot = []; + foreach ($model->getData() as $key => $val) { + if (strpos($key, '__')) { + list($name, $attr) = explode('__', $key, 2); + if ('pivot' == $name) { + $pivot[$attr] = $val; + unset($model->$key); + } + } + } + $model->setRelation($this->pivotDataName, $this->newPivot($pivot, true)); + } + } + + /** + * 创建关联查询Query对象 + * @return Query + */ + protected function buildQuery() + { + $foreignKey = $this->foreignKey; + $localKey = $this->localKey; + $pk = $this->parent->getPk(); + // 关联查询 + $condition['pivot.' . $localKey] = $this->parent->$pk; + return $this->belongsToManyQuery($foreignKey, $localKey, $condition); + } + + /** + * 延迟获取关联数据 + * @param string $subRelation 子关联名 + * @param \Closure $closure 闭包查询条件 + * @return false|\PDOStatement|string|\think\Collection + */ + public function getRelation($subRelation = '', $closure = null) + { + if ($closure) { + call_user_func_array($closure, [ & $this->query]); + } + $result = $this->buildQuery()->relation($subRelation)->select(); + $this->hydratePivot($result); + return $result; + } + + /** + * 重载select方法 + * @param null $data + * @return false|\PDOStatement|string|Collection + */ + public function select($data = null) + { + $result = $this->buildQuery()->select($data); + $this->hydratePivot($result); + return $result; + } + + /** + * 重载paginate方法 + * @param null $listRows + * @param bool $simple + * @param array $config + * @return Paginator + */ + public function paginate($listRows = null, $simple = false, $config = []) + { + $result = $this->buildQuery()->paginate($listRows, $simple, $config); + $this->hydratePivot($result); + return $result; + } + + /** + * 重载find方法 + * @param null $data + * @return array|false|\PDOStatement|string|Model + */ + public function find($data = null) + { + $result = $this->buildQuery()->find($data); + if ($result) { + $this->hydratePivot([$result]); + } + return $result; + } + + /** + * 查找多条记录 如果不存在则抛出异常 + * @access public + * @param array|string|Query|\Closure $data + * @return array|\PDOStatement|string|Model + */ + public function selectOrFail($data = null) + { + return $this->failException(true)->select($data); + } + + /** + * 查找单条记录 如果不存在则抛出异常 + * @access public + * @param array|string|Query|\Closure $data + * @return array|\PDOStatement|string|Model + */ + public function findOrFail($data = null) + { + return $this->failException(true)->find($data); + } + + /** + * 根据关联条件查询当前模型 + * @access public + * @param string $operator 比较操作符 + * @param integer $count 个数 + * @param string $id 关联表的统计字段 + * @param string $joinType JOIN类型 + * @return Query + */ + public function has($operator = '>=', $count = 1, $id = '*', $joinType = 'INNER') + { + return $this->parent; + } + + /** + * 根据关联条件查询当前模型 + * @access public + * @param mixed $where 查询条件(数组或者闭包) + * @param mixed $fields 字段 + * @return Query + * @throws Exception + */ + public function hasWhere($where = [], $fields = null) + { + throw new Exception('relation not support: hasWhere'); + } + + /** + * 设置中间表的查询条件 + * @param $field + * @param null $op + * @param null $condition + * @return $this + */ + public function wherePivot($field, $op = null, $condition = null) + { + $field = 'pivot.' . $field; + $this->query->where($field, $op, $condition); + return $this; + } + + /** + * 预载入关联查询(数据集) + * @access public + * @param array $resultSet 数据集 + * @param string $relation 当前关联名 + * @param string $subRelation 子关联名 + * @param \Closure $closure 闭包 + * @return void + */ + public function eagerlyResultSet(&$resultSet, $relation, $subRelation, $closure) + { + $localKey = $this->localKey; + $foreignKey = $this->foreignKey; + + $pk = $resultSet[0]->getPk(); + $range = []; + foreach ($resultSet as $result) { + // 获取关联外键列表 + if (isset($result->$pk)) { + $range[] = $result->$pk; + } + } + + if (!empty($range)) { + // 查询关联数据 + $data = $this->eagerlyManyToMany([ + 'pivot.' . $localKey => [ + 'in', + $range, + ], + ], $relation, $subRelation); + // 关联属性名 + $attr = Loader::parseName($relation); + // 关联数据封装 + foreach ($resultSet as $result) { + if (!isset($data[$result->$pk])) { + $data[$result->$pk] = []; + } + + $result->setRelation($attr, $this->resultSetBuild($data[$result->$pk])); + } + } + } + + /** + * 预载入关联查询(单个数据) + * @access public + * @param Model $result 数据对象 + * @param string $relation 当前关联名 + * @param string $subRelation 子关联名 + * @param \Closure $closure 闭包 + * @return void + */ + public function eagerlyResult(&$result, $relation, $subRelation, $closure) + { + $pk = $result->getPk(); + if (isset($result->$pk)) { + $pk = $result->$pk; + // 查询管理数据 + $data = $this->eagerlyManyToMany(['pivot.' . $this->localKey => $pk], $relation, $subRelation); + + // 关联数据封装 + if (!isset($data[$pk])) { + $data[$pk] = []; + } + $result->setRelation(Loader::parseName($relation), $this->resultSetBuild($data[$pk])); + } + } + + /** + * 关联统计 + * @access public + * @param Model $result 数据对象 + * @param \Closure $closure 闭包 + * @return integer + */ + public function relationCount($result, $closure) + { + $pk = $result->getPk(); + $count = 0; + if (isset($result->$pk)) { + $pk = $result->$pk; + $count = $this->belongsToManyQuery($this->foreignKey, $this->localKey, ['pivot.' . $this->localKey => $pk])->count(); + } + return $count; + } + + /** + * 获取关联统计子查询 + * @access public + * @param \Closure $closure 闭包 + * @param string $name 统计数据别名 + * @return string + */ + public function getRelationCountQuery($closure, &$name = null) + { + if ($closure) { + $return = call_user_func_array($closure, [ & $this->query]); + if ($return && is_string($return)) { + $name = $return; + } + } + + return $this->belongsToManyQuery($this->foreignKey, $this->localKey, [ + 'pivot.' . $this->localKey => [ + 'exp', + Db::raw('=' . $this->parent->getTable() . '.' . $this->parent->getPk()), + ], + ])->fetchSql()->count(); + } + + /** + * 多对多 关联模型预查询 + * @access public + * @param array $where 关联预查询条件 + * @param string $relation 关联名 + * @param string $subRelation 子关联 + * @return array + */ + protected function eagerlyManyToMany($where, $relation, $subRelation = '') + { + // 预载入关联查询 支持嵌套预载入 + $list = $this->belongsToManyQuery($this->foreignKey, $this->localKey, $where)->with($subRelation)->select(); + + // 组装模型数据 + $data = []; + foreach ($list as $set) { + $pivot = []; + foreach ($set->getData() as $key => $val) { + if (strpos($key, '__')) { + list($name, $attr) = explode('__', $key, 2); + if ('pivot' == $name) { + $pivot[$attr] = $val; + unset($set->$key); + } + } + } + $set->setRelation($this->pivotDataName, $this->newPivot($pivot, true)); + $data[$pivot[$this->localKey]][] = $set; + } + return $data; + } + + /** + * BELONGS TO MANY 关联查询 + * @access public + * @param string $foreignKey 关联模型关联键 + * @param string $localKey 当前模型关联键 + * @param array $condition 关联查询条件 + * @return Query + */ + protected function belongsToManyQuery($foreignKey, $localKey, $condition = []) + { + // 关联查询封装 + $tableName = $this->query->getTable(); + $table = $this->pivot->getTable(); + $fields = $this->getQueryFields($tableName); + + $query = $this->query->field($fields) + ->field(true, false, $table, 'pivot', 'pivot__'); + + if (empty($this->baseQuery)) { + $relationFk = $this->query->getPk(); + $query->join([$table => 'pivot'], 'pivot.' . $foreignKey . '=' . $tableName . '.' . $relationFk) + ->where($condition); + } + return $query; + } + + /** + * 保存(新增)当前关联数据对象 + * @access public + * @param mixed $data 数据 可以使用数组 关联模型对象 和 关联对象的主键 + * @param array $pivot 中间表额外数据 + * @return integer + */ + public function save($data, array $pivot = []) + { + // 保存关联表/中间表数据 + return $this->attach($data, $pivot); + } + + /** + * 批量保存当前关联数据对象 + * @access public + * @param array $dataSet 数据集 + * @param array $pivot 中间表额外数据 + * @param bool $samePivot 额外数据是否相同 + * @return integer + */ + public function saveAll(array $dataSet, array $pivot = [], $samePivot = false) + { + $result = false; + foreach ($dataSet as $key => $data) { + if (!$samePivot) { + $pivotData = isset($pivot[$key]) ? $pivot[$key] : []; + } else { + $pivotData = $pivot; + } + $result = $this->attach($data, $pivotData); + } + return $result; + } + + /** + * 附加关联的一个中间表数据 + * @access public + * @param mixed $data 数据 可以使用数组、关联模型对象 或者 关联对象的主键 + * @param array $pivot 中间表额外数据 + * @return array|Pivot + * @throws Exception + */ + public function attach($data, $pivot = []) + { + if (is_array($data)) { + if (key($data) === 0) { + $id = $data; + } else { + // 保存关联表数据 + $model = new $this->model; + $model->save($data); + $id = $model->getLastInsID(); + } + } elseif (is_numeric($data) || is_string($data)) { + // 根据关联表主键直接写入中间表 + $id = $data; + } elseif ($data instanceof Model) { + // 根据关联表主键直接写入中间表 + $relationFk = $data->getPk(); + $id = $data->$relationFk; + } + + if ($id) { + // 保存中间表数据 + $pk = $this->parent->getPk(); + $pivot[$this->localKey] = $this->parent->$pk; + $ids = (array) $id; + foreach ($ids as $id) { + $pivot[$this->foreignKey] = $id; + $this->pivot->insert($pivot, true); + $result[] = $this->newPivot($pivot, true); + } + if (count($result) == 1) { + // 返回中间表模型对象 + $result = $result[0]; + } + return $result; + } else { + throw new Exception('miss relation data'); + } + } + + /** + * 判断是否存在关联数据 + * @access public + * @param mixed $data 数据 可以使用关联模型对象 或者 关联对象的主键 + * @return Pivot + * @throws Exception + */ + public function attached($data) + { + if ($data instanceof Model) { + $relationFk = $data->getPk(); + $id = $data->$relationFk; + } else { + $id = $data; + } + + $pk = $this->parent->getPk(); + + $pivot = $this->pivot->where($this->localKey, $this->parent->$pk)->where($this->foreignKey, $id)->find(); + + return $pivot ?: false; + } + + /** + * 解除关联的一个中间表数据 + * @access public + * @param integer|array $data 数据 可以使用关联对象的主键 + * @param bool $relationDel 是否同时删除关联表数据 + * @return integer + */ + public function detach($data = null, $relationDel = false) + { + if (is_array($data)) { + $id = $data; + } elseif (is_numeric($data) || is_string($data)) { + // 根据关联表主键直接写入中间表 + $id = $data; + } elseif ($data instanceof Model) { + // 根据关联表主键直接写入中间表 + $relationFk = $data->getPk(); + $id = $data->$relationFk; + } + // 删除中间表数据 + $pk = $this->parent->getPk(); + $pivot[$this->localKey] = $this->parent->$pk; + if (isset($id)) { + $pivot[$this->foreignKey] = is_array($id) ? ['in', $id] : $id; + } + $this->pivot->where($pivot)->delete(); + // 删除关联表数据 + if (isset($id) && $relationDel) { + $model = $this->model; + $model::destroy($id); + } + } + + /** + * 数据同步 + * @param array $ids + * @param bool $detaching + * @return array + */ + public function sync($ids, $detaching = true) + { + $changes = [ + 'attached' => [], + 'detached' => [], + 'updated' => [], + ]; + $pk = $this->parent->getPk(); + $current = $this->pivot->where($this->localKey, $this->parent->$pk) + ->column($this->foreignKey); + $records = []; + + foreach ($ids as $key => $value) { + if (!is_array($value)) { + $records[$value] = []; + } else { + $records[$key] = $value; + } + } + + $detach = array_diff($current, array_keys($records)); + + if ($detaching && count($detach) > 0) { + $this->detach($detach); + + $changes['detached'] = $detach; + } + + foreach ($records as $id => $attributes) { + if (!in_array($id, $current)) { + $this->attach($id, $attributes); + $changes['attached'][] = $id; + } elseif (count($attributes) > 0 && + $this->attach($id, $attributes) + ) { + $changes['updated'][] = $id; + } + } + + return $changes; + + } + + /** + * 执行基础查询(进执行一次) + * @access protected + * @return void + */ + protected function baseQuery() + { + if (empty($this->baseQuery) && $this->parent->getData()) { + $pk = $this->parent->getPk(); + $table = $this->pivot->getTable(); + $this->query->join([$table => 'pivot'], 'pivot.' . $this->foreignKey . '=' . $this->query->getTable() . '.' . $this->query->getPk())->where('pivot.' . $this->localKey, $this->parent->$pk); + $this->baseQuery = true; + } + } + +} diff --git a/thinkphp/library/think/model/relation/HasMany.php b/thinkphp/library/think/model/relation/HasMany.php new file mode 100644 index 0000000..240d2ca --- /dev/null +++ b/thinkphp/library/think/model/relation/HasMany.php @@ -0,0 +1,318 @@ + +// +---------------------------------------------------------------------- + +namespace think\model\relation; + +use think\db\Query; +use think\Loader; +use think\Model; +use think\model\Relation; + +class HasMany extends Relation +{ + /** + * 构造函数 + * @access public + * @param Model $parent 上级模型对象 + * @param string $model 模型名 + * @param string $foreignKey 关联外键 + * @param string $localKey 当前模型主键 + */ + public function __construct(Model $parent, $model, $foreignKey, $localKey) + { + $this->parent = $parent; + $this->model = $model; + $this->foreignKey = $foreignKey; + $this->localKey = $localKey; + $this->query = (new $model)->db(); + } + + /** + * 延迟获取关联数据 + * @param string $subRelation 子关联名 + * @param \Closure $closure 闭包查询条件 + * @return false|\PDOStatement|string|\think\Collection + */ + public function getRelation($subRelation = '', $closure = null) + { + if ($closure) { + call_user_func_array($closure, [ & $this->query]); + } + $list = $this->relation($subRelation)->select(); + $parent = clone $this->parent; + + foreach ($list as &$model) { + $model->setParent($parent); + } + + return $list; + } + + /** + * 预载入关联查询 + * @access public + * @param array $resultSet 数据集 + * @param string $relation 当前关联名 + * @param string $subRelation 子关联名 + * @param \Closure $closure 闭包 + * @return void + */ + public function eagerlyResultSet(&$resultSet, $relation, $subRelation, $closure) + { + $localKey = $this->localKey; + $range = []; + foreach ($resultSet as $result) { + // 获取关联外键列表 + if (isset($result->$localKey)) { + $range[] = $result->$localKey; + } + } + + if (!empty($range)) { + $data = $this->eagerlyOneToMany($this->query, [ + $this->foreignKey => [ + 'in', + $range, + ], + ], $relation, $subRelation, $closure); + // 关联属性名 + $attr = Loader::parseName($relation); + // 关联数据封装 + foreach ($resultSet as $result) { + if (!isset($data[$result->$localKey])) { + $data[$result->$localKey] = []; + } + + foreach ($data[$result->$localKey] as &$relationModel) { + $relationModel->setParent(clone $result); + } + + $result->setRelation($attr, $this->resultSetBuild($data[$result->$localKey])); + } + } + } + + /** + * 预载入关联查询 + * @access public + * @param Model $result 数据对象 + * @param string $relation 当前关联名 + * @param string $subRelation 子关联名 + * @param \Closure $closure 闭包 + * @return void + */ + public function eagerlyResult(&$result, $relation, $subRelation, $closure) + { + $localKey = $this->localKey; + + if (isset($result->$localKey)) { + $data = $this->eagerlyOneToMany($this->query, [$this->foreignKey => $result->$localKey], $relation, $subRelation, $closure); + // 关联数据封装 + if (!isset($data[$result->$localKey])) { + $data[$result->$localKey] = []; + } + + foreach ($data[$result->$localKey] as &$relationModel) { + $relationModel->setParent(clone $result); + } + + $result->setRelation(Loader::parseName($relation), $this->resultSetBuild($data[$result->$localKey])); + } + } + + /** + * 关联统计 + * @access public + * @param Model $result 数据对象 + * @param \Closure $closure 闭包 + * @return integer + */ + public function relationCount($result, $closure) + { + $localKey = $this->localKey; + $count = 0; + if (isset($result->$localKey)) { + if ($closure) { + call_user_func_array($closure, [ & $this->query]); + } + $count = $this->query->where($this->foreignKey, $result->$localKey)->count(); + } + return $count; + } + + /** + * 创建关联统计子查询 + * @access public + * @param \Closure $closure 闭包 + * @param string $name 统计数据别名 + * @return string + */ + public function getRelationCountQuery($closure, &$name = null) + { + if ($closure) { + $return = call_user_func_array($closure, [ & $this->query]); + if ($return && is_string($return)) { + $name = $return; + } + } + $localKey = $this->localKey ?: $this->parent->getPk(); + return $this->query->alias( 'count_table')->whereExp( 'count_table.' . $this->foreignKey, '=' . $this->parent->getTable() . '.' . $localKey)->fetchSql()->count(); + } + + /** + * 一对多 关联模型预查询 + * @access public + * @param object $model 关联模型对象 + * @param array $where 关联预查询条件 + * @param string $relation 关联名 + * @param string $subRelation 子关联 + * @param bool $closure + * @return array + */ + protected function eagerlyOneToMany($model, $where, $relation, $subRelation = '', $closure = false) + { + $foreignKey = $this->foreignKey; + // 预载入关联查询 支持嵌套预载入 + if ($closure) { + call_user_func_array($closure, [ & $model]); + } + $list = $model->removeWhereField($foreignKey)->where($where)->with($subRelation)->select(); + + // 组装模型数据 + $data = []; + foreach ($list as $set) { + $data[$set->$foreignKey][] = $set; + } + return $data; + } + + /** + * 保存(新增)当前关联数据对象 + * @access public + * @param mixed $data 数据 可以使用数组 关联模型对象 和 关联对象的主键 + * @return Model|false + */ + public function save($data) + { + if ($data instanceof Model) { + $data = $data->getData(); + } + + // 保存关联表数据 + $data[$this->foreignKey] = $this->parent->{$this->localKey}; + + $model = new $this->model(); + return $model->save($data) ? $model : false; + } + + /** + * 创建关联对象实例 + * @param array $data + * @return Model + */ + public function make($data = []) + { + if ($data instanceof Model) { + $data = $data->getData(); + } + + // 保存关联表数据 + $data[$this->foreignKey] = $this->parent->{$this->localKey}; + + return new $this->model($data); + } + + /** + * 批量保存当前关联数据对象 + * @access public + * @param array $dataSet 数据集 + * @return integer + */ + public function saveAll(array $dataSet) + { + $result = false; + foreach ($dataSet as $key => $data) { + $result = $this->save($data); + } + return $result; + } + + /** + * 根据关联条件查询当前模型 + * @access public + * @param string $operator 比较操作符 + * @param integer $count 个数 + * @param string $id 关联表的统计字段 + * @param string $joinType JOIN类型 + * @return Query + */ + public function has($operator = '>=', $count = 1, $id = '*', $joinType = 'INNER') + { + $table = $this->query->getTable(); + $model = basename(str_replace('\\', '/', get_class($this->parent))); + $relation = basename(str_replace('\\', '/', $this->model)); + + return $this->parent->db() + ->alias($model) + ->field($model . '.*') + ->join([$table => $relation], $model . '.' . $this->localKey . '=' . $relation . '.' . $this->foreignKey, $joinType) + ->group($relation . '.' . $this->foreignKey) + ->having('count(' . $id . ')' . $operator . $count); + } + + /** + * 根据关联条件查询当前模型 + * @access public + * @param mixed $where 查询条件(数组或者闭包) + * @param mixed $fields 字段 + * @return Query + */ + public function hasWhere($where = [], $fields = null) + { + $table = $this->query->getTable(); + $model = basename(str_replace('\\', '/', get_class($this->parent))); + $relation = basename(str_replace('\\', '/', $this->model)); + + if (is_array($where)) { + foreach ($where as $key => $val) { + if (false === strpos($key, '.')) { + $where[$relation . '.' . $key] = $val; + unset($where[$key]); + } + } + } + + $fields = $this->getRelationQueryFields($fields, $model); + + return $this->parent->db()->alias($model) + ->field($fields) + ->group($model . '.' . $this->localKey) + ->join([$table => $relation], $model . '.' . $this->localKey . '=' . $relation . '.' . $this->foreignKey) + ->where($where); + } + + /** + * 执行基础查询(进执行一次) + * @access protected + * @return void + */ + protected function baseQuery() + { + if (empty($this->baseQuery)) { + if (isset($this->parent->{$this->localKey})) { + // 关联查询带入关联条件 + $this->query->where($this->foreignKey, $this->parent->{$this->localKey}); + } + $this->baseQuery = true; + } + } + +} diff --git a/thinkphp/library/think/model/relation/HasManyThrough.php b/thinkphp/library/think/model/relation/HasManyThrough.php new file mode 100644 index 0000000..3a9a548 --- /dev/null +++ b/thinkphp/library/think/model/relation/HasManyThrough.php @@ -0,0 +1,157 @@ + +// +---------------------------------------------------------------------- + +namespace think\model\relation; + +use think\db\Query; +use think\Exception; +use think\Loader; +use think\Model; +use think\model\Relation; + +class HasManyThrough extends Relation +{ + // 中间关联表外键 + protected $throughKey; + // 中间表模型 + protected $through; + + /** + * 构造函数 + * @access public + * @param Model $parent 上级模型对象 + * @param string $model 模型名 + * @param string $through 中间模型名 + * @param string $foreignKey 关联外键 + * @param string $throughKey 关联外键 + * @param string $localKey 关联主键 + */ + public function __construct(Model $parent, $model, $through, $foreignKey, $throughKey, $localKey) + { + $this->parent = $parent; + $this->model = $model; + $this->through = $through; + $this->foreignKey = $foreignKey; + $this->throughKey = $throughKey; + $this->localKey = $localKey; + $this->query = (new $model)->db(); + } + + /** + * 延迟获取关联数据 + * @param string $subRelation 子关联名 + * @param \Closure $closure 闭包查询条件 + * @return false|\PDOStatement|string|\think\Collection + */ + public function getRelation($subRelation = '', $closure = null) + { + if ($closure) { + call_user_func_array($closure, [ & $this->query]); + } + + return $this->relation($subRelation)->select(); + } + + /** + * 根据关联条件查询当前模型 + * @access public + * @param string $operator 比较操作符 + * @param integer $count 个数 + * @param string $id 关联表的统计字段 + * @param string $joinType JOIN类型 + * @return Query + */ + public function has($operator = '>=', $count = 1, $id = '*', $joinType = 'INNER') + { + return $this->parent; + } + + /** + * 根据关联条件查询当前模型 + * @access public + * @param mixed $where 查询条件(数组或者闭包) + * @param mixed $fields 字段 + * @return Query + */ + public function hasWhere($where = [], $fields = null) + { + throw new Exception('relation not support: hasWhere'); + } + + /** + * 预载入关联查询 + * @access public + * @param array $resultSet 数据集 + * @param string $relation 当前关联名 + * @param string $subRelation 子关联名 + * @param \Closure $closure 闭包 + * @return void + */ + public function eagerlyResultSet(&$resultSet, $relation, $subRelation, $closure) + {} + + /** + * 预载入关联查询 返回模型对象 + * @access public + * @param Model $result 数据对象 + * @param string $relation 当前关联名 + * @param string $subRelation 子关联名 + * @param \Closure $closure 闭包 + * @return void + */ + public function eagerlyResult(&$result, $relation, $subRelation, $closure) + {} + + /** + * 关联统计 + * @access public + * @param Model $result 数据对象 + * @param \Closure $closure 闭包 + * @return integer + */ + public function relationCount($result, $closure) + {} + + /** + * 创建关联统计子查询 + * @access public + * @param \Closure $closure 闭包 + * @param string $name 统计数据别名 + * @return string + */ + public function getRelationCountQuery($closure, &$name = null) + { + throw new Exception('relation not support: withCount'); + } + + /** + * 执行基础查询(进执行一次) + * @access protected + * @return void + */ + protected function baseQuery() + { + if (empty($this->baseQuery) && $this->parent->getData()) { + $through = $this->through; + $alias = Loader::parseName(basename(str_replace('\\', '/', $this->model))); + $throughTable = $through::getTable(); + $pk = (new $through)->getPk(); + $throughKey = $this->throughKey; + $modelTable = $this->parent->getTable(); + $this->query->field($alias . '.*')->alias($alias) + ->join($throughTable, $throughTable . '.' . $pk . '=' . $alias . '.' . $throughKey) + ->join($modelTable, $modelTable . '.' . $this->localKey . '=' . $throughTable . '.' . $this->foreignKey) + ->where($throughTable . '.' . $this->foreignKey, $this->parent->{$this->localKey}); + $this->baseQuery = true; + } + } + +} diff --git a/thinkphp/library/think/model/relation/HasOne.php b/thinkphp/library/think/model/relation/HasOne.php new file mode 100644 index 0000000..db74e4a --- /dev/null +++ b/thinkphp/library/think/model/relation/HasOne.php @@ -0,0 +1,215 @@ + +// +---------------------------------------------------------------------- + +namespace think\model\relation; + +use think\db\Query; +use think\Loader; +use think\Model; + +class HasOne extends OneToOne +{ + /** + * 构造函数 + * @access public + * @param Model $parent 上级模型对象 + * @param string $model 模型名 + * @param string $foreignKey 关联外键 + * @param string $localKey 当前模型主键 + * @param string $joinType JOIN类型 + */ + public function __construct(Model $parent, $model, $foreignKey, $localKey, $joinType = 'INNER') + { + $this->parent = $parent; + $this->model = $model; + $this->foreignKey = $foreignKey; + $this->localKey = $localKey; + $this->joinType = $joinType; + $this->query = (new $model)->db(); + } + + /** + * 延迟获取关联数据 + * @param string $subRelation 子关联名 + * @param \Closure $closure 闭包查询条件 + * @return array|false|\PDOStatement|string|Model + */ + public function getRelation($subRelation = '', $closure = null) + { + // 执行关联定义方法 + $localKey = $this->localKey; + if ($closure) { + call_user_func_array($closure, [ & $this->query]); + } + // 判断关联类型执行查询 + $relationModel = $this->query + ->removeWhereField($this->foreignKey) + ->where($this->foreignKey, $this->parent->$localKey) + ->relation($subRelation) + ->find(); + + if ($relationModel) { + $relationModel->setParent(clone $this->parent); + } + + return $relationModel; + } + + /** + * 根据关联条件查询当前模型 + * @access public + * @return Query + */ + public function has() + { + $table = $this->query->getTable(); + $model = basename(str_replace('\\', '/', get_class($this->parent))); + $relation = basename(str_replace('\\', '/', $this->model)); + $localKey = $this->localKey; + $foreignKey = $this->foreignKey; + return $this->parent->db() + ->alias($model) + ->whereExists(function ($query) use ($table, $model, $relation, $localKey, $foreignKey) { + $query->table([$table => $relation])->field($relation . '.' . $foreignKey)->whereExp($model . '.' . $localKey, '=' . $relation . '.' . $foreignKey); + }); + } + + /** + * 根据关联条件查询当前模型 + * @access public + * @param mixed $where 查询条件(数组或者闭包) + * @param mixed $fields 字段 + * @return Query + */ + public function hasWhere($where = [], $fields = null) + { + $table = $this->query->getTable(); + $model = basename(str_replace('\\', '/', get_class($this->parent))); + $relation = basename(str_replace('\\', '/', $this->model)); + + if (is_array($where)) { + foreach ($where as $key => $val) { + if (false === strpos($key, '.')) { + $where[$relation . '.' . $key] = $val; + unset($where[$key]); + } + } + } + $fields = $this->getRelationQueryFields($fields, $model); + + return $this->parent->db()->alias($model) + ->field($fields) + ->join([$table => $relation], $model . '.' . $this->localKey . '=' . $relation . '.' . $this->foreignKey, $this->joinType) + ->where($where); + } + + /** + * 预载入关联查询(数据集) + * @access public + * @param array $resultSet 数据集 + * @param string $relation 当前关联名 + * @param string $subRelation 子关联名 + * @param \Closure $closure 闭包 + * @return void + */ + protected function eagerlySet(&$resultSet, $relation, $subRelation, $closure) + { + $localKey = $this->localKey; + $foreignKey = $this->foreignKey; + + $range = []; + foreach ($resultSet as $result) { + // 获取关联外键列表 + if (isset($result->$localKey)) { + $range[] = $result->$localKey; + } + } + + if (!empty($range)) { + $this->query->removeWhereField($foreignKey); + $data = $this->eagerlyWhere($this->query, [ + $foreignKey => [ + 'in', + $range, + ], + ], $foreignKey, $relation, $subRelation, $closure); + // 关联属性名 + $attr = Loader::parseName($relation); + // 关联数据封装 + foreach ($resultSet as $result) { + // 关联模型 + if (!isset($data[$result->$localKey])) { + $relationModel = null; + } else { + $relationModel = $data[$result->$localKey]; + $relationModel->setParent(clone $result); + $relationModel->isUpdate(true); + } + if (!empty($this->bindAttr)) { + // 绑定关联属性 + $this->bindAttr($relationModel, $result, $this->bindAttr); + } else { + // 设置关联属性 + $result->setRelation($attr, $relationModel); + } + } + } + } + + /** + * 预载入关联查询(数据) + * @access public + * @param Model $result 数据对象 + * @param string $relation 当前关联名 + * @param string $subRelation 子关联名 + * @param \Closure $closure 闭包 + * @return void + */ + protected function eagerlyOne(&$result, $relation, $subRelation, $closure) + { + $localKey = $this->localKey; + $foreignKey = $this->foreignKey; + $this->query->removeWhereField($foreignKey); + $data = $this->eagerlyWhere($this->query, [$foreignKey => $result->$localKey], $foreignKey, $relation, $subRelation, $closure); + + // 关联模型 + if (!isset($data[$result->$localKey])) { + $relationModel = null; + } else { + $relationModel = $data[$result->$localKey]; + $relationModel->setParent(clone $result); + $relationModel->isUpdate(true); + } + if (!empty($this->bindAttr)) { + // 绑定关联属性 + $this->bindAttr($relationModel, $result, $this->bindAttr); + } else { + $result->setRelation(Loader::parseName($relation), $relationModel); + } + } + + /** + * 执行基础查询(仅执行一次) + * @access protected + * @return void + */ + protected function baseQuery() + { + if (empty($this->baseQuery)) { + if (isset($this->parent->{$this->localKey})) { + // 关联查询带入关联条件 + $this->query->where($this->foreignKey, '=', $this->parent->{$this->localKey}); + } + + $this->baseQuery = true; + } + } +} diff --git a/thinkphp/library/think/model/relation/MorphMany.php b/thinkphp/library/think/model/relation/MorphMany.php new file mode 100644 index 0000000..2755d57 --- /dev/null +++ b/thinkphp/library/think/model/relation/MorphMany.php @@ -0,0 +1,314 @@ + +// +---------------------------------------------------------------------- + +namespace think\model\relation; + +use think\Db; +use think\db\Query; +use think\Exception; +use think\Loader; +use think\Model; +use think\model\Relation; + +class MorphMany extends Relation +{ + // 多态字段 + protected $morphKey; + protected $morphType; + // 多态类型 + protected $type; + + /** + * 构造函数 + * @access public + * @param Model $parent 上级模型对象 + * @param string $model 模型名 + * @param string $morphKey 关联外键 + * @param string $morphType 多态字段名 + * @param string $type 多态类型 + */ + public function __construct(Model $parent, $model, $morphKey, $morphType, $type) + { + $this->parent = $parent; + $this->model = $model; + $this->type = $type; + $this->morphKey = $morphKey; + $this->morphType = $morphType; + $this->query = (new $model)->db(); + } + + /** + * 延迟获取关联数据 + * @param string $subRelation 子关联名 + * @param \Closure $closure 闭包查询条件 + * @return false|\PDOStatement|string|\think\Collection + */ + public function getRelation($subRelation = '', $closure = null) + { + if ($closure) { + call_user_func_array($closure, [ & $this->query]); + } + $list = $this->relation($subRelation)->select(); + $parent = clone $this->parent; + + foreach ($list as &$model) { + $model->setParent($parent); + } + + return $list; + } + + /** + * 根据关联条件查询当前模型 + * @access public + * @param string $operator 比较操作符 + * @param integer $count 个数 + * @param string $id 关联表的统计字段 + * @param string $joinType JOIN类型 + * @return Query + */ + public function has($operator = '>=', $count = 1, $id = '*', $joinType = 'INNER') + { + throw new Exception('relation not support: has'); + } + + /** + * 根据关联条件查询当前模型 + * @access public + * @param mixed $where 查询条件(数组或者闭包) + * @param mixed $fields 字段 + * @return Query + */ + public function hasWhere($where = [], $fields = null) + { + throw new Exception('relation not support: hasWhere'); + } + + /** + * 预载入关联查询 + * @access public + * @param array $resultSet 数据集 + * @param string $relation 当前关联名 + * @param string $subRelation 子关联名 + * @param \Closure $closure 闭包 + * @return void + */ + public function eagerlyResultSet(&$resultSet, $relation, $subRelation, $closure) + { + $morphType = $this->morphType; + $morphKey = $this->morphKey; + $type = $this->type; + $range = []; + foreach ($resultSet as $result) { + $pk = $result->getPk(); + // 获取关联外键列表 + if (isset($result->$pk)) { + $range[] = $result->$pk; + } + } + + if (!empty($range)) { + $data = $this->eagerlyMorphToMany([ + $morphKey => ['in', $range], + $morphType => $type, + ], $relation, $subRelation, $closure); + // 关联属性名 + $attr = Loader::parseName($relation); + // 关联数据封装 + foreach ($resultSet as $result) { + if (!isset($data[$result->$pk])) { + $data[$result->$pk] = []; + } + foreach ($data[$result->$pk] as &$relationModel) { + $relationModel->setParent(clone $result); + $relationModel->isUpdate(true); + } + $result->setRelation($attr, $this->resultSetBuild($data[$result->$pk])); + } + } + } + + /** + * 预载入关联查询 + * @access public + * @param Model $result 数据对象 + * @param string $relation 当前关联名 + * @param string $subRelation 子关联名 + * @param \Closure $closure 闭包 + * @return void + */ + public function eagerlyResult(&$result, $relation, $subRelation, $closure) + { + $pk = $result->getPk(); + if (isset($result->$pk)) { + $data = $this->eagerlyMorphToMany([ + $this->morphKey => $result->$pk, + $this->morphType => $this->type, + ], $relation, $subRelation, $closure); + + if (!isset($data[$result->$pk])) { + $data[$result->$pk] = []; + } + + foreach ($data[$result->$pk] as &$relationModel) { + $relationModel->setParent(clone $result); + $relationModel->isUpdate(true); + } + + $result->setRelation(Loader::parseName($relation), $this->resultSetBuild($data[$result->$pk])); + } + } + + /** + * 关联统计 + * @access public + * @param Model $result 数据对象 + * @param \Closure $closure 闭包 + * @return integer + */ + public function relationCount($result, $closure) + { + $pk = $result->getPk(); + $count = 0; + if (isset($result->$pk)) { + if ($closure) { + call_user_func_array($closure, [ & $this->query]); + } + $count = $this->query->where([$this->morphKey => $result->$pk, $this->morphType => $this->type])->count(); + } + return $count; + } + + /** + * 创建关联统计子查询 + * @access public + * @param \Closure $closure 闭包 + * @param string $name 统计数据别名 + * @return string + */ + public function getRelationCountQuery($closure, &$name = null) + { + if ($closure) { + $return = call_user_func_array($closure, [ & $this->query]); + if ($return && is_string($return)) { + $name = $return; + } + } + + return $this->query->where([ + $this->morphKey => [ + 'exp', + Db::raw('=' . $this->parent->getTable() . '.' . $this->parent->getPk()), + ], + $this->morphType => $this->type, + ])->fetchSql()->count(); + } + + /** + * 多态一对多 关联模型预查询 + * @access public + * @param array $where 关联预查询条件 + * @param string $relation 关联名 + * @param string $subRelation 子关联 + * @param bool|\Closure $closure 闭包 + * @return array + */ + protected function eagerlyMorphToMany($where, $relation, $subRelation = '', $closure = false) + { + // 预载入关联查询 支持嵌套预载入 + if ($closure) { + call_user_func_array($closure, [ & $this]); + } + $list = $this->query->where($where)->with($subRelation)->select(); + $morphKey = $this->morphKey; + // 组装模型数据 + $data = []; + foreach ($list as $set) { + $data[$set->$morphKey][] = $set; + } + return $data; + } + + /** + * 保存(新增)当前关联数据对象 + * @access public + * @param mixed $data 数据 可以使用数组 关联模型对象 和 关联对象的主键 + * @return Model|false + */ + public function save($data) + { + if ($data instanceof Model) { + $data = $data->getData(); + } + + // 保存关联表数据 + $pk = $this->parent->getPk(); + + $data[$this->morphKey] = $this->parent->$pk; + $data[$this->morphType] = $this->type; + + $model = new $this->model(); + + return $model->save() ? $model : false; + } + + /** + * 创建关联对象实例 + * @param array $data + * @return Model + */ + public function make($data = []) + { + if ($data instanceof Model) { + $data = $data->getData(); + } + + // 保存关联表数据 + $pk = $this->parent->getPk(); + + $data[$this->morphKey] = $this->parent->$pk; + $data[$this->morphType] = $this->type; + + return new $this->model($data); + } + + /** + * 批量保存当前关联数据对象 + * @access public + * @param array $dataSet 数据集 + * @return integer + */ + public function saveAll(array $dataSet) + { + $result = false; + foreach ($dataSet as $key => $data) { + $result = $this->save($data); + } + return $result; + } + + /** + * 执行基础查询(进执行一次) + * @access protected + * @return void + */ + protected function baseQuery() + { + if (empty($this->baseQuery) && $this->parent->getData()) { + $pk = $this->parent->getPk(); + $map[$this->morphKey] = $this->parent->$pk; + $map[$this->morphType] = $this->type; + $this->query->where($map); + $this->baseQuery = true; + } + } + +} diff --git a/thinkphp/library/think/model/relation/MorphOne.php b/thinkphp/library/think/model/relation/MorphOne.php new file mode 100644 index 0000000..d7f1712 --- /dev/null +++ b/thinkphp/library/think/model/relation/MorphOne.php @@ -0,0 +1,263 @@ + +// +---------------------------------------------------------------------- + +namespace think\model\relation; + +use think\db\Query; +use think\Exception; +use think\Loader; +use think\Model; +use think\model\Relation; + +class MorphOne extends Relation +{ + // 多态字段 + protected $morphKey; + protected $morphType; + // 多态类型 + protected $type; + + /** + * 构造函数 + * @access public + * @param Model $parent 上级模型对象 + * @param string $model 模型名 + * @param string $morphKey 关联外键 + * @param string $morphType 多态字段名 + * @param string $type 多态类型 + */ + public function __construct(Model $parent, $model, $morphKey, $morphType, $type) + { + $this->parent = $parent; + $this->model = $model; + $this->type = $type; + $this->morphKey = $morphKey; + $this->morphType = $morphType; + $this->query = (new $model)->db(); + } + + /** + * 延迟获取关联数据 + * @param string $subRelation 子关联名 + * @param \Closure $closure 闭包查询条件 + * @return false|\PDOStatement|string|\think\Collection + */ + public function getRelation($subRelation = '', $closure = null) + { + if ($closure) { + call_user_func_array($closure, [ & $this->query]); + } + $relationModel = $this->relation($subRelation)->find(); + + if ($relationModel) { + $relationModel->setParent(clone $this->parent); + } + + return $relationModel; + } + + /** + * 根据关联条件查询当前模型 + * @access public + * @param string $operator 比较操作符 + * @param integer $count 个数 + * @param string $id 关联表的统计字段 + * @param string $joinType JOIN类型 + * @return Query + */ + public function has($operator = '>=', $count = 1, $id = '*', $joinType = 'INNER') + { + return $this->parent; + } + + /** + * 根据关联条件查询当前模型 + * @access public + * @param mixed $where 查询条件(数组或者闭包) + * @param mixed $fields 字段 + * @return Query + */ + public function hasWhere($where = [], $fields = null) + { + throw new Exception('relation not support: hasWhere'); + } + + /** + * 预载入关联查询 + * @access public + * @param array $resultSet 数据集 + * @param string $relation 当前关联名 + * @param string $subRelation 子关联名 + * @param \Closure $closure 闭包 + * @return void + */ + public function eagerlyResultSet(&$resultSet, $relation, $subRelation, $closure) + { + $morphType = $this->morphType; + $morphKey = $this->morphKey; + $type = $this->type; + $range = []; + foreach ($resultSet as $result) { + $pk = $result->getPk(); + // 获取关联外键列表 + if (isset($result->$pk)) { + $range[] = $result->$pk; + } + } + + if (!empty($range)) { + $data = $this->eagerlyMorphToOne([ + $morphKey => ['in', $range], + $morphType => $type, + ], $relation, $subRelation, $closure); + // 关联属性名 + $attr = Loader::parseName($relation); + // 关联数据封装 + foreach ($resultSet as $result) { + if (!isset($data[$result->$pk])) { + $relationModel = null; + } else { + $relationModel = $data[$result->$pk]; + $relationModel->setParent(clone $result); + $relationModel->isUpdate(true); + } + + $result->setRelation($attr, $relationModel); + } + } + } + + /** + * 预载入关联查询 + * @access public + * @param Model $result 数据对象 + * @param string $relation 当前关联名 + * @param string $subRelation 子关联名 + * @param \Closure $closure 闭包 + * @return void + */ + public function eagerlyResult(&$result, $relation, $subRelation, $closure) + { + $pk = $result->getPk(); + if (isset($result->$pk)) { + $pk = $result->$pk; + $data = $this->eagerlyMorphToOne([ + $this->morphKey => $pk, + $this->morphType => $this->type, + ], $relation, $subRelation, $closure); + + if (isset($data[$pk])) { + $relationModel = $data[$pk]; + $relationModel->setParent(clone $result); + $relationModel->isUpdate(true); + } else { + $relationModel = null; + } + + $result->setRelation(Loader::parseName($relation), $relationModel); + } + } + + /** + * 多态一对一 关联模型预查询 + * @access public + * @param array $where 关联预查询条件 + * @param string $relation 关联名 + * @param string $subRelation 子关联 + * @param bool|\Closure $closure 闭包 + * @return array + */ + protected function eagerlyMorphToOne($where, $relation, $subRelation = '', $closure = false) + { + // 预载入关联查询 支持嵌套预载入 + if ($closure) { + call_user_func_array($closure, [ & $this]); + } + $list = $this->query->where($where)->with($subRelation)->find(); + $morphKey = $this->morphKey; + // 组装模型数据 + $data = []; + foreach ($list as $set) { + $data[$set->$morphKey][] = $set; + } + return $data; + } + + /** + * 保存(新增)当前关联数据对象 + * @access public + * @param mixed $data 数据 可以使用数组 关联模型对象 和 关联对象的主键 + * @return Model|false + */ + public function save($data) + { + if ($data instanceof Model) { + $data = $data->getData(); + } + + // 保存关联表数据 + $pk = $this->parent->getPk(); + + $data[$this->morphKey] = $this->parent->$pk; + $data[$this->morphType] = $this->type; + + $model = new $this->model(); + + return $model->save($data) ? $model : false; + } + + /** + * 创建关联对象实例 + * @param array $data + * @return Model + */ + public function make($data = []) + { + if ($data instanceof Model) { + $data = $data->getData(); + } + // 保存关联表数据 + $pk = $this->parent->getPk(); + + $data[$this->morphKey] = $this->parent->$pk; + $data[$this->morphType] = $this->type; + + return new $this->model($data); + } + + /** + * 执行基础查询(进执行一次) + * @access protected + * @return void + */ + protected function baseQuery() + { + if (empty($this->baseQuery) && $this->parent->getData()) { + $pk = $this->parent->getPk(); + $map[$this->morphKey] = $this->parent->$pk; + $map[$this->morphType] = $this->type; + $this->query->where($map); + $this->baseQuery = true; + } + } + + /** + * 创建关联统计子查询 + * @access public + * @param \Closure $closure 闭包 + * @param string $name 统计数据别名 + * @return string + */ + public function getRelationCountQuery($closure, &$name = null) + { + throw new Exception('relation not support: withCount'); + } +} diff --git a/thinkphp/library/think/model/relation/MorphTo.php b/thinkphp/library/think/model/relation/MorphTo.php new file mode 100644 index 0000000..7d45265 --- /dev/null +++ b/thinkphp/library/think/model/relation/MorphTo.php @@ -0,0 +1,299 @@ + +// +---------------------------------------------------------------------- + +namespace think\model\relation; + +use think\Exception; +use think\Loader; +use think\Model; +use think\model\Relation; + +class MorphTo extends Relation +{ + // 多态字段 + protected $morphKey; + protected $morphType; + // 多态别名 + protected $alias; + protected $relation; + + /** + * 构造函数 + * @access public + * @param Model $parent 上级模型对象 + * @param string $morphType 多态字段名 + * @param string $morphKey 外键名 + * @param array $alias 多态别名定义 + * @param string $relation 关联名 + */ + public function __construct(Model $parent, $morphType, $morphKey, $alias = [], $relation = null) + { + $this->parent = $parent; + $this->morphType = $morphType; + $this->morphKey = $morphKey; + $this->alias = $alias; + $this->relation = $relation; + } + + /** + * 获取当前的关联模型类的实例 + * @access public + * @return Model + */ + public function getModel() + { + $morphType = $this->morphType; + $model = $this->parseModel($this->parent->$morphType); + return (new $model); + } + + /** + * 延迟获取关联数据 + * @param string $subRelation 子关联名 + * @param \Closure $closure 闭包查询条件 + * @return mixed + */ + public function getRelation($subRelation = '', $closure = null) + { + $morphKey = $this->morphKey; + $morphType = $this->morphType; + // 多态模型 + $model = $this->parseModel($this->parent->$morphType); + // 主键数据 + $pk = $this->parent->$morphKey; + $relationModel = (new $model)->relation($subRelation)->find($pk); + + if ($relationModel) { + $relationModel->setParent(clone $this->parent); + } + return $relationModel; + } + + /** + * 根据关联条件查询当前模型 + * @access public + * @param string $operator 比较操作符 + * @param integer $count 个数 + * @param string $id 关联表的统计字段 + * @param string $joinType JOIN类型 + * @return Query + */ + public function has($operator = '>=', $count = 1, $id = '*', $joinType = 'INNER') + { + return $this->parent; + } + + /** + * 根据关联条件查询当前模型 + * @access public + * @param mixed $where 查询条件(数组或者闭包) + * @param mixed $fields 字段 + * @return Query + */ + public function hasWhere($where = [], $fields = null) + { + throw new Exception('relation not support: hasWhere'); + } + + /** + * 解析模型的完整命名空间 + * @access protected + * @param string $model 模型名(或者完整类名) + * @return string + */ + protected function parseModel($model) + { + if (isset($this->alias[$model])) { + $model = $this->alias[$model]; + } + if (false === strpos($model, '\\')) { + $path = explode('\\', get_class($this->parent)); + array_pop($path); + array_push($path, Loader::parseName($model, 1)); + $model = implode('\\', $path); + } + return $model; + } + + /** + * 设置多态别名 + * @access public + * @param array $alias 别名定义 + * @return $this + */ + public function setAlias($alias) + { + $this->alias = $alias; + return $this; + } + + /** + * 移除关联查询参数 + * @access public + * @return $this + */ + public function removeOption() + { + return $this; + } + + /** + * 预载入关联查询 + * @access public + * @param array $resultSet 数据集 + * @param string $relation 当前关联名 + * @param string $subRelation 子关联名 + * @param \Closure $closure 闭包 + * @return void + * @throws Exception + */ + public function eagerlyResultSet(&$resultSet, $relation, $subRelation, $closure) + { + $morphKey = $this->morphKey; + $morphType = $this->morphType; + $range = []; + foreach ($resultSet as $result) { + // 获取关联外键列表 + if (!empty($result->$morphKey)) { + $range[$result->$morphType][] = $result->$morphKey; + } + } + + if (!empty($range)) { + // 关联属性名 + $attr = Loader::parseName($relation); + foreach ($range as $key => $val) { + // 多态类型映射 + $model = $this->parseModel($key); + $obj = new $model; + $pk = $obj->getPk(); + $list = $obj->all($val, $subRelation); + $data = []; + foreach ($list as $k => $vo) { + $data[$vo->$pk] = $vo; + } + foreach ($resultSet as $result) { + if ($key == $result->$morphType) { + // 关联模型 + if (!isset($data[$result->$morphKey])) { + throw new Exception('relation data not exists :' . $this->model); + } else { + $relationModel = $data[$result->$morphKey]; + $relationModel->setParent(clone $result); + $relationModel->isUpdate(true); + + $result->setRelation($attr, $relationModel); + } + } + } + } + } + } + + /** + * 预载入关联查询 + * @access public + * @param Model $result 数据对象 + * @param string $relation 当前关联名 + * @param string $subRelation 子关联名 + * @param \Closure $closure 闭包 + * @return void + */ + public function eagerlyResult(&$result, $relation, $subRelation, $closure) + { + $morphKey = $this->morphKey; + $morphType = $this->morphType; + // 多态类型映射 + $model = $this->parseModel($result->{$this->morphType}); + $this->eagerlyMorphToOne($model, $relation, $result, $subRelation); + } + + /** + * 关联统计 + * @access public + * @param Model $result 数据对象 + * @param \Closure $closure 闭包 + * @return integer + */ + public function relationCount($result, $closure) + { + } + + /** + * 多态MorphTo 关联模型预查询 + * @access public + * @param object $model 关联模型对象 + * @param string $relation 关联名 + * @param $result + * @param string $subRelation 子关联 + * @return void + */ + protected function eagerlyMorphToOne($model, $relation, &$result, $subRelation = '') + { + // 预载入关联查询 支持嵌套预载入 + $pk = $this->parent->{$this->morphKey}; + $data = (new $model)->with($subRelation)->find($pk); + if ($data) { + $data->setParent(clone $result); + $data->isUpdate(true); + } + $result->setRelation(Loader::parseName($relation), $data ?: null); + } + + /** + * 添加关联数据 + * @access public + * @param Model $model 关联模型对象 + * @param string $type 多态类型 + * @return Model + */ + public function associate($model, $type = '') + { + $morphKey = $this->morphKey; + $morphType = $this->morphType; + $pk = $model->getPk(); + + $this->parent->setAttr($morphKey, $model->$pk); + $this->parent->setAttr($morphType, $type ?: get_class($model)); + $this->parent->save(); + + return $this->parent->setRelation($this->relation, $model); + } + + /** + * 注销关联数据 + * @access public + * @return Model + */ + public function dissociate() + { + $morphKey = $this->morphKey; + $morphType = $this->morphType; + + $this->parent->setAttr($morphKey, null); + $this->parent->setAttr($morphType, null); + $this->parent->save(); + + return $this->parent->setRelation($this->relation, null); + } + + /** + * 创建关联统计子查询 + * @access public + * @param \Closure $closure 闭包 + * @param string $name 统计数据别名 + * @return string + */ + public function getRelationCountQuery($closure, &$name = null) + { + throw new Exception('relation not support: withCount'); + } +} diff --git a/thinkphp/library/think/model/relation/OneToOne.php b/thinkphp/library/think/model/relation/OneToOne.php new file mode 100644 index 0000000..353ce21 --- /dev/null +++ b/thinkphp/library/think/model/relation/OneToOne.php @@ -0,0 +1,337 @@ + +// +---------------------------------------------------------------------- + +namespace think\model\relation; + +use think\db\Query; +use think\Exception; +use think\Loader; +use think\Model; +use think\model\Relation; + +/** + * Class OneToOne + * @package think\model\relation + * + */ +abstract class OneToOne extends Relation +{ + // 预载入方式 0 -JOIN 1 -IN + protected $eagerlyType = 1; + // 当前关联的JOIN类型 + protected $joinType; + // 要绑定的属性 + protected $bindAttr = []; + // 关联方法名 + protected $relation; + + /** + * 设置join类型 + * @access public + * @param string $type JOIN类型 + * @return $this + */ + public function joinType($type) + { + $this->joinType = $type; + return $this; + } + + /** + * 预载入关联查询(JOIN方式) + * @access public + * @param Query $query 查询对象 + * @param string $relation 关联名 + * @param string $subRelation 子关联 + * @param \Closure $closure 闭包条件 + * @param bool $first + * @return void + */ + public function eagerly(Query $query, $relation, $subRelation, $closure, $first) + { + $name = Loader::parseName(basename(str_replace('\\', '/', get_class($query->getModel())))); + + if ($first) { + $table = $query->getTable(); + $query->table([$table => $name]); + if ($query->getOptions('field')) { + $field = $query->getOptions('field'); + $query->removeOption('field'); + } else { + $field = true; + } + $query->field($field, false, $table, $name); + $field = null; + } + + // 预载入封装 + $joinTable = $this->query->getTable(); + $joinAlias = $relation; + $query->via($joinAlias); + + if ($this instanceof BelongsTo) { + $query->join([$joinTable => $joinAlias], $name . '.' . $this->foreignKey . '=' . $joinAlias . '.' . $this->localKey, $this->joinType); + } else { + $query->join([$joinTable => $joinAlias], $name . '.' . $this->localKey . '=' . $joinAlias . '.' . $this->foreignKey, $this->joinType); + } + + if ($closure) { + // 执行闭包查询 + call_user_func_array($closure, [ & $query]); + // 使用withField指定获取关联的字段,如 + // $query->where(['id'=>1])->withField('id,name'); + if ($query->getOptions('with_field')) { + $field = $query->getOptions('with_field'); + $query->removeOption('with_field'); + } + } elseif (isset($this->option['field'])) { + $field = $this->option['field']; + } + $query->field(isset($field) ? $field : true, false, $joinTable, $joinAlias, $relation . '__'); + } + + /** + * 预载入关联查询(数据集) + * @param array $resultSet + * @param string $relation + * @param string $subRelation + * @param \Closure $closure + * @return mixed + */ + abstract protected function eagerlySet(&$resultSet, $relation, $subRelation, $closure); + + /** + * 预载入关联查询(数据) + * @param Model $result + * @param string $relation + * @param string $subRelation + * @param \Closure $closure + * @return mixed + */ + abstract protected function eagerlyOne(&$result, $relation, $subRelation, $closure); + + /** + * 预载入关联查询(数据集) + * @access public + * @param array $resultSet 数据集 + * @param string $relation 当前关联名 + * @param string $subRelation 子关联名 + * @param \Closure $closure 闭包 + * @return void + */ + public function eagerlyResultSet(&$resultSet, $relation, $subRelation, $closure) + { + if (1 == $this->eagerlyType) { + // IN查询 + $this->eagerlySet($resultSet, $relation, $subRelation, $closure); + } else { + // 模型关联组装 + foreach ($resultSet as $result) { + $this->match($this->model, $relation, $result); + } + } + } + + /** + * 预载入关联查询(数据) + * @access public + * @param Model $result 数据对象 + * @param string $relation 当前关联名 + * @param string $subRelation 子关联名 + * @param \Closure $closure 闭包 + * @return void + */ + public function eagerlyResult(&$result, $relation, $subRelation, $closure) + { + if (1 == $this->eagerlyType) { + // IN查询 + $this->eagerlyOne($result, $relation, $subRelation, $closure); + } else { + // 模型关联组装 + $this->match($this->model, $relation, $result); + } + } + + /** + * 保存(新增)当前关联数据对象 + * @access public + * @param mixed $data 数据 可以使用数组 关联模型对象 和 关联对象的主键 + * @return Model|false + */ + public function save($data) + { + if ($data instanceof Model) { + $data = $data->getData(); + } + $model = new $this->model; + // 保存关联表数据 + $data[$this->foreignKey] = $this->parent->{$this->localKey}; + return $model->save($data) ? $model : false; + } + + /** + * 设置预载入方式 + * @access public + * @param integer $type 预载入方式 0 JOIN查询 1 IN查询 + * @return $this + */ + public function setEagerlyType($type) + { + $this->eagerlyType = $type; + return $this; + } + + /** + * 获取预载入方式 + * @access public + * @return integer + */ + public function getEagerlyType() + { + return $this->eagerlyType; + } + + /** + * 绑定关联表的属性到父模型属性 + * @access public + * @param mixed $attr 要绑定的属性列表 + * @return $this + */ + public function bind($attr) + { + if (is_string($attr)) { + $attr = explode(',', $attr); + } + $this->bindAttr = $attr; + return $this; + } + + /** + * 获取绑定属性 + * @access public + * @return array + */ + public function getBindAttr() + { + return $this->bindAttr; + } + + /** + * 关联统计 + * @access public + * @param Model $result 数据对象 + * @param \Closure $closure 闭包 + * @return integer + */ + public function relationCount($result, $closure) + { + } + + /** + * 一对一 关联模型预查询拼装 + * @access public + * @param string $model 模型名称 + * @param string $relation 关联名 + * @param Model $result 模型对象实例 + * @return void + */ + protected function match($model, $relation, &$result) + { + // 重新组装模型数据 + foreach ($result->getData() as $key => $val) { + if (strpos($key, '__')) { + list($name, $attr) = explode('__', $key, 2); + if ($name == $relation) { + $list[$name][$attr] = $val; + unset($result->$key); + } + } + } + + if (isset($list[$relation])) { + $relationModel = new $model($list[$relation]); + $relationModel->setParent(clone $result); + $relationModel->isUpdate(true); + + if (!empty($this->bindAttr)) { + $this->bindAttr($relationModel, $result, $this->bindAttr); + } + } else { + $relationModel = null; + } + $result->setRelation(Loader::parseName($relation), $relationModel); + } + + /** + * 绑定关联属性到父模型 + * @access protected + * @param Model $model 关联模型对象 + * @param Model $result 父模型对象 + * @param array $bindAttr 绑定属性 + * @return void + * @throws Exception + */ + protected function bindAttr($model, &$result, $bindAttr) + { + foreach ($bindAttr as $key => $attr) { + $key = is_numeric($key) ? $attr : $key; + if (isset($result->$key)) { + throw new Exception('bind attr has exists:' . $key); + } else { + $result->setAttr($key, $model ? $model->$attr : null); + } + } + } + + /** + * 一对一 关联模型预查询(IN方式) + * @access public + * @param object $model 关联模型对象 + * @param array $where 关联预查询条件 + * @param string $key 关联键名 + * @param string $relation 关联名 + * @param string $subRelation 子关联 + * @param bool|\Closure $closure + * @return array + */ + protected function eagerlyWhere($model, $where, $key, $relation, $subRelation = '', $closure = false) + { + $this->baseQuery = true; + + // 预载入关联查询 支持嵌套预载入 + if ($closure) { + call_user_func_array($closure, [ & $model]); + if ($field = $model->getOptions('with_field')) { + $model->field($field)->removeOption('with_field'); + } + } + $list = $model->where($where)->with($subRelation)->select(); + + // 组装模型数据 + $data = []; + foreach ($list as $set) { + $data[$set->$key] = $set; + } + return $data; + } + + /** + * 创建关联统计子查询 + * @access public + * @param \Closure $closure 闭包 + * @param string $name 统计数据别名 + * @return string + */ + public function getRelationCountQuery($closure, &$name = null) + { + throw new Exception('relation not support: withCount'); + } +} diff --git a/thinkphp/library/think/paginator/driver/Bootstrap.php b/thinkphp/library/think/paginator/driver/Bootstrap.php new file mode 100644 index 0000000..c5ac60d --- /dev/null +++ b/thinkphp/library/think/paginator/driver/Bootstrap.php @@ -0,0 +1,205 @@ + +// +---------------------------------------------------------------------- + +namespace think\paginator\driver; + +use think\Paginator; + +class Bootstrap extends Paginator +{ + + /** + * 上一页按钮 + * @param string $text + * @return string + */ + protected function getPreviousButton($text = "«") + { + + if ($this->currentPage() <= 1) { + return $this->getDisabledTextWrapper($text); + } + + $url = $this->url( + $this->currentPage() - 1 + ); + + return $this->getPageLinkWrapper($url, $text); + } + + /** + * 下一页按钮 + * @param string $text + * @return string + */ + protected function getNextButton($text = '»') + { + if (!$this->hasMore) { + return $this->getDisabledTextWrapper($text); + } + + $url = $this->url($this->currentPage() + 1); + + return $this->getPageLinkWrapper($url, $text); + } + + /** + * 页码按钮 + * @return string + */ + protected function getLinks() + { + if ($this->simple) + return ''; + + $block = [ + 'first' => null, + 'slider' => null, + 'last' => null + ]; + + $side = 3; + $window = $side * 2; + + if ($this->lastPage < $window + 6) { + $block['first'] = $this->getUrlRange(1, $this->lastPage); + } elseif ($this->currentPage <= $window) { + $block['first'] = $this->getUrlRange(1, $window + 2); + $block['last'] = $this->getUrlRange($this->lastPage - 1, $this->lastPage); + } elseif ($this->currentPage > ($this->lastPage - $window)) { + $block['first'] = $this->getUrlRange(1, 2); + $block['last'] = $this->getUrlRange($this->lastPage - ($window + 2), $this->lastPage); + } else { + $block['first'] = $this->getUrlRange(1, 2); + $block['slider'] = $this->getUrlRange($this->currentPage - $side, $this->currentPage + $side); + $block['last'] = $this->getUrlRange($this->lastPage - 1, $this->lastPage); + } + + $html = ''; + + if (is_array($block['first'])) { + $html .= $this->getUrlLinks($block['first']); + } + + if (is_array($block['slider'])) { + $html .= $this->getDots(); + $html .= $this->getUrlLinks($block['slider']); + } + + if (is_array($block['last'])) { + $html .= $this->getDots(); + $html .= $this->getUrlLinks($block['last']); + } + + return $html; + } + + /** + * 渲染分页html + * @return mixed + */ + public function render() + { + if ($this->hasPages()) { + if ($this->simple) { + return sprintf( + '
    %s %s
', + $this->getPreviousButton(), + $this->getNextButton() + ); + } else { + return sprintf( + '
    %s %s %s
', + $this->getPreviousButton(), + $this->getLinks(), + $this->getNextButton() + ); + } + } + } + + /** + * 生成一个可点击的按钮 + * + * @param string $url + * @param int $page + * @return string + */ + protected function getAvailablePageWrapper($url, $page) + { + return '
  • ' . $page . '
  • '; + } + + /** + * 生成一个禁用的按钮 + * + * @param string $text + * @return string + */ + protected function getDisabledTextWrapper($text) + { + return '
  • ' . $text . '
  • '; + } + + /** + * 生成一个激活的按钮 + * + * @param string $text + * @return string + */ + protected function getActivePageWrapper($text) + { + return '
  • ' . $text . '
  • '; + } + + /** + * 生成省略号按钮 + * + * @return string + */ + protected function getDots() + { + return $this->getDisabledTextWrapper('...'); + } + + /** + * 批量生成页码按钮. + * + * @param array $urls + * @return string + */ + protected function getUrlLinks(array $urls) + { + $html = ''; + + foreach ($urls as $page => $url) { + $html .= $this->getPageLinkWrapper($url, $page); + } + + return $html; + } + + /** + * 生成普通页码按钮 + * + * @param string $url + * @param int $page + * @return string + */ + protected function getPageLinkWrapper($url, $page) + { + if ($page == $this->currentPage()) { + return $this->getActivePageWrapper($page); + } + + return $this->getAvailablePageWrapper($url, $page); + } +} diff --git a/thinkphp/library/think/process/Builder.php b/thinkphp/library/think/process/Builder.php new file mode 100644 index 0000000..da56163 --- /dev/null +++ b/thinkphp/library/think/process/Builder.php @@ -0,0 +1,233 @@ + +// +---------------------------------------------------------------------- + +namespace think\process; + +use think\Process; + +class Builder +{ + private $arguments; + private $cwd; + private $env = null; + private $input; + private $timeout = 60; + private $options = []; + private $inheritEnv = true; + private $prefix = []; + private $outputDisabled = false; + + /** + * 构造方法 + * @param string[] $arguments 参数 + */ + public function __construct(array $arguments = []) + { + $this->arguments = $arguments; + } + + /** + * 创建一个实例 + * @param string[] $arguments 参数 + * @return self + */ + public static function create(array $arguments = []) + { + return new static($arguments); + } + + /** + * 添加一个参数 + * @param string $argument 参数 + * @return self + */ + public function add($argument) + { + $this->arguments[] = $argument; + + return $this; + } + + /** + * 添加一个前缀 + * @param string|array $prefix + * @return self + */ + public function setPrefix($prefix) + { + $this->prefix = is_array($prefix) ? $prefix : [$prefix]; + + return $this; + } + + /** + * 设置参数 + * @param string[] $arguments + * @return self + */ + public function setArguments(array $arguments) + { + $this->arguments = $arguments; + + return $this; + } + + /** + * 设置工作目录 + * @param null|string $cwd + * @return self + */ + public function setWorkingDirectory($cwd) + { + $this->cwd = $cwd; + + return $this; + } + + /** + * 是否初始化环境变量 + * @param bool $inheritEnv + * @return self + */ + public function inheritEnvironmentVariables($inheritEnv = true) + { + $this->inheritEnv = $inheritEnv; + + return $this; + } + + /** + * 设置环境变量 + * @param string $name + * @param null|string $value + * @return self + */ + public function setEnv($name, $value) + { + $this->env[$name] = $value; + + return $this; + } + + /** + * 添加环境变量 + * @param array $variables + * @return self + */ + public function addEnvironmentVariables(array $variables) + { + $this->env = array_replace($this->env, $variables); + + return $this; + } + + /** + * 设置输入 + * @param mixed $input + * @return self + */ + public function setInput($input) + { + $this->input = Utils::validateInput(sprintf('%s::%s', __CLASS__, __FUNCTION__), $input); + + return $this; + } + + /** + * 设置超时时间 + * @param float|null $timeout + * @return self + */ + public function setTimeout($timeout) + { + if (null === $timeout) { + $this->timeout = null; + + return $this; + } + + $timeout = (float) $timeout; + + if ($timeout < 0) { + throw new \InvalidArgumentException('The timeout value must be a valid positive integer or float number.'); + } + + $this->timeout = $timeout; + + return $this; + } + + /** + * 设置proc_open选项 + * @param string $name + * @param string $value + * @return self + */ + public function setOption($name, $value) + { + $this->options[$name] = $value; + + return $this; + } + + /** + * 禁止输出 + * @return self + */ + public function disableOutput() + { + $this->outputDisabled = true; + + return $this; + } + + /** + * 开启输出 + * @return self + */ + public function enableOutput() + { + $this->outputDisabled = false; + + return $this; + } + + /** + * 创建一个Process实例 + * @return Process + */ + public function getProcess() + { + if (0 === count($this->prefix) && 0 === count($this->arguments)) { + throw new \LogicException('You must add() command arguments before calling getProcess().'); + } + + $options = $this->options; + + $arguments = array_merge($this->prefix, $this->arguments); + $script = implode(' ', array_map([__NAMESPACE__ . '\\Utils', 'escapeArgument'], $arguments)); + + if ($this->inheritEnv) { + // include $_ENV for BC purposes + $env = array_replace($_ENV, $_SERVER, $this->env); + } else { + $env = $this->env; + } + + $process = new Process($script, $this->cwd, $env, $this->input, $this->timeout, $options); + + if ($this->outputDisabled) { + $process->disableOutput(); + } + + return $process; + } +} diff --git a/thinkphp/library/think/process/Utils.php b/thinkphp/library/think/process/Utils.php new file mode 100644 index 0000000..f94c648 --- /dev/null +++ b/thinkphp/library/think/process/Utils.php @@ -0,0 +1,75 @@ + +// +---------------------------------------------------------------------- + +namespace think\process; + +class Utils +{ + + /** + * 转义字符串 + * @param string $argument + * @return string + */ + public static function escapeArgument($argument) + { + + if ('' === $argument) { + return escapeshellarg($argument); + } + $escapedArgument = ''; + $quote = false; + foreach (preg_split('/(")/i', $argument, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE) as $part) { + if ('"' === $part) { + $escapedArgument .= '\\"'; + } elseif (self::isSurroundedBy($part, '%')) { + // Avoid environment variable expansion + $escapedArgument .= '^%"' . substr($part, 1, -1) . '"^%'; + } else { + // escape trailing backslash + if ('\\' === substr($part, -1)) { + $part .= '\\'; + } + $quote = true; + $escapedArgument .= $part; + } + } + if ($quote) { + $escapedArgument = '"' . $escapedArgument . '"'; + } + return $escapedArgument; + } + + /** + * 验证并进行规范化Process输入。 + * @param string $caller + * @param mixed $input + * @return string + * @throws \InvalidArgumentException + */ + public static function validateInput($caller, $input) + { + if (null !== $input) { + if (is_resource($input)) { + return $input; + } + if (is_scalar($input)) { + return (string) $input; + } + throw new \InvalidArgumentException(sprintf('%s only accepts strings or stream resources.', $caller)); + } + return $input; + } + + private static function isSurroundedBy($arg, $char) + { + return 2 < strlen($arg) && $char === $arg[0] && $char === $arg[strlen($arg) - 1]; + } + +} diff --git a/thinkphp/library/think/process/exception/Failed.php b/thinkphp/library/think/process/exception/Failed.php new file mode 100644 index 0000000..5295082 --- /dev/null +++ b/thinkphp/library/think/process/exception/Failed.php @@ -0,0 +1,42 @@ + +// +---------------------------------------------------------------------- + +namespace think\process\exception; + +use think\Process; + +class Failed extends \RuntimeException +{ + + private $process; + + public function __construct(Process $process) + { + if ($process->isSuccessful()) { + throw new \InvalidArgumentException('Expected a failed process, but the given process was successful.'); + } + + $error = sprintf('The command "%s" failed.' . "\nExit Code: %s(%s)", $process->getCommandLine(), $process->getExitCode(), $process->getExitCodeText()); + + if (!$process->isOutputDisabled()) { + $error .= sprintf("\n\nOutput:\n================\n%s\n\nError Output:\n================\n%s", $process->getOutput(), $process->getErrorOutput()); + } + + parent::__construct($error); + + $this->process = $process; + } + + public function getProcess() + { + return $this->process; + } +} diff --git a/thinkphp/library/think/process/exception/Timeout.php b/thinkphp/library/think/process/exception/Timeout.php new file mode 100644 index 0000000..d5f1162 --- /dev/null +++ b/thinkphp/library/think/process/exception/Timeout.php @@ -0,0 +1,61 @@ + +// +---------------------------------------------------------------------- + +namespace think\process\exception; + +use think\Process; + +class Timeout extends \RuntimeException +{ + + const TYPE_GENERAL = 1; + const TYPE_IDLE = 2; + + private $process; + private $timeoutType; + + public function __construct(Process $process, $timeoutType) + { + $this->process = $process; + $this->timeoutType = $timeoutType; + + parent::__construct(sprintf('The process "%s" exceeded the timeout of %s seconds.', $process->getCommandLine(), $this->getExceededTimeout())); + } + + public function getProcess() + { + return $this->process; + } + + public function isGeneralTimeout() + { + return $this->timeoutType === self::TYPE_GENERAL; + } + + public function isIdleTimeout() + { + return $this->timeoutType === self::TYPE_IDLE; + } + + public function getExceededTimeout() + { + switch ($this->timeoutType) { + case self::TYPE_GENERAL: + return $this->process->getTimeout(); + + case self::TYPE_IDLE: + return $this->process->getIdleTimeout(); + + default: + throw new \LogicException(sprintf('Unknown timeout type "%d".', $this->timeoutType)); + } + } +} diff --git a/thinkphp/library/think/process/pipes/Pipes.php b/thinkphp/library/think/process/pipes/Pipes.php new file mode 100644 index 0000000..82396b8 --- /dev/null +++ b/thinkphp/library/think/process/pipes/Pipes.php @@ -0,0 +1,93 @@ + +// +---------------------------------------------------------------------- + +namespace think\process\pipes; + +abstract class Pipes +{ + + /** @var array */ + public $pipes = []; + + /** @var string */ + protected $inputBuffer = ''; + /** @var resource|null */ + protected $input; + + /** @var bool */ + private $blocked = true; + + const CHUNK_SIZE = 16384; + + /** + * 返回用于 proc_open 描述符的数组 + * @return array + */ + abstract public function getDescriptors(); + + /** + * 返回一个数组的索引由其相关的流,以防这些管道使用的临时文件的文件名。 + * @return string[] + */ + abstract public function getFiles(); + + /** + * 文件句柄和管道中读取数据。 + * @param bool $blocking 是否使用阻塞调用 + * @param bool $close 是否要关闭管道,如果他们已经到达 EOF。 + * @return string[] + */ + abstract public function readAndWrite($blocking, $close = false); + + /** + * 返回当前状态如果有打开的文件句柄或管道。 + * @return bool + */ + abstract public function areOpen(); + + /** + * {@inheritdoc} + */ + public function close() + { + foreach ($this->pipes as $pipe) { + fclose($pipe); + } + $this->pipes = []; + } + + /** + * 检查系统调用已被中断 + * @return bool + */ + protected function hasSystemCallBeenInterrupted() + { + $lastError = error_get_last(); + + return isset($lastError['message']) && false !== stripos($lastError['message'], 'interrupted system call'); + } + + protected function unblock() + { + if (!$this->blocked) { + return; + } + + foreach ($this->pipes as $pipe) { + stream_set_blocking($pipe, 0); + } + if (null !== $this->input) { + stream_set_blocking($this->input, 0); + } + + $this->blocked = false; + } +} diff --git a/thinkphp/library/think/process/pipes/Unix.php b/thinkphp/library/think/process/pipes/Unix.php new file mode 100644 index 0000000..fd99a5d --- /dev/null +++ b/thinkphp/library/think/process/pipes/Unix.php @@ -0,0 +1,196 @@ + +// +---------------------------------------------------------------------- + +namespace think\process\pipes; + +use think\Process; + +class Unix extends Pipes +{ + + /** @var bool */ + private $ttyMode; + /** @var bool */ + private $ptyMode; + /** @var bool */ + private $disableOutput; + + public function __construct($ttyMode, $ptyMode, $input, $disableOutput) + { + $this->ttyMode = (bool) $ttyMode; + $this->ptyMode = (bool) $ptyMode; + $this->disableOutput = (bool) $disableOutput; + + if (is_resource($input)) { + $this->input = $input; + } else { + $this->inputBuffer = (string) $input; + } + } + + public function __destruct() + { + $this->close(); + } + + /** + * {@inheritdoc} + */ + public function getDescriptors() + { + if ($this->disableOutput) { + $nullstream = fopen('/dev/null', 'c'); + + return [ + ['pipe', 'r'], + $nullstream, + $nullstream, + ]; + } + + if ($this->ttyMode) { + return [ + ['file', '/dev/tty', 'r'], + ['file', '/dev/tty', 'w'], + ['file', '/dev/tty', 'w'], + ]; + } + + if ($this->ptyMode && Process::isPtySupported()) { + return [ + ['pty'], + ['pty'], + ['pty'], + ]; + } + + return [ + ['pipe', 'r'], + ['pipe', 'w'], // stdout + ['pipe', 'w'], // stderr + ]; + } + + /** + * {@inheritdoc} + */ + public function getFiles() + { + return []; + } + + /** + * {@inheritdoc} + */ + public function readAndWrite($blocking, $close = false) + { + + if (1 === count($this->pipes) && [0] === array_keys($this->pipes)) { + fclose($this->pipes[0]); + unset($this->pipes[0]); + } + + if (empty($this->pipes)) { + return []; + } + + $this->unblock(); + + $read = []; + + if (null !== $this->input) { + $r = array_merge($this->pipes, ['input' => $this->input]); + } else { + $r = $this->pipes; + } + + unset($r[0]); + + $w = isset($this->pipes[0]) ? [$this->pipes[0]] : null; + $e = null; + + if (false === $n = @stream_select($r, $w, $e, 0, $blocking ? Process::TIMEOUT_PRECISION * 1E6 : 0)) { + + if (!$this->hasSystemCallBeenInterrupted()) { + $this->pipes = []; + } + + return $read; + } + + if (0 === $n) { + return $read; + } + + foreach ($r as $pipe) { + + $type = (false !== $found = array_search($pipe, $this->pipes)) ? $found : 'input'; + $data = ''; + while ('' !== $dataread = (string) fread($pipe, self::CHUNK_SIZE)) { + $data .= $dataread; + } + + if ('' !== $data) { + if ('input' === $type) { + $this->inputBuffer .= $data; + } else { + $read[$type] = $data; + } + } + + if (false === $data || (true === $close && feof($pipe) && '' === $data)) { + if ('input' === $type) { + $this->input = null; + } else { + fclose($this->pipes[$type]); + unset($this->pipes[$type]); + } + } + } + + if (null !== $w && 0 < count($w)) { + while (strlen($this->inputBuffer)) { + $written = fwrite($w[0], $this->inputBuffer, 2 << 18); // write 512k + if ($written > 0) { + $this->inputBuffer = (string) substr($this->inputBuffer, $written); + } else { + break; + } + } + } + + if ('' === $this->inputBuffer && null === $this->input && isset($this->pipes[0])) { + fclose($this->pipes[0]); + unset($this->pipes[0]); + } + + return $read; + } + + /** + * {@inheritdoc} + */ + public function areOpen() + { + return (bool) $this->pipes; + } + + /** + * 创建一个新的 UnixPipes 实例 + * @param Process $process + * @param string|resource $input + * @return self + */ + public static function create(Process $process, $input) + { + return new static($process->isTty(), $process->isPty(), $input, $process->isOutputDisabled()); + } +} diff --git a/thinkphp/library/think/process/pipes/Windows.php b/thinkphp/library/think/process/pipes/Windows.php new file mode 100644 index 0000000..1b8b0d4 --- /dev/null +++ b/thinkphp/library/think/process/pipes/Windows.php @@ -0,0 +1,228 @@ + +// +---------------------------------------------------------------------- + +namespace think\process\pipes; + +use think\Process; + +class Windows extends Pipes +{ + + /** @var array */ + private $files = []; + /** @var array */ + private $fileHandles = []; + /** @var array */ + private $readBytes = [ + Process::STDOUT => 0, + Process::STDERR => 0, + ]; + /** @var bool */ + private $disableOutput; + + public function __construct($disableOutput, $input) + { + $this->disableOutput = (bool) $disableOutput; + + if (!$this->disableOutput) { + + $this->files = [ + Process::STDOUT => tempnam(sys_get_temp_dir(), 'sf_proc_stdout'), + Process::STDERR => tempnam(sys_get_temp_dir(), 'sf_proc_stderr'), + ]; + foreach ($this->files as $offset => $file) { + $this->fileHandles[$offset] = fopen($this->files[$offset], 'rb'); + if (false === $this->fileHandles[$offset]) { + throw new \RuntimeException('A temporary file could not be opened to write the process output to, verify that your TEMP environment variable is writable'); + } + } + } + + if (is_resource($input)) { + $this->input = $input; + } else { + $this->inputBuffer = $input; + } + } + + public function __destruct() + { + $this->close(); + $this->removeFiles(); + } + + /** + * {@inheritdoc} + */ + public function getDescriptors() + { + if ($this->disableOutput) { + $nullstream = fopen('NUL', 'c'); + + return [ + ['pipe', 'r'], + $nullstream, + $nullstream, + ]; + } + + return [ + ['pipe', 'r'], + ['file', 'NUL', 'w'], + ['file', 'NUL', 'w'], + ]; + } + + /** + * {@inheritdoc} + */ + public function getFiles() + { + return $this->files; + } + + /** + * {@inheritdoc} + */ + public function readAndWrite($blocking, $close = false) + { + $this->write($blocking, $close); + + $read = []; + $fh = $this->fileHandles; + foreach ($fh as $type => $fileHandle) { + if (0 !== fseek($fileHandle, $this->readBytes[$type])) { + continue; + } + $data = ''; + $dataread = null; + while (!feof($fileHandle)) { + if (false !== $dataread = fread($fileHandle, self::CHUNK_SIZE)) { + $data .= $dataread; + } + } + if (0 < $length = strlen($data)) { + $this->readBytes[$type] += $length; + $read[$type] = $data; + } + + if (false === $dataread || (true === $close && feof($fileHandle) && '' === $data)) { + fclose($this->fileHandles[$type]); + unset($this->fileHandles[$type]); + } + } + + return $read; + } + + /** + * {@inheritdoc} + */ + public function areOpen() + { + return (bool) $this->pipes && (bool) $this->fileHandles; + } + + /** + * {@inheritdoc} + */ + public function close() + { + parent::close(); + foreach ($this->fileHandles as $handle) { + fclose($handle); + } + $this->fileHandles = []; + } + + /** + * 创建一个新的 WindowsPipes 实例。 + * @param Process $process + * @param $input + * @return self + */ + public static function create(Process $process, $input) + { + return new static($process->isOutputDisabled(), $input); + } + + /** + * 删除临时文件 + */ + private function removeFiles() + { + foreach ($this->files as $filename) { + if (file_exists($filename)) { + @unlink($filename); + } + } + $this->files = []; + } + + /** + * 写入到 stdin 输入 + * @param bool $blocking + * @param bool $close + */ + private function write($blocking, $close) + { + if (empty($this->pipes)) { + return; + } + + $this->unblock(); + + $r = null !== $this->input ? ['input' => $this->input] : null; + $w = isset($this->pipes[0]) ? [$this->pipes[0]] : null; + $e = null; + + if (false === $n = @stream_select($r, $w, $e, 0, $blocking ? Process::TIMEOUT_PRECISION * 1E6 : 0)) { + if (!$this->hasSystemCallBeenInterrupted()) { + $this->pipes = []; + } + + return; + } + + if (0 === $n) { + return; + } + + if (null !== $r && 0 < count($r)) { + $data = ''; + while ($dataread = fread($r['input'], self::CHUNK_SIZE)) { + $data .= $dataread; + } + + $this->inputBuffer .= $data; + + if (false === $data || (true === $close && feof($r['input']) && '' === $data)) { + $this->input = null; + } + } + + if (null !== $w && 0 < count($w)) { + while (strlen($this->inputBuffer)) { + $written = fwrite($w[0], $this->inputBuffer, 2 << 18); + if ($written > 0) { + $this->inputBuffer = (string) substr($this->inputBuffer, $written); + } else { + break; + } + } + } + + if ('' === $this->inputBuffer && null === $this->input && isset($this->pipes[0])) { + fclose($this->pipes[0]); + unset($this->pipes[0]); + } + } +} diff --git a/thinkphp/library/think/response/Json.php b/thinkphp/library/think/response/Json.php new file mode 100644 index 0000000..c906bfc --- /dev/null +++ b/thinkphp/library/think/response/Json.php @@ -0,0 +1,51 @@ + +// +---------------------------------------------------------------------- + +namespace think\response; + +use think\Response; + +class Json extends Response +{ + // 输出参数 + protected $options = [ + 'json_encode_param' => JSON_UNESCAPED_UNICODE, + ]; + + protected $contentType = 'application/json'; + + /** + * 处理数据 + * @access protected + * @param mixed $data 要处理的数据 + * @return mixed + * @throws \Exception + */ + protected function output($data) + { + try { + // 返回JSON数据格式到客户端 包含状态信息 + $data = json_encode($data, $this->options['json_encode_param']); + + if ($data === false) { + throw new \InvalidArgumentException(json_last_error_msg()); + } + + return $data; + } catch (\Exception $e) { + if ($e->getPrevious()) { + throw $e->getPrevious(); + } + throw $e; + } + } + +} diff --git a/thinkphp/library/think/response/Jsonp.php b/thinkphp/library/think/response/Jsonp.php new file mode 100644 index 0000000..404bacb --- /dev/null +++ b/thinkphp/library/think/response/Jsonp.php @@ -0,0 +1,58 @@ + +// +---------------------------------------------------------------------- + +namespace think\response; + +use think\Request; +use think\Response; + +class Jsonp extends Response +{ + // 输出参数 + protected $options = [ + 'var_jsonp_handler' => 'callback', + 'default_jsonp_handler' => 'jsonpReturn', + 'json_encode_param' => JSON_UNESCAPED_UNICODE, + ]; + + protected $contentType = 'application/javascript'; + + /** + * 处理数据 + * @access protected + * @param mixed $data 要处理的数据 + * @return mixed + * @throws \Exception + */ + protected function output($data) + { + try { + // 返回JSON数据格式到客户端 包含状态信息 [当url_common_param为false时是无法获取到$_GET的数据的,故使用Request来获取] + $var_jsonp_handler = Request::instance()->param($this->options['var_jsonp_handler'], ""); + $handler = !empty($var_jsonp_handler) ? $var_jsonp_handler : $this->options['default_jsonp_handler']; + + $data = json_encode($data, $this->options['json_encode_param']); + + if ($data === false) { + throw new \InvalidArgumentException(json_last_error_msg()); + } + + $data = $handler . '(' . $data . ');'; + return $data; + } catch (\Exception $e) { + if ($e->getPrevious()) { + throw $e->getPrevious(); + } + throw $e; + } + } + +} diff --git a/thinkphp/library/think/response/Redirect.php b/thinkphp/library/think/response/Redirect.php new file mode 100644 index 0000000..91694cb --- /dev/null +++ b/thinkphp/library/think/response/Redirect.php @@ -0,0 +1,105 @@ + +// +---------------------------------------------------------------------- + +namespace think\response; + +use think\Request; +use think\Response; +use think\Session; +use think\Url; + +class Redirect extends Response +{ + + protected $options = []; + + // URL参数 + protected $params = []; + + public function __construct($data = '', $code = 302, array $header = [], array $options = []) + { + parent::__construct($data, $code, $header, $options); + $this->cacheControl('no-cache,must-revalidate'); + } + + /** + * 处理数据 + * @access protected + * @param mixed $data 要处理的数据 + * @return mixed + */ + protected function output($data) + { + $this->header['Location'] = $this->getTargetUrl(); + return; + } + + /** + * 重定向传值(通过Session) + * @access protected + * @param string|array $name 变量名或者数组 + * @param mixed $value 值 + * @return $this + */ + public function with($name, $value = null) + { + if (is_array($name)) { + foreach ($name as $key => $val) { + Session::flash($key, $val); + } + } else { + Session::flash($name, $value); + } + return $this; + } + + /** + * 获取跳转地址 + * @return string + */ + public function getTargetUrl() + { + if (strpos($this->data, '://') || (0 === strpos($this->data, '/') && empty($this->params))) { + return $this->data; + } else { + return Url::build($this->data, $this->params); + } + } + + public function params($params = []) + { + $this->params = $params; + return $this; + } + + /** + * 记住当前url后跳转 + * @return $this + */ + public function remember() + { + Session::set('redirect_url', Request::instance()->url()); + return $this; + } + + /** + * 跳转到上次记住的url + * @return $this + */ + public function restore() + { + if (Session::has('redirect_url')) { + $this->data = Session::get('redirect_url'); + Session::delete('redirect_url'); + } + return $this; + } +} diff --git a/thinkphp/library/think/response/View.php b/thinkphp/library/think/response/View.php new file mode 100644 index 0000000..48f944a --- /dev/null +++ b/thinkphp/library/think/response/View.php @@ -0,0 +1,89 @@ + +// +---------------------------------------------------------------------- + +namespace think\response; + +use think\Config; +use think\Response; +use think\View as ViewTemplate; + +class View extends Response +{ + // 输出参数 + protected $options = []; + protected $vars = []; + protected $replace = []; + protected $contentType = 'text/html'; + + /** + * 处理数据 + * @access protected + * @param mixed $data 要处理的数据 + * @return mixed + */ + protected function output($data) + { + // 渲染模板输出 + return ViewTemplate::instance(Config::get('template'), Config::get('view_replace_str')) + ->fetch($data, $this->vars, $this->replace); + } + + /** + * 获取视图变量 + * @access public + * @param string $name 模板变量 + * @return mixed + */ + public function getVars($name = null) + { + if (is_null($name)) { + return $this->vars; + } else { + return isset($this->vars[$name]) ? $this->vars[$name] : null; + } + } + + /** + * 模板变量赋值 + * @access public + * @param mixed $name 变量名 + * @param mixed $value 变量值 + * @return $this + */ + public function assign($name, $value = '') + { + if (is_array($name)) { + $this->vars = array_merge($this->vars, $name); + return $this; + } else { + $this->vars[$name] = $value; + } + return $this; + } + + /** + * 视图内容替换 + * @access public + * @param string|array $content 被替换内容(支持批量替换) + * @param string $replace 替换内容 + * @return $this + */ + public function replace($content, $replace = '') + { + if (is_array($content)) { + $this->replace = array_merge($this->replace, $content); + } else { + $this->replace[$content] = $replace; + } + return $this; + } + +} diff --git a/thinkphp/library/think/response/Xml.php b/thinkphp/library/think/response/Xml.php new file mode 100644 index 0000000..3bdc052 --- /dev/null +++ b/thinkphp/library/think/response/Xml.php @@ -0,0 +1,102 @@ + +// +---------------------------------------------------------------------- + +namespace think\response; + +use think\Collection; +use think\Model; +use think\Response; + +class Xml extends Response +{ + // 输出参数 + protected $options = [ + // 根节点名 + 'root_node' => 'think', + // 根节点属性 + 'root_attr' => '', + //数字索引的子节点名 + 'item_node' => 'item', + // 数字索引子节点key转换的属性名 + 'item_key' => 'id', + // 数据编码 + 'encoding' => 'utf-8', + ]; + + protected $contentType = 'text/xml'; + + /** + * 处理数据 + * @access protected + * @param mixed $data 要处理的数据 + * @return mixed + */ + protected function output($data) + { + // XML数据转换 + return $this->xmlEncode($data, $this->options['root_node'], $this->options['item_node'], $this->options['root_attr'], $this->options['item_key'], $this->options['encoding']); + } + + /** + * XML编码 + * @param mixed $data 数据 + * @param string $root 根节点名 + * @param string $item 数字索引的子节点名 + * @param string $attr 根节点属性 + * @param string $id 数字索引子节点key转换的属性名 + * @param string $encoding 数据编码 + * @return string + */ + protected function xmlEncode($data, $root, $item, $attr, $id, $encoding) + { + if (is_array($attr)) { + $array = []; + foreach ($attr as $key => $value) { + $array[] = "{$key}=\"{$value}\""; + } + $attr = implode(' ', $array); + } + $attr = trim($attr); + $attr = empty($attr) ? '' : " {$attr}"; + $xml = ""; + $xml .= "<{$root}{$attr}>"; + $xml .= $this->dataToXml($data, $item, $id); + $xml .= ""; + return $xml; + } + + /** + * 数据XML编码 + * @param mixed $data 数据 + * @param string $item 数字索引时的节点名称 + * @param string $id 数字索引key转换为的属性名 + * @return string + */ + protected function dataToXml($data, $item, $id) + { + $xml = $attr = ''; + + if ($data instanceof Collection || $data instanceof Model) { + $data = $data->toArray(); + } + + foreach ($data as $key => $val) { + if (is_numeric($key)) { + $id && $attr = " {$id}=\"{$key}\""; + $key = $item; + } + $xml .= "<{$key}{$attr}>"; + $xml .= (is_array($val) || is_object($val)) ? $this->dataToXml($val, $item, $id) : $val; + $xml .= ""; + } + return $xml; + } +} diff --git a/thinkphp/library/think/session/driver/Memcache.php b/thinkphp/library/think/session/driver/Memcache.php new file mode 100644 index 0000000..877d7bd --- /dev/null +++ b/thinkphp/library/think/session/driver/Memcache.php @@ -0,0 +1,118 @@ + +// +---------------------------------------------------------------------- + +namespace think\session\driver; + +use SessionHandler; +use think\Exception; + +class Memcache extends SessionHandler +{ + protected $handler = null; + protected $config = [ + 'host' => '127.0.0.1', // memcache主机 + 'port' => 11211, // memcache端口 + 'expire' => 3600, // session有效期 + 'timeout' => 0, // 连接超时时间(单位:毫秒) + 'persistent' => true, // 长连接 + 'session_name' => '', // memcache key前缀 + ]; + + public function __construct($config = []) + { + $this->config = array_merge($this->config, $config); + } + + /** + * 打开Session + * @access public + * @param string $savePath + * @param mixed $sessName + */ + public function open($savePath, $sessName) + { + // 检测php环境 + if (!extension_loaded('memcache')) { + throw new Exception('not support:memcache'); + } + $this->handler = new \Memcache; + // 支持集群 + $hosts = explode(',', $this->config['host']); + $ports = explode(',', $this->config['port']); + if (empty($ports[0])) { + $ports[0] = 11211; + } + // 建立连接 + foreach ((array) $hosts as $i => $host) { + $port = isset($ports[$i]) ? $ports[$i] : $ports[0]; + $this->config['timeout'] > 0 ? + $this->handler->addServer($host, $port, $this->config['persistent'], 1, $this->config['timeout']) : + $this->handler->addServer($host, $port, $this->config['persistent'], 1); + } + return true; + } + + /** + * 关闭Session + * @access public + */ + public function close() + { + $this->gc(ini_get('session.gc_maxlifetime')); + $this->handler->close(); + $this->handler = null; + return true; + } + + /** + * 读取Session + * @access public + * @param string $sessID + */ + public function read($sessID) + { + return (string) $this->handler->get($this->config['session_name'] . $sessID); + } + + /** + * 写入Session + * @access public + * @param string $sessID + * @param String $sessData + * @return bool + */ + public function write($sessID, $sessData) + { + return $this->handler->set($this->config['session_name'] . $sessID, $sessData, 0, $this->config['expire']); + } + + /** + * 删除Session + * @access public + * @param string $sessID + * @return bool + */ + public function destroy($sessID) + { + return $this->handler->delete($this->config['session_name'] . $sessID); + } + + /** + * Session 垃圾回收 + * @access public + * @param string $sessMaxLifeTime + * @return true + */ + public function gc($sessMaxLifeTime) + { + return true; + } +} diff --git a/thinkphp/library/think/session/driver/Memcached.php b/thinkphp/library/think/session/driver/Memcached.php new file mode 100644 index 0000000..2994a07 --- /dev/null +++ b/thinkphp/library/think/session/driver/Memcached.php @@ -0,0 +1,126 @@ + +// +---------------------------------------------------------------------- + +namespace think\session\driver; + +use SessionHandler; +use think\Exception; + +class Memcached extends SessionHandler +{ + protected $handler = null; + protected $config = [ + 'host' => '127.0.0.1', // memcache主机 + 'port' => 11211, // memcache端口 + 'expire' => 3600, // session有效期 + 'timeout' => 0, // 连接超时时间(单位:毫秒) + 'session_name' => '', // memcache key前缀 + 'username' => '', //账号 + 'password' => '', //密码 + ]; + + public function __construct($config = []) + { + $this->config = array_merge($this->config, $config); + } + + /** + * 打开Session + * @access public + * @param string $savePath + * @param mixed $sessName + */ + public function open($savePath, $sessName) + { + // 检测php环境 + if (!extension_loaded('memcached')) { + throw new Exception('not support:memcached'); + } + $this->handler = new \Memcached; + // 设置连接超时时间(单位:毫秒) + if ($this->config['timeout'] > 0) { + $this->handler->setOption(\Memcached::OPT_CONNECT_TIMEOUT, $this->config['timeout']); + } + // 支持集群 + $hosts = explode(',', $this->config['host']); + $ports = explode(',', $this->config['port']); + if (empty($ports[0])) { + $ports[0] = 11211; + } + // 建立连接 + $servers = []; + foreach ((array) $hosts as $i => $host) { + $servers[] = [$host, (isset($ports[$i]) ? $ports[$i] : $ports[0]), 1]; + } + $this->handler->addServers($servers); + if ('' != $this->config['username']) { + $this->handler->setOption(\Memcached::OPT_BINARY_PROTOCOL, true); + $this->handler->setSaslAuthData($this->config['username'], $this->config['password']); + } + return true; + } + + /** + * 关闭Session + * @access public + */ + public function close() + { + $this->gc(ini_get('session.gc_maxlifetime')); + $this->handler->quit(); + $this->handler = null; + return true; + } + + /** + * 读取Session + * @access public + * @param string $sessID + */ + public function read($sessID) + { + return (string) $this->handler->get($this->config['session_name'] . $sessID); + } + + /** + * 写入Session + * @access public + * @param string $sessID + * @param String $sessData + * @return bool + */ + public function write($sessID, $sessData) + { + return $this->handler->set($this->config['session_name'] . $sessID, $sessData, $this->config['expire']); + } + + /** + * 删除Session + * @access public + * @param string $sessID + * @return bool + */ + public function destroy($sessID) + { + return $this->handler->delete($this->config['session_name'] . $sessID); + } + + /** + * Session 垃圾回收 + * @access public + * @param string $sessMaxLifeTime + * @return true + */ + public function gc($sessMaxLifeTime) + { + return true; + } +} diff --git a/thinkphp/library/think/session/driver/Redis.php b/thinkphp/library/think/session/driver/Redis.php new file mode 100644 index 0000000..b927868 --- /dev/null +++ b/thinkphp/library/think/session/driver/Redis.php @@ -0,0 +1,134 @@ + +// +---------------------------------------------------------------------- + +namespace think\session\driver; + +use SessionHandler; +use think\Exception; + +class Redis extends SessionHandler +{ + /** @var \Redis */ + protected $handler = null; + protected $config = [ + 'host' => '127.0.0.1', // redis主机 + 'port' => 6379, // redis端口 + 'password' => '', // 密码 + 'select' => 0, // 操作库 + 'expire' => 3600, // 有效期(秒) + 'timeout' => 0, // 超时时间(秒) + 'persistent' => true, // 是否长连接 + 'session_name' => '', // sessionkey前缀 + ]; + + public function __construct($config = []) + { + $this->config = array_merge($this->config, $config); + } + + /** + * 打开Session + * @access public + * @param string $savePath + * @param mixed $sessName + * @return bool + * @throws Exception + */ + #[\ReturnTypeWillChange] + public function open($savePath, $sessName) + { + // 检测php环境 + if (!extension_loaded('redis')) { + throw new Exception('not support:redis'); + } + $this->handler = new \Redis; + + // 建立连接 + $func = $this->config['persistent'] ? 'pconnect' : 'connect'; + $this->handler->$func($this->config['host'], $this->config['port'], $this->config['timeout']); + + if ('' != $this->config['password']) { + $this->handler->auth($this->config['password']); + } + + if (0 != $this->config['select']) { + $this->handler->select($this->config['select']); + } + + return true; + } + + /** + * 关闭Session + * @access public + */ + #[\ReturnTypeWillChange] + public function close() + { + $this->gc(ini_get('session.gc_maxlifetime')); + $this->handler->close(); + $this->handler = null; + return true; + } + + /** + * 读取Session + * @access public + * @param string $sessID + * @return string + */ + #[\ReturnTypeWillChange] + public function read($sessID) + { + return (string) $this->handler->get($this->config['session_name'] . $sessID); + } + + /** + * 写入Session + * @access public + * @param string $sessID + * @param string $sessData + * @return bool + */ + #[\ReturnTypeWillChange] + public function write($sessID, $sessData) + { + if ($this->config['expire'] > 0) { + return $this->handler->setex($this->config['session_name'] . $sessID, $this->config['expire'], $sessData); + } else { + return $this->handler->set($this->config['session_name'] . $sessID, $sessData); + } + } + + /** + * 删除Session + * @access public + * @param string $sessID + * @return bool + */ + #[\ReturnTypeWillChange] + public function destroy($sessID) + { + return $this->handler->del($this->config['session_name'] . $sessID) > 0; + } + + /** + * Session 垃圾回收 + * @access public + * @param string $sessMaxLifeTime + * @return bool + */ + #[\ReturnTypeWillChange] + public function gc($sessMaxLifeTime) + { + return true; + } +} diff --git a/thinkphp/library/think/template/TagLib.php b/thinkphp/library/think/template/TagLib.php new file mode 100644 index 0000000..c5b72f9 --- /dev/null +++ b/thinkphp/library/think/template/TagLib.php @@ -0,0 +1,334 @@ + +// +---------------------------------------------------------------------- + +namespace think\template; + +use think\Exception; + +/** + * ThinkPHP标签库TagLib解析基类 + * @category Think + * @package Think + * @subpackage Template + * @author liu21st + */ +class TagLib +{ + + /** + * 标签库定义XML文件 + * @var string + * @access protected + */ + protected $xml = ''; + protected $tags = []; // 标签定义 + /** + * 标签库名称 + * @var string + * @access protected + */ + protected $tagLib = ''; + + /** + * 标签库标签列表 + * @var array + * @access protected + */ + protected $tagList = []; + + /** + * 标签库分析数组 + * @var array + * @access protected + */ + protected $parse = []; + + /** + * 标签库是否有效 + * @var bool + * @access protected + */ + protected $valid = false; + + /** + * 当前模板对象 + * @var object + * @access protected + */ + protected $tpl; + + protected $comparison = [' nheq ' => ' !== ', ' heq ' => ' === ', ' neq ' => ' != ', ' eq ' => ' == ', ' egt ' => ' >= ', ' gt ' => ' > ', ' elt ' => ' <= ', ' lt ' => ' < ']; + + /** + * 构造函数 + * @access public + * @param \stdClass $template 模板引擎对象 + */ + public function __construct($template) + { + $this->tpl = $template; + } + + /** + * 按签标库替换页面中的标签 + * @access public + * @param string $content 模板内容 + * @param string $lib 标签库名 + * @return void + */ + public function parseTag(&$content, $lib = '') + { + $tags = []; + $lib = $lib ? strtolower($lib) . ':' : ''; + foreach ($this->tags as $name => $val) { + $close = !isset($val['close']) || $val['close'] ? 1 : 0; + $tags[$close][$lib . $name] = $name; + if (isset($val['alias'])) { + // 别名设置 + $array = (array) $val['alias']; + foreach (explode(',', $array[0]) as $v) { + $tags[$close][$lib . $v] = $name; + } + } + } + + // 闭合标签 + if (!empty($tags[1])) { + $nodes = []; + $regex = $this->getRegex(array_keys($tags[1]), 1); + if (preg_match_all($regex, $content, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE)) { + $right = []; + foreach ($matches as $match) { + if ('' == $match[1][0]) { + $name = strtolower($match[2][0]); + // 如果有没闭合的标签头则取出最后一个 + if (!empty($right[$name])) { + // $match[0][1]为标签结束符在模板中的位置 + $nodes[$match[0][1]] = [ + 'name' => $name, + 'begin' => array_pop($right[$name]), // 标签开始符 + 'end' => $match[0], // 标签结束符 + ]; + } + } else { + // 标签头压入栈 + $right[strtolower($match[1][0])][] = $match[0]; + } + } + unset($right, $matches); + // 按标签在模板中的位置从后向前排序 + krsort($nodes); + } + + $break = ''; + if ($nodes) { + $beginArray = []; + // 标签替换 从后向前 + foreach ($nodes as $pos => $node) { + // 对应的标签名 + $name = $tags[1][$node['name']]; + $alias = $lib . $name != $node['name'] ? ($lib ? strstr($node['name'], $lib) : $node['name']) : ''; + // 解析标签属性 + $attrs = $this->parseAttr($node['begin'][0], $name, $alias); + $method = 'tag' . $name; + // 读取标签库中对应的标签内容 replace[0]用来替换标签头,replace[1]用来替换标签尾 + $replace = explode($break, $this->$method($attrs, $break)); + if (count($replace) > 1) { + while ($beginArray) { + $begin = end($beginArray); + // 判断当前标签尾的位置是否在栈中最后一个标签头的后面,是则为子标签 + if ($node['end'][1] > $begin['pos']) { + break; + } else { + // 不为子标签时,取出栈中最后一个标签头 + $begin = array_pop($beginArray); + // 替换标签头部 + $content = substr_replace($content, $begin['str'], $begin['pos'], $begin['len']); + } + } + // 替换标签尾部 + $content = substr_replace($content, $replace[1], $node['end'][1], strlen($node['end'][0])); + // 把标签头压入栈 + $beginArray[] = ['pos' => $node['begin'][1], 'len' => strlen($node['begin'][0]), 'str' => $replace[0]]; + } + } + while ($beginArray) { + $begin = array_pop($beginArray); + // 替换标签头部 + $content = substr_replace($content, $begin['str'], $begin['pos'], $begin['len']); + } + } + } + // 自闭合标签 + if (!empty($tags[0])) { + $regex = $this->getRegex(array_keys($tags[0]), 0); + $content = preg_replace_callback($regex, function ($matches) use (&$tags, &$lib) { + // 对应的标签名 + $name = $tags[0][strtolower($matches[1])]; + $alias = $lib . $name != $matches[1] ? ($lib ? strstr($matches[1], $lib) : $matches[1]) : ''; + // 解析标签属性 + $attrs = $this->parseAttr($matches[0], $name, $alias); + $method = 'tag' . $name; + return $this->$method($attrs, ''); + }, $content); + } + return; + } + + /** + * 按标签生成正则 + * @access private + * @param array|string $tags 标签名 + * @param boolean $close 是否为闭合标签 + * @return string + */ + public function getRegex($tags, $close) + { + $begin = $this->tpl->config('taglib_begin'); + $end = $this->tpl->config('taglib_end'); + $single = strlen(ltrim($begin, '\\')) == 1 && strlen(ltrim($end, '\\')) == 1 ? true : false; + $tagName = is_array($tags) ? implode('|', $tags) : $tags; + if ($single) { + if ($close) { + // 如果是闭合标签 + $regex = $begin . '(?:(' . $tagName . ')\b(?>[^' . $end . ']*)|\/(' . $tagName . '))' . $end; + } else { + $regex = $begin . '(' . $tagName . ')\b(?>[^' . $end . ']*)' . $end; + } + } else { + if ($close) { + // 如果是闭合标签 + $regex = $begin . '(?:(' . $tagName . ')\b(?>(?:(?!' . $end . ').)*)|\/(' . $tagName . '))' . $end; + } else { + $regex = $begin . '(' . $tagName . ')\b(?>(?:(?!' . $end . ').)*)' . $end; + } + } + return '/' . $regex . '/is'; + } + + /** + * 分析标签属性 正则方式 + * @access public + * @param string $str 标签属性字符串 + * @param string $name 标签名 + * @param string $alias 别名 + * @return array + */ + public function parseAttr($str, $name, $alias = '') + { + $regex = '/\s+(?>(?P[\w-]+)\s*)=(?>\s*)([\"\'])(?P(?:(?!\\2).)*)\\2/is'; + $result = []; + if (preg_match_all($regex, $str, $matches)) { + foreach ($matches['name'] as $key => $val) { + $result[$val] = $matches['value'][$key]; + } + if (!isset($this->tags[$name])) { + // 检测是否存在别名定义 + foreach ($this->tags as $key => $val) { + if (isset($val['alias'])) { + $array = (array) $val['alias']; + if (in_array($name, explode(',', $array[0]))) { + $tag = $val; + $type = !empty($array[1]) ? $array[1] : 'type'; + $result[$type] = $name; + break; + } + } + } + } else { + $tag = $this->tags[$name]; + // 设置了标签别名 + if (!empty($alias) && isset($tag['alias'])) { + $type = !empty($tag['alias'][1]) ? $tag['alias'][1] : 'type'; + $result[$type] = $alias; + } + } + if (!empty($tag['must'])) { + $must = explode(',', $tag['must']); + foreach ($must as $name) { + if (!isset($result[$name])) { + throw new Exception('tag attr must:' . $name); + } + } + } + } else { + // 允许直接使用表达式的标签 + if (!empty($this->tags[$name]['expression'])) { + static $_taglibs; + if (!isset($_taglibs[$name])) { + $_taglibs[$name][0] = strlen($this->tpl->config('taglib_begin_origin') . $name); + $_taglibs[$name][1] = strlen($this->tpl->config('taglib_end_origin')); + } + $result['expression'] = substr($str, $_taglibs[$name][0], -$_taglibs[$name][1]); + // 清除自闭合标签尾部/ + $result['expression'] = rtrim($result['expression'], '/'); + $result['expression'] = trim($result['expression']); + } elseif (empty($this->tags[$name]) || !empty($this->tags[$name]['attr'])) { + throw new Exception('tag error:' . $name); + } + } + return $result; + } + + /** + * 解析条件表达式 + * @access public + * @param string $condition 表达式标签内容 + * @return string + */ + public function parseCondition($condition) + { + if (strpos($condition, ':')) { + $condition = ' ' . substr(strstr($condition, ':'), 1); + } + $condition = str_ireplace(array_keys($this->comparison), array_values($this->comparison), $condition); + $this->tpl->parseVar($condition); + // $this->tpl->parseVarFunction($condition); // XXX: 此句能解析表达式中用|分隔的函数,但表达式中如果有|、||这样的逻辑运算就产生了歧异 + return $condition; + } + + /** + * 自动识别构建变量 + * @access public + * @param string $name 变量描述 + * @return string + */ + public function autoBuildVar(&$name) + { + $flag = substr($name, 0, 1); + if (':' == $flag) { + // 以:开头为函数调用,解析前去掉: + $name = substr($name, 1); + } elseif ('$' != $flag && preg_match('/[a-zA-Z_]/', $flag)) { + // XXX: 这句的写法可能还需要改进 + // 常量不需要解析 + if (defined($name)) { + return $name; + } + // 不以$开头并且也不是常量,自动补上$前缀 + $name = '$' . $name; + } + $this->tpl->parseVar($name); + $this->tpl->parseVarFunction($name); + return $name; + } + + /** + * 获取标签列表 + * @access public + * @return array + */ + // 获取标签定义 + public function getTags() + { + return $this->tags; + } +} diff --git a/thinkphp/library/think/template/driver/File.php b/thinkphp/library/think/template/driver/File.php new file mode 100644 index 0000000..a9a86bf --- /dev/null +++ b/thinkphp/library/think/template/driver/File.php @@ -0,0 +1,74 @@ + +// +---------------------------------------------------------------------- + +namespace think\template\driver; + +use think\Exception; + +class File +{ + protected $cacheFile; + + /** + * 写入编译缓存 + * @param string $cacheFile 缓存的文件名 + * @param string $content 缓存的内容 + * @return void|array + */ + public function write($cacheFile, $content) + { + // 检测模板目录 + $dir = dirname($cacheFile); + if (!is_dir($dir)) { + mkdir($dir, 0755, true); + } + // 生成模板缓存文件 + if (false === file_put_contents($cacheFile, $content)) { + throw new Exception('cache write error:' . $cacheFile, 11602); + } + } + + /** + * 读取编译编译 + * @param string $cacheFile 缓存的文件名 + * @param array $vars 变量数组 + * @return void + */ + public function read($cacheFile, $vars = []) + { + $this->cacheFile = $cacheFile; + if (!empty($vars) && is_array($vars)) { + // 模板阵列变量分解成为独立变量 + extract($vars, EXTR_OVERWRITE); + } + //载入模版缓存文件 + include $this->cacheFile; + } + + /** + * 检查编译缓存是否有效 + * @param string $cacheFile 缓存的文件名 + * @param int $cacheTime 缓存时间 + * @return boolean + */ + public function check($cacheFile, $cacheTime) + { + // 缓存文件不存在, 直接返回false + if (!file_exists($cacheFile)) { + return false; + } + if (0 != $cacheTime && $_SERVER['REQUEST_TIME'] > filemtime($cacheFile) + $cacheTime) { + // 缓存是否在有效期 + return false; + } + return true; + } +} diff --git a/thinkphp/library/think/template/taglib/Cx.php b/thinkphp/library/think/template/taglib/Cx.php new file mode 100644 index 0000000..31e0698 --- /dev/null +++ b/thinkphp/library/think/template/taglib/Cx.php @@ -0,0 +1,673 @@ + +// +---------------------------------------------------------------------- + +namespace think\template\taglib; + +use think\template\TagLib; + +/** + * CX标签库解析类 + * @category Think + * @package Think + * @subpackage Driver.Taglib + * @author liu21st + */ +class Cx extends Taglib +{ + + // 标签定义 + protected $tags = [ + // 标签定义: attr 属性列表 close 是否闭合(0 或者1 默认1) alias 标签别名 level 嵌套层次 + 'php' => ['attr' => ''], + 'volist' => ['attr' => 'name,id,offset,length,key,mod', 'alias' => 'iterate'], + 'foreach' => ['attr' => 'name,id,item,key,offset,length,mod', 'expression' => true], + 'if' => ['attr' => 'condition', 'expression' => true], + 'elseif' => ['attr' => 'condition', 'close' => 0, 'expression' => true], + 'else' => ['attr' => '', 'close' => 0], + 'switch' => ['attr' => 'name', 'expression' => true], + 'case' => ['attr' => 'value,break', 'expression' => true], + 'default' => ['attr' => '', 'close' => 0], + 'compare' => ['attr' => 'name,value,type', 'alias' => ['eq,equal,notequal,neq,gt,lt,egt,elt,heq,nheq', 'type']], + 'range' => ['attr' => 'name,value,type', 'alias' => ['in,notin,between,notbetween', 'type']], + 'empty' => ['attr' => 'name'], + 'notempty' => ['attr' => 'name'], + 'present' => ['attr' => 'name'], + 'notpresent' => ['attr' => 'name'], + 'defined' => ['attr' => 'name'], + 'notdefined' => ['attr' => 'name'], + 'load' => ['attr' => 'file,href,type,value,basepath', 'close' => 0, 'alias' => ['import,css,js', 'type']], + 'assign' => ['attr' => 'name,value', 'close' => 0], + 'define' => ['attr' => 'name,value', 'close' => 0], + 'for' => ['attr' => 'start,end,name,comparison,step'], + 'url' => ['attr' => 'link,vars,suffix,domain', 'close' => 0, 'expression' => true], + 'function' => ['attr' => 'name,vars,use,call'], + ]; + + /** + * php标签解析 + * 格式: + * {php}echo $name{/php} + * @access public + * @param array $tag 标签属性 + * @param string $content 标签内容 + * @return string + */ + public function tagPhp($tag, $content) + { + $parseStr = ''; + return $parseStr; + } + + /** + * volist标签解析 循环输出数据集 + * 格式: + * {volist name="userList" id="user" empty=""} + * {user.username} + * {user.email} + * {/volist} + * @access public + * @param array $tag 标签属性 + * @param string $content 标签内容 + * @return string|void + */ + public function tagVolist($tag, $content) + { + $name = $tag['name']; + $id = $tag['id']; + $empty = isset($tag['empty']) ? $tag['empty'] : ''; + $key = !empty($tag['key']) ? $tag['key'] : 'i'; + $mod = isset($tag['mod']) ? $tag['mod'] : '2'; + $offset = !empty($tag['offset']) && is_numeric($tag['offset']) ? intval($tag['offset']) : 0; + $length = !empty($tag['length']) && is_numeric($tag['length']) ? intval($tag['length']) : 'null'; + // 允许使用函数设定数据集 {$vo.name} + $parseStr = 'autoBuildVar($name); + $parseStr .= '$_result=' . $name . ';'; + $name = '$_result'; + } else { + $name = $this->autoBuildVar($name); + } + + $parseStr .= 'if(is_array(' . $name . ') || ' . $name . ' instanceof \think\Collection || ' . $name . ' instanceof \think\Paginator): $' . $key . ' = 0;'; + // 设置了输出数组长度 + if (0 != $offset || 'null' != $length) { + $parseStr .= '$__LIST__ = is_array(' . $name . ') ? array_slice(' . $name . ',' . $offset . ',' . $length . ', true) : ' . $name . '->slice(' . $offset . ',' . $length . ', true); '; + } else { + $parseStr .= ' $__LIST__ = ' . $name . ';'; + } + $parseStr .= 'if( count($__LIST__)==0 ) : echo "' . $empty . '" ;'; + $parseStr .= 'else: '; + $parseStr .= 'foreach($__LIST__ as $key=>$' . $id . '): '; + $parseStr .= '$mod = ($' . $key . ' % ' . $mod . ' );'; + $parseStr .= '++$' . $key . ';?>'; + $parseStr .= $content; + $parseStr .= ''; + + if (!empty($parseStr)) { + return $parseStr; + } + return; + } + + /** + * foreach标签解析 循环输出数据集 + * 格式: + * {foreach name="userList" id="user" key="key" index="i" mod="2" offset="3" length="5" empty=""} + * {user.username} + * {/foreach} + * @access public + * @param array $tag 标签属性 + * @param string $content 标签内容 + * @return string|void + */ + public function tagForeach($tag, $content) + { + // 直接使用表达式 + if (!empty($tag['expression'])) { + $expression = ltrim(rtrim($tag['expression'], ')'), '('); + $expression = $this->autoBuildVar($expression); + $parseStr = ''; + $parseStr .= $content; + $parseStr .= ''; + return $parseStr; + } + $name = $tag['name']; + $key = !empty($tag['key']) ? $tag['key'] : 'key'; + $item = !empty($tag['id']) ? $tag['id'] : $tag['item']; + $empty = isset($tag['empty']) ? $tag['empty'] : ''; + $offset = !empty($tag['offset']) && is_numeric($tag['offset']) ? intval($tag['offset']) : 0; + $length = !empty($tag['length']) && is_numeric($tag['length']) ? intval($tag['length']) : 'null'; + + $parseStr = 'autoBuildVar($name); + $parseStr .= $var . '=' . $name . '; '; + $name = $var; + } else { + $name = $this->autoBuildVar($name); + } + $parseStr .= 'if(is_array(' . $name . ') || ' . $name . ' instanceof \think\Collection || ' . $name . ' instanceof \think\Paginator): '; + // 设置了输出数组长度 + if (0 != $offset || 'null' != $length) { + if (!isset($var)) { + $var = '$_' . uniqid(); + } + $parseStr .= $var . ' = is_array(' . $name . ') ? array_slice(' . $name . ',' . $offset . ',' . $length . ', true) : ' . $name . '->slice(' . $offset . ',' . $length . ', true); '; + } else { + $var = &$name; + } + + $parseStr .= 'if( count(' . $var . ')==0 ) : echo "' . $empty . '" ;'; + $parseStr .= 'else: '; + + // 设置了索引项 + if (isset($tag['index'])) { + $index = $tag['index']; + $parseStr .= '$' . $index . '=0; '; + } + $parseStr .= 'foreach(' . $var . ' as $' . $key . '=>$' . $item . '): '; + // 设置了索引项 + if (isset($tag['index'])) { + $index = $tag['index']; + if (isset($tag['mod'])) { + $mod = (int) $tag['mod']; + $parseStr .= '$mod = ($' . $index . ' % ' . $mod . '); '; + } + $parseStr .= '++$' . $index . '; '; + } + $parseStr .= '?>'; + // 循环体中的内容 + $parseStr .= $content; + $parseStr .= ''; + + if (!empty($parseStr)) { + return $parseStr; + } + return; + } + + /** + * if标签解析 + * 格式: + * {if condition=" $a eq 1"} + * {elseif condition="$a eq 2" /} + * {else /} + * {/if} + * 表达式支持 eq neq gt egt lt elt == > >= < <= or and || && + * @access public + * @param array $tag 标签属性 + * @param string $content 标签内容 + * @return string + */ + public function tagIf($tag, $content) + { + $condition = !empty($tag['expression']) ? $tag['expression'] : $tag['condition']; + $condition = $this->parseCondition($condition); + $parseStr = '' . $content . ''; + return $parseStr; + } + + /** + * elseif标签解析 + * 格式:见if标签 + * @access public + * @param array $tag 标签属性 + * @param string $content 标签内容 + * @return string + */ + public function tagElseif($tag, $content) + { + $condition = !empty($tag['expression']) ? $tag['expression'] : $tag['condition']; + $condition = $this->parseCondition($condition); + $parseStr = ''; + return $parseStr; + } + + /** + * else标签解析 + * 格式:见if标签 + * @access public + * @param array $tag 标签属性 + * @return string + */ + public function tagElse($tag) + { + $parseStr = ''; + return $parseStr; + } + + /** + * switch标签解析 + * 格式: + * {switch name="a.name"} + * {case value="1" break="false"}1{/case} + * {case value="2" }2{/case} + * {default /}other + * {/switch} + * @access public + * @param array $tag 标签属性 + * @param string $content 标签内容 + * @return string + */ + public function tagSwitch($tag, $content) + { + $name = !empty($tag['expression']) ? $tag['expression'] : $tag['name']; + $name = $this->autoBuildVar($name); + $parseStr = '' . $content . ''; + return $parseStr; + } + + /** + * case标签解析 需要配合switch才有效 + * @access public + * @param array $tag 标签属性 + * @param string $content 标签内容 + * @return string + */ + public function tagCase($tag, $content) + { + $value = isset($tag['expression']) ? $tag['expression'] : $tag['value']; + $flag = substr($value, 0, 1); + if ('$' == $flag || ':' == $flag) { + $value = $this->autoBuildVar($value); + $value = 'case ' . $value . ':'; + } elseif (strpos($value, '|')) { + $values = explode('|', $value); + $value = ''; + foreach ($values as $val) { + $value .= 'case "' . addslashes($val) . '":'; + } + } else { + $value = 'case "' . $value . '":'; + } + $parseStr = '' . $content; + $isBreak = isset($tag['break']) ? $tag['break'] : ''; + if ('' == $isBreak || $isBreak) { + $parseStr .= ''; + } + return $parseStr; + } + + /** + * default标签解析 需要配合switch才有效 + * 使用: {default /}ddfdf + * @access public + * @param array $tag 标签属性 + * @param string $content 标签内容 + * @return string + */ + public function tagDefault($tag) + { + $parseStr = ''; + return $parseStr; + } + + /** + * compare标签解析 + * 用于值的比较 支持 eq neq gt lt egt elt heq nheq 默认是eq + * 格式: {compare name="" type="eq" value="" }content{/compare} + * @access public + * @param array $tag 标签属性 + * @param string $content 标签内容 + * @return string + */ + public function tagCompare($tag, $content) + { + $name = $tag['name']; + $value = $tag['value']; + $type = isset($tag['type']) ? $tag['type'] : 'eq'; // 比较类型 + $name = $this->autoBuildVar($name); + $flag = substr($value, 0, 1); + if ('$' == $flag || ':' == $flag) { + $value = $this->autoBuildVar($value); + } else { + $value = '\'' . $value . '\''; + } + switch ($type) { + case 'equal': + $type = 'eq'; + break; + case 'notequal': + $type = 'neq'; + break; + } + $type = $this->parseCondition(' ' . $type . ' '); + $parseStr = '' . $content . ''; + return $parseStr; + } + + /** + * range标签解析 + * 如果某个变量存在于某个范围 则输出内容 type= in 表示在范围内 否则表示在范围外 + * 格式: {range name="var|function" value="val" type='in|notin' }content{/range} + * example: {range name="a" value="1,2,3" type='in' }content{/range} + * @access public + * @param array $tag 标签属性 + * @param string $content 标签内容 + * @return string + */ + public function tagRange($tag, $content) + { + $name = $tag['name']; + $value = $tag['value']; + $type = isset($tag['type']) ? $tag['type'] : 'in'; // 比较类型 + + $name = $this->autoBuildVar($name); + $flag = substr($value, 0, 1); + if ('$' == $flag || ':' == $flag) { + $value = $this->autoBuildVar($value); + $str = 'is_array(' . $value . ')?' . $value . ':explode(\',\',' . $value . ')'; + } else { + $value = '"' . $value . '"'; + $str = 'explode(\',\',' . $value . ')'; + } + if ('between' == $type) { + $parseStr = '= $_RANGE_VAR_[0] && ' . $name . '<= $_RANGE_VAR_[1]):?>' . $content . ''; + } elseif ('notbetween' == $type) { + $parseStr = '$_RANGE_VAR_[1]):?>' . $content . ''; + } else { + $fun = ('in' == $type) ? 'in_array' : '!in_array'; + $parseStr = '' . $content . ''; + } + return $parseStr; + } + + /** + * present标签解析 + * 如果某个变量已经设置 则输出内容 + * 格式: {present name="" }content{/present} + * @access public + * @param array $tag 标签属性 + * @param string $content 标签内容 + * @return string + */ + public function tagPresent($tag, $content) + { + $name = $tag['name']; + $name = $this->autoBuildVar($name); + $parseStr = '' . $content . ''; + return $parseStr; + } + + /** + * notpresent标签解析 + * 如果某个变量没有设置,则输出内容 + * 格式: {notpresent name="" }content{/notpresent} + * @access public + * @param array $tag 标签属性 + * @param string $content 标签内容 + * @return string + */ + public function tagNotpresent($tag, $content) + { + $name = $tag['name']; + $name = $this->autoBuildVar($name); + $parseStr = '' . $content . ''; + return $parseStr; + } + + /** + * empty标签解析 + * 如果某个变量为empty 则输出内容 + * 格式: {empty name="" }content{/empty} + * @access public + * @param array $tag 标签属性 + * @param string $content 标签内容 + * @return string + */ + public function tagEmpty($tag, $content) + { + $name = $tag['name']; + $name = $this->autoBuildVar($name); + $parseStr = 'isEmpty())): ?>' . $content . ''; + return $parseStr; + } + + /** + * notempty标签解析 + * 如果某个变量不为empty 则输出内容 + * 格式: {notempty name="" }content{/notempty} + * @access public + * @param array $tag 标签属性 + * @param string $content 标签内容 + * @return string + */ + public function tagNotempty($tag, $content) + { + $name = $tag['name']; + $name = $this->autoBuildVar($name); + $parseStr = 'isEmpty()))): ?>' . $content . ''; + return $parseStr; + } + + /** + * 判断是否已经定义了该常量 + * {defined name='TXT'}已定义{/defined} + * @param array $tag + * @param string $content + * @return string + */ + public function tagDefined($tag, $content) + { + $name = $tag['name']; + $parseStr = '' . $content . ''; + return $parseStr; + } + + /** + * 判断是否没有定义了该常量 + * {notdefined name='TXT'}已定义{/notdefined} + * @param array $tag + * @param string $content + * @return string + */ + public function tagNotdefined($tag, $content) + { + $name = $tag['name']; + $parseStr = '' . $content . ''; + return $parseStr; + } + + /** + * load 标签解析 {load file="/static/js/base.js" /} + * 格式:{load file="/static/css/base.css" /} + * @access public + * @param array $tag 标签属性 + * @param string $content 标签内容 + * @return string + */ + public function tagLoad($tag, $content) + { + $file = isset($tag['file']) ? $tag['file'] : $tag['href']; + $type = isset($tag['type']) ? strtolower($tag['type']) : ''; + $parseStr = ''; + $endStr = ''; + // 判断是否存在加载条件 允许使用函数判断(默认为isset) + if (isset($tag['value'])) { + $name = $tag['value']; + $name = $this->autoBuildVar($name); + $name = 'isset(' . $name . ')'; + $parseStr .= ''; + $endStr = ''; + } + + // 文件方式导入 + $array = explode(',', $file); + foreach ($array as $val) { + $type = strtolower(substr(strrchr($val, '.'), 1)); + switch ($type) { + case 'js': + $parseStr .= ''; + break; + case 'css': + $parseStr .= ''; + break; + case 'php': + $parseStr .= ''; + break; + } + } + return $parseStr . $endStr; + } + + /** + * assign标签解析 + * 在模板中给某个变量赋值 支持变量赋值 + * 格式: {assign name="" value="" /} + * @access public + * @param array $tag 标签属性 + * @param string $content 标签内容 + * @return string + */ + public function tagAssign($tag, $content) + { + $name = $this->autoBuildVar($tag['name']); + $flag = substr($tag['value'], 0, 1); + if ('$' == $flag || ':' == $flag) { + $value = $this->autoBuildVar($tag['value']); + } else { + $value = '\'' . $tag['value'] . '\''; + } + $parseStr = ''; + return $parseStr; + } + + /** + * define标签解析 + * 在模板中定义常量 支持变量赋值 + * 格式: {define name="" value="" /} + * @access public + * @param array $tag 标签属性 + * @param string $content 标签内容 + * @return string + */ + public function tagDefine($tag, $content) + { + $name = '\'' . $tag['name'] . '\''; + $flag = substr($tag['value'], 0, 1); + if ('$' == $flag || ':' == $flag) { + $value = $this->autoBuildVar($tag['value']); + } else { + $value = '\'' . $tag['value'] . '\''; + } + $parseStr = ''; + return $parseStr; + } + + /** + * for标签解析 + * 格式: + * {for start="" end="" comparison="" step="" name=""} + * content + * {/for} + * @access public + * @param array $tag 标签属性 + * @param string $content 标签内容 + * @return string + */ + public function tagFor($tag, $content) + { + //设置默认值 + $start = 0; + $end = 0; + $step = 1; + $comparison = 'lt'; + $name = 'i'; + $rand = rand(); //添加随机数,防止嵌套变量冲突 + //获取属性 + foreach ($tag as $key => $value) { + $value = trim($value); + $flag = substr($value, 0, 1); + if ('$' == $flag || ':' == $flag) { + $value = $this->autoBuildVar($value); + } + + switch ($key) { + case 'start': + $start = $value; + break; + case 'end': + $end = $value; + break; + case 'step': + $step = $value; + break; + case 'comparison': + $comparison = $value; + break; + case 'name': + $name = $value; + break; + } + } + + $parseStr = 'parseCondition('$' . $name . ' ' . $comparison . ' $__FOR_END_' . $rand . '__') . ';$' . $name . '+=' . $step . '){ ?>'; + $parseStr .= $content; + $parseStr .= ''; + return $parseStr; + } + + /** + * url函数的tag标签 + * 格式:{url link="模块/控制器/方法" vars="参数" suffix="true或者false 是否带有后缀" domain="true或者false 是否携带域名" /} + * @access public + * @param array $tag 标签属性 + * @param string $content 标签内容 + * @return string + */ + public function tagUrl($tag, $content) + { + $url = isset($tag['link']) ? $tag['link'] : ''; + $vars = isset($tag['vars']) ? $tag['vars'] : ''; + $suffix = isset($tag['suffix']) ? $tag['suffix'] : 'true'; + $domain = isset($tag['domain']) ? $tag['domain'] : 'false'; + return ''; + } + + /** + * function标签解析 匿名函数,可实现递归 + * 使用: + * {function name="func" vars="$data" call="$list" use="&$a,&$b"} + * {if is_array($data)} + * {foreach $data as $val} + * {~func($val) /} + * {/foreach} + * {else /} + * {$data} + * {/if} + * {/function} + * @access public + * @param array $tag 标签属性 + * @param string $content 标签内容 + * @return string + */ + public function tagFunction($tag, $content) + { + $name = !empty($tag['name']) ? $tag['name'] : 'func'; + $vars = !empty($tag['vars']) ? $tag['vars'] : ''; + $call = !empty($tag['call']) ? $tag['call'] : ''; + $use = ['&$' . $name]; + if (!empty($tag['use'])) { + foreach (explode(',', $tag['use']) as $val) { + $use[] = '&' . ltrim(trim($val), '&'); + } + } + $parseStr = '' . $content . '' : '?>'; + return $parseStr; + } +} diff --git a/thinkphp/library/think/view/driver/Php.php b/thinkphp/library/think/view/driver/Php.php new file mode 100644 index 0000000..f594a43 --- /dev/null +++ b/thinkphp/library/think/view/driver/Php.php @@ -0,0 +1,160 @@ + +// +---------------------------------------------------------------------- + +namespace think\view\driver; + +use think\App; +use think\exception\TemplateNotFoundException; +use think\Loader; +use think\Log; +use think\Request; + +class Php +{ + // 模板引擎参数 + protected $config = [ + // 视图基础目录(集中式) + 'view_base' => '', + // 模板起始路径 + 'view_path' => '', + // 模板文件后缀 + 'view_suffix' => 'php', + // 模板文件名分隔符 + 'view_depr' => DS, + // 默认模板渲染规则 1 解析为小写+下划线 2 全部转换小写 + 'auto_rule' => 1, + ]; + protected $template; + protected $content; + + public function __construct($config = []) + { + $this->config = array_merge($this->config, $config); + } + + /** + * 检测是否存在模板文件 + * @access public + * @param string $template 模板文件或者模板规则 + * @return bool + */ + public function exists($template) + { + if ('' == pathinfo($template, PATHINFO_EXTENSION)) { + // 获取模板文件名 + $template = $this->parseTemplate($template); + } + return is_file($template); + } + + /** + * 渲染模板文件 + * @access public + * @param string $template 模板文件 + * @param array $data 模板变量 + * @return void + */ + public function fetch($template, $data = []) + { + if ('' == pathinfo($template, PATHINFO_EXTENSION)) { + // 获取模板文件名 + $template = $this->parseTemplate($template); + } + // 模板不存在 抛出异常 + if (!is_file($template)) { + throw new TemplateNotFoundException('template not exists:' . $template, $template); + } + $this->template = $template; + // 记录视图信息 + App::$debug && Log::record('[ VIEW ] ' . $template . ' [ ' . var_export(array_keys($data), true) . ' ]', 'info'); + + extract($data, EXTR_OVERWRITE); + include $this->template; + } + + /** + * 渲染模板内容 + * @access public + * @param string $content 模板内容 + * @param array $data 模板变量 + * @return void + */ + public function display($content, $data = []) + { + $this->content = $content; + + extract($data, EXTR_OVERWRITE); + eval('?>' . $this->content); + } + + /** + * 自动定位模板文件 + * @access private + * @param string $template 模板文件规则 + * @return string + */ + private function parseTemplate($template) + { + if (empty($this->config['view_path'])) { + $this->config['view_path'] = App::$modulePath . 'view' . DS; + } + + $request = Request::instance(); + // 获取视图根目录 + if (strpos($template, '@')) { + // 跨模块调用 + list($module, $template) = explode('@', $template); + } + if ($this->config['view_base']) { + // 基础视图目录 + $module = isset($module) ? $module : $request->module(); + $path = $this->config['view_base'] . ($module ? $module . DS : ''); + } else { + $path = isset($module) ? APP_PATH . $module . DS . 'view' . DS : $this->config['view_path']; + } + + $depr = $this->config['view_depr']; + if (0 !== strpos($template, '/')) { + $template = str_replace(['/', ':'], $depr, $template); + $controller = Loader::parseName($request->controller()); + if ($controller) { + if ('' == $template) { + // 如果模板文件名为空 按照默认规则定位 + $template = str_replace('.', DS, $controller) . $depr . (1 == $this->config['auto_rule'] ? Loader::parseName($request->action(true)) : $request->action()); + } elseif (false === strpos($template, $depr)) { + $template = str_replace('.', DS, $controller) . $depr . $template; + } + } + } else { + $template = str_replace(['/', ':'], $depr, substr($template, 1)); + } + return $path . ltrim($template, '/') . '.' . ltrim($this->config['view_suffix'], '.'); + } + + /** + * 配置模板引擎 + * @access private + * @param string|array $name 参数名 + * @param mixed $value 参数值 + * @return void + */ + public function config($name, $value = null) + { + if (is_array($name)) { + $this->config = array_merge($this->config, $name); + } elseif (is_null($value)) { + return isset($this->config[$name]) ? $this->config[$name] : null; + } else { + $this->config[$name] = $value; + } + } + +} diff --git a/thinkphp/library/think/view/driver/Think.php b/thinkphp/library/think/view/driver/Think.php new file mode 100644 index 0000000..a314ad6 --- /dev/null +++ b/thinkphp/library/think/view/driver/Think.php @@ -0,0 +1,167 @@ + +// +---------------------------------------------------------------------- + +namespace think\view\driver; + +use think\App; +use think\exception\TemplateNotFoundException; +use think\Loader; +use think\Log; +use think\Request; +use think\Template; + +class Think +{ + // 模板引擎实例 + private $template; + // 模板引擎参数 + protected $config = [ + // 视图基础目录(集中式) + 'view_base' => '', + // 模板起始路径 + 'view_path' => '', + // 模板文件后缀 + 'view_suffix' => 'html', + // 模板文件名分隔符 + 'view_depr' => DS, + // 是否开启模板编译缓存,设为false则每次都会重新编译 + 'tpl_cache' => true, + // 默认模板渲染规则 1 解析为小写+下划线 2 全部转换小写 + 'auto_rule' => 1, + ]; + + public function __construct($config = []) + { + $this->config = array_merge($this->config, $config); + if (empty($this->config['view_path'])) { + $this->config['view_path'] = App::$modulePath . 'view' . DS; + } + + $this->template = new Template($this->config); + } + + /** + * 检测是否存在模板文件 + * @access public + * @param string $template 模板文件或者模板规则 + * @return bool + */ + public function exists($template) + { + if ('' == pathinfo($template, PATHINFO_EXTENSION)) { + // 获取模板文件名 + $template = $this->parseTemplate($template); + } + return is_file($template); + } + + /** + * 渲染模板文件 + * @access public + * @param string $template 模板文件 + * @param array $data 模板变量 + * @param array $config 模板参数 + * @return void + */ + public function fetch($template, $data = [], $config = []) + { + if ('' == pathinfo($template, PATHINFO_EXTENSION)) { + // 获取模板文件名 + $template = $this->parseTemplate($template); + } + // 模板不存在 抛出异常 + if (!is_file($template)) { + throw new TemplateNotFoundException('template not exists:' . $template, $template); + } + // 记录视图信息 + App::$debug && Log::record('[ VIEW ] ' . $template . ' [ ' . var_export(array_keys($data), true) . ' ]', 'info'); + $this->template->fetch($template, $data, $config); + } + + /** + * 渲染模板内容 + * @access public + * @param string $template 模板内容 + * @param array $data 模板变量 + * @param array $config 模板参数 + * @return void + */ + public function display($template, $data = [], $config = []) + { + $this->template->display($template, $data, $config); + } + + /** + * 自动定位模板文件 + * @access private + * @param string $template 模板文件规则 + * @return string + */ + private function parseTemplate($template) + { + // 分析模板文件规则 + $request = Request::instance(); + // 获取视图根目录 + if (strpos($template, '@')) { + // 跨模块调用 + list($module, $template) = explode('@', $template); + } + if ($this->config['view_base']) { + // 基础视图目录 + $module = isset($module) ? $module : $request->module(); + $path = $this->config['view_base'] . ($module ? $module . DS : ''); + } else { + $path = isset($module) ? APP_PATH . $module . DS . 'view' . DS : $this->config['view_path']; + } + + $depr = $this->config['view_depr']; + if (0 !== strpos($template, '/')) { + $template = str_replace(['/', ':'], $depr, $template); + $controller = Loader::parseName($request->controller()); + if ($controller) { + if ('' == $template) { + // 如果模板文件名为空 按照默认规则定位 + $template = str_replace('.', DS, $controller) . $depr . (1 == $this->config['auto_rule'] ? Loader::parseName($request->action(true)) : $request->action()); + } elseif (false === strpos($template, $depr)) { + $template = str_replace('.', DS, $controller) . $depr . $template; + } + } + } else { + $template = str_replace(['/', ':'], $depr, substr($template, 1)); + } + return $path . ltrim($template, '/') . '.' . ltrim($this->config['view_suffix'], '.'); + } + + /** + * 配置或者获取模板引擎参数 + * @access private + * @param string|array $name 参数名 + * @param mixed $value 参数值 + * @return mixed + */ + public function config($name, $value = null) + { + if (is_array($name)) { + $this->template->config($name); + $this->config = array_merge($this->config, $name); + } elseif (is_null($value)) { + return $this->template->config($name); + } else { + $this->template->$name = $value; + $this->config[$name] = $value; + } + } + + public function __call($method, $params) + { + return call_user_func_array([$this->template, $method], $params); + } +} diff --git a/thinkphp/library/traits/controller/Jump.php b/thinkphp/library/traits/controller/Jump.php new file mode 100644 index 0000000..019b520 --- /dev/null +++ b/thinkphp/library/traits/controller/Jump.php @@ -0,0 +1,167 @@ +error(); + * $this->redirect(); + * } + * } + */ +namespace traits\controller; + +use think\Config; +use think\exception\HttpResponseException; +use think\Request; +use think\Response; +use think\response\Redirect; +use think\Url; +use think\View as ViewTemplate; + +trait Jump +{ + /** + * 操作成功跳转的快捷方法 + * @access protected + * @param mixed $msg 提示信息 + * @param string $url 跳转的 URL 地址 + * @param mixed $data 返回的数据 + * @param int $wait 跳转等待时间 + * @param array $header 发送的 Header 信息 + * @return void + * @throws HttpResponseException + */ + protected function success($msg = '', $url = null, $data = '', $wait = 3, array $header = []) + { + if (is_null($url) && !is_null(Request::instance()->server('HTTP_REFERER'))) { + $url = Request::instance()->server('HTTP_REFERER'); + } elseif ('' !== $url && !strpos($url ?? '', '://') && 0 !== strpos($url ?? '', '/')) { + $url = Url::build($url ?? ''); + } + + $type = $this->getResponseType(); + $result = [ + 'code' => 1, + 'msg' => $msg, + 'data' => $data, + 'url' => $url, + 'wait' => $wait, + ]; + + if ('html' == strtolower($type)) { + $template = Config::get('template'); + $view = Config::get('view_replace_str'); + + $result = ViewTemplate::instance($template, $view) + ->fetch(Config::get('dispatch_success_tmpl'), $result); + } + + $response = Response::create($result, $type)->header($header); + + throw new HttpResponseException($response); + } + + /** + * 操作错误跳转的快捷方法 + * @access protected + * @param mixed $msg 提示信息 + * @param string $url 跳转的 URL 地址 + * @param mixed $data 返回的数据 + * @param int $wait 跳转等待时间 + * @param array $header 发送的 Header 信息 + * @return void + * @throws HttpResponseException + */ + protected function error($msg = '', $url = null, $data = '', $wait = 3, array $header = []) + { + if (is_null($url)) { + $url = Request::instance()->isAjax() ? '' : 'javascript:history.back(-1);'; + } elseif ('' !== $url && !strpos($url, '://') && 0 !== strpos($url, '/')) { + $url = Url::build($url); + } + + $type = $this->getResponseType(); + $result = [ + 'code' => 0, + 'msg' => $msg, + 'data' => $data, + 'url' => $url, + 'wait' => $wait, + ]; + + if ('html' == strtolower($type)) { + $template = Config::get('template'); + $view = Config::get('view_replace_str'); + + $result = ViewTemplate::instance($template, $view) + ->fetch(Config::get('dispatch_error_tmpl'), $result); + } + + $response = Response::create($result, $type)->header($header); + + throw new HttpResponseException($response); + } + + /** + * 返回封装后的 API 数据到客户端 + * @access protected + * @param mixed $data 要返回的数据 + * @param int $code 返回的 code + * @param mixed $msg 提示信息 + * @param string $type 返回数据格式 + * @param array $header 发送的 Header 信息 + * @return void + * @throws HttpResponseException + */ + protected function result($data, $code = 0, $msg = '', $type = '', array $header = []) + { + $result = [ + 'code' => $code, + 'msg' => $msg, + 'time' => Request::instance()->server('REQUEST_TIME'), + 'data' => $data, + ]; + $type = $type ?: $this->getResponseType(); + $response = Response::create($result, $type)->header($header); + + throw new HttpResponseException($response); + } + + /** + * URL 重定向 + * @access protected + * @param string $url 跳转的 URL 表达式 + * @param array|int $params 其它 URL 参数 + * @param int $code http code + * @param array $with 隐式传参 + * @return void + * @throws HttpResponseException + */ + protected function redirect($url, $params = [], $code = 302, $with = []) + { + if (is_integer($params)) { + $code = $params; + $params = []; + } + + $response = new Redirect($url); + $response->code($code)->params($params)->with($with); + + throw new HttpResponseException($response); + } + + /** + * 获取当前的 response 输出类型 + * @access protected + * @return string + */ + protected function getResponseType() + { + return Request::instance()->isAjax() + ? Config::get('default_ajax_return') + : Config::get('default_return_type'); + } +} diff --git a/thinkphp/library/traits/model/SoftDelete.php b/thinkphp/library/traits/model/SoftDelete.php new file mode 100644 index 0000000..70f31ba --- /dev/null +++ b/thinkphp/library/traits/model/SoftDelete.php @@ -0,0 +1,200 @@ +getDeleteTimeField(); + + if ($field && !empty($this->data[$field])) { + return true; + } + return false; + } + + /** + * 查询包含软删除的数据 + * @access public + * @return Query + */ + public static function withTrashed() + { + return (new static )->getQuery(); + } + + /** + * 只查询软删除数据 + * @access public + * @return Query + */ + public static function onlyTrashed() + { + $model = new static(); + $field = $model->getDeleteTimeField(true); + + if ($field) { + return $model->getQuery()->useSoftDelete($field, ['not null', '']); + } else { + return $model->getQuery(); + } + } + + /** + * 删除当前的记录 + * @access public + * @param bool $force 是否强制删除 + * @return integer + */ + public function delete($force = false) + { + if (false === $this->trigger('before_delete', $this)) { + return false; + } + + $name = $this->getDeleteTimeField(); + if ($name && !$force) { + // 软删除 + $this->data[$name] = $this->autoWriteTimestamp($name); + $result = $this->isUpdate()->save(); + } else { + // 强制删除当前模型数据 + $result = $this->getQuery()->where($this->getWhere())->delete(); + } + + // 关联删除 + if (!empty($this->relationWrite)) { + foreach ($this->relationWrite as $key => $name) { + $name = is_numeric($key) ? $name : $key; + $result = $this->getRelation($name); + if ($result instanceof Model) { + $result->delete(); + } elseif ($result instanceof Collection || is_array($result)) { + foreach ($result as $model) { + $model->delete(); + } + } + } + } + + $this->trigger('after_delete', $this); + + // 清空原始数据 + $this->origin = []; + + return $result; + } + + /** + * 删除记录 + * @access public + * @param mixed $data 主键列表(支持闭包查询条件) + * @param bool $force 是否强制删除 + * @return integer 成功删除的记录数 + */ + public static function destroy($data, $force = false) + { + if (is_null($data)) { + return 0; + } + + // 包含软删除数据 + $query = (new static())->db(false); + if (is_array($data) && key($data) !== 0) { + $query->where($data); + $data = null; + } elseif ($data instanceof \Closure) { + call_user_func_array($data, [ & $query]); + $data = null; + } + + $count = 0; + if ($resultSet = $query->select($data)) { + foreach ($resultSet as $data) { + $result = $data->delete($force); + $count += $result; + } + } + + return $count; + } + + /** + * 恢复被软删除的记录 + * @access public + * @param array $where 更新条件 + * @return integer + */ + public function restore($where = []) + { + if (empty($where)) { + $pk = $this->getPk(); + $where[$pk] = $this->getData($pk); + } + + $name = $this->getDeleteTimeField(); + + if ($name) { + // 恢复删除 + return $this->getQuery() + ->useSoftDelete($name, ['not null', '']) + ->where($where) + ->update([$name => null]); + } else { + return 0; + } + } + + /** + * 查询默认不包含软删除数据 + * @access protected + * @param Query $query 查询对象 + * @return Query + */ + protected function base($query) + { + $field = $this->getDeleteTimeField(true); + return $field ? $query->useSoftDelete($field) : $query; + } + + /** + * 获取软删除字段 + * @access public + * @param bool $read 是否查询操作(写操作的时候会自动去掉表别名) + * @return string + */ + protected function getDeleteTimeField($read = false) + { + $field = property_exists($this, 'deleteTime') && isset($this->deleteTime) ? + $this->deleteTime : + 'delete_time'; + + if (false === $field) { + return false; + } + + if (!strpos($field, '.')) { + $field = '__TABLE__.' . $field; + } + + if (!$read && strpos($field, '.')) { + $array = explode('.', $field); + $field = array_pop($array); + } + + return $field; + } +} diff --git a/thinkphp/library/traits/think/Instance.php b/thinkphp/library/traits/think/Instance.php new file mode 100644 index 0000000..428c8fd --- /dev/null +++ b/thinkphp/library/traits/think/Instance.php @@ -0,0 +1,54 @@ + +// +---------------------------------------------------------------------- + +namespace traits\think; + +use think\Exception; + +trait Instance +{ + /** + * @var null|static 实例对象 + */ + protected static $instance = null; + + /** + * 获取示例 + * @param array $options 实例配置 + * @return static + */ + public static function instance($options = []) + { + if (is_null(self::$instance)) self::$instance = new self($options); + + return self::$instance; + } + + /** + * 静态调用 + * @param string $method 调用方法 + * @param array $params 调用参数 + * @return mixed + * @throws Exception + */ + public static function __callStatic($method, array $params) + { + if (is_null(self::$instance)) self::$instance = new self(); + + $call = substr($method, 1); + + if (0 !== strpos($method, '_') || !is_callable([self::$instance, $call])) { + throw new Exception("method not exists:" . $method); + } + + return call_user_func_array([self::$instance, $call], $params); + } +} diff --git a/thinkphp/logo.png b/thinkphp/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..25fd0593688de5c9f4cd321da1a72ab9566fe331 GIT binary patch literal 6995 zcmV-Z8?5AsP)KLZ*U+5Lu!Sk^o_Z5E4Meg@_7P6crJiNL9pw)e1;Xm069{HJUZAPk55R%$-RIA z6-eL&AQ0xu!e<4=008gy@A0LT~suv4>S3ILP<0Bm`DLLvaF4FK%)Nj?Pt*r}7;7Xa9z9H|HZjR63e zC`Tj$K)V27Re@400>HumpsYY5E(E}?0f1SyGDiY{y#)Yvj#!WnKwtoXnL;eg03bL5 z07D)V%>y7z1E4U{zu>7~aD})?0RX_umCct+(lZpemCzb@^6=o|A>zVpu|i=NDG+7} zl4`aK{0#b-!z=TL9Wt0BGO&T{GJWpjryhdijfaIQ&2!o}p04JRKYg3k&Tf zVxhe-O!X z{f;To;xw^bEES6JSc$k$B2CA6xl)ltA<32E66t?3@gJ7`36pmX0IY^jz)rRYwaaY4 ze(nJRiw;=Qb^t(r^DT@T3y}a2XEZW-_W%Hszxj_qD**t_m!#tW0KDiJT&R>6OvVTR z07RgHDzHHZ48atvzz&?j9lXF70$~P3Knx_nJP<+#`N z#-MZ2bTkiLfR>_b(HgWKJ%F~Nr_oF3b#wrIijHG|(J>BYjM-sajE6;FiC7vY#};Gd zST$CUHDeuEH+B^pz@B062qXfFfD`NpUW5?BY=V%GM_5c)L#QR}BeW8_2v-S%gfYS= zB9o|3v?Y2H`NVi)In3rTB8+ej^> zQ=~r95NVuDChL%G$=>7$vVg20myx%S50Foi`^m%Pw-h?Xh~i8Mq9jtJloCocWk2Nv zrJpiFnV_ms&8eQ$2&#xWpIS+6pmtC%Q-`S&GF4Q#^mhymh7E(qNMa}%YZ-ePrx>>xFPTiH1=E+A$W$=bG8>s^ zm=Bn5Rah$aDtr}@$`X}2l~$F0mFKEdRdZE8)p@E5RI61Ft6o-prbbn>P~)iy)E2AN zsU20jsWz_8Qg>31P|s0cqrPALg8E|(vWA65poU1JRAaZs8I2(p#xiB`SVGovRs-uS zYnV-9TeA7=Om+qP8+I>yOjAR1s%ETak!GFdam@h^# z)@rS0t$wXH+Irf)+G6c;?H29p+V6F6oj{!|o%K3xI`?%6x;DB|x`n#ibhIR?(H}Q3Gzd138Ei2)WAMz7W9Vy`X}HnwgyEn!VS)>mv$8&{hQn>w4zwy3R}t;BYlZQm5)6pty=DfLrs+A-|>>;~;Q z_F?uV_HFjh9n2gO9o9Q^JA86v({H5aB!kjoO6 zc9$1ZZKsN-Zl8L~mE{`ly3)1N^`o1+o7}D0ZPeY&J;i;i`%NyJ8_8Y6J?}yE@b_5a zam?eLr<8@mESk|3$_SkmS{wQ>%qC18))9_|&j{ZT zes8AvOzF(F2#DZEY>2oYX&IRp`F#{ADl)1r>QS^)ba8a|EY_^#S^HO&t^Rgqwv=MZThqqEWH8 zxJo>d=ABlR_Bh=;eM9Tw|Ih34~oTE|= zX_mAr*D$vzw@+p(E0Yc6dFE}(8oqt`+R{gE3x4zjX+Sb3_cYE^= zgB=w+-tUy`ytONMS8KgRef4hA?t0j zufM;t32jm~jUGrkaOInTZ`zyfns>EuS}G30LFK_G-==(f<51|K&cocp&EJ`SxAh3? zNO>#LI=^+SEu(FqJ)ynt=!~PC9bO$rzPJB=?=j6w@a-(u02P7 zaQ)#(uUl{HW%tYNS3ItC^iAtK(eKlL`f9+{bJzISE?u8_z3;~C8@FyI-5j_jy7l;W z_U#vU3hqqYU3!mrul&B+{ptt$59)uk{;_4iZQ%G|z+lhASr6|H35TBkl>gI*;nGLU zN7W-nBaM%pA0HbH8olyl&XeJ%vZoWz%6?Y=dFykl=imL}`%BMQ{Mhgd`HRoLu6e2R za__6DuR6yg#~-}Tc|Gx_{H@O0eebyMy5GmWADJlpK>kqk(fVV@r_fLLKIeS?{4e)} z^ZO;zpECde03c&XQcVB=dL;k=fP(-4`Tqa_faw4Lbua(`>RI+y?e7jKeZ#YO-C z5P(TUK~#9!?3{UYROQ`(pS#SOWU`Z$BxDa^-w_0qRROJ_;)fy#YSH7?R(p-EbfAWiV7kMvdB&nAVk8FL`WvH-R=7$piE{anUI+fzQgaoxpU{e z?>zT?fBU_{y(@BL2)I=z*^UwhrBB4Gy1NZP^@0FsfM9?m zni!jV17^vBVHn-U3SSTeCDDXMvXbQ}q9l1ZKFxCxV26x|C7C!&G6175J~lZPfZnN>kQrBS-YxP4wF1jhNB;QPBv~1dJ^|$-!0_NXtSR(MALn;`VETA$ z^7(aXE(m~L%}u|waU@wY{ElZiiph2qqiV`UfT35Pj!ll`@?JLub*@WOMxYuO0frQh z+RW&jnPkNk1^vD_c_=2)f`M@nU~5q{FPU)#Tv2#?$aAtCB_vpTpzGR2fUOOOAc)NB z^B^(i_>kw>O%Bpx^U%)IHtv=H4Gg@Ri|HkIQkF8Z-SabJ3(?P0nyXs^^e9fo42dL=^itc4<@j~YGe*{@Hcl=KXB7)F%YR0E| zC`jth!1M`tHTVAyfIiKQMYeNu|3|s1%ujjLW)#gE8lurskdj3+!)iSOO%F;6rfMmMxJ)Pzb#T)~f@M`T}3q>QoLm63&4b&(U_o1c~4M|tX~ zh>d;d)Q)z~DNg>WTctd86lt-&sB_hH$l9Nm6=-1KQJaxPGgFK2;8&Nt6j69y%}v!0 z+d>*2-Oz})rc#ErqI!0Q+o=WM*922j;~sJcRa;sCBFyp_IbW21JH)>SV@50Q~J z(6LG}T$VRG;JcpjWu(RCanxCLPOei_0BX95Pxp`!o6m&&xs1rZs?$2Az16qt_&Usz zErfgH;?kUJ$#w+xhnhq)g-L@r+_>lb1Jn%-ujVGnmciKES&YfO9=pjARo$xUKHlE@ zESjMqVG8oSLZUT|D~lF}9HS_C2%jBV(&8wd<2LRTKm!A>>LSJz&zRin8J~YMiPo;^ zko#c&3sf|0`LWE|dS0sT;B{v;e$%hp$VwHl&%xZ&pqf0*>z$)uWf(ibo?9Wg}GHHy;Cn?X7Bsk|MQ}ml$dO48uuZKQPzPi+qIcQ zTLx1KZ)J4PnMk7CrSP^L{e+jdJ%plrgDQTH+Dwk4jQIl}#}dM@w3ZZmPjt?`o+5|4 z>U2Y8c-C~TF1?2&TSk}1&z~N6oj3RV72VK7!pnA)uyE)zI4mh)kLxfeb*js&U4UNI zg~OV{jIv)aJZpNFgLA7+R_uC;b=Au;NtU2)ky~++o6wtuL;i;(TV{vGx0@V@f*2iu zZq-R);y~u~e}wedUR@4vf5T>$?tFqnr*>kMV*(-u0|U3>q)(60%p34W9H%?CIwF!F z1&u^>Lu<24&@Mo?;$%?fB8K5GA{21uIv3k z$WSgEA2txGOp+~~I@kB@LX<=OfgxE_m^a{$m^$I5pNo83yPEg+KSxdDUMx}!<{)6a znj5QR=eoWRFeZ0ar>@tmoI+~_(W|*APaVy7$3LgueFRC6!w2ZqT$CgaV{ZRPyA)pa zsokusc!6z4KS4mmCdUO?Ejk{xnf%25%i2NS_%hPc=&j?U%9mJQy#lxD#3I{+>Lj1$Mi$LnQFI$u7T(_B z!c!=zZK?>^rUC*kAe&t502OzPI*pH>#Pc}>;^hkIfhts0z)&eV9kM7 zLasvj>`Y3EJ)28<{w(V7wjW!|2m7Dr;K}chMGH1lY|!oM)m$W5)0t2(kFmM4BA(gV zQ@@c$&j~E8Zk&MlV@y9PX9nvJufQ<$pplRK)4umok}@o+S(I9574PqRj&EyM17Ho2 z2=J;dta3{pZ&JZ6QFGkCu6Zv2ieVU-B^#NJmUg<#xI#)(MzHPZCqdPQ{1bJ^OXw4| z?fP-mt9*Rm6`a14ZR$BukQkUgo+*X5k(*E+wVS!O{%iKue;wfdXofVc2GpS$!eR_KC1jDislKb z=hV|(2|123Cgk7Du&inAb{Iq?u0Hr0d+WXqxS0km+jm&@G{56EIhL~2k*qzqqz!-u zGV7VDZ-9py*yqq9tHknB_n{lw=@RF{poO03!mHxBP51DFyB4!#r*&(BS8Zl|{+y7}O^i8# zp7CXDJN7A(6a=6wnmOFKo0`VG^mLSVc!KZm|2yyPdk$GNVUjF?EZO|xN=;YL43$fBuI1{Idx*1i{aaMNs(F{CyZ($@aR!B_87d~p z%b-zSr3<=fhim{PcaSaV`n6I`+TX+Erc5t}K_Z|nOs4>6{A zt}Va+yd+{>N+WOYd6qA#mmvxAX`^8TglwwjV|KsaQWQprm~79+Zi>UFd4F6eer~uV z$~3r-@Xe8xVNG&X#UfT$F2*MN!}F>x(qnsZ_wc`;7kE35uj8o=x3KomzcERcptYMb zs^!X}+qpF7+OWorx1?Y*IWW#je+7&zi6*{0{3fGwW(HWQvt`qfmAtd}ZZ?H0GdP#HH~}OaqM#jW=sqj)4s9uaYRA#bH06=n~b;u77lra1Z$5j1E(7r>kq%l zs)|L_xoWUV_K=AO-O%xAE+!W)U`E+5I&>XT5V4!${Ccc|rdkCAzNlUn6rg6Pys_g? zG`xTQ4ZaK#*3T{jYq`|GM+B@v7+Ym5OMe{Jd_zrU8%ew^Jk){e(R{Vo4wX4xj-@LZO ztGTh89Nf_7zZsf&MJKKt20#G;RaaPh;NN}#J!&(nD_;(%%c{CUdTcMogNsgXR-kXI2bDXH4EK zW|aN1&FvkIcr`aoz6QjzoR^RQTO8|V)>OU9ya9gzV9U|f2(7w;4Gd(_OmXs%sKGmM zayxJDd6qqO8<9m5wsy*_#_8fykJvn}DZP(DA&g;1rQY>DPHzLED7O#r%qrY+bPbc6 z=96O2;_#_G$dbABY_Z68lI@Xy0g_vF@?pgyK0WX{KHbxEi<7SoFFBtC-4 ziUTLN<5rveR(_iR1wlN$3SZ{R;)OITr~H;LfR2tuvPHa#x37K^OLzX6LyfzzO7?cs zU1z$+3X=vgt@zHUbdBve{sls-oN2qgF&4?rmZNJ(kITm_Spy!E5)koe9@GeQyr0>A zD=QYUs$vnU?!zv}wUfA2@u_Zl#O5+Fe;%W9X0%xdKUb-BRfxm4Sf`6WCq2hmvf~eIsa=Cbwg*jmp6w8OH5U#`G86LWa(S;C zi8DtpS@GGyCAgKQ05uZUtr7(Zx6*hzfEEH=9z}OkeQFo^i384gf`?A+WbxMDaHOfC zO(XGB)y~eCoa>lSFqgELyr{ZP)s4IPs^;CGJ%?eh^|tCIq9C#B#0JI%d7K~|*?w#- zuWtJ-&C01ZT@9b+Mi3+hWlUsJ!ThLI5nJolq1T z@6c~Ie*Yf-+Ws(xp@%d?ita<#Rf>`aGo|o0dZ%8}WufA`d;i9s`i-G(Y-DsV9a+V=ytZTF{SBLW?YrNf{+<66G+jl}z4T2R%QdCAJy|3W|cn}vBt^p-4q|69C(dY6^rnw&bHjBoxo$j zlGbia9T9w!ulcNG?AcF=H!G+3uwqd_Z;7g_Oe~nk%(DBteAONJVLQurKgIrr&7tCX lAFv5{16U3OylCP71_0o>R4vh7BrN~{002ovPDHLkV1liRoDKj0 literal 0 HcmV?d00001 diff --git a/thinkphp/phpunit.xml b/thinkphp/phpunit.xml new file mode 100644 index 0000000..7c6ef03 --- /dev/null +++ b/thinkphp/phpunit.xml @@ -0,0 +1,35 @@ + + + + + ./tests/thinkphp/ + + + + + + + + ./ + + tests + vendor + + + + + + + + + + diff --git a/thinkphp/start.php b/thinkphp/start.php new file mode 100644 index 0000000..adb1bc6 --- /dev/null +++ b/thinkphp/start.php @@ -0,0 +1,19 @@ + +// +---------------------------------------------------------------------- + +namespace think; + +// ThinkPHP 引导文件 +// 1. 加载基础文件 +require __DIR__ . '/base.php'; + +// 2. 执行应用 +App::run()->send(); diff --git a/thinkphp/tests/.gitignore b/thinkphp/tests/.gitignore new file mode 100644 index 0000000..a0306ec --- /dev/null +++ b/thinkphp/tests/.gitignore @@ -0,0 +1,4 @@ +/runtime/ +/application/common.php +/application/demo/ +/application/runtime/ \ No newline at end of file diff --git a/thinkphp/tests/README.md b/thinkphp/tests/README.md new file mode 100644 index 0000000..0c1d086 --- /dev/null +++ b/thinkphp/tests/README.md @@ -0,0 +1,132 @@ +## 测试目录结构 + +测试文件主要在 tests 文件下面,主要有以下几个文件夹 + +- conf 测试环境配置文件。 +- script 测试环境配置脚本。 +- thinkphp 测试用例和相关文件,与项目文件夹结构一致。 +- mock.php 测试入口文件。 + +## 主要测试流程 + +thinkphp5 的测试的主要流程是跟 thinkphp 的系统流程是相似的,大体的流程为: + +1. 引用 mock.php 文件加载框架 + +2. 根据文件目录,添加测试文件 + +3. 执行单元测试,输出结果 + +## 测试举例 + +例如测试 thinkphp 里的 apc 缓存,将分为以下几个过程: + +1. 创建 apcTest.php 文件 + +该文件应与 apc.php 目录路径 `thinkphp/library/think/cache/driver` 一致,命名空间与目录所在一致,并引用 `PHPUnit_Framework_TestCase`。 + + ```php + markTestSkipped('apc扩展不可用!'); + }; + ``` + + - 编写测试用例 + + *具体写法参照 [PHPUnit 官方文档](https://phpunit.de/manual/4.8/zh_cn/index.html)* + + ```php + public function testGet() + { + App::run(); + $this->assertInstanceOf( + '\think\cache\driver\Apc', + Cache::connect(['type' => 'apc', 'expire' => 1]) + ); + $this->assertTrue(Cache::set('key', 'value')); + $this->assertEquals('value', Cache::get('key')); + $this->assertTrue(Cache::rm('key')); + $this->assertFalse(Cache::get('key')); + $this->assertTrue(Cache::clear('key')); + Config::reset(); + } + ``` + +3. 执行单元测试命令 + + 在项目根目录执行 + + ```bash + $ phpunit + ``` + + 若想看到所有结果,请添加-v参数 + + ```bash + $ phpunit -v + ``` + +4. 输出结果 + +## 相关文档 + +[各个部分单元测试说明](http://www.kancloud.cn/brother_simon/tp5_test/96971 "各部分单元测试说明") + +## 大家一起来 + +单元测试的内容会跟框架同步,测试内容方方面面,是一个相对复杂的模块,同时也是一个值得重视的部分。希望大家能够多多提出意见,多多参与。如果你有任何问题或想法,可以随时提 issue,我们期待着收到听大家的质疑和讨论。 + +## 任务进度 + +单元测试任务进度,请大家认领模块 + +|模块|认领人|进度| +|---|---|---| +|Base||| +|App|Haotong Lin|√| +|Build|刘志淳|| +|Config|Haotong Lin|√| +|Cache||| +|Controller|Haotong Lin|√| +|Cookie|Haotong Lin|√| +|Db||| +|Debug|大漠|√| +|Error|大漠|| +|Exception|Haotong Lin|√| +|Hook|流年|√| +|Input|Haotong Lin|√| +|Lang|流年|√| +|Loader|流年|| +|Log||| +|Model||| +|Response|大漠|√| +|Route|流年|| +|Session|大漠|√| +|Template|oldrind|| +|Url|流年|| +|View|mahuan|| diff --git a/thinkphp/tests/application/config.php b/thinkphp/tests/application/config.php new file mode 100644 index 0000000..d94a864 --- /dev/null +++ b/thinkphp/tests/application/config.php @@ -0,0 +1,33 @@ + +// +---------------------------------------------------------------------- +// $Id$ + +return [ + 'url_route_on' => true, + 'log' => [ + 'type' => 'file', // 支持 socket trace file + ], + 'view' => [ + // 模板引擎 + 'engine_type' => 'think', + // 模板引擎配置 + 'engine_config' => [ + // 模板路径 + 'view_path' => '', + // 模板后缀 + 'view_suffix' => '.html', + // 模板文件名分隔符 + 'view_depr' => DS, + ], + // 输出字符串替换 + 'parse_str' => [], + ], +]; diff --git a/thinkphp/tests/application/database.php b/thinkphp/tests/application/database.php new file mode 100644 index 0000000..24434ef --- /dev/null +++ b/thinkphp/tests/application/database.php @@ -0,0 +1,44 @@ + +// +---------------------------------------------------------------------- +// $Id$ + +return [ + // 数据库类型 + 'type' => 'mysql', + // 数据库连接DSN配置 + 'dsn' => '', + // 服务器地址 + 'hostname' => '127.0.0.1', + // 数据库名 + 'database' => '', + // 数据库用户名 + 'username' => 'root', + // 数据库密码 + 'password' => '', + // 数据库连接端口 + 'hostport' => '', + // 数据库连接参数 + 'params' => [], + // 数据库编码默认采用utf8 + 'charset' => 'utf8', + // 数据库表前缀 + 'prefix' => '', + // 数据库调试模式 + 'debug' => true, + // 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器) + 'deploy' => 0, + // 数据库读写是否分离 主从式有效 + 'rw_separate' => false, + // 读写分离后 主服务器数量 + 'master_num' => 1, + // 指定从服务器序号 + 'slave_no' => '', +]; diff --git a/thinkphp/tests/application/index/controller/Index.php b/thinkphp/tests/application/index/controller/Index.php new file mode 100644 index 0000000..803fe95 --- /dev/null +++ b/thinkphp/tests/application/index/controller/Index.php @@ -0,0 +1,10 @@ +*{ padding: 0; margin: 0; } div{ padding: 4px 48px;} a{color:#2E5CD5;cursor: pointer;text-decoration: none} a:hover{text-decoration:underline; } body{ background: #fff; font-family: "Century Gothic","Microsoft yahei"; color: #333;font-size:18px} h1{ font-size: 100px; font-weight: normal; margin-bottom: 12px; } p{ line-height: 1.6em; font-size: 42px }

    :)

    ThinkPHP V5
    十年磨一剑 - 为API开发设计的高性能框架

    [ V5.0 版本由 七牛云 独家赞助发布 ]
    '; + } +} diff --git a/thinkphp/tests/application/route.php b/thinkphp/tests/application/route.php new file mode 100644 index 0000000..45bcf79 --- /dev/null +++ b/thinkphp/tests/application/route.php @@ -0,0 +1,22 @@ + +// +---------------------------------------------------------------------- +// $Id$ + +return [ + '__pattern__' => [ + 'name' => '\w+', + ], + '[hello]' => [ + ':id' => ['index/hello', ['method' => 'get'], ['id' => '\d+']], + ':name' => ['index/hello', ['method' => 'post']], + ], + +]; diff --git a/thinkphp/tests/application/views/display.html b/thinkphp/tests/application/views/display.html new file mode 100644 index 0000000..e99d302 --- /dev/null +++ b/thinkphp/tests/application/views/display.html @@ -0,0 +1 @@ +{$name??'default'} \ No newline at end of file diff --git a/thinkphp/tests/application/views/display.phtml b/thinkphp/tests/application/views/display.phtml new file mode 100644 index 0000000..e99d302 --- /dev/null +++ b/thinkphp/tests/application/views/display.phtml @@ -0,0 +1 @@ +{$name??'default'} \ No newline at end of file diff --git a/thinkphp/tests/application/views/extend.html b/thinkphp/tests/application/views/extend.html new file mode 100644 index 0000000..922192d --- /dev/null +++ b/thinkphp/tests/application/views/extend.html @@ -0,0 +1,2 @@ +{extend name="extend2" /} +{block name="head"}header{/block} \ No newline at end of file diff --git a/thinkphp/tests/application/views/extend2.html b/thinkphp/tests/application/views/extend2.html new file mode 100644 index 0000000..eb22e1d --- /dev/null +++ b/thinkphp/tests/application/views/extend2.html @@ -0,0 +1,17 @@ +{layout name="layout2" replace="[__REPLACE__]" /} +{block name="head"}{/block} +
    + {include file="include" name="info" value="$info.value" /} +{block name="main"} +{block name="side"} + side +{/block} +{block name="mainbody"} + +{/block} +{/block} +{literal} + {$name} +{/literal} + +
    \ No newline at end of file diff --git a/thinkphp/tests/application/views/include.html b/thinkphp/tests/application/views/include.html new file mode 100644 index 0000000..e01ae9e --- /dev/null +++ b/thinkphp/tests/application/views/include.html @@ -0,0 +1,2 @@ + +{include file="include2" /} \ No newline at end of file diff --git a/thinkphp/tests/application/views/include2.html b/thinkphp/tests/application/views/include2.html new file mode 100644 index 0000000..24bdacb --- /dev/null +++ b/thinkphp/tests/application/views/include2.html @@ -0,0 +1 @@ +{$info.value}: \ No newline at end of file diff --git a/thinkphp/tests/application/views/layout.html b/thinkphp/tests/application/views/layout.html new file mode 100644 index 0000000..be8d4a0 --- /dev/null +++ b/thinkphp/tests/application/views/layout.html @@ -0,0 +1,2 @@ +
    {__CONTENT__} +
    \ No newline at end of file diff --git a/thinkphp/tests/application/views/layout2.html b/thinkphp/tests/application/views/layout2.html new file mode 100644 index 0000000..a5b7572 --- /dev/null +++ b/thinkphp/tests/application/views/layout2.html @@ -0,0 +1,2 @@ + \ No newline at end of file diff --git a/thinkphp/tests/conf/memcached.ini b/thinkphp/tests/conf/memcached.ini new file mode 100644 index 0000000..7d09664 --- /dev/null +++ b/thinkphp/tests/conf/memcached.ini @@ -0,0 +1 @@ +extension=memcached.so diff --git a/thinkphp/tests/conf/redis.ini b/thinkphp/tests/conf/redis.ini new file mode 100644 index 0000000..6aecae4 --- /dev/null +++ b/thinkphp/tests/conf/redis.ini @@ -0,0 +1 @@ +extension=redis.so diff --git a/thinkphp/tests/conf/timezone.ini b/thinkphp/tests/conf/timezone.ini new file mode 100644 index 0000000..ced3e0d --- /dev/null +++ b/thinkphp/tests/conf/timezone.ini @@ -0,0 +1 @@ +date.timezone = UTC \ No newline at end of file diff --git a/thinkphp/tests/mock.php b/thinkphp/tests/mock.php new file mode 100644 index 0000000..0c29e59 --- /dev/null +++ b/thinkphp/tests/mock.php @@ -0,0 +1,20 @@ + +// +---------------------------------------------------------------------- + +// 测试入口文件 +$_SERVER['REQUEST_METHOD'] = 'GET'; +// 定义项目测试基础路径 +define('TEST_PATH', __DIR__ . '/'); +// 定义项目路径 +define('APP_PATH', __DIR__ . '/application/'); +// 加载框架基础文件 +require __DIR__ . '/../base.php'; +\think\Loader::addNamespace('tests', TEST_PATH); diff --git a/thinkphp/tests/script/install.sh b/thinkphp/tests/script/install.sh new file mode 100644 index 0000000..8344169 --- /dev/null +++ b/thinkphp/tests/script/install.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +if [ $(phpenv version-name) != "hhvm" ]; then + cp tests/extensions/$(phpenv version-name)/*.so $(php-config --extension-dir) + + phpenv config-add tests/conf/memcached.ini + phpenv config-add tests/conf/redis.ini + + phpenv config-add tests/conf/timezone.ini +fi + +composer install --no-interaction --ignore-platform-reqs +composer update diff --git a/thinkphp/tests/thinkphp/baseTest.php b/thinkphp/tests/thinkphp/baseTest.php new file mode 100644 index 0000000..18f1d3d --- /dev/null +++ b/thinkphp/tests/thinkphp/baseTest.php @@ -0,0 +1,39 @@ + +// +---------------------------------------------------------------------- + +/** + * 保证运行环境正常 + */ +class baseTest extends \PHPUnit_Framework_TestCase +{ + public function testConstants() + { + $this->assertNotEmpty(THINK_START_TIME); + $this->assertNotEmpty(THINK_START_MEM); + $this->assertNotEmpty(THINK_VERSION); + $this->assertNotEmpty(DS); + $this->assertNotEmpty(THINK_PATH); + $this->assertNotEmpty(LIB_PATH); + $this->assertNotEmpty(EXTEND_PATH); + $this->assertNotEmpty(CORE_PATH); + $this->assertNotEmpty(TRAIT_PATH); + $this->assertNotEmpty(APP_PATH); + $this->assertNotEmpty(RUNTIME_PATH); + $this->assertNotEmpty(LOG_PATH); + $this->assertNotEmpty(CACHE_PATH); + $this->assertNotEmpty(TEMP_PATH); + $this->assertNotEmpty(VENDOR_PATH); + $this->assertNotEmpty(EXT); + $this->assertNotEmpty(ENV_PREFIX); + $this->assertTrue(!is_null(IS_WIN)); + $this->assertTrue(!is_null(IS_CLI)); + } +} diff --git a/thinkphp/tests/thinkphp/library/think/appTest.php b/thinkphp/tests/thinkphp/library/think/appTest.php new file mode 100644 index 0000000..016bbf9 --- /dev/null +++ b/thinkphp/tests/thinkphp/library/think/appTest.php @@ -0,0 +1,90 @@ + +// +---------------------------------------------------------------------- + +/** + * app类测试 + * @author Haotong Lin + */ + +namespace tests\thinkphp\library\think; + +use think\App; +use think\Config; +use think\Request; + +function func_trim($value) +{ + return trim($value); +} + +function func_strpos($haystack, $needle) +{ + return strpos($haystack, $needle); +} + +class AppInvokeMethodTestClass +{ + public static function staticRun($string) + { + return $string; + } + + public function run($string) + { + return $string; + } +} + +class appTest extends \PHPUnit_Framework_TestCase +{ + public function testRun() + { + $response = App::run(Request::create("http://www.example.com")); + + $expectOutputString = '

    :)

    ThinkPHP V5
    十年磨一剑 - 为API开发设计的高性能框架

    [ V5.0 版本由 七牛云 独家赞助发布 ]
    '; + + $this->assertEquals($expectOutputString, $response->getContent()); + $this->assertEquals(200, $response->getCode()); + + $this->assertEquals(true, function_exists('lang')); + $this->assertEquals(true, function_exists('config')); + $this->assertEquals(true, function_exists('input')); + + $this->assertEquals(Config::get('default_timezone'), date_default_timezone_get()); + + } + + // function调度 + public function testInvokeFunction() + { + $args1 = ['a b c ']; + $this->assertEquals( + trim($args1[0]), + App::invokeFunction('tests\thinkphp\library\think\func_trim', $args1) + ); + + $args2 = ['abcdefg', 'g']; + $this->assertEquals( + strpos($args2[0], $args2[1]), + App::invokeFunction('tests\thinkphp\library\think\func_strpos', $args2) + ); + } + + // 类method调度 + public function testInvokeMethod() + { + $result = App::invokeMethod(['tests\thinkphp\library\think\AppInvokeMethodTestClass', 'run'], ['thinkphp']); + $this->assertEquals('thinkphp', $result); + + $result = App::invokeMethod('tests\thinkphp\library\think\AppInvokeMethodTestClass::staticRun', ['thinkphp']); + $this->assertEquals('thinkphp', $result); + } +} diff --git a/thinkphp/tests/thinkphp/library/think/behavior/One.php b/thinkphp/tests/thinkphp/library/think/behavior/One.php new file mode 100644 index 0000000..1ec6e66 --- /dev/null +++ b/thinkphp/tests/thinkphp/library/think/behavior/One.php @@ -0,0 +1,15 @@ + +// +---------------------------------------------------------------------- + +/** + * build测试 + * @author 刘志淳 + */ + +namespace tests\thinkphp\library\think; + +use think\Build; + +class buildTest extends \PHPUnit_Framework_TestCase +{ + public function testRun() + { + $build = [ + // Test run directory + '__dir__' => ['runtime/cache', 'runtime/log', 'runtime/temp', 'runtime/template'], + '__file__' => ['common.php'], + + // Test generation module + 'demo' => [ + '__file__' => ['common.php'], + '__dir__' => ['behavior', 'controller', 'model', 'view', 'service'], + 'controller' => ['Index', 'Test', 'UserType'], + 'model' => ['User', 'UserType'], + 'service' => ['User', 'UserType'], + 'view' => ['index/index'], + ], + ]; + Build::run($build); + + $this->buildFileExists($build); + } + + protected function buildFileExists($build) + { + foreach ($build as $module => $list) { + if ('__dir__' == $module || '__file__' == $module) { + foreach ($list as $file) { + $this->assertFileExists(APP_PATH . $file); + } + } else { + foreach ($list as $path => $moduleList) { + if ('__file__' == $path || '__dir__' == $path) { + foreach ($moduleList as $file) { + $this->assertFileExists(APP_PATH . $module . '/' . $file); + } + } else { + foreach ($moduleList as $file) { + if ('view' == $path) { + $file_name = APP_PATH . $module . '/' . $path . '/' . $file . '.html'; + } else { + $file_name = APP_PATH . $module . '/' . $path . '/' . $file . EXT; + } + $this->assertFileExists($file_name); + } + } + } + $this->assertFileExists(APP_PATH . ($module ? $module . DS : '') . 'config.php'); + } + } + } +} diff --git a/thinkphp/tests/thinkphp/library/think/cache/driver/cacheTestCase.php b/thinkphp/tests/thinkphp/library/think/cache/driver/cacheTestCase.php new file mode 100644 index 0000000..5b2f2a3 --- /dev/null +++ b/thinkphp/tests/thinkphp/library/think/cache/driver/cacheTestCase.php @@ -0,0 +1,207 @@ + +// +---------------------------------------------------------------------- + +/** + * 缓存抽象类,提供一些测试 + * @author simon + */ + +namespace tests\thinkphp\library\think\cache\driver; + +use think\Cache; + +abstract class cacheTestCase extends \PHPUnit_Framework_TestCase +{ + + /** + * 获取缓存句柄,子类必须有 + * @access protected + */ + abstract protected function getCacheInstance(); + + /** + * tearDown函数 + */ + protected function tearDown() + { + } + + /** + * 设定一组测试值,包括测试字符串、整数、数组和对象 + * @return mixed + * @access public + */ + public function prepare() + { + $cache = $this->getCacheInstance(); + $cache->clear(); + $cache->set('string_test', 'string_test'); + $cache->set('number_test', 11); + $cache->set('array_test', ['array_test' => 'array_test']); + return $cache; + } + + /** + * 测试缓存设置,包括测试字符串、整数、数组和对象 + * @return mixed + * @access public + */ + public function testSet() + { + $cache = $this->getCacheInstance(); + $this->assertTrue($cache->set('string_test', 'string_test')); + $this->assertTrue($cache->set('number_test', 11)); + $this->assertTrue($cache->set('array_test', ['array_test' => 'array_test'])); + } + + /** + * 测试缓存自增 + * @return mixed + * @access public + */ + public function testInc() + { + $cache = $this->getCacheInstance(); + $this->assertEquals(14, $cache->inc('number_test', 3)); + } + + /** + * 测试缓存自减 + * @return mixed + * @access public + */ + public function testDec() + { + $cache = $this->getCacheInstance(); + $this->assertEquals(8, $cache->dec('number_test', 6)); + } + + /** + * 测试缓存读取,包括测试字符串、整数、数组和对象 + * @return mixed + * @access public + */ + public function testGet() + { + $cache = $this->prepare(); + $this->assertEquals('string_test', $cache->get('string_test')); + $this->assertEquals(11, $cache->get('number_test')); + $array = $cache->get('array_test'); + $this->assertArrayHasKey('array_test', $array); + $this->assertEquals('array_test', $array['array_test']); + + $result = $cache->set('no_expire', 1, 0); + $this->assertTrue($result); + } + + /** + * 测试缓存存在情况,包括测试字符串、整数、数组和对象 + * @return mixed + * @access public + */ + public function testExists() + { + $cache = $this->prepare(); + $this->assertNotEmpty($cache->has('string_test')); + $this->assertNotEmpty($cache->has('number_test')); + $this->assertFalse($cache->has('not_exists')); + } + + /** + * 测试缓存不存在情况,包括测试字符串、整数、数组和对象 + * @return mixed + * @access public + */ + public function testGetNonExistent() + { + $cache = $this->getCacheInstance(); + $this->assertFalse($cache->get('non_existent_key', false)); + } + + /** + * 测试特殊值缓存,包括测试字符串、整数、数组和对象 + * @return mixed + * @access public + */ + public function testStoreSpecialValues() + { + $cache = $this->getCacheInstance(); + $cache->set('null_value', null); + //清空缓存后,返回null而不是false + $this->assertTrue(is_null($cache->get('null_value'))); + } + + /** + * 缓存过期测试 + * @return mixed + * @access public + */ + public function testExpire() + { + $cache = $this->getCacheInstance(); + $this->assertTrue($cache->set('expire_test', 'expire_test', 1)); + usleep(600000); + $this->assertEquals('expire_test', $cache->get('expire_test')); + usleep(800000); + $this->assertFalse($cache->get('expire_test')); + } + + /** + * 删除缓存测试 + * @return mixed + * @access public + */ + public function testDelete() + { + $cache = $this->prepare(); + $this->assertNotNull($cache->rm('number_test')); + $this->assertFalse($cache->get('number_test')); + } + + /** + * 获取并删除缓存测试 + * @return mixed + * @access public + */ + public function testPull() + { + $cache = $this->prepare(); + $this->assertEquals(11, $cache->pull('number_test')); + $this->assertFalse($cache->get('number_test')); + } + + /** + * 清空缓存测试 + * @return mixed + * @access public + */ + public function testClear() + { + $cache = $this->prepare(); + $this->assertTrue($cache->clear()); + $this->assertFalse($cache->get('number_test')); + } + + public function testStaticCall() + { + $this->assertTrue(Cache::set('a', 1)); + $this->assertEquals(1, Cache::get('a')); + $this->assertEquals(2, Cache::inc('a')); + $this->assertEquals(4, Cache::inc('a', 2)); + $this->assertEquals(4, Cache::get('a')); + $this->assertEquals(3, Cache::dec('a')); + $this->assertEquals(1, Cache::dec('a', 2)); + $this->assertEquals(1, Cache::get('a')); + $this->assertNotNull(Cache::rm('a')); + $this->assertNotNull(Cache::clear()); + } + +} diff --git a/thinkphp/tests/thinkphp/library/think/cache/driver/fileTest.php b/thinkphp/tests/thinkphp/library/think/cache/driver/fileTest.php new file mode 100644 index 0000000..eb2099c --- /dev/null +++ b/thinkphp/tests/thinkphp/library/think/cache/driver/fileTest.php @@ -0,0 +1,46 @@ + +// +---------------------------------------------------------------------- + +/** + * File缓存驱动测试 + * @author 刘志淳 + */ + +namespace tests\thinkphp\library\think\cache\driver; + +class fileTest extends cacheTestCase +{ + private $_cacheInstance = null; + + /** + * 基境缓存类型 + */ + protected function setUp() + { + \think\Cache::connect(['type' => 'File', 'path' => CACHE_PATH]); + } + + /** + * @return FileCache + */ + protected function getCacheInstance() + { + if (null === $this->_cacheInstance) { + $this->_cacheInstance = new \think\cache\driver\File(); + } + return $this->_cacheInstance; + } + + // skip testExpire + public function testExpire() + { + } +} diff --git a/thinkphp/tests/thinkphp/library/think/cache/driver/liteTest.php b/thinkphp/tests/thinkphp/library/think/cache/driver/liteTest.php new file mode 100644 index 0000000..19cbb9e --- /dev/null +++ b/thinkphp/tests/thinkphp/library/think/cache/driver/liteTest.php @@ -0,0 +1,69 @@ + +// +---------------------------------------------------------------------- + +/** + * Lite缓存驱动测试 + * @author 刘志淳 + */ + +namespace tests\thinkphp\library\think\cache\driver; + +use think\Cache; + +class liteTest extends \PHPUnit_Framework_TestCase +{ + protected function getCacheInstance() + { + return Cache::connect(['type' => 'Lite', 'path' => CACHE_PATH]); + } + + /** + * 测试缓存读取 + * @return mixed + * @access public + */ + public function testGet() + { + $cache = $this->getCacheInstance(); + $this->assertFalse($cache->get('test')); + } + + /** + * 测试缓存设置 + * @return mixed + * @access public + */ + public function testSet() + { + $cache = $this->getCacheInstance(); + $this->assertNotEmpty($cache->set('test', 'test')); + } + + /** + * 删除缓存测试 + * @return mixed + * @access public + */ + public function testRm() + { + $cache = $this->getCacheInstance(); + $this->assertTrue($cache->rm('test')); + } + + /** + * 清空缓存测试 + * @return mixed + * @access public + */ + public function testClear() + { + } +} diff --git a/thinkphp/tests/thinkphp/library/think/cache/driver/memcacheTest.php b/thinkphp/tests/thinkphp/library/think/cache/driver/memcacheTest.php new file mode 100644 index 0000000..8975fa2 --- /dev/null +++ b/thinkphp/tests/thinkphp/library/think/cache/driver/memcacheTest.php @@ -0,0 +1,49 @@ + +// +---------------------------------------------------------------------- + +/** + * Memcache缓存驱动测试 + * @author 刘志淳 + */ + +namespace tests\thinkphp\library\think\cache\driver; + +class memcacheTest extends cacheTestCase +{ + private $_cacheInstance = null; + + /** + * 基境缓存类型 + */ + protected function setUp() + { + if (!extension_loaded('memcache')) { + $this->markTestSkipped("Memcache没有安装,已跳过测试!"); + } + \think\Cache::connect(['type' => 'memcache', 'expire' => 2]); + } + + /** + * @return ApcCache + */ + protected function getCacheInstance() + { + if (null === $this->_cacheInstance) { + $this->_cacheInstance = new \think\cache\driver\Memcache(['length' => 3]); + } + return $this->_cacheInstance; + } + + // skip testExpire + public function testExpire() + { + } +} diff --git a/thinkphp/tests/thinkphp/library/think/cache/driver/memcachedTest.php b/thinkphp/tests/thinkphp/library/think/cache/driver/memcachedTest.php new file mode 100644 index 0000000..d528dd2 --- /dev/null +++ b/thinkphp/tests/thinkphp/library/think/cache/driver/memcachedTest.php @@ -0,0 +1,72 @@ + +// +---------------------------------------------------------------------- + +/** + * Memcached缓存驱动测试 + * @author 7IN0SAN9 + */ + +namespace tests\thinkphp\library\think\cache\driver; + +class memcachedTest extends cacheTestCase +{ + private $_cacheInstance = null; + /** + * 基境缓存类型 + */ + protected function setUp() + { + if (!extension_loaded("memcached") && !extension_loaded('memcache')) { + $this->markTestSkipped("Memcached或Memcache没有安装,已跳过测试!"); + } + \think\Cache::connect(array('type' => 'memcached', 'expire' => 2)); + } + /** + * @return ApcCache + */ + protected function getCacheInstance() + { + if (null === $this->_cacheInstance) { + $this->_cacheInstance = new \think\cache\driver\Memcached(['length' => 3]); + } + return $this->_cacheInstance; + } + /** + * 缓存过期测试《提出来测试,因为目前看通不过缓存过期测试,所以还需研究》 + * @return mixed + * @access public + */ + public function testExpire() + { + } + + public function testStaticCall() + { + } + + /** + * 测试缓存自增 + * @return mixed + * @access public + */ + public function testInc() + { + } + + /** + * 测试缓存自减 + * @return mixed + * @access public + */ + public function testDec() + { + } +} diff --git a/thinkphp/tests/thinkphp/library/think/cache/driver/redisTest.php b/thinkphp/tests/thinkphp/library/think/cache/driver/redisTest.php new file mode 100644 index 0000000..2000ee4 --- /dev/null +++ b/thinkphp/tests/thinkphp/library/think/cache/driver/redisTest.php @@ -0,0 +1,66 @@ + +// +---------------------------------------------------------------------- + +/** + * Redis缓存驱动测试 + * @author 7IN0SAN9 + */ + +namespace tests\thinkphp\library\think\cache\driver; + +class redisTest extends cacheTestCase +{ + private $_cacheInstance = null; + + protected function setUp() + { + if (!extension_loaded("redis")) { + $this->markTestSkipped("Redis没有安装,已跳过测试!"); + } + \think\Cache::connect(array('type' => 'redis', 'expire' => 2)); + } + + protected function getCacheInstance() + { + if (null === $this->_cacheInstance) { + $this->_cacheInstance = new \think\cache\driver\Redis(['length' => 3]); + } + return $this->_cacheInstance; + } + + public function testGet() + { + $cache = $this->prepare(); + $this->assertEquals('string_test', $cache->get('string_test')); + $this->assertEquals(11, $cache->get('number_test')); + $result = $cache->get('array_test'); + $this->assertEquals('array_test', $result['array_test']); + } + + public function testStoreSpecialValues() + { + $redis = new \think\cache\driver\Redis(['length' => 3]); + $redis->set('key', 'value'); + $redis->get('key'); + + $redis->handler()->setnx('key', 'value'); + $value = $redis->handler()->get('key'); + $this->assertEquals('value', $value); + + $redis->handler()->hset('hash', 'key', 'value'); + $value = $redis->handler()->hget('hash', 'key'); + $this->assertEquals('value', $value); + } + + public function testExpire() + { + } +} diff --git a/thinkphp/tests/thinkphp/library/think/cacheTest.php b/thinkphp/tests/thinkphp/library/think/cacheTest.php new file mode 100644 index 0000000..dbcd705 --- /dev/null +++ b/thinkphp/tests/thinkphp/library/think/cacheTest.php @@ -0,0 +1,315 @@ + +// +---------------------------------------------------------------------- + +namespace tests\thinkphp\library\think; + +use tests\thinkphp\library\think\config\ConfigInitTrait; +use think\Cache; +use think\Config; + +class cacheTest extends \PHPUnit_Framework_TestCase +{ + use ConfigInitTrait { + ConfigInitTrait::tearDown as ConfigTearDown; + } + + public function tearDown() + { + $this->ConfigTearDown(); + + call_user_func(\Closure::bind(function () { + Cache::$handler = null; + Cache::$instance = []; + Cache::$readTimes = 0; + Cache::$writeTimes = 0; + }, null, '\think\Cache')); + } + + /** + * @dataProvider provideTestConnect + */ + public function testConnect($options, $expected) + { + $connection = Cache::connect($options); + $this->assertInstanceOf($expected, $connection); + $this->assertSame($connection, Cache::connect($options)); + + $instance = $this->getPropertyVal('instance'); + $this->assertArrayHasKey(md5(serialize($options)), $instance); + + $newConnection = Cache::connect($options, true); + $newInstance = $this->getPropertyVal('instance'); + $this->assertInstanceOf($expected, $connection); + $this->assertNotSame($connection, $newConnection); + $this->assertEquals($instance, $newInstance); + } + + /** + * @dataProvider provideTestInit + */ + public function testInit($options, $expected) + { + $connection = Cache::init($options); + $this->assertInstanceOf($expected, $connection); + + $connectionNew = Cache::init(['type' => 'foo']); + $this->assertSame($connection, $connectionNew); + } + + public function testStore() + { + Config::set('cache.redis', ['type' => 'redis']); + + $connectionDefault = Cache::store(); + $this->assertInstanceOf('\think\cache\driver\File', $connectionDefault); + + Config::set('cache.type', false); + $connectionNotRedis = Cache::store('redis'); + $this->assertSame($connectionDefault, $connectionNotRedis); + + Config::set('cache.type', 'complex'); + $connectionRedis = Cache::store('redis'); + $this->assertNotSame($connectionNotRedis, $connectionRedis); + $this->assertInstanceOf('\think\cache\driver\Redis', $connectionRedis); + + // 即便成功切换到其他存储类型,也不影响原先的操作句柄 + $this->assertSame($connectionDefault, Cache::store()); + } + + public function testHas() + { + $key = $this->buildTestKey('Has'); + + $this->assertFalse(Cache::has($key)); + + Cache::set($key, 5); + $this->assertTrue(Cache::has($key)); + } + + public function testGet() + { + $key = $this->buildTestKey('Get'); + + $this->assertFalse(Cache::get($key)); + + $this->assertEquals('default', Cache::get($key, 'default')); + + Cache::set($key, 5); + $this->assertSame(5, Cache::get($key)); + } + + public function testSet() + { + $key = $this->buildTestKey('Set'); + + $this->assertTrue(Cache::set(null, null)); + $this->assertTrue(Cache::set($key, 'ThinkPHP3.2')); + $this->assertTrue(Cache::set($key, 'ThinkPHP5.0', null)); + $this->assertTrue(Cache::set($key, 'ThinkPHP5.0', -1)); + $this->assertTrue(Cache::set($key, 'ThinkPHP5.0', 0)); + $this->assertTrue(Cache::set($key, 'ThinkPHP5.0', 7200)); + } + + public function testInc() + { + $key = $this->buildTestKey('Inc'); + + Cache::inc($key); + $this->assertEquals(1, Cache::get($key)); + + Cache::inc($key, '2'); + $this->assertEquals(3, Cache::get($key)); + + Cache::inc($key, -1); + $this->assertEquals(2, Cache::get($key)); + + Cache::inc($key, null); + $this->assertEquals(2, Cache::get($key)); + + Cache::inc($key, true); + $this->assertEquals(3, Cache::get($key)); + + Cache::inc($key, false); + $this->assertEquals(3, Cache::get($key)); + + Cache::inc($key, 0.789); + $this->assertEquals(3.789, Cache::get($key)); + } + public function testDec() + { + $key = $this->buildTestKey('Dec'); + + Cache::dec($key); + $this->assertEquals(-1, Cache::get($key)); + + Cache::dec($key, '2'); + $this->assertEquals(-3, Cache::get($key)); + + Cache::dec($key, -1); + $this->assertEquals(-2, Cache::get($key)); + + Cache::dec($key, null); + $this->assertEquals(-2, Cache::get($key)); + + Cache::dec($key, true); + $this->assertEquals(-3, Cache::get($key)); + + Cache::dec($key, false); + $this->assertEquals(-3, Cache::get($key)); + + Cache::dec($key, 0.359); + $this->assertEquals(-3.359, Cache::get($key)); + } + + public function testRm() + { + $key = $this->buildTestKey('Rm'); + + $this->assertFalse(Cache::rm($key)); + + Cache::set($key, 'ThinkPHP'); + $this->assertTrue(Cache::rm($key)); + } + + public function testClear() + { + $key1 = $this->buildTestKey('Clear1'); + $key2 = $this->buildTestKey('Clear2'); + + Cache::set($key1, 'ThinkPHP3.2'); + Cache::set($key2, 'ThinkPHP5.0'); + + $this->assertEquals('ThinkPHP3.2', Cache::get($key1)); + $this->assertEquals('ThinkPHP5.0', Cache::get($key2)); + Cache::clear(); + $this->assertFalse(Cache::get($key1)); + $this->assertFalse(Cache::get($key2)); + } + + public function testPull() + { + $key = $this->buildTestKey('Pull'); + + $this->assertNull(Cache::pull($key)); + + Cache::set($key, 'ThinkPHP'); + $this->assertEquals('ThinkPHP', Cache::pull($key)); + $this->assertFalse(Cache::get($key)); + } + + public function testRemember() + { + $key1 = $this->buildTestKey('Remember1'); + $key2 = $this->buildTestKey('Remember2'); + + $this->assertEquals('ThinkPHP3.2', Cache::remember($key1, 'ThinkPHP3.2')); + $this->assertEquals('ThinkPHP3.2', Cache::remember($key1, 'ThinkPHP5.0')); + + $this->assertEquals('ThinkPHP5.0', Cache::remember($key2, function () { + return 'ThinkPHP5.0'; + })); + $this->assertEquals('ThinkPHP5.0', Cache::remember($key2, function () { + return 'ThinkPHP3.2'; + })); + } + + public function testTag() + { + $key = $this->buildTestKey('Tag'); + + $cacheTagWithoutName = Cache::tag(null); + $this->assertInstanceOf('think\cache\Driver', $cacheTagWithoutName); + + $cacheTagWithKey = Cache::tag($key, [1, 2, 3]); + $this->assertSame($cacheTagWithoutName, $cacheTagWithKey); + } + + protected function getPropertyVal($name) + { + static $reflectionClass; + if (empty($reflectionClass)) { + $reflectionClass = new \ReflectionClass('\think\Cache'); + } + + $property = $reflectionClass->getProperty($name); + $property->setAccessible(true); + + return $property->getValue(); + } + + public function provideTestConnect() + { + $provideData = []; + + $options = ['type' => null]; + $expected = '\think\cache\driver\File'; + $provideData[] = [$options, $expected]; + + $options = ['type' => 'File']; + $expected = '\think\cache\driver\File'; + $provideData[] = [$options, $expected]; + + $options = ['type' => 'Lite']; + $expected = '\think\cache\driver\Lite'; + $provideData[] = [$options, $expected]; + + $options = ['type' => 'Memcached']; + $expected = '\think\cache\driver\Memcached'; + $provideData[] = [$options, $expected]; + + $options = ['type' => 'Redis']; + $expected = '\think\cache\driver\Redis'; + $provideData[] = [$options, $expected]; + + // TODO + // $options = ['type' => 'Memcache']; + // $expected = '\think\cache\driver\Memcache'; + // $provideData[] = [$options, $expected]; + // + // $options = ['type' => 'Wincache']; + // $expected = '\think\cache\driver\Wincache'; + // $provideData[] = [$options, $expected]; + + // $options = ['type' => 'Sqlite']; + // $expected = '\think\cache\driver\Sqlite'; + // $provideData[] = [$options, $expected]; + // + // $options = ['type' => 'Xcache']; + // $expected = '\think\cache\driver\Xcache'; + // $provideData[] = [$options, $expected]; + + return $provideData; + } + + public function provideTestInit() + { + $provideData = []; + + $options = []; + $expected = '\think\cache\driver\File'; + $provideData[] = [$options, $expected]; + + $options = ['type' => 'File']; + $expected = '\think\cache\driver\File'; + $provideData[] = [$options, $expected]; + + $options = ['type' => 'Lite']; + $expected = '\think\cache\driver\Lite'; + $provideData[] = [$options, $expected]; + + return $provideData; + } + + protected function buildTestKey($tag) + { + return sprintf('ThinkPHP_Test_%s_%d_%d', $tag, time(), rand(0, 10000)); + } +} diff --git a/thinkphp/tests/thinkphp/library/think/config/ConfigInitTrait.php b/thinkphp/tests/thinkphp/library/think/config/ConfigInitTrait.php new file mode 100644 index 0000000..ce2b397 --- /dev/null +++ b/thinkphp/tests/thinkphp/library/think/config/ConfigInitTrait.php @@ -0,0 +1,52 @@ + + + + 1 + + \ No newline at end of file diff --git a/thinkphp/tests/thinkphp/library/think/config/driver/iniTest.php b/thinkphp/tests/thinkphp/library/think/config/driver/iniTest.php new file mode 100644 index 0000000..66b38d9 --- /dev/null +++ b/thinkphp/tests/thinkphp/library/think/config/driver/iniTest.php @@ -0,0 +1,36 @@ + +// +---------------------------------------------------------------------- + +/** + * Ini配置测试 + * @author 7IN0SAN9 + */ + +namespace tests\thinkphp\library\think\config\driver; + +use tests\thinkphp\library\think\config\ConfigInitTrait; +use think\config; + +class iniTest extends \PHPUnit_Framework_TestCase +{ + use ConfigInitTrait; + + public function testParse() + { + Config::parse('inistring=1', 'ini'); + $this->assertEquals(1, Config::get('inistring')); + Config::reset(); + Config::parse(__DIR__ . '/fixtures/config.ini'); + $this->assertTrue(Config::has('inifile')); + $this->assertEquals(1, Config::get('inifile')); + Config::reset(); + } +} diff --git a/thinkphp/tests/thinkphp/library/think/config/driver/jsonTest.php b/thinkphp/tests/thinkphp/library/think/config/driver/jsonTest.php new file mode 100644 index 0000000..583e6dd --- /dev/null +++ b/thinkphp/tests/thinkphp/library/think/config/driver/jsonTest.php @@ -0,0 +1,36 @@ + +// +---------------------------------------------------------------------- + +/** + * Xml配置测试 + * @author 7IN0SAN9 + */ + +namespace tests\thinkphp\library\think\config\driver; + +use tests\thinkphp\library\think\config\ConfigInitTrait; +use think\config; + +class jsonTest extends \PHPUnit_Framework_TestCase +{ + use ConfigInitTrait; + + public function testParse() + { + Config::parse('{"jsonstring":1}', 'json'); + $this->assertEquals(1, Config::get('jsonstring')); + Config::reset(); + Config::parse(__DIR__ . '/fixtures/config.json'); + $this->assertTrue(Config::has('jsonstring')); + $this->assertEquals(1, Config::get('jsonstring')); + Config::reset(); + } +} diff --git a/thinkphp/tests/thinkphp/library/think/config/driver/xmlTest.php b/thinkphp/tests/thinkphp/library/think/config/driver/xmlTest.php new file mode 100644 index 0000000..e2225f7 --- /dev/null +++ b/thinkphp/tests/thinkphp/library/think/config/driver/xmlTest.php @@ -0,0 +1,36 @@ + +// +---------------------------------------------------------------------- + +/** + * Xml配置测试 + * @author 7IN0SAN9 + */ + +namespace tests\thinkphp\library\think\config\driver; + +use tests\thinkphp\library\think\config\ConfigInitTrait; +use think\config; + +class xmlTest extends \PHPUnit_Framework_TestCase +{ + use ConfigInitTrait; + + public function testParse() + { + Config::parse('1', 'xml'); + $this->assertEquals(1, Config::get('xmlstring')); + Config::reset(); + Config::parse(__DIR__ . '/fixtures/config.xml'); + $this->assertTrue(Config::has('xmlfile.istrue')); + $this->assertEquals(1, Config::get('xmlfile.istrue')); + Config::reset(); + } +} diff --git a/thinkphp/tests/thinkphp/library/think/configTest.php b/thinkphp/tests/thinkphp/library/think/configTest.php new file mode 100644 index 0000000..4c92df5 --- /dev/null +++ b/thinkphp/tests/thinkphp/library/think/configTest.php @@ -0,0 +1,149 @@ + +// +---------------------------------------------------------------------- + +/** + * 配置测试 + * @author Haotong Lin + */ + +namespace tests\thinkphp\library\think; + +use tests\thinkphp\library\think\config\ConfigInitTrait; +use think\Config; + +class configTest extends \PHPUnit_Framework_TestCase +{ + use ConfigInitTrait; + + public function testRange() + { + // test default range + $this->assertEquals('_sys_', call_user_func(self::$internalRangeFoo)); + + $this->assertTrue(is_array(call_user_func(self::$internalConfigFoo))); + // test range initialization + Config::range('_test_'); + $this->assertEquals('_test_', call_user_func(self::$internalRangeFoo)); + $this->assertEquals([], call_user_func(self::$internalConfigFoo)['_test_']); + } + + // public function testParse() + // { + // see \think\config\driver\...Test.php + // } + + public function testLoad() + { + $file = APP_PATH . 'config' . EXT; + $config = array_change_key_case(include $file); + $name = '_name_'; + $range = '_test_'; + + $this->assertEquals($config, Config::load($file, $name, $range)); + $this->assertNotEquals(null, Config::load($file, $name, $range)); + } + + public function testHas() + { + $range = '_test_'; + $this->assertFalse(Config::has('abcd', $range)); + + call_user_func(self::$internalConfigFoo, [ + $range => ['abcd' => 'value'], + ]); + $this->assertTrue(Config::has('abcd', $range)); + + // else ... + $this->assertFalse(Config::has('abcd.efg', $range)); + + call_user_func(self::$internalConfigFoo, [ + $range => ['abcd' => ['efg' => 'value']], + ]); + $this->assertTrue(Config::has('abcd.efg', $range)); + } + + public function testGet() + { + $range = '_test_'; + call_user_func(self::$internalConfigFoo, [ + $range => [] + ]); + $this->assertEquals([], Config::get(null, $range)); + $this->assertEquals(null, Config::get(null, 'does_not_exist')); + $value = 'value'; + // test getting configuration + call_user_func(self::$internalConfigFoo, [ + $range => ['abcd' => 'efg'] + ]); + $this->assertEquals('efg', Config::get('abcd', $range)); + $this->assertEquals(null, Config::get('does_not_exist', $range)); + $this->assertEquals(null, Config::get('abcd', 'does_not_exist')); + // test getting configuration with dot syntax + call_user_func(self::$internalConfigFoo, [ + $range => ['one' => ['two' => $value]] + ]); + $this->assertEquals($value, Config::get('one.two', $range)); + $this->assertEquals(null, Config::get('one.does_not_exist', $range)); + $this->assertEquals(null, Config::get('one.two', 'does_not_exist')); + } + + public function testSet() + { + $range = '_test_'; + + // without dot syntax + $name = 'name'; + $value = 'value'; + Config::set($name, $value, $range); + $config = call_user_func(self::$internalConfigFoo); + $this->assertEquals($value, $config[$range][$name]); + // with dot syntax + $name = 'one.two'; + $value = 'dot value'; + Config::set($name, $value, $range); + $config = call_user_func(self::$internalConfigFoo); + $this->assertEquals($value, $config[$range]['one']['two']); + // if (is_array($name)): + // see testLoad() + // ... + // test getting all configurations...? + // return self::$config[$range]; ?? + $value = ['all' => 'configuration']; + call_user_func(self::$internalConfigFoo, [$range => $value]); + $this->assertEquals($value, Config::set(null, null, $range)); + $this->assertNotEquals(null, Config::set(null, null, $range)); + } + + public function testReset() + { + $range = '_test_'; + call_user_func(self::$internalConfigFoo, [$range => ['abcd' => 'efg']]); + + // clear all configurations + Config::reset(true); + $config = call_user_func(self::$internalConfigFoo); + $this->assertEquals([], $config); + // clear the configuration in range of parameter. + call_user_func(self::$internalConfigFoo, [ + $range => [ + 'abcd' => 'efg', + 'hijk' => 'lmn', + ], + 'a' => 'b', + ]); + Config::reset($range); + $config = call_user_func(self::$internalConfigFoo); + $this->assertEquals([ + $range => [], + 'a' => 'b', + ], $config); + } +} diff --git a/thinkphp/tests/thinkphp/library/think/controller/.gitignore b/thinkphp/tests/thinkphp/library/think/controller/.gitignore new file mode 100644 index 0000000..c96a04f --- /dev/null +++ b/thinkphp/tests/thinkphp/library/think/controller/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore \ No newline at end of file diff --git a/thinkphp/tests/thinkphp/library/think/controllerTest.php b/thinkphp/tests/thinkphp/library/think/controllerTest.php new file mode 100644 index 0000000..4164770 --- /dev/null +++ b/thinkphp/tests/thinkphp/library/think/controllerTest.php @@ -0,0 +1,194 @@ + +// +---------------------------------------------------------------------- + +/** + * 控制器测试 + * @author Haotong Lin + */ + +namespace tests\thinkphp\library\think; + +use ReflectionClass; +use think\Controller; +use think\Request; +use think\View; + +require_once CORE_PATH . '../../helper.php'; + +class Foo extends Controller +{ + public $test = 'test'; + + public function _initialize() + { + $this->test = 'abcd'; + } + + public function assignTest() + { + $this->assign('abcd', 'dcba'); + $this->assign(['key1' => 'value1', 'key2' => 'value2']); + } + + public function fetchTest() + { + $template = APP_PATH . 'views' . DS .'display.html'; + return $this->fetch($template, ['name' => 'ThinkPHP']); + } + + public function displayTest() + { + $template = APP_PATH . 'views' . DS .'display.html'; + return $this->display($template, ['name' => 'ThinkPHP']); + } + public function test() + { + $data = [ + 'username' => 'username', + 'nickname' => 'nickname', + 'password' => '123456', + 'repassword' => '123456', + 'email' => 'abc@abc.com', + 'sex' => '0', + 'age' => '20', + 'code' => '1234', + ]; + + $validate = [ + ['username', 'length:5,15', '用户名长度为5到15个字符'], + ['nickname', 'require', '请填昵称'], + ['password', '[\w-]{6,15}', '密码长度为6到15个字符'], + ['repassword', 'confirm:password', '两次密码不一到致'], + ['email', 'filter:validate_email', '邮箱格式错误'], + ['sex', 'in:0,1', '性别只能为为男或女'], + ['age', 'between:1,80', '年龄只能在10-80之间'], + ]; + return $this->validate($data, $validate); + } +} + +class Bar extends Controller +{ + public $test = 1; + + public $beforeActionList = ['action1', 'action2']; + + public function action1() + { + $this->test += 2; + return 'action1'; + } + + public function action2() + { + $this->test += 4; + return 'action2'; + } +} + +class Baz extends Controller +{ + public $test = 1; + + public $beforeActionList = [ + 'action1' => ['only' => 'index'], + 'action2' => ['except' => 'index'], + 'action3' => ['only' => 'abcd'], + 'action4' => ['except' => 'abcd'], + ]; + + public function action1() + { + $this->test += 2; + return 'action1'; + } + + public function action2() + { + $this->test += 4; + return 'action2'; + } + + public function action3() + { + $this->test += 8; + return 'action2'; + } + + public function action4() + { + $this->test += 16; + return 'action2'; + } +} + +class controllerTest extends \PHPUnit_Framework_TestCase +{ + public function testInitialize() + { + $foo = new Foo(Request::instance()); + $this->assertEquals('abcd', $foo->test); + } + + public function testBeforeAction() + { + $obj = new Bar(Request::instance()); + $this->assertEquals(7, $obj->test); + + $obj = new Baz(Request::instance()); + $this->assertEquals(19, $obj->test); + } + + private function getView($controller) + { + $view = new View(); + $rc = new ReflectionClass(get_class($controller)); + $property = $rc->getProperty('view'); + $property->setAccessible(true); + $property->setValue($controller, $view); + return $view; + } + + public function testFetch() + { + $controller = new Foo(Request::instance()); + $view = $this->getView($controller); + $template = APP_PATH . 'views' . DS .'display.html'; + $viewFetch = $view->fetch($template, ['name' => 'ThinkPHP']); + $this->assertEquals($controller->fetchTest(), $viewFetch); + } + + public function testDisplay() + { + $controller = new Foo; + $view = $this->getView($controller); + $template = APP_PATH . 'views' . DS .'display.html'; + $viewFetch = $view->display($template, ['name' => 'ThinkPHP']); + + $this->assertEquals($controller->displayTest(), $viewFetch); + } + + public function testAssign() + { + $controller = new Foo(Request::instance()); + $view = $this->getView($controller); + $controller->assignTest(); + $expect = ['abcd' => 'dcba', 'key1' => 'value1', 'key2' => 'value2']; + $this->assertAttributeEquals($expect, 'data', $view); + } + + public function testValidate() + { + $controller = new Foo(Request::instance()); + $result = $controller->test(); + $this->assertTrue($result); + } +} diff --git a/thinkphp/tests/thinkphp/library/think/cookieTest.php b/thinkphp/tests/thinkphp/library/think/cookieTest.php new file mode 100644 index 0000000..24cb153 --- /dev/null +++ b/thinkphp/tests/thinkphp/library/think/cookieTest.php @@ -0,0 +1,150 @@ + +// +---------------------------------------------------------------------- + +/** + * Cookie测试 + * @author Haotong Lin + */ + +namespace tests\thinkphp\library\think; + +use ReflectionClass; +use think\Cookie; + +class cookieTest extends \PHPUnit_Framework_TestCase +{ + protected $ref; + + protected $default = [ + // cookie 名称前缀 + 'prefix' => '', + // cookie 保存时间 + 'expire' => 0, + // cookie 保存路径 + 'path' => '/', + // cookie 有效域名 + 'domain' => '', + // cookie 启用安全传输 + 'secure' => false, + // httponly设置 + 'httponly' => '', + // 是否使用 setcookie + 'setcookie' => false, + ]; + + protected function setUp() + { + $reflectedClass = new ReflectionClass('\think\Cookie'); + $reflectedPropertyConfig = $reflectedClass->getProperty('config'); + $reflectedPropertyConfig->setAccessible(true); + $reflectedPropertyConfig->setValue($this->default); + $this->ref = $reflectedPropertyConfig; + } + + public function testInit() + { + $config = [ + // cookie 名称前缀 + 'prefix' => 'think_', + // cookie 保存时间 + 'expire' => 0, + // cookie 保存路径 + 'path' => '/path/to/test/', + // cookie 有效域名 + 'domain' => '.thinkphp.cn', + // cookie 启用安全传输 + 'secure' => true, + // httponly设置 + 'httponly' => '1', + ]; + Cookie::init($config); + + $this->assertEquals( + array_merge($this->default, array_change_key_case($config)), + $this->ref->getValue() + ); + } + + public function testPrefix() + { + $this->assertEquals($this->default['prefix'], Cookie::prefix()); + + $prefix = '_test_'; + $this->assertNotEquals($prefix, Cookie::prefix()); + Cookie::prefix($prefix); + + $config = $this->ref->getValue(); + $this->assertEquals($prefix, $config['prefix']); + } + + public function testSet() + { + $value = 'value'; + + $name = 'name1'; + Cookie::set($name, $value, 10); + $this->assertEquals($value, $_COOKIE[$this->default['prefix'] . $name]); + + $name = 'name2'; + Cookie::set($name, $value, null); + $this->assertEquals($value, $_COOKIE[$this->default['prefix'] . $name]); + + $name = 'name3'; + Cookie::set($name, $value, 'expire=100&prefix=pre_'); + $this->assertEquals($value, $_COOKIE['pre_' . $name]); + + $name = 'name4'; + $value = ['_test_中文_']; + Cookie::set($name, $value); + $this->assertEquals('think:' . json_encode([urlencode('_test_中文_')]), $_COOKIE[$name]); + } + + public function testGet() + { + $_COOKIE = [ + 'a' => 'b', + 'pre_abc' => 'c', + 'd' => 'think:' . json_encode([urlencode('_test_中文_')]), + ]; + $this->assertEquals('b', Cookie::get('a')); + $this->assertEquals(null, Cookie::get('does_not_exist')); + $this->assertEquals('c', Cookie::get('abc', 'pre_')); + $this->assertEquals(['_test_中文_'], Cookie::get('d')); + } + + public function testDelete() + { + $_COOKIE = [ + 'a' => 'b', + 'pre_abc' => 'c', + ]; + $this->assertEquals('b', Cookie::get('a')); + Cookie::delete('a'); + $this->assertEquals(null, Cookie::get('a')); + + $this->assertEquals('c', Cookie::get('abc', 'pre_')); + Cookie::delete('abc', 'pre_'); + $this->assertEquals(null, Cookie::get('abc', 'pre_')); + } + + public function testClear() + { + $_COOKIE = []; + $this->assertEquals(null, Cookie::clear()); + + $_COOKIE = [ + 'a' => 'b', + 'pre_abc' => 'c', + ]; + Cookie::clear('pre_'); + $this->assertEquals(['a' => 'b'], $_COOKIE); + } +} diff --git a/thinkphp/tests/thinkphp/library/think/db/driver/.gitignore b/thinkphp/tests/thinkphp/library/think/db/driver/.gitignore new file mode 100644 index 0000000..c96a04f --- /dev/null +++ b/thinkphp/tests/thinkphp/library/think/db/driver/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore \ No newline at end of file diff --git a/thinkphp/tests/thinkphp/library/think/dbTest.php b/thinkphp/tests/thinkphp/library/think/dbTest.php new file mode 100644 index 0000000..5724ee2 --- /dev/null +++ b/thinkphp/tests/thinkphp/library/think/dbTest.php @@ -0,0 +1,352 @@ + +// +---------------------------------------------------------------------- + +/** + * Db类测试 + * @author: 刘志淳 + */ + +namespace tests\thinkphp\library\think; + +use think\Db; + +class dbTest extends \PHPUnit_Framework_TestCase +{ + // 获取测试数据库配置 + private function getConfig() + { + return [ + // 数据库类型 + 'type' => 'mysql', + // 服务器地址 + 'hostname' => '127.0.0.1', + // 数据库名 + 'database' => 'test', + // 用户名 + 'username' => 'root', + // 密码 + 'password' => '', + // 端口 + 'hostport' => '', + // 连接dsn + 'dsn' => '', + // 数据库连接参数 + 'params' => [], + // 数据库编码默认采用utf8 + 'charset' => 'utf8', + // 数据库表前缀 + 'prefix' => 'tp_', + // 数据库调试模式 + 'debug' => true, + // 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器) + 'deploy' => 0, + // 数据库读写是否分离 主从式有效 + 'rw_separate' => false, + // 读写分离后 主服务器数量 + 'master_num' => 1, + // 指定从服务器序号 + 'slave_no' => '', + // 是否严格检查字段是否存在 + 'fields_strict' => true, + // 数据集返回类型 array 数组 collection Collection对象 + 'resultset_type' => 'array', + // 是否自动写入时间戳字段 + 'auto_timestamp' => false, + // 是否需要进行SQL性能分析 + 'sql_explain' => false, + ]; + } + + // 获取创建数据库 SQL + private function getCreateTableSql() + { + $sql[] = <<getConfig(); + $result = Db::connect($config)->execute('show databases'); + $this->assertNotEmpty($result); + } + + public function testExecute() + { + $config = $this->getConfig(); + $sql = $this->getCreateTableSql(); + foreach ($sql as $one) { + Db::connect($config)->execute($one); + } + $tableNum = Db::connect($config)->execute("show tables;"); + $this->assertEquals(4, $tableNum); + } + + public function testQuery() + { + $config = $this->getConfig(); + $sql = $this->getCreateTableSql(); + Db::connect($config)->batchQuery($sql); + + $tableQueryResult = Db::connect($config)->query("show tables;"); + + $this->assertTrue(is_array($tableQueryResult)); + + $tableNum = count($tableQueryResult); + $this->assertEquals(4, $tableNum); + } + + public function testBatchQuery() + { + $config = $this->getConfig(); + $sql = $this->getCreateTableSql(); + Db::connect($config)->batchQuery($sql); + + $tableNum = Db::connect($config)->execute("show tables;"); + $this->assertEquals(4, $tableNum); + } + + public function testTable() + { + $config = $this->getConfig(); + $tableName = 'tp_user'; + $result = Db::connect($config)->table($tableName); + $this->assertEquals($tableName, $result->getOptions()['table']); + } + + public function testName() + { + $config = $this->getConfig(); + $tableName = 'user'; + $result = Db::connect($config)->name($tableName); + $this->assertEquals($config['prefix'] . $tableName, $result->getTable()); + } + + public function testInsert() + { + $config = $this->getConfig(); + $data = [ + 'username' => 'chunice', + 'password' => md5('chunice'), + 'status' => 1, + 'create_time' => time(), + ]; + $result = Db::connect($config)->name('user')->insert($data); + $this->assertEquals(1, $result); + } + + public function testUpdate() + { + $config = $this->getConfig(); + $data = [ + 'username' => 'chunice_update', + 'password' => md5('chunice'), + 'status' => 1, + 'create_time' => time(), + ]; + $result = Db::connect($config)->name('user')->where('username', 'chunice')->update($data); + $this->assertEquals(1, $result); + } + + public function testFind() + { + $config = $this->getConfig(); + $mustFind = Db::connect($config)->name('user')->where('username', 'chunice_update')->find(); + $this->assertNotEmpty($mustFind); + $mustNotFind = Db::connect($config)->name('user')->where('username', 'chunice')->find(); + $this->assertEmpty($mustNotFind); + } + + public function testInsertAll() + { + $config = $this->getConfig(); + + $data = [ + ['username' => 'foo', 'password' => md5('foo'), 'status' => 1, 'create_time' => time()], + ['username' => 'bar', 'password' => md5('bar'), 'status' => 1, 'create_time' => time()], + ]; + + $insertNum = Db::connect($config)->name('user')->insertAll($data); + $this->assertEquals(count($data), $insertNum); + } + + public function testSelect() + { + $config = $this->getConfig(); + $mustFound = Db::connect($config)->name('user')->where('status', 1)->select(); + $this->assertNotEmpty($mustFound); + $mustNotFound = Db::connect($config)->name('user')->where('status', 0)->select(); + $this->assertEmpty($mustNotFound); + } + + public function testValue() + { + $config = $this->getConfig(); + $username = Db::connect($config)->name('user')->where('id', 1)->value('username'); + $this->assertEquals('chunice_update', $username); + $usernameNull = Db::connect($config)->name('user')->where('id', 0)->value('username'); + $this->assertEmpty($usernameNull); + } + + public function testColumn() + { + $config = $this->getConfig(); + $username = Db::connect($config)->name('user')->where('status', 1)->column('username'); + $this->assertNotEmpty($username); + $usernameNull = Db::connect($config)->name('user')->where('status', 0)->column('username'); + $this->assertEmpty($usernameNull); + + } + + public function testInsertGetId() + { + $config = $this->getConfig(); + $id = Db::connect($config)->name('user')->order('id', 'desc')->value('id'); + + $data = [ + 'username' => uniqid(), + 'password' => md5('chunice'), + 'status' => 1, + 'create_time' => time(), + ]; + $lastId = Db::connect($config)->name('user')->insertGetId($data); + $this->assertEquals($id + 1, $lastId); + + } + + public function testGetLastInsId() + { + $config = $this->getConfig(); + $data = [ + 'username' => uniqid(), + 'password' => md5('chunice'), + 'status' => 1, + 'create_time' => time(), + ]; + $lastId = Db::connect($config)->name('user')->insertGetId($data); + + $lastInsId = Db::connect($config)->name('user')->getLastInsID(); + $this->assertEquals($lastId, $lastInsId); + } + + public function testSetField() + { + $config = $this->getConfig(); + + $setFieldNum = Db::connect($config)->name('user')->where('id', 1)->setField('username', 'chunice_setField'); + $this->assertEquals(1, $setFieldNum); + + $setFieldNum = Db::connect($config)->name('user')->where('id', 1)->setField('username', 'chunice_setField'); + $this->assertEquals(0, $setFieldNum); + } + + public function testSetInc() + { + $config = $this->getConfig(); + $originCreateTime = Db::connect($config)->name('user')->where('id', 1)->value('create_time'); + Db::connect($config)->name('user')->where('id', 1)->setInc('create_time'); + $newCreateTime = Db::connect($config)->name('user')->where('id', 1)->value('create_time'); + $this->assertEquals($originCreateTime + 1, $newCreateTime); + + } + + public function testSetDec() + { + $config = $this->getConfig(); + $originCreateTime = Db::connect($config)->name('user')->where('id', 1)->value('create_time'); + Db::connect($config)->name('user')->where('id', 1)->setDec('create_time'); + $newCreateTime = Db::connect($config)->name('user')->where('id', 1)->value('create_time'); + $this->assertEquals($originCreateTime - 1, $newCreateTime); + } + + public function testDelete() + { + $config = $this->getConfig(); + Db::connect($config)->name('user')->where('id', 1)->delete(); + $result = Db::connect($config)->name('user')->where('id', 1)->find(); + $this->assertEmpty($result); + } + + public function testChunk() + { + // todo 暂未想到测试方法 + } + + public function testCache() + { + $config = $this->getConfig(); + $result = Db::connect($config)->name('user')->where('id', 1)->cache('key', 60)->find(); + $cache = \think\Cache::get('key'); + $this->assertEquals($result, $cache); + + $updateCache = Db::connect($config)->name('user')->cache('key')->find(1); + $this->assertEquals($cache, $updateCache); + } + +} diff --git a/thinkphp/tests/thinkphp/library/think/debugTest.php b/thinkphp/tests/thinkphp/library/think/debugTest.php new file mode 100644 index 0000000..36e1f04 --- /dev/null +++ b/thinkphp/tests/thinkphp/library/think/debugTest.php @@ -0,0 +1,220 @@ + +// +---------------------------------------------------------------------- + +/** + * Debug测试 + * @author 大漠 + */ + +namespace tests\thinkphp\library\think; + +use tests\thinkphp\library\think\config\ConfigInitTrait; +use think\Config; +use think\Debug; +use think\Response; +use think\response\Redirect; + +class debugTest extends \PHPUnit_Framework_TestCase +{ + use ConfigInitTrait; + + /** + * + * @var Debug + */ + protected $object; + + /** + * Sets up the fixture, for example, opens a network connection. + * This method is called before a test is executed. + */ + protected function setUp() + { + $this->object = new Debug(); + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + */ + protected function tearDown() + {} + + /** + * @covers \think\Debug::remark + * @todo Implement testRemark(). + */ + public function testRemark() + { + $name = "testremarkkey"; + Debug::remark($name); + } + + /** + * @covers \think\Debug::getRangeTime + * @todo Implement testGetRangeTime(). + */ + public function testGetRangeTime() + { + $start = "testGetRangeTimeStart"; + $end = "testGetRangeTimeEnd"; + Debug::remark($start); + usleep(20000); + // \think\Debug::remark($end); + + $time = Debug::getRangeTime($start, $end); + $this->assertLessThan(0.03, $time); + //$this->assertEquals(0.03, ceil($time)); + } + + /** + * @covers \think\Debug::getUseTime + * @todo Implement testGetUseTime(). + */ + public function testGetUseTime() + { + $time = Debug::getUseTime(); + $this->assertLessThan(30, $time); + } + + /** + * @covers \think\Debug::getThroughputRate + * @todo Implement testGetThroughputRate(). + */ + public function testGetThroughputRate() + { + usleep(100000); + $throughputRate = Debug::getThroughputRate(); + $this->assertLessThan(10, $throughputRate); + } + + /** + * @covers \think\Debug::getRangeMem + * @todo Implement testGetRangeMem(). + */ + public function testGetRangeMem() + { + $start = "testGetRangeMemStart"; + $end = "testGetRangeMemEnd"; + Debug::remark($start); + $str = ""; + for ($i = 0; $i < 10000; $i++) { + $str .= "mem"; + } + + $rangeMem = Debug::getRangeMem($start, $end); + + $this->assertLessThan(33, explode(" ", $rangeMem)[0]); + } + + /** + * @covers \think\Debug::getUseMem + * @todo Implement testGetUseMem(). + */ + public function testGetUseMem() + { + $useMem = Debug::getUseMem(); + + $this->assertLessThan(35, explode(" ", $useMem)[0]); + } + + /** + * @covers \think\Debug::getMemPeak + * @todo Implement testGetMemPeak(). + */ + public function testGetMemPeak() + { + $start = "testGetMemPeakStart"; + $end = "testGetMemPeakEnd"; + Debug::remark($start); + $str = ""; + for ($i = 0; $i < 100000; $i++) { + $str .= "mem"; + } + $memPeak = Debug::getMemPeak($start, $end); + $this->assertLessThan(500, explode(" ", $memPeak)[0]); + } + + /** + * @covers \think\Debug::getFile + * @todo Implement testGetFile(). + */ + public function testGetFile() + { + $count = Debug::getFile(); + + $this->assertEquals(count(get_included_files()), $count); + + $info = Debug::getFile(true); + $this->assertEquals(count(get_included_files()), count($info)); + + $this->assertContains("KB", $info[0]); + } + + /** + * @covers \think\Debug::dump + * @todo Implement testDump(). + */ + public function testDump() + { + if (strstr(PHP_VERSION, 'hhvm')) { + return; + } + + $var = []; + $var["key"] = "val"; + $output = Debug::dump($var, false, $label = "label"); + $array = explode("array", json_encode($output)); + if (IS_WIN) { + $this->assertEquals("(1) {\\n [\\\"key\\\"] => string(3) \\\"val\\\"\\n}\\n\\r\\n\"", end($array)); + } elseif (strstr(PHP_OS, 'Darwin')) { + $this->assertEquals("(1) {\\n [\\\"key\\\"] => string(3) \\\"val\\\"\\n}\\n\\n\"", end($array)); + } else { + $this->assertEquals("(1) {\\n 'key' =>\\n string(3) \\\"val\\\"\\n}\\n\\n\"", end($array)); + } + } + + /** + * @expectedException \think\exception\ClassNotFoundException + */ + public function testInjectWithErrorType() + { + Config::set('trace', ['type' => 'NullDebug']); + + $response = new Response(); + $context = 'TestWithErrorType'; + + Debug::inject($response, $context); + } + + public function testInject() + { + Config::set('trace', ['type' => 'Console']); + + $response = new Response(); + $context = 'TestWithoutBodyTag'; + Debug::inject($response, $context); + $this->assertNotEquals('TestWithoutBodyTag', $context); + $this->assertStringStartsWith('TestWithoutBodyTag', $context); + + $response = new Response(); + $context = ''; + Debug::inject($response, $context); + $this->assertNotEquals('', $context); + $this->assertStringStartsWith('', $context); + $this->assertStringEndsWith('', $context); + + $response = new Redirect(); + $context = ''; + Debug::inject($response, $context); + $this->assertEquals('', $context); + } +} diff --git a/thinkphp/tests/thinkphp/library/think/exceptionTest.php b/thinkphp/tests/thinkphp/library/think/exceptionTest.php new file mode 100644 index 0000000..66957ce --- /dev/null +++ b/thinkphp/tests/thinkphp/library/think/exceptionTest.php @@ -0,0 +1,52 @@ + +// +---------------------------------------------------------------------- + +/** + * exception类测试 + * @author Haotong Lin + */ + +namespace tests\thinkphp\library\think; + +use ReflectionMethod; +use think\Exception as ThinkException; +use think\exception\HttpException; + +class MyException extends ThinkException +{ + +} + +class exceptionTest extends \PHPUnit_Framework_TestCase +{ + public function testGetHttpStatus() + { + try { + throw new HttpException(404, "Error Processing Request"); + } catch (HttpException $e) { + $this->assertEquals(404, $e->getStatusCode()); + } + } + + public function testDebugData() + { + $data = ['a' => 'b', 'c' => 'd']; + try { + $e = new MyException("Error Processing Request", 1); + $method = new ReflectionMethod($e, 'setData'); + $method->setAccessible(true); + $method->invokeArgs($e, ['test', $data]); + throw $e; + } catch (MyException $e) { + $this->assertEquals(['test' => $data], $e->getData()); + } + } +} diff --git a/thinkphp/tests/thinkphp/library/think/hookTest.php b/thinkphp/tests/thinkphp/library/think/hookTest.php new file mode 100644 index 0000000..930ecf5 --- /dev/null +++ b/thinkphp/tests/thinkphp/library/think/hookTest.php @@ -0,0 +1,67 @@ + +// +---------------------------------------------------------------------- + +/** + * Hook类测试 + * @author liu21st + */ + +namespace tests\thinkphp\library\think; + +use think\Hook; + +class hookTest extends \PHPUnit_Framework_TestCase +{ + + public function testRun() + { + Hook::add('my_pos', '\tests\thinkphp\library\think\behavior\One'); + Hook::add('my_pos', ['\tests\thinkphp\library\think\behavior\Two']); + Hook::add('my_pos', '\tests\thinkphp\library\think\behavior\Three', true); + $data['id'] = 0; + $data['name'] = 'thinkphp'; + Hook::listen('my_pos', $data); + $this->assertEquals(2, $data['id']); + $this->assertEquals('thinkphp', $data['name']); + $this->assertEquals([ + '\tests\thinkphp\library\think\behavior\Three', + '\tests\thinkphp\library\think\behavior\One', + '\tests\thinkphp\library\think\behavior\Two'], + Hook::get('my_pos')); + } + + public function testImport() + { + Hook::import(['my_pos' => [ + '\tests\thinkphp\library\think\behavior\One', + '\tests\thinkphp\library\think\behavior\Three'], + ]); + Hook::import(['my_pos' => ['\tests\thinkphp\library\think\behavior\Two']], false); + Hook::import(['my_pos' => ['\tests\thinkphp\library\think\behavior\Three', '_overlay' => true]]); + $data['id'] = 0; + $data['name'] = 'thinkphp'; + Hook::listen('my_pos', $data); + $this->assertEquals(3, $data['id']); + + } + + public function testExec() + { + $data['id'] = 0; + $data['name'] = 'thinkphp'; + $this->assertEquals(true, Hook::exec('\tests\thinkphp\library\think\behavior\One')); + $this->assertEquals(false, Hook::exec('\tests\thinkphp\library\think\behavior\One', 'test', $data)); + $this->assertEquals('test', $data['name']); + $this->assertEquals('Closure', Hook::exec(function (&$data) {$data['name'] = 'Closure';return 'Closure';})); + + } + +} diff --git a/thinkphp/tests/thinkphp/library/think/lang/lang.php b/thinkphp/tests/thinkphp/library/think/lang/lang.php new file mode 100644 index 0000000..96880b1 --- /dev/null +++ b/thinkphp/tests/thinkphp/library/think/lang/lang.php @@ -0,0 +1,4 @@ +'加载', +]; diff --git a/thinkphp/tests/thinkphp/library/think/langTest.php b/thinkphp/tests/thinkphp/library/think/langTest.php new file mode 100644 index 0000000..360ee43 --- /dev/null +++ b/thinkphp/tests/thinkphp/library/think/langTest.php @@ -0,0 +1,76 @@ + +// +---------------------------------------------------------------------- + +/** + * Lang测试 + * @author liu21st + */ + +namespace tests\thinkphp\library\think; + +use think\Config; +use think\Lang; + +class langTest extends \PHPUnit_Framework_TestCase +{ + + public function testSetAndGet() + { + Lang::set('hello,%s', '欢迎,%s'); + $this->assertEquals('欢迎,ThinkPHP', Lang::get('hello,%s', ['ThinkPHP'])); + Lang::set('hello,%s', '歡迎,%s', 'zh-tw'); + $this->assertEquals('歡迎,ThinkPHP', Lang::get('hello,%s', ['ThinkPHP'], 'zh-tw')); + Lang::set(['hello' => '欢迎', 'use' => '使用']); + $this->assertEquals('欢迎', Lang::get('hello')); + $this->assertEquals('欢迎', Lang::get('HELLO')); + $this->assertEquals('使用', Lang::get('use')); + + Lang::set('hello,{:name}', '欢迎,{:name}'); + $this->assertEquals('欢迎,liu21st', Lang::get('hello,{:name}', ['name' => 'liu21st'])); + } + + public function testLoad() + { + Lang::load(__DIR__ . DS . 'lang' . DS . 'lang.php'); + $this->assertEquals('加载', Lang::get('load')); + Lang::load(__DIR__ . DS . 'lang' . DS . 'lang.php', 'test'); + $this->assertEquals('加载', Lang::get('load', [], 'test')); + } + + public function testDetect() + { + + Config::set('lang_list', ['zh-cn', 'zh-tw']); + Lang::set('hello', '欢迎', 'zh-cn'); + Lang::set('hello', '歡迎', 'zh-tw'); + + Config::set('lang_detect_var', 'lang'); + Config::set('lang_cookie_var', 'think_cookie'); + + $_GET['lang'] = 'zh-tw'; + Lang::detect(); + $this->assertEquals('歡迎', Lang::get('hello')); + + $_GET['lang'] = 'zh-cn'; + Lang::detect(); + $this->assertEquals('欢迎', Lang::get('hello')); + + } + + public function testRange() + { + $this->assertEquals('zh-cn', Lang::range()); + Lang::set('hello', '欢迎', 'test'); + Lang::range('test'); + $this->assertEquals('test', Lang::range()); + $this->assertEquals('欢迎', Lang::get('hello')); + } +} diff --git a/thinkphp/tests/thinkphp/library/think/loader/test/Hello.php b/thinkphp/tests/thinkphp/library/think/loader/test/Hello.php new file mode 100644 index 0000000..c141456 --- /dev/null +++ b/thinkphp/tests/thinkphp/library/think/loader/test/Hello.php @@ -0,0 +1,7 @@ + +// +---------------------------------------------------------------------- + +/** + * Loader测试 + * @author liu21st + */ + +namespace tests\thinkphp\library\think; + +use think\Loader; + +class loaderTest extends \PHPUnit_Framework_TestCase +{ + + public function testAutoload() + { + $this->assertEquals(false, Loader::autoload('\think\Url')); + $this->assertEquals(false, Loader::autoload('think\Test')); + $this->assertEquals(false, Loader::autoload('my\HelloTest')); + } + + public function testAddClassMap() + { + Loader::addClassMap('my\hello\Test', __DIR__ . DS . 'loader' . DS . 'Test.php'); + } + + public function testAddNamespace() + { + Loader::addNamespace('top', __DIR__ . DS . 'loader' . DS); + $this->assertEquals(true, Loader::autoload('top\test\Hello')); + } + + public function testAddNamespaceAlias() + { + Loader::addNamespaceAlias('top', 'top\test'); + Loader::addNamespaceAlias(['top' => 'top\test', 'app' => 'app\index']); + //$this->assertEquals(true, Loader::autoload('top\Hello')); + } + + public function testTable() + { + Loader::db('mysql://root@127.0.0.1/test#utf8'); + } + + public function testImport() + { + $this->assertEquals(false, Loader::import('think.log.driver.MyTest')); + } + + public function testParseName() + { + $this->assertEquals('HelloTest', Loader::parseName('hello_test', 1)); + $this->assertEquals('hello_test', Loader::parseName('HelloTest', 0)); + } + + public function testParseClass() + { + $this->assertEquals('app\index\controller\User', Loader::parseClass('index', 'controller', 'user')); + $this->assertEquals('app\index\controller\user\Type', Loader::parseClass('index', 'controller', 'user.type')); + $this->assertEquals('app\admin\model\UserType', Loader::parseClass('admin', 'model', 'user_type')); + } +} diff --git a/thinkphp/tests/thinkphp/library/think/log/driver/fileTest.php b/thinkphp/tests/thinkphp/library/think/log/driver/fileTest.php new file mode 100644 index 0000000..ad6dd22 --- /dev/null +++ b/thinkphp/tests/thinkphp/library/think/log/driver/fileTest.php @@ -0,0 +1,34 @@ + +// +---------------------------------------------------------------------- + +/** + * Test File Log + */ +namespace tests\thinkphp\library\think\log\driver; + +use think\Log; + +class fileTest extends \PHPUnit_Framework_TestCase +{ + protected function setUp() + { + Log::init(['type' => 'file']); + } + + public function testRecord() + { + $record_msg = 'record'; + Log::record($record_msg, 'notice'); + $logs = Log::getLog(); + + $this->assertEquals([], $logs); + } +} diff --git a/thinkphp/tests/thinkphp/library/think/logTest.php b/thinkphp/tests/thinkphp/library/think/logTest.php new file mode 100644 index 0000000..e786b17 --- /dev/null +++ b/thinkphp/tests/thinkphp/library/think/logTest.php @@ -0,0 +1,39 @@ + +// +---------------------------------------------------------------------- + +/** + * Log测试 + * @author liu21st + */ +namespace tests\thinkphp\library\think; + +use think\Log; + +class logTest extends \PHPUnit_Framework_TestCase +{ + + public function testSave() + { + Log::init(['type' => 'test']); + Log::clear(); + Log::record('test'); + Log::record([1, 2, 3]); + $this->assertTrue(Log::save()); + } + + public function testWrite() + { + Log::init(['type' => 'test']); + Log::clear(); + $this->assertTrue(Log::write('hello', 'info')); + $this->assertTrue(Log::write([1, 2, 3], 'log')); + } +} diff --git a/thinkphp/tests/thinkphp/library/think/model/.gitignore b/thinkphp/tests/thinkphp/library/think/model/.gitignore new file mode 100644 index 0000000..c96a04f --- /dev/null +++ b/thinkphp/tests/thinkphp/library/think/model/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore \ No newline at end of file diff --git a/thinkphp/tests/thinkphp/library/think/paginateTest.php b/thinkphp/tests/thinkphp/library/think/paginateTest.php new file mode 100644 index 0000000..8cd4550 --- /dev/null +++ b/thinkphp/tests/thinkphp/library/think/paginateTest.php @@ -0,0 +1,40 @@ + +// +---------------------------------------------------------------------- + +namespace tests\thinkphp\library\think; + +use think\paginator\driver\Bootstrap; + +class paginateTest extends \PHPUnit_Framework_TestCase +{ + public function testPaginatorInfo() + { + $p = Bootstrap::make($array = ['item3', 'item4'], 2, 2, 4); + + $this->assertEquals(4, $p->total()); + + $this->assertEquals(2, $p->listRows()); + + $this->assertEquals(2, $p->currentPage()); + + $p2 = Bootstrap::make($array2 = ['item3', 'item4'], 2, 2, 2); + $this->assertEquals(1, $p2->currentPage()); + } + + public function testPaginatorRender() + { + $p = Bootstrap::make($array = ['item3', 'item4'], 2, 2, 100); + $render = ''; + + $this->assertEquals($render, $p->render()); + } + +} diff --git a/thinkphp/tests/thinkphp/library/think/requestTest.php b/thinkphp/tests/thinkphp/library/think/requestTest.php new file mode 100644 index 0000000..3da94a2 --- /dev/null +++ b/thinkphp/tests/thinkphp/library/think/requestTest.php @@ -0,0 +1,203 @@ + +// +---------------------------------------------------------------------- + +/** + * Db类测试 + */ + +namespace tests\thinkphp\library\think; + +use think\Config; +use think\Request; + +class requestTest extends \PHPUnit_Framework_TestCase +{ + protected $request; + + public function setUp() + { + //$request = Request::create('http://www.domain.com/index/index/hello/?name=thinkphp'); + + } + + public function testCreate() + { + $request = Request::create('http://www.thinkphp.cn/index/index/hello.html?name=thinkphp'); + $this->assertEquals('http://www.thinkphp.cn', $request->domain()); + $this->assertEquals('/index/index/hello.html?name=thinkphp', $request->url()); + $this->assertEquals('/index/index/hello.html', $request->baseurl()); + $this->assertEquals('index/index/hello.html', $request->pathinfo()); + $this->assertEquals('index/index/hello', $request->path()); + $this->assertEquals('html', $request->ext()); + $this->assertEquals('name=thinkphp', $request->query()); + $this->assertEquals('www.thinkphp.cn', $request->host()); + $this->assertEquals(80, $request->port()); + $this->assertEquals($_SERVER['REQUEST_TIME'], $request->time()); + $this->assertEquals($_SERVER['REQUEST_TIME_FLOAT'], $request->time(true)); + $this->assertEquals('GET', $request->method()); + $this->assertEquals(['name' => 'thinkphp'], $request->param()); + $this->assertFalse($request->isSsl()); + $this->assertEquals('http', $request->scheme()); + } + + public function testDomain() + { + $request = Request::instance(); + $request->domain('http://thinkphp.cn'); + $this->assertEquals('http://thinkphp.cn', $request->domain()); + } + + public function testUrl() + { + $request = Request::instance(); + $request->url('/index.php/index/hello?name=thinkphp'); + $this->assertEquals('/index.php/index/hello?name=thinkphp', $request->url()); + $this->assertEquals('http://thinkphp.cn/index.php/index/hello?name=thinkphp', $request->url(true)); + } + + public function testBaseUrl() + { + $request = Request::instance(); + $request->baseurl('/index.php/index/hello'); + $this->assertEquals('/index.php/index/hello', $request->baseurl()); + $this->assertEquals('http://thinkphp.cn/index.php/index/hello', $request->baseurl(true)); + } + + public function testbaseFile() + { + $request = Request::instance(); + $request->basefile('/index.php'); + $this->assertEquals('/index.php', $request->basefile()); + $this->assertEquals('http://thinkphp.cn/index.php', $request->basefile(true)); + } + + public function testroot() + { + $request = Request::instance(); + $request->root('/index.php'); + $this->assertEquals('/index.php', $request->root()); + $this->assertEquals('http://thinkphp.cn/index.php', $request->root(true)); + } + + public function testType() + { + $request = Request::instance(); + $request->server(['HTTP_ACCEPT' => 'application/json']); + + $this->assertEquals('json', $request->type()); + $request->mimeType('test', 'application/test'); + $request->mimeType(['test' => 'application/test']); + $request->server(['HTTP_ACCEPT' => 'application/test']); + + $this->assertEquals('test', $request->type()); + } + + public function testmethod() + { + $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'] = 'DELETE'; + + $request = Request::create('', ''); + $this->assertEquals('DELETE', $request->method()); + $this->assertEquals('GET', $request->method(true)); + + Config::set('var_method', '_method'); + $_POST['_method'] = 'POST'; + $request = Request::create('', ''); + $this->assertEquals('POST', $request->method()); + $this->assertEquals('GET', $request->method(true)); + $this->assertTrue($request->isPost()); + $this->assertFalse($request->isGet()); + $this->assertFalse($request->isPut()); + $this->assertFalse($request->isDelete()); + $this->assertFalse($request->isHead()); + $this->assertFalse($request->isPatch()); + $this->assertFalse($request->isOptions()); + } + + public function testCli() + { + $request = Request::instance(); + $this->assertTrue($request->isCli()); + } + + public function testVar() + { + Config::set('app_multi_module', true); + $request = Request::create(''); + $request->route(['name' => 'thinkphp', 'id' => 6]); + $request->get(['id' => 10]); + $request->post(['id' => 8]); + $request->put(['id' => 7]); + $request->request(['test' => 'value']); + $this->assertEquals(['name' => 'thinkphp', 'id' => 6], $request->route()); + //$this->assertEquals(['id' => 10], $request->get()); + $this->assertEquals('thinkphp', $request->route('name')); + $this->assertEquals('default', $request->route('test', 'default')); + $this->assertEquals(10, $request->get('id')); + $this->assertEquals(0, $request->get('ids', 0)); + $this->assertEquals(8, $request->post('id')); + $this->assertEquals(7, $request->put('id')); + $this->assertEquals('value', $request->request('test')); + $this->assertEquals('thinkphp', $request->param('name')); + $this->assertEquals(6, $request->param('id')); + $this->assertFalse($request->has('user_id')); + $this->assertTrue($request->has('test', 'request')); + $this->assertEquals(['id' => 6], $request->only('id')); + $this->assertEquals(['name' => 'thinkphp', 'lang' => 'zh-cn'], $request->except('id')); + $this->assertEquals('THINKPHP', $request->param('name', '', 'strtoupper')); + } + + public function testIsAjax() + { + $request = Request::create(''); + + $this->assertFalse($request->isAjax()); + + $_SERVER['HTTP_X_REQUESTED_WITH'] = 'xmlhttprequest'; + $this->assertFalse($request->isAjax()); + $this->assertFalse($request->isAjax(true)); + + $request->server(['HTTP_X_REQUESTED_WITH' => 'xmlhttprequest']); + $this->assertTrue($request->isAjax()); + } + + public function testIsPjax() + { + $request = Request::create(''); + + $this->assertFalse($request->isPjax()); + + $_SERVER['HTTP_X_PJAX'] = true; + $this->assertFalse($request->isPjax()); + $this->assertFalse($request->isPjax(true)); + + $request->server(['HTTP_X_PJAX' => true]); + $this->assertTrue($request->isPjax()); + $request->server(['HTTP_X_PJAX' => false]); + $this->assertTrue($request->isPjax()); + } + + public function testIsMobile() + { + $request = Request::create(''); + $_SERVER['HTTP_VIA'] = 'wap'; + $this->assertTrue($request->isMobile()); + } + + public function testBind() + { + $request = Request::create(''); + $request->user = 'User1'; + $request->bind(['user' => 'User2']); + $this->assertEquals('User2', $request->user); + } + +} diff --git a/thinkphp/tests/thinkphp/library/think/responseTest.php b/thinkphp/tests/thinkphp/library/think/responseTest.php new file mode 100644 index 0000000..62d1574 --- /dev/null +++ b/thinkphp/tests/thinkphp/library/think/responseTest.php @@ -0,0 +1,95 @@ + +// +---------------------------------------------------------------------- + +/** + * Response测试 + * @author 大漠 + */ + +namespace tests\thinkphp\library\think; + +use think\Config; +use think\Request; +use think\Response; + +class responseTest extends \PHPUnit_Framework_TestCase +{ + + /** + * + * @var \think\Response + */ + protected $object; + + protected $default_return_type; + + protected $default_ajax_return; + + /** + * Sets up the fixture, for example, opens a network connection. + * This method is called before a test is executed. + */ + protected function setUp() + { + // 1. + // restore_error_handler(); + // Warning: Cannot modify header information - headers already sent by (output started at PHPUnit\Util\Printer.php:173) + // more see in https://www.analysisandsolutions.com/blog/html/writing-phpunit-tests-for-wordpress-plugins-wp-redirect-and-continuing-after-php-errors.htm + + // 2. + // the Symfony used the HeaderMock.php + + // 3. + // not run the eclipse will held, and travis-ci.org Searching for coverage reports + // **> Python coverage not found + // **> No coverage report found. + // add the + // /** + // * @runInSeparateProcess + // */ + if (!$this->default_return_type) { + $this->default_return_type = Config::get('default_return_type'); + } + if (!$this->default_ajax_return) { + $this->default_ajax_return = Config::get('default_ajax_return'); + } + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + */ + protected function tearDown() + { + Config::set('default_ajax_return', $this->default_ajax_return); + Config::set('default_return_type', $this->default_return_type); + } + + /** + * @covers think\Response::send + * @todo Implement testSend(). + */ + public function testSend() + { + $dataArr = []; + $dataArr["key"] = "value"; + + $response = Response::create($dataArr, 'json'); + $result = $response->getContent(); + $this->assertEquals('{"key":"value"}', $result); + $request = Request::instance(); + $request->get(['callback' => 'callback']); + $response = Response::create($dataArr, 'jsonp'); + $result = $response->getContent(); + $this->assertEquals('callback({"key":"value"});', $result); + } + +} diff --git a/thinkphp/tests/thinkphp/library/think/routeTest.php b/thinkphp/tests/thinkphp/library/think/routeTest.php new file mode 100644 index 0000000..31e1b86 --- /dev/null +++ b/thinkphp/tests/thinkphp/library/think/routeTest.php @@ -0,0 +1,287 @@ + +// +---------------------------------------------------------------------- + +/** + * Route测试 + * @author liu21st + */ + +namespace tests\thinkphp\library\think; + +use think\Config; +use think\Request; +use think\Route; + +class routeTest extends \PHPUnit_Framework_TestCase +{ + + protected function setUp() + { + Config::set('app_multi_module', true); + } + + public function testRegister() + { + $request = Request::instance(); + Route::get('hello/:name', 'index/hello'); + Route::get(['hello/:name' => 'index/hello']); + Route::post('hello/:name', 'index/post'); + Route::put('hello/:name', 'index/put'); + Route::delete('hello/:name', 'index/delete'); + Route::patch('hello/:name', 'index/patch'); + Route::any('user/:id', 'index/user'); + $result = Route::check($request, 'hello/thinkphp'); + $this->assertEquals([null, 'index', 'hello'], $result['module']); + $this->assertEquals(['hello' => true, 'user/:id' => true, 'hello/:name' => ['rule' => 'hello/:name', 'route' => 'index/hello', 'var' => ['name' => 1], 'option' => [], 'pattern' => []]], Route::rules('GET')); + Route::rule('type1/:name', 'index/type', 'PUT|POST'); + Route::rule(['type2/:name' => 'index/type1']); + Route::rule([['type3/:name', 'index/type2', ['method' => 'POST']]]); + Route::rule(['name', 'type4/:name'], 'index/type4'); + } + + public function testImport() + { + $rule = [ + '__domain__' => ['subdomain2.thinkphp.cn' => 'blog1'], + '__alias__' => ['blog1' => 'blog1'], + '__rest__' => ['res' => ['index/blog']], + 'bbb' => ['index/blog1', ['method' => 'POST']], + 'ddd' => '', + ['hello1/:ddd', 'index/hello1', ['method' => 'POST']], + ]; + Route::import($rule); + } + + public function testResource() + { + $request = Request::instance(); + Route::resource('res', 'index/blog'); + Route::resource(['res' => ['index/blog']]); + $result = Route::check($request, 'res'); + $this->assertEquals(['index', 'blog', 'index'], $result['module']); + $result = Route::check($request, 'res/create'); + $this->assertEquals(['index', 'blog', 'create'], $result['module']); + $result = Route::check($request, 'res/8'); + $this->assertEquals(['index', 'blog', 'read'], $result['module']); + $result = Route::check($request, 'res/8/edit'); + $this->assertEquals(['index', 'blog', 'edit'], $result['module']); + + Route::resource('blog.comment', 'index/comment'); + $result = Route::check($request, 'blog/8/comment/10'); + $this->assertEquals(['index', 'comment', 'read'], $result['module']); + $result = Route::check($request, 'blog/8/comment/10/edit'); + $this->assertEquals(['index', 'comment', 'edit'], $result['module']); + + } + + public function testRest() + { + $request = Request::instance(); + Route::rest('read', ['GET', '/:id', 'look']); + Route::rest('create', ['GET', '/create', 'add']); + Route::rest(['read' => ['GET', '/:id', 'look'], 'create' => ['GET', '/create', 'add']]); + Route::resource('res', 'index/blog'); + $result = Route::check($request, 'res/create'); + $this->assertEquals(['index', 'blog', 'add'], $result['module']); + $result = Route::check($request, 'res/8'); + $this->assertEquals(['index', 'blog', 'look'], $result['module']); + + } + + public function testMixVar() + { + $request = Request::instance(); + Route::get('hello-', 'index/hello', [], ['name' => '\w+']); + $result = Route::check($request, 'hello-thinkphp'); + $this->assertEquals([null, 'index', 'hello'], $result['module']); + Route::get('hello-', 'index/hello', [], ['name' => '\w+', 'id' => '\d+']); + $result = Route::check($request, 'hello-thinkphp2016'); + $this->assertEquals([null, 'index', 'hello'], $result['module']); + Route::get('hello-/[:id]', 'index/hello', [], ['name' => '\w+', 'id' => '\d+']); + $result = Route::check($request, 'hello-thinkphp/2016'); + $this->assertEquals([null, 'index', 'hello'], $result['module']); + } + + public function testParseUrl() + { + $result = Route::parseUrl('hello'); + $this->assertEquals(['hello', null, null], $result['module']); + $result = Route::parseUrl('index/hello'); + $this->assertEquals(['index', 'hello', null], $result['module']); + $result = Route::parseUrl('index/hello?name=thinkphp'); + $this->assertEquals(['index', 'hello', null], $result['module']); + $result = Route::parseUrl('index/user/hello'); + $this->assertEquals(['index', 'user', 'hello'], $result['module']); + $result = Route::parseUrl('index/user/hello/name/thinkphp'); + $this->assertEquals(['index', 'user', 'hello'], $result['module']); + $result = Route::parseUrl('index-index-hello', '-'); + $this->assertEquals(['index', 'index', 'hello'], $result['module']); + } + + public function testCheckRoute() + { + Route::get('hello/:name', 'index/hello'); + Route::get('blog/:id', 'blog/read', [], ['id' => '\d+']); + $request = Request::instance(); + $this->assertEquals(false, Route::check($request, 'test/thinkphp')); + $this->assertEquals(false, Route::check($request, 'blog/thinkphp')); + $result = Route::check($request, 'blog/5'); + $this->assertEquals([null, 'blog', 'read'], $result['module']); + $result = Route::check($request, 'hello/thinkphp/abc/test'); + $this->assertEquals([null, 'index', 'hello'], $result['module']); + } + + public function testCheckRouteGroup() + { + $request = Request::instance(); + Route::pattern(['id' => '\d+']); + Route::pattern('name', '\w{6,25}'); + Route::group('group', [':id' => 'index/hello', ':name' => 'index/say']); + $this->assertEquals(false, Route::check($request, 'empty/think')); + $result = Route::check($request, 'group/think'); + $this->assertEquals(false, $result['module']); + $result = Route::check($request, 'group/10'); + $this->assertEquals([null, 'index', 'hello'], $result['module']); + $result = Route::check($request, 'group/thinkphp'); + $this->assertEquals([null, 'index', 'say'], $result['module']); + Route::group('group2', function () { + Route::group('group3', [':id' => 'index/hello', ':name' => 'index/say']); + Route::rule(':name', 'index/hello'); + Route::auto('index'); + }); + $result = Route::check($request, 'group2/thinkphp'); + $this->assertEquals([null, 'index', 'hello'], $result['module']); + $result = Route::check($request, 'group2/think'); + $this->assertEquals(['index', 'group2', 'think'], $result['module']); + $result = Route::check($request, 'group2/group3/thinkphp'); + $this->assertEquals([null, 'index', 'say'], $result['module']); + Route::group('group4', function () { + Route::group('group3', [':id' => 'index/hello', ':name' => 'index/say']); + Route::rule(':name', 'index/hello'); + Route::miss('index/__miss__'); + }); + $result = Route::check($request, 'group4/thinkphp'); + $this->assertEquals([null, 'index', 'hello'], $result['module']); + $result = Route::check($request, 'group4/think'); + $this->assertEquals([null, 'index', '__miss__'], $result['module']); + + Route::group(['prefix' => 'prefix/'], function () { + Route::rule('hello4/:name', 'hello'); + }); + Route::group(['prefix' => 'prefix/'], [ + 'hello4/:name' => 'hello', + ]); + $result = Route::check($request, 'hello4/thinkphp'); + $this->assertEquals([null, 'prefix', 'hello'], $result['module']); + Route::group('group5', [ + [':name', 'hello', ['method' => 'GET|POST']], + ':id' => 'hello', + ], ['prefix' => 'prefix/']); + $result = Route::check($request, 'group5/thinkphp'); + $this->assertEquals([null, 'prefix', 'hello'], $result['module']); + } + + public function testControllerRoute() + { + $request = Request::instance(); + Route::controller('controller', 'index/Blog'); + $result = Route::check($request, 'controller/info'); + $this->assertEquals(['index', 'Blog', 'getinfo'], $result['module']); + Route::setMethodPrefix('GET', 'read'); + Route::setMethodPrefix(['get' => 'read']); + Route::controller('controller', 'index/Blog'); + $result = Route::check($request, 'controller/phone'); + $this->assertEquals(['index', 'Blog', 'readphone'], $result['module']); + } + + public function testAliasRoute() + { + $request = Request::instance(); + Route::alias('alias', 'index/Alias'); + $result = Route::check($request, 'alias/info'); + $this->assertEquals('index/Alias/info', $result['module']); + } + + public function testRouteToModule() + { + $request = Request::instance(); + Route::get('hello/:name', 'index/hello'); + Route::get('blog/:id', 'blog/read', [], ['id' => '\d+']); + $this->assertEquals(false, Route::check($request, 'test/thinkphp')); + $this->assertEquals(false, Route::check($request, 'blog/thinkphp')); + $result = Route::check($request, 'hello/thinkphp'); + $this->assertEquals([null, 'index', 'hello'], $result['module']); + $result = Route::check($request, 'blog/5'); + $this->assertEquals([null, 'blog', 'read'], $result['module']); + } + + public function testRouteToController() + { + $request = Request::instance(); + Route::get('say/:name', '@index/hello'); + $this->assertEquals(['type' => 'controller', 'controller' => 'index/hello', 'var' => []], Route::check($request, 'say/thinkphp')); + } + + public function testRouteToMethod() + { + $request = Request::instance(); + Route::get('user/:name', '\app\index\service\User::get', [], ['name' => '\w+']); + Route::get('info/:name', '\app\index\model\Info@getInfo', [], ['name' => '\w+']); + $this->assertEquals(['type' => 'method', 'method' => '\app\index\service\User::get', 'var' => []], Route::check($request, 'user/thinkphp')); + $this->assertEquals(['type' => 'method', 'method' => ['\app\index\model\Info', 'getInfo'], 'var' => []], Route::check($request, 'info/thinkphp')); + } + + public function testRouteToRedirect() + { + $request = Request::instance(); + Route::get('art/:id', '/article/read/id/:id', [], ['id' => '\d+']); + $this->assertEquals(['type' => 'redirect', 'url' => '/article/read/id/8', 'status' => 301], Route::check($request, 'art/8')); + } + + public function testBind() + { + $request = Request::instance(); + Route::bind('index/blog'); + Route::get('blog/:id', 'index/blog/read'); + $result = Route::check($request, 'blog/10'); + $this->assertEquals(['index', 'blog', 'read'], $result['module']); + $result = Route::parseUrl('test'); + $this->assertEquals(['index', 'blog', 'test'], $result['module']); + + Route::bind('\app\index\controller', 'namespace'); + $this->assertEquals(['type' => 'method', 'method' => ['\app\index\controller\Blog', 'read'], 'var' => []], Route::check($request, 'blog/read')); + + Route::bind('\app\index\controller\Blog', 'class'); + $this->assertEquals(['type' => 'method', 'method' => ['\app\index\controller\Blog', 'read'], 'var' => []], Route::check($request, 'read')); + } + + public function testDomain() + { + $request = Request::create('http://subdomain.thinkphp.cn'); + Route::domain('subdomain.thinkphp.cn', 'sub?abc=test&status=1'); + $rules = Route::rules('GET'); + Route::checkDomain($request, $rules); + $this->assertEquals('sub', Route::getbind('module')); + $this->assertEquals('test', $_GET['abc']); + $this->assertEquals(1, $_GET['status']); + + Route::domain('subdomain.thinkphp.cn', '\app\index\controller'); + $rules = Route::rules('GET'); + Route::checkDomain($request, $rules); + $this->assertEquals('\app\index\controller', Route::getbind('namespace')); + + Route::domain(['subdomain.thinkphp.cn' => '@\app\index\controller\blog']); + $rules = Route::rules('GET'); + Route::checkDomain($request, $rules); + $this->assertEquals('\app\index\controller\blog', Route::getbind('class')); + + } +} diff --git a/thinkphp/tests/thinkphp/library/think/session/.gitignore b/thinkphp/tests/thinkphp/library/think/session/.gitignore new file mode 100644 index 0000000..c96a04f --- /dev/null +++ b/thinkphp/tests/thinkphp/library/think/session/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore \ No newline at end of file diff --git a/thinkphp/tests/thinkphp/library/think/sessionTest.php b/thinkphp/tests/thinkphp/library/think/sessionTest.php new file mode 100644 index 0000000..5fd95f1 --- /dev/null +++ b/thinkphp/tests/thinkphp/library/think/sessionTest.php @@ -0,0 +1,319 @@ + +// +---------------------------------------------------------------------- + +/** + * Session测试 + * @author 大漠 + */ + +namespace tests\thinkphp\library\think; + +use think\Session; + +class sessionTest extends \PHPUnit_Framework_TestCase +{ + + /** + * + * @var \think\Session + */ + protected $object; + + /** + * Sets up the fixture, for example, opens a network connection. + * This method is called before a test is executed. + */ + protected function setUp() + { + // $this->object = new Session (); + // register_shutdown_function ( function () { + // } ); // 此功能无法取消,需要回调函数配合。 + set_exception_handler(function () {}); + set_error_handler(function () {}); + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + */ + protected function tearDown() + { + register_shutdown_function('think\Error::appShutdown'); + set_error_handler('think\Error::appError'); + set_exception_handler('think\Error::appException'); + } + + /** + * @covers think\Session::prefix + * + * @todo Implement testPrefix(). + */ + public function testPrefix() + { + Session::prefix(null); + Session::prefix('think_'); + + $this->assertEquals('think_', Session::prefix()); + } + + /** + * @covers think\Session::init + * + * @todo Implement testInit(). + */ + public function testInit() + { + Session::prefix(null); + $config = [ + // cookie 名称前缀 + 'prefix' => 'think_', + // cookie 保存时间 + 'expire' => 60, + // cookie 保存路径 + 'path' => '/path/to/test/session/', + // cookie 有效域名 + 'domain' => '.thinkphp.cn', + 'var_session_id' => 'sessionidtest', + 'id' => 'sess_8fhgkjuakhatbeg2fa14lo84q1', + 'name' => 'session_name', + 'use_trans_sid' => '1', + 'use_cookies' => '1', + 'cache_limiter' => '60', + 'cache_expire' => '60', + 'type' => '', // memcache + 'namespace' => '\\think\\session\\driver\\', // ? + 'auto_start' => '1', + ]; + + $_REQUEST[$config['var_session_id']] = $config['id']; + Session::init($config); + + // 开始断言 + $this->assertEquals($config['prefix'], Session::prefix()); + $this->assertEquals($config['id'], $_REQUEST[$config['var_session_id']]); + $this->assertEquals($config['name'], session_name()); + + $this->assertEquals($config['path'], session_save_path()); + $this->assertEquals($config['use_cookies'], ini_get('session.use_cookies')); + $this->assertEquals($config['domain'], ini_get('session.cookie_domain')); + $this->assertEquals($config['expire'], ini_get('session.gc_maxlifetime')); + $this->assertEquals($config['expire'], ini_get('session.cookie_lifetime')); + + $this->assertEquals($config['cache_limiter'], session_cache_limiter($config['cache_limiter'])); + $this->assertEquals($config['cache_expire'], session_cache_expire($config['cache_expire'])); + + // 检测分支 + $_REQUEST[$config['var_session_id']] = null; + session_write_close(); + session_destroy(); + + Session::init($config); + + // 测试auto_start + // PHP_SESSION_DISABLED + // PHP_SESSION_NONE + // PHP_SESSION_ACTIVE + // session_status() + if (strstr(PHP_VERSION, 'hhvm')) { + $this->assertEquals('', ini_get('session.auto_start')); + } else { + $this->assertEquals(0, ini_get('session.auto_start')); + } + + $this->assertEquals($config['use_trans_sid'], ini_get('session.use_trans_sid')); + + Session::init($config); + $this->assertEquals($config['id'], session_id()); + } + + /** + * 单独重现异常 + * @expectedException \think\Exception + */ + public function testException() + { + $config = [ + // cookie 名称前缀 + 'prefix' => 'think_', + // cookie 保存时间 + 'expire' => 0, + // cookie 保存路径 + 'path' => '/path/to/test/session/', + // cookie 有效域名 + 'domain' => '.thinkphp.cn', + 'var_session_id' => 'sessionidtest', + 'id' => 'sess_8fhgkjuakhatbeg2fa14lo84q1', + 'name' => 'session_name', + 'use_trans_sid' => '1', + 'use_cookies' => '1', + 'cache_limiter' => '60', + 'cache_expire' => '60', + 'type' => '\\think\\session\\driver\\Memcache', // + 'auto_start' => '1', + ]; + + // 测试session驱动是否存在 + // @expectedException 异常类名 + $this->setExpectedException('\think\exception\ClassNotFoundException', 'error session handler'); + + Session::init($config); + } + + /** + * @covers think\Session::set + * + * @todo Implement testSet(). + */ + public function testSet() + { + Session::prefix(null); + Session::set('sessionname', 'sessionvalue'); + $this->assertEquals('sessionvalue', $_SESSION['sessionname']); + + Session::set('sessionnamearr.subname', 'sessionvalue'); + $this->assertEquals('sessionvalue', $_SESSION['sessionnamearr']['subname']); + + Session::set('sessionnameper', 'sessionvalue', 'think_'); + $this->assertEquals('sessionvalue', $_SESSION['think_']['sessionnameper']); + + Session::set('sessionnamearrper.subname', 'sessionvalue', 'think_'); + $this->assertEquals('sessionvalue', $_SESSION['think_']['sessionnamearrper']['subname']); + } + + /** + * @covers think\Session::get + * + * @todo Implement testGet(). + */ + public function testGet() + { + Session::prefix(null); + + Session::set('sessionnameget', 'sessionvalue'); + $this->assertEquals(Session::get('sessionnameget'), $_SESSION['sessionnameget']); + + Session::set('sessionnamegetarr.subname', 'sessionvalue'); + $this->assertEquals(Session::get('sessionnamegetarr.subname'), $_SESSION['sessionnamegetarr']['subname']); + + Session::set('sessionnamegetarrperall', 'sessionvalue', 'think_'); + $this->assertEquals(Session::get('', 'think_')['sessionnamegetarrperall'], $_SESSION['think_']['sessionnamegetarrperall']); + + Session::set('sessionnamegetper', 'sessionvalue', 'think_'); + $this->assertEquals(Session::get('sessionnamegetper', 'think_'), $_SESSION['think_']['sessionnamegetper']); + + Session::set('sessionnamegetarrper.subname', 'sessionvalue', 'think_'); + $this->assertEquals(Session::get('sessionnamegetarrper.subname', 'think_'), $_SESSION['think_']['sessionnamegetarrper']['subname']); + } + + public function testPull() + { + Session::prefix(null); + Session::set('sessionnamedel', 'sessionvalue'); + $this->assertEquals('sessionvalue', Session::pull('sessionnameget')); + $this->assertNull(Session::get('sessionnameget')); + } + + /** + * @covers think\Session::delete + * + * @todo Implement testDelete(). + */ + public function testDelete() + { + Session::prefix(null); + Session::set('sessionnamedel', 'sessionvalue'); + Session::delete('sessionnamedel'); + $this->assertEmpty($_SESSION['sessionnamedel']); + + Session::set('sessionnamedelarr.subname', 'sessionvalue'); + Session::delete('sessionnamedelarr.subname'); + $this->assertEmpty($_SESSION['sessionnamedelarr']['subname']); + + Session::set('sessionnamedelper', 'sessionvalue', 'think_'); + Session::delete('sessionnamedelper', 'think_'); + $this->assertEmpty($_SESSION['think_']['sessionnamedelper']); + + Session::set('sessionnamedelperarr.subname', 'sessionvalue', 'think_'); + Session::delete('sessionnamedelperarr.subname', 'think_'); + $this->assertEmpty($_SESSION['think_']['sessionnamedelperarr']['subname']); + } + + /** + * @covers think\Session::clear + * + * @todo Implement testClear(). + */ + public function testClear() + { + Session::prefix(null); + + Session::set('sessionnameclsper', 'sessionvalue1', 'think_'); + Session::clear('think_'); + $this->assertNull($_SESSION['think_']); + + Session::set('sessionnameclsper', 'sessionvalue1', 'think_'); + Session::clear(); + $this->assertEmpty($_SESSION); + } + + /** + * @covers think\Session::has + * + * @todo Implement testHas(). + */ + public function testHas() + { + Session::prefix(null); + Session::set('sessionnamehas', 'sessionvalue'); + $this->assertTrue(Session::has('sessionnamehas')); + + Session::set('sessionnamehasarr.subname', 'sessionvalue'); + $this->assertTrue(Session::has('sessionnamehasarr.subname')); + + Session::set('sessionnamehasper', 'sessionvalue', 'think_'); + $this->assertTrue(Session::has('sessionnamehasper', 'think_')); + + Session::set('sessionnamehasarrper.subname', 'sessionvalue', 'think_'); + $this->assertTrue(Session::has('sessionnamehasarrper.subname', 'think_')); + } + + /** + * @covers think\Session::pause + * + * @todo Implement testPause(). + */ + public function testPause() + { + Session::pause(); + } + + /** + * @covers think\Session::start + * + * @todo Implement testStart(). + */ + public function testStart() + { + Session::start(); + } + + /** + * @covers think\Session::destroy + * + * @todo Implement testDestroy(). + */ + public function testDestroy() + { + Session::set('sessionnamedestroy', 'sessionvalue'); + Session::destroy(); + $this->assertEmpty($_SESSION['sessionnamedestroy']); + } +} diff --git a/thinkphp/tests/thinkphp/library/think/template/driver/.gitignore b/thinkphp/tests/thinkphp/library/think/template/driver/.gitignore new file mode 100644 index 0000000..c96a04f --- /dev/null +++ b/thinkphp/tests/thinkphp/library/think/template/driver/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore \ No newline at end of file diff --git a/thinkphp/tests/thinkphp/library/think/template/taglib/cxTest.php b/thinkphp/tests/thinkphp/library/think/template/taglib/cxTest.php new file mode 100644 index 0000000..8aee392 --- /dev/null +++ b/thinkphp/tests/thinkphp/library/think/template/taglib/cxTest.php @@ -0,0 +1,575 @@ + +// +---------------------------------------------------------------------- + +/** + * 模板测试 + * @author Haotong Lin + */ + +namespace tests\thinkphp\library\think\tempplate\taglib; + +use think\Template; +use think\template\taglib\Cx; + +class cxTest extends \PHPUnit_Framework_TestCase +{ + public function testPhp() + { + $template = new template(); + $cx = new Cx($template); + + $content = << +EOF; + $cx->parseTag($content); + $this->assertEquals($content, $data); + } + + public function testVolist() + { + $template = new template(); + $cx = new Cx($template); + + $content = <<\$vo): \$mod = (\$key % 2 );++\$key;?> + + +EOF; + $cx->parseTag($content); + $this->assertEquals($data, $content); + + $content = <<display($content, ['list' => [1, 2, 3, 4, 5]]); + $this->expectOutputString('234'); + } + + public function testForeach() + { + $template = new template(); + $cx = new Cx($template); + + $content = <<\$val} + +{/foreach} +EOF; + $data = <<\$val): ?> + + +EOF; + $cx->parseTag($content); + $this->assertEquals($content, $data); + + $content = <<\$val): ?> + + +EOF; + $cx->parseTag($content); + $this->assertEquals($content, $data); + + $content = <<display($content); + $this->expectOutputString('234'); + } + + public function testIf() + { + $template = new template(); + $cx = new Cx($template); + + $content = << +one + +two + +default + +EOF; + $cx->parseTag($content); + $this->assertEquals($content, $data); + } + + public function testSwitch() + { + $template = new template(); + $cx = new Cx($template); + + $content = << + +a + + +b + + +d + + +default + +EOF; + $cx->parseTag($content); + $this->assertEquals($content, $data); + } + + public function testCompare() + { + $template = new template(); + $cx = new Cx($template); + + $content = << +default + +EOF; + $cx->parseTag($content); + $this->assertEquals($content, $data); + + $content = << +default + +EOF; + $cx->parseTag($content); + $this->assertEquals($content, $data); + + $content = << +default + +EOF; + $cx->parseTag($content); + $this->assertEquals($content, $data); + + $content = << +default + +EOF; + $cx->parseTag($content); + $this->assertEquals($content, $data); + + $content = << '0'): ?> +default + +EOF; + $cx->parseTag($content); + $this->assertEquals($content, $data); + + $content = <<= '0'): ?> +default + +EOF; + $cx->parseTag($content); + $this->assertEquals($content, $data); + + $content = << +default + +EOF; + $cx->parseTag($content); + $this->assertEquals($content, $data); + + $content = << +default + +EOF; + $cx->parseTag($content); + $this->assertEquals($content, $data); + + $content = << +default + +EOF; + $cx->parseTag($content); + $this->assertEquals($content, $data); + + $content = << +default + +EOF; + $cx->parseTag($content); + $this->assertEquals($content, $data); + + } + + public function testRange() + { + $template = new template(); + $cx = new Cx($template); + + $content = << +default + +EOF; + $cx->parseTag($content); + $this->assertEquals($content, $data); + + $content = << +default + +EOF; + $cx->parseTag($content); + $this->assertEquals($content, $data); + + $content = <<display($content); + $this->expectOutputString('yesno'); + } + + public function testPresent() + { + $template = new template(); + $cx = new Cx($template); + + $content = << +default + +EOF; + $cx->parseTag($content); + $this->assertEquals($content, $data); + + $content = << +default + +EOF; + $cx->parseTag($content); + $this->assertEquals($content, $data); + } + + public function testEmpty() + { + $template = new template(); + $cx = new Cx($template); + + $content = <<isEmpty())): ?> +default + +EOF; + $cx->parseTag($content); + $this->assertEquals($content, $data); + + $content = <<isEmpty()))): ?> +default + +EOF; + $cx->parseTag($content); + $this->assertEquals($content, $data); + } + + public function testDefined() + { + $template = new template(); + $cx = new Cx($template); + + $content = << +default + +EOF; + $cx->parseTag($content); + $this->assertEquals($content, $data); + + $content = << +default + +EOF; + $cx->parseTag($content); + $this->assertEquals($content, $data); + } + + public function testImport() + { + $template = new template(); + $cx = new Cx($template); + + $content = << +EOF; + $cx->parseTag($content); + $this->assertEquals($content, $data); + + $content = << +EOF; + $cx->parseTag($content); + $this->assertEquals($content, $data); + + $content = << +EOF; + $cx->parseTag($content); + $this->assertEquals($content, $data); + } + + public function testAssign() + { + $template = new template(); + $cx = new Cx($template); + + $content = << +EOF; + $cx->parseTag($content); + $this->assertEquals($content, $data); + + $content = << +EOF; + $cx->parseTag($content); + $this->assertEquals($content, $data); + } + + public function testDefine() + { + $template = new template(); + $cx = new Cx($template); + + $content = << +EOF; + $cx->parseTag($content); + $this->assertEquals($content, $data); + + $content = << +EOF; + $cx->parseTag($content); + $this->assertEquals($content, $data); + } + + public function testFor() + { + $template = new template(); + + $content = <<display($content); + $this->expectOutputString('123456789'); + } + public function testUrl() + { + $template = new template(); + $content = <<display($content); + $this->expectOutputString(\think\Url::build('Index/index')); + } + + public function testFunction() + { + $template = new template(); + $data = [ + 'list' => ['language' => 'php', 'version' => ['5.4', '5.5']], + 'a' => '[', + 'b' => ']', + ]; + + $content = <<\$val} +{if is_array(\$val)} +{~\$func(\$val)} +{else} +{if !is_numeric(\$key)} +{\$key.':'.\$val.','} +{else} +{\$a.\$val.\$b} +{/if} +{/if} +{/foreach} +{/function} +EOF; + $template->display($content, $data); + $this->expectOutputString("language:php,[5.4][5.5]"); + } +} diff --git a/thinkphp/tests/thinkphp/library/think/templateTest.php b/thinkphp/tests/thinkphp/library/think/templateTest.php new file mode 100644 index 0000000..1135830 --- /dev/null +++ b/thinkphp/tests/thinkphp/library/think/templateTest.php @@ -0,0 +1,415 @@ + +// +---------------------------------------------------------------------- + +/** + * 模板测试 + * @author oldrind + */ + +namespace tests\thinkphp\library\think; + +use think\Cache; +use think\Template; + +class templateTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var Template + */ + protected $template; + + public function setUp() + { + $this->template = new Template(); + } + + public function testAssign() + { + $reflectProperty = new \ReflectionProperty(get_class($this->template), 'data'); + $reflectProperty->setAccessible(true); + + $this->template->assign('version', 'ThinkPHP3.2'); + $data = $reflectProperty->getValue($this->template); + $this->assertEquals('ThinkPHP3.2', $data['version']); + + $this->template->assign(['name' => 'Gao', 'version' => 'ThinkPHP5']); + $data = $reflectProperty->getValue($this->template); + $this->assertEquals('Gao', $data['name']); + $this->assertEquals('ThinkPHP5', $data['version']); + } + + public function testGet() + { + $this->template = new Template(); + $data = [ + 'project' => 'ThinkPHP', + 'version' => [ + 'ThinkPHP5' => ['Think5.0', 'Think5.1'] + ] + ]; + $this->template->assign($data); + + $this->assertSame($data, $this->template->get()); + $this->assertSame('ThinkPHP', $this->template->get('project')); + $this->assertSame(['Think5.0', 'Think5.1'], $this->template->get('version.ThinkPHP5')); + $this->assertNull($this->template->get('version.ThinkPHP3.2')); + } + + /** + * @dataProvider provideTestParseWithVar + */ + public function testParseWithVar($content, $expected) + { + $this->template = new Template(); + + $this->template->parse($content); + $this->assertEquals($expected, $content); + } + + /** + * @dataProvider provideTestParseWithVarFunction + */ + public function testParseWithVarFunction($content, $expected) + { + $this->template = new Template(); + + $this->template->parse($content); + $this->assertEquals($expected, $content); + } + + /** + * @dataProvider provideTestParseWithVarIdentify + */ + public function testParseWithVarIdentify($content, $expected, $config) + { + $this->template = new Template($config); + + $this->template->parse($content); + $this->assertEquals($expected, $content); + } + + /** + * @dataProvider provideTestParseWithThinkVar + */ + public function testParseWithThinkVar($content, $expected) + { + $config['tpl_begin'] = '{'; + $config['tpl_end'] = '}'; + $this->template = new Template($config); + + $_SERVER['SERVER_NAME'] = 'server_name'; + $_GET['action'] = 'action'; + $_POST['action'] = 'action'; + $_COOKIE['name'] = 'name'; + $_SESSION['action'] = ['name' => 'name']; + + $this->template->parse($content); + $this->assertEquals($expected, $content); + } + + /** + * @expectedException \think\exception\TemplateNotFoundException + */ + public function testFetchWithEmptyTemplate() + { + $this->template = new Template(); + + $this->template->fetch('Foo'); + } + + /** + * @dataProvider provideTestFetchWithNoCache + */ + public function testFetchWithNoCache($data, $expected) + { + $this->template = new Template(); + + $this->template->fetch($data['template'], $data['vars'], $data['config']); + + $this->expectOutputString($expected); + } + + public function testFetchWithCache() + { + $this->template = new Template(); + + $data = [ + 'name' => 'value' + ]; + $config = [ + 'cache_id' => 'TEST_FETCH_WITH_CACHE', + 'display_cache' => true, + ]; + + $this->template->fetch(APP_PATH . 'views' . DS .'display.html', $data, $config); + + $this->expectOutputString('value'); + $this->assertEquals('value', Cache::get($config['cache_id'])); + } + + public function testDisplay() + { + $config = [ + 'view_path' => APP_PATH . DS . 'views' . DS, + 'view_suffix' => '.html', + 'layout_on' => true, + 'layout_name' => 'layout' + ]; + + $this->template = new Template($config); + + $this->template->assign('files', ['extend' => 'extend', 'include' => 'include']); + $this->template->assign('user', ['name' => 'name', 'account' => 100]); + $this->template->assign('message', 'message'); + $this->template->assign('info', ['value' => 'value']); + + $content = << +header +
    + +value: + +main + + + side + + +value: + message{\$message} + + + mainbody + + + + {\$name} + + php code
    + +EOF; + $this->template->display($content); + $this->expectOutputString($expected); + } + + /** + * @dataProvider provideTestLayout + */ + public function testLayout($data, $expected) + { + $this->template = new Template(); + + $this->template->layout($data['name'], $data['replace']); + + $this->assertSame($expected['layout_on'], $this->template->config('layout_on')); + $this->assertSame($expected['layout_name'], $this->template->config('layout_name')); + $this->assertSame($expected['layout_item'], $this->template->config('layout_item')); + } + + public function testParseAttr() + { + $attributes = $this->template->parseAttr(""); + $this->assertSame(['version' => 'ThinkPHP', 'name' => 'Gao'], $attributes); + + $attributes = $this->template->parseAttr("TestCase", 'version'); + $this->assertSame('ThinkPHP', $attributes); + } + + public function testIsCache() + { + $this->template = new Template(); + $config = [ + 'cache_id' => rand(0, 10000) . rand(0, 10000) . time(), + 'display_cache' => true + ]; + + $this->assertFalse($this->template->isCache($config['cache_id'])); + + $this->template->fetch(APP_PATH . 'views' . DS .'display.html', [], $config); + $this->assertTrue($this->template->isCache($config['cache_id'])); + } + + public function provideTestParseWithVar() + { + return [ + ["{\$name.a.b}", ""], + ["{\$name.a??'test'}", ""], + ["{\$name.a?='test'}", ""], + ["{\$name.a?:'test'}", ""], + ["{\$name.a?\$name.b:'no'}", ""], + ["{\$name.a==\$name.b?='test'}", ""], + ["{\$name.a==\$name.b?'a':'b'}", ""], + ["{\$name.a|default='test'==\$name.b?'a':'b'}", ""], + ["{\$name.a|trim==\$name.b?='eq'}", ""], + ["{:ltrim(rtrim(\$name.a))}", ""], + ["{~echo(trim(\$name.a))}", ""], + ["{++\$name.a}", ""], + ["{/*\$name*/}", ""], + ["{\$0a}", "{\$0a}"] + ]; + } + + public function provideTestParseWithVarFunction() + { + return [ + ["{\$name.a.b|default='test'}", ""], + ["{\$create_time|date=\"y-m-d\",###}", ""], + ["{\$name}\n{\$name|trim|substr=0,3}", "\n"] + ]; + } + + public function provideTestParseWithVarIdentify() + { + $config['tpl_begin'] = '<#'; + $config['tpl_end'] = '#>'; + $config['tpl_var_identify'] = ''; + + return [ + [ + "<#\$info.a??'test'#>", + "a)) ? (is_array(\$info)?\$info['a']:\$info->a) : 'test'; ?>", + $config + ], + [ + "<#\$info.a?='test'#>", + "a)) echo 'test'; ?>", + $config + ], + [ + "<#\$info.a==\$info.b?='test'#>", + "a)==(is_array(\$info)?\$info['b']:\$info->b)) echo 'test'; ?>", + $config + ], + [ + "<#\$info.a|default='test'?'yes':'no'#>", + "a) ?: 'test')?'yes':'no'; ?>", + $config + ], + [ + "{\$info2.b|trim?'yes':'no'}", + "b)?'yes':'no'; ?>", + array_merge(['tpl_var_identify' => 'obj']) + ] + ]; + } + + public function provideTestParseWithThinkVar() + { + return [ + ["{\$Think.SERVER.SERVER_NAME}
    ", "server('SERVER_NAME'); ?>
    "], + ["{\$Think.GET.action}
    ", "get('action'); ?>
    "], + ["{\$Think.POST.action}
    ", "post('action'); ?>
    "], + ["{\$Think.COOKIE.action}
    ", "
    "], + ["{\$Think.COOKIE.action.name}
    ", "
    "], + ["{\$Think.SESSION.action}
    ", "
    "], + ["{\$Think.SESSION.action.name}
    ", "
    "], + ["{\$Think.ENV.OS}
    ", "env('OS'); ?>
    "], + ["{\$Think.REQUEST.action}
    ", "request('action'); ?>
    "], + ["{\$Think.CONST.THINK_VERSION}
    ", "
    "], + ["{\$Think.LANG.action}
    ", "
    "], + ["{\$Think.CONFIG.action.name}
    ", "
    "], + ["{\$Think.NOW}
    ", "
    "], + ["{\$Think.VERSION}
    ", "
    "], + ["{\$Think.LDELIM}
    ", "
    "], + ["{\$Think.RDELIM}
    ", "
    "], + ["{\$Think.THINK_VERSION}
    ", "
    "], + ["{\$Think.SITE.URL}", ""] + ]; + } + + public function provideTestFetchWithNoCache() + { + $provideData = []; + + $this->template = [ + 'template' => APP_PATH . 'views' . DS .'display.html', + 'vars' => [], + 'config' => [] + ]; + $expected = 'default'; + $provideData[] = [$this->template, $expected]; + + $this->template = [ + 'template' => APP_PATH . 'views' . DS .'display.html', + 'vars' => ['name' => 'ThinkPHP5'], + 'config' => [] + ]; + $expected = 'ThinkPHP5'; + $provideData[] = [$this->template, $expected]; + + $this->template = [ + 'template' => 'views@display', + 'vars' => [], + 'config' => [ + 'view_suffix' => 'html' + ] + ]; + $expected = 'default'; + $provideData[] = [$this->template, $expected]; + + $this->template = [ + 'template' => 'views@/display', + 'vars' => ['name' => 'ThinkPHP5'], + 'config' => [ + 'view_suffix' => 'phtml' + ] + ]; + $expected = 'ThinkPHP5'; + $provideData[] = [$this->template, $expected]; + + $this->template = [ + 'template' => 'display', + 'vars' => ['name' => 'ThinkPHP5'], + 'config' => [ + 'view_suffix' => 'html', + 'view_base' => APP_PATH . 'views' . DS + ] + ]; + $expected = 'ThinkPHP5'; + $provideData[] = [$this->template, $expected]; + + return $provideData; + } + + public function provideTestLayout() + { + $provideData = []; + + $data = ['name' => false, 'replace' => '']; + $expected = ['layout_on' => false, 'layout_name' => 'layout', 'layout_item' => '{__CONTENT__}']; + $provideData[] = [$data, $expected]; + + $data = ['name' => null, 'replace' => '']; + $expected = ['layout_on' => true, 'layout_name' => 'layout', 'layout_item' => '{__CONTENT__}']; + $provideData[] = [$data, $expected]; + + $data = ['name' => 'ThinkName', 'replace' => 'ThinkReplace']; + $expected = ['layout_on' => true, 'layout_name' => 'ThinkName', 'layout_item' => 'ThinkReplace']; + $provideData[] = [$data, $expected]; + + return $provideData; + } +} diff --git a/thinkphp/tests/thinkphp/library/think/urlTest.php b/thinkphp/tests/thinkphp/library/think/urlTest.php new file mode 100644 index 0000000..401d973 --- /dev/null +++ b/thinkphp/tests/thinkphp/library/think/urlTest.php @@ -0,0 +1,129 @@ + +// +---------------------------------------------------------------------- + +/** + * Url测试 + * @author liu21st + */ + +namespace tests\thinkphp\library\think; + +use tests\thinkphp\library\think\config\ConfigInitTrait; +use think\Config; +use think\Route; +use think\Url; + +class urlTest extends \PHPUnit_Framework_TestCase +{ + use ConfigInitTrait; + + public function setUp() + { + Route::rules(['get' => [], + 'post' => [], + 'put' => [], + 'delete' => [], + 'patch' => [], + 'head' => [], + 'options' => [], + '*' => [], + 'alias' => [], + 'domain' => [], + 'pattern' => [], + 'name' => []]); + Route::name([]); + } + + public function testBuildModule() + { + + Route::get('blog/:name', 'index/blog'); + Route::get('blog/:id', 'index/blog'); + Config::set('pathinfo_depr', '/'); + Config::set('url_html_suffix', ''); + + $this->assertEquals('/blog/thinkphp', Url::build('index/blog?name=thinkphp')); + $this->assertEquals('/blog/thinkphp.html', Url::build('index/blog', 'name=thinkphp', 'html')); + $this->assertEquals('/blog/10', Url::build('index/blog?id=10')); + $this->assertEquals('/blog/10.html', Url::build('index/blog', 'id=10', 'html')); + + Route::get('item-', 'blog/item', [], ['name' => '\w+', 'id' => '\d+']); + $this->assertEquals('/item-thinkphp', Url::build('blog/item?name=thinkphp')); + $this->assertEquals('/item-thinkphp2016', Url::build('blog/item?name=thinkphp&id=2016')); + } + + public function testBuildController() + { + Config::set('url_html_suffix', ''); + Route::get('blog/:id', '@index/blog/read'); + $this->assertEquals('/blog/10.html', Url::build('@index/blog/read', 'id=10', 'html')); + + Route::get('foo/bar', '@foo/bar/index'); + $this->assertEquals('/foo/bar', Url::build('@foo/bar/index')); + + Route::get('foo/bar/baz', '@foo/bar.BAZ/index'); + $this->assertEquals('/foo/bar/baz', Url::build('@foo/bar.BAZ/index')); + } + + public function testBuildMethod() + { + Route::get('blog/:id', '\app\index\controller\blog@read'); + $this->assertEquals('/blog/10.html', Url::build('\app\index\controller\blog@read', 'id=10', 'html')); + } + + public function testBuildRoute() + { + Route::get('blog/:id', 'index/blog'); + Config::set('url_html_suffix', 'shtml'); + $this->assertNotEquals('/blog/10.html', Url::build('/blog/10')); + $this->assertEquals('/blog/10.shtml', Url::build('/blog/10')); + } + + public function testBuildNameRoute() + { + Route::get(['name', 'blog/:id'], 'index/blog'); + $this->assertEquals([['blog/:id', ['id' => 1], null, null]], Route::name('name')); + Config::set('url_html_suffix', 'shtml'); + $this->assertEquals('/blog/10.shtml', Url::build('name?id=10')); + } + + public function testBuildAnchor() + { + Route::get('blog/:id', 'index/blog'); + Config::set('url_html_suffix', 'shtml'); + $this->assertEquals('/blog/10.shtml#detail', Url::build('index/blog#detail', 'id=10')); + + Config::set('url_common_param', true); + $this->assertEquals('/blog/10.shtml?foo=bar#detail', Url::build('index/blog#detail', "id=10&foo=bar")); + } + + public function testBuildDomain() + { + Config::set('url_domain_deploy', true); + Route::domain('subdomain.thinkphp.cn', 'admin'); + $this->assertEquals('http://subdomain.thinkphp.cn/blog/10.html', Url::build('/blog/10')); + Route::domain('subdomain.thinkphp.cn', [ + 'hello/:name' => 'index/hello', + ]); + $this->assertEquals('http://subdomain.thinkphp.cn/hello/thinkphp.html', Url::build('index/hello?name=thinkphp')); + } + + public function testRoot() + { + Config::set('url_domain_deploy', false); + Config::set('url_common_param', false); + Url::root('/index.php'); + Route::get('blog/:id', 'index/blog/read'); + Config::set('url_html_suffix', 'shtml'); + $this->assertEquals('/index.php/blog/10/name/thinkphp.shtml', Url::build('index/blog/read?id=10&name=thinkphp')); + + } +} diff --git a/thinkphp/tests/thinkphp/library/think/validateTest.php b/thinkphp/tests/thinkphp/library/think/validateTest.php new file mode 100644 index 0000000..b5f4333 --- /dev/null +++ b/thinkphp/tests/thinkphp/library/think/validateTest.php @@ -0,0 +1,200 @@ + +// +---------------------------------------------------------------------- + +/** + * Validate类测试 + */ + +namespace tests\thinkphp\library\think; + +use think\File; +use think\Validate; + +class validateTest extends \PHPUnit_Framework_TestCase +{ + + public function testCheck() + { + $rule = [ + 'name' => 'require|max:25', + 'age' => 'number|between:1,120', + 'email' => 'email', + ]; + $msg = [ + 'name.require' => '名称必须', + 'name.max' => '名称最多不能超过25个字符', + 'age.number' => '年龄必须是数字', + 'age.between' => '年龄只能在1-120之间', + 'email' => '邮箱格式错误', + ]; + $data = [ + 'name' => 'thinkphp', + 'age' => 10, + 'email' => 'thinkphp@qq.com', + ]; + $validate = new Validate($rule, $msg); + $result = $validate->check($data); + $this->assertEquals(true, $result); + } + + public function testRule() + { + $rule = [ + 'name' => 'require|method:get|alphaNum|max:25|expire:2016-1-1,2026-1-1', + 'account' => 'requireIf:name,thinkphp|alphaDash|min:4|length:4,30', + 'age' => 'number|between:1,120', + 'email' => 'requireWith:name|email', + 'host' => 'activeUrl|activeUrl:A', + 'url' => 'url', + 'ip' => 'ip|ip:ipv4', + 'score' => 'float|gt:60|notBetween:90,100|notIn:70,80|lt:100|elt:100|egt:60', + 'status' => 'integer|in:0,1,2', + 'begin_time' => 'after:2016-3-18|beforeWith:end_time', + 'end_time' => 'before:2016-10-01|afterWith:begin_time', + 'info' => 'require|array|length:4|max:5|min:2', + 'info.name' => 'require|length:8|alpha|same:thinkphp', + 'value' => 'same:100|different:status', + 'bool' => 'boolean', + 'title' => 'chsAlpha', + 'city' => 'chs', + 'nickname' => 'chsDash', + 'aliasname' => 'chsAlphaNum', + 'file' => 'file|fileSize:20480', + 'image' => 'image|fileMime:image/png|image:80,80,png', + 'test' => 'test', + ]; + $data = [ + 'name' => 'thinkphp', + 'account' => 'liuchen', + 'age' => 10, + 'email' => 'thinkphp@qq.com', + 'host' => 'thinkphp.cn', + 'url' => 'http://thinkphp.cn/topic', + 'ip' => '114.34.54.5', + 'score' => '89.15', + 'status' => 1, + 'begin_time' => '2016-3-20', + 'end_time' => '2016-5-1', + 'info' => [1, 2, 3, 'name' => 'thinkphp'], + 'zip' => '200000', + 'date' => '16-3-8', + 'ok' => 'yes', + 'value' => 100, + 'bool' => true, + 'title' => '流年ThinkPHP', + 'city' => '上海', + 'nickname' => '流年ThinkPHP_2016', + 'aliasname' => '流年Think2016', + 'file' => new File(THINK_PATH . 'base.php'), + 'image' => new File(THINK_PATH . 'logo.png'), + 'test' => 'test', + ]; + $validate = new Validate($rule); + $validate->extend('test', function ($value) {return 'test' == $value ? true : false;}); + $validate->rule('zip', '/^\d{6}$/'); + $validate->rule([ + 'ok' => 'require|accepted', + 'date' => 'date|dateFormat:y-m-d', + ]); + $result = $validate->batch()->check($data); + $this->assertEquals(true, $result); + } + + public function testMsg() + { + $validate = new Validate(); + $validate->message('name.require', '名称必须'); + $validate->message([ + 'name.require' => '名称必须', + 'name.max' => '名称最多不能超过25个字符', + 'age.number' => '年龄必须是数字', + 'age.between' => '年龄只能在1-120之间', + 'email' => '邮箱格式错误', + ]); + } + + public function testMake() + { + $rule = [ + 'name' => 'require|max:25', + 'age' => 'number|between:1,120', + 'email' => 'email', + ]; + $msg = [ + 'name.require' => '名称必须', + 'name.max' => '名称最多不能超过25个字符', + 'age.number' => '年龄必须是数字', + 'age.between' => '年龄只能在1-120之间', + 'email' => '邮箱格式错误', + ]; + $validate = Validate::make($rule, $msg); + } + + public function testExtend() + { + $validate = new Validate(['name' => 'check:1']); + $validate->extend('check', function ($value, $rule) {return $rule == $value ? true : false;}); + $validate->extend(['check' => function ($value, $rule) {return $rule == $value ? true : false;}]); + $data = ['name' => 1]; + $result = $validate->check($data); + $this->assertEquals(true, $result); + } + + public function testScene() + { + $rule = [ + 'name' => 'require|max:25', + 'age' => 'number|between:1,120', + 'email' => 'email', + ]; + $msg = [ + 'name.require' => '名称必须', + 'name.max' => '名称最多不能超过25个字符', + 'age.number' => '年龄必须是数字', + 'age.between' => '年龄只能在1-120之间', + 'email' => '邮箱格式错误', + ]; + $data = [ + 'name' => 'thinkphp', + 'age' => 10, + 'email' => 'thinkphp@qq.com', + ]; + $validate = new Validate($rule); + $validate->scene(['edit' => ['name', 'age']]); + $validate->scene('edit', ['name', 'age']); + $validate->scene('edit'); + $result = $validate->check($data); + $this->assertEquals(true, $result); + } + + public function testSetTypeMsg() + { + $rule = [ + 'name|名称' => 'require|max:25', + 'age' => 'number|between:1,120', + 'email' => 'email', + ['sex', 'in:1,2', '性别错误'], + ]; + $data = [ + 'name' => '', + 'age' => 10, + 'email' => 'thinkphp@qq.com', + 'sex' => '3', + ]; + $validate = new Validate($rule); + $validate->setTypeMsg('require', ':attribute必须'); + $validate->setTypeMsg(['require' => ':attribute必须']); + $result = $validate->batch()->check($data); + $this->assertFalse($result); + $this->assertEquals(['name' => '名称必须', 'sex' => '性别错误'], $validate->getError()); + } + +} diff --git a/thinkphp/tests/thinkphp/library/think/view/driver/.gitignore b/thinkphp/tests/thinkphp/library/think/view/driver/.gitignore new file mode 100644 index 0000000..c96a04f --- /dev/null +++ b/thinkphp/tests/thinkphp/library/think/view/driver/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore \ No newline at end of file diff --git a/thinkphp/tests/thinkphp/library/think/view/theme/index/template.html b/thinkphp/tests/thinkphp/library/think/view/theme/index/template.html new file mode 100644 index 0000000..5f4548b --- /dev/null +++ b/thinkphp/tests/thinkphp/library/think/view/theme/index/template.html @@ -0,0 +1,14 @@ + + + + + + + + + Document + + + + + diff --git a/thinkphp/tests/thinkphp/library/think/viewTest.php b/thinkphp/tests/thinkphp/library/think/viewTest.php new file mode 100644 index 0000000..5bb7de1 --- /dev/null +++ b/thinkphp/tests/thinkphp/library/think/viewTest.php @@ -0,0 +1,76 @@ + +// +---------------------------------------------------------------------- + +/** + * view测试 + * @author mahuan + */ + +namespace tests\thinkphp\library\think; + +class viewTest extends \PHPUnit_Framework_TestCase +{ + + /** + * 句柄测试 + * @return mixed + * @access public + */ + public function testGetInstance() + { + \think\Cookie::get('a'); + $view_instance = \think\View::instance(); + $this->assertInstanceOf('\think\view', $view_instance, 'instance方法返回错误'); + } + + /** + * 测试变量赋值 + * @return mixed + * @access public + */ + public function testAssign() + { + $view_instance = \think\View::instance(); + $view_instance->key = 'value'; + $this->assertTrue(isset($view_instance->key)); + $this->assertEquals('value', $view_instance->key); + $data = $view_instance->assign(array('key' => 'value')); + $data = $view_instance->assign('key2', 'value2'); + //测试私有属性 + $expect_data = array('key' => 'value', 'key2' => 'value2'); + $this->assertAttributeEquals($expect_data, 'data', $view_instance); + } + + /** + * 测试引擎设置 + * @return mixed + * @access public + */ + public function testEngine() + { + $view_instance = \think\View::instance(); + $data = $view_instance->engine('php'); + $data = $view_instance->engine(['type' => 'php', 'view_path' => '', 'view_suffix' => '.php', 'view_depr' => DS]); + $php_engine = new \think\view\driver\Php(['view_path' => '', 'view_suffix' => '.php', 'view_depr' => DS]); + $this->assertAttributeEquals($php_engine, 'engine', $view_instance); + //测试模板引擎驱动 + $data = $view_instance->engine(['type' => 'think', 'view_path' => '', 'view_suffix' => '.html', 'view_depr' => DS]); + $think_engine = new \think\view\driver\Think(['view_path' => '', 'view_suffix' => '.html', 'view_depr' => DS]); + $this->assertAttributeEquals($think_engine, 'engine', $view_instance); + } + + public function testReplace() + { + $view_instance = \think\View::instance(); + $view_instance->replace('string', 'replace')->display('string'); + } + +} diff --git a/thinkphp/tests/thinkphp/library/traits/controller/jumpTest.php b/thinkphp/tests/thinkphp/library/traits/controller/jumpTest.php new file mode 100644 index 0000000..47e9dbf --- /dev/null +++ b/thinkphp/tests/thinkphp/library/traits/controller/jumpTest.php @@ -0,0 +1,339 @@ +testClass = new testClassWithJump(); + $this->request = Request::create(''); + + $this->originServerData = Request::instance()->server(); + } + + public function tearDown() + { + Request::instance()->server($this->originServerData); + } + + /** + * @dataProvider provideTestSuccess + */ + public function testSuccess($arguments, $expected, array $extra) + { + if (isset($extra['server'])) { + $this->request->server($extra['server']); + } + + $mock = $this->getMockBuilder(get_class($this->testClass))->setMethods(['getResponseType'])->getMock(); + $mock->expects($this->any())->method('getResponseType')->willReturn($extra['return']); + + try { + call_user_func_array([$mock, 'success'], $arguments); + $this->setExpectedException('\think\exception\HttpResponseException'); + } catch (\Exception $e) { + $this->assertInstanceOf('\think\exception\HttpResponseException', $e); + + /** @var Response $response */ + $response = $e->getResponse(); + + $this->assertInstanceOf('\Think\Response', $response); + $this->assertEquals($expected['header'], $response->getHeader()); + $this->assertEquals($expected['data'], $response->getData()); + } + } + + /** + * @dataProvider provideTestError + */ + public function testError($arguments, $expected, array $extra) + { + if (isset($extra['server'])) { + $this->request->server($extra['server']); + } + + $mock = $this->getMockBuilder(get_class($this->testClass))->setMethods(['getResponseType'])->getMock(); + $mock->expects($this->any())->method('getResponseType')->willReturn($extra['return']); + + try { + call_user_func_array([$mock, 'error'], $arguments); + $this->setExpectedException('\think\exception\HttpResponseException'); + } catch (\Exception $e) { + $this->assertInstanceOf('\think\exception\HttpResponseException', $e); + + /** @var Response $response */ + $response = $e->getResponse(); + + $this->assertInstanceOf('\Think\Response', $response); + $this->assertEquals($expected['header'], $response->getHeader()); + $this->assertEquals($expected['data'], $response->getData()); + } + } + + /** + * @dataProvider provideTestResult + */ + public function testResult($arguments, $expected, array $extra) + { + if (isset($extra['server'])) { + $this->request->server($extra['server']); + } + + $mock = $this->getMockBuilder(get_class($this->testClass))->setMethods(['getResponseType'])->getMock(); + $mock->expects($this->any())->method('getResponseType')->willReturn($extra['return']); + + try { + call_user_func_array([$mock, 'result'], $arguments); + $this->setExpectedException('\think\exception\HttpResponseException'); + } catch (\Exception $e) { + $this->assertInstanceOf('\think\exception\HttpResponseException', $e); + + /** @var Response $response */ + $response = $e->getResponse(); + + $this->assertInstanceOf('\Think\Response', $response); + $this->assertEquals($expected['header'], $response->getHeader()); + $this->assertEquals($expected['data'], $response->getData()); + } + } + + /** + * @dataProvider provideTestRedirect + */ + public function testRedirect($arguments, $expected) + { + try { + call_user_func_array([$this->testClass, 'redirect'], $arguments); + $this->setExpectedException('\think\exception\HttpResponseException'); + } catch (\Exception $e) { + $this->assertInstanceOf('\think\exception\HttpResponseException', $e); + + /** @var Redirect $response */ + $response = $e->getResponse(); + + $this->assertInstanceOf('\think\response\Redirect', $response); + $this->assertEquals($expected['url'], $response->getTargetUrl()); + $this->assertEquals($expected['code'], $response->getCode()); + } + } + + public function testGetResponseType() + { + Request::instance()->server(['HTTP_X_REQUESTED_WITH' => null]); + $this->assertEquals('html', $this->testClass->getResponseType()); + + Request::instance()->server(['HTTP_X_REQUESTED_WITH' => true]); + $this->assertEquals('html', $this->testClass->getResponseType()); + + Request::instance()->server(['HTTP_X_REQUESTED_WITH' => 'xmlhttprequest']); + $this->assertEquals('json', $this->testClass->getResponseType()); + } + + public function provideTestSuccess() + { + $provideData = []; + + $arguments = ['', null, '', 3, []]; + $expected = [ + 'header' => [ + 'Content-Type' => 'text/html; charset=utf-8' + ], + 'data' => View::instance(Config::get('template'), Config::get('view_replace_str')) + ->fetch(Config::get('dispatch_error_tmpl'), [ + 'code' => 1, + 'msg' => '', + 'data' => '', + 'url' => '/index.php/', + 'wait' => 3, + ]) + ]; + $provideData[] = [$arguments, $expected, ['server' => ['HTTP_REFERER' => null], 'return' => 'html']]; + + $arguments = ['thinkphp', null, ['foo'], 4, ['Power-By' => 'thinkphp', 'Content-Type' => 'text/html; charset=gbk']]; + $expected = [ + 'header' => [ + 'Content-Type' => 'text/html; charset=gbk', + 'Power-By' => 'thinkphp' + ], + 'data' => View::instance(Config::get('template'), Config::get('view_replace_str')) + ->fetch(Config::get('dispatch_error_tmpl'), [ + 'code' => 1, + 'msg' => 'thinkphp', + 'data' => ['foo'], + 'url' => 'http://www.thinkphp.cn', + 'wait' => 4, + ]) + ]; + $provideData[] = [$arguments, $expected, ['server' => ['HTTP_REFERER' => 'http://www.thinkphp.cn'], 'return' => 'html']]; + + $arguments = ['thinkphp', 'index', ['foo'], 5, []]; + $expected = [ + 'header' => [ + 'Content-Type' => 'application/json; charset=utf-8' + ], + 'data' => [ + 'code' => 1, + 'msg' => 'thinkphp', + 'data' => ['foo'], + 'url' => '/index.php/index.html', + 'wait' => 5, + ] + ]; + $provideData[] = [$arguments, $expected, ['server' => ['HTTP_REFERER' => null], 'return' => 'json']]; + + return $provideData; + } + + public function provideTestError() + { + $provideData = []; + + $arguments = ['', null, '', 3, []]; + $expected = [ + 'header' => [ + 'Content-Type' => 'text/html; charset=utf-8' + ], + 'data' => View::instance(Config::get('template'), Config::get('view_replace_str')) + ->fetch(Config::get('dispatch_error_tmpl'), [ + 'code' => 0, + 'msg' => '', + 'data' => '', + 'url' => 'javascript:history.back(-1);', + 'wait' => 3, + ]) + ]; + $provideData[] = [$arguments, $expected, ['return' => 'html']]; + + $arguments = ['thinkphp', 'http://www.thinkphp.cn', ['foo'], 4, ['Power-By' => 'thinkphp', 'Content-Type' => 'text/html; charset=gbk']]; + $expected = [ + 'header' => [ + 'Content-Type' => 'text/html; charset=gbk', + 'Power-By' => 'thinkphp' + ], + 'data' => View::instance(Config::get('template'), Config::get('view_replace_str')) + ->fetch(Config::get('dispatch_error_tmpl'), [ + 'code' => 0, + 'msg' => 'thinkphp', + 'data' => ['foo'], + 'url' => 'http://www.thinkphp.cn', + 'wait' => 4, + ]) + ]; + $provideData[] = [$arguments, $expected, ['return' => 'html']]; + + $arguments = ['thinkphp', '', ['foo'], 5, []]; + $expected = [ + 'header' => [ + 'Content-Type' => 'application/json; charset=utf-8' + ], + 'data' => [ + 'code' => 0, + 'msg' => 'thinkphp', + 'data' => ['foo'], + 'url' => '', + 'wait' => 5, + ] + ]; + $provideData[] = [$arguments, $expected, ['return' => 'json']]; + + return $provideData; + } + + public function provideTestResult() + { + $provideData = []; + + $arguments = [null, 0, '', '', []]; + $expected = [ + 'header' => [ + 'Content-Type' => 'text/html; charset=utf-8' + ], + 'data' => [ + 'code' => 0, + 'msg' => '', + 'time' => Request::create('')->server('REQUEST_TIME'), + 'data' => null, + ] + ]; + $provideData[] = [$arguments, $expected, ['return' => 'html']]; + + $arguments = [['foo'], 200, 'thinkphp', 'json', ['Power-By' => 'thinkphp']]; + $expected = [ + 'header' => [ + 'Power-By' => 'thinkphp', + 'Content-Type' => 'application/json; charset=utf-8' + ], + 'data' => [ + 'code' => 200, + 'msg' => 'thinkphp', + 'time' => 1000, + 'data' => ['foo'], + ] + ]; + + $provideData[] = [$arguments, $expected, ['server' => ['REQUEST_TIME' => 1000], 'return' => 'json']]; + + return $provideData; + } + + public function provideTestRedirect() + { + $provideData = []; + + $arguments = ['', [], 302, []]; + $expected = [ + 'code'=> 302, + 'url' => '/index.php/' + ]; + $provideData[] = [$arguments, $expected, []]; + + $arguments = ['index', 302, null, []]; + $expected = [ + 'code'=> 302, + 'url' => '/index.php/index.html' + ]; + $provideData[] = [$arguments, $expected, []]; + + $arguments = ['http://www.thinkphp.cn', 301, 302, []]; + $expected = [ + 'code'=> 301, + 'url' => 'http://www.thinkphp.cn' + ]; + $provideData[] = [$arguments, $expected, []]; + + return $provideData; + } +} + +class testClassWithJump +{ + use Jump { + success as public; + error as public; + result as public; + redirect as public; + getResponseType as public; + } +} diff --git a/thinkphp/tests/thinkphp/library/traits/model/softDeleteTest.php b/thinkphp/tests/thinkphp/library/traits/model/softDeleteTest.php new file mode 100644 index 0000000..8410efa --- /dev/null +++ b/thinkphp/tests/thinkphp/library/traits/model/softDeleteTest.php @@ -0,0 +1,179 @@ +connection; + + $sql[] = <<execute($one); + } + } + + public function testTrashed() + { + /** @var testClassWithSoftDelete[] $selections */ + $selections = testClassWithSoftDelete::withTrashed()->select(); + + $this->assertFalse($selections[0]->trashed()); + $this->assertTrue($selections[1]->trashed()); + $this->assertTrue($selections[2]->trashed()); + } + + public function testDefaultTrashed() + { + $this->assertCount(3, testClassWithSoftDelete::all()); + } + + public function testWithTrashed() + { + $this->assertCount(5, testClassWithSoftDelete::withTrashed()->select()); + } + + public function testOnlyTrashed() + { + $this->assertCount(2, testClassWithSoftDelete::onlyTrashed()->select()); + } + + public function testSoftDelete() + { + $this->assertEquals(1, testClassWithSoftDelete::get(1)->delete()); + $this->assertNotNull(testClassWithSoftDelete::withTrashed()->find(1)->getData('delete_time')); + } + + public function testForceDelete() + { + $this->assertEquals(1, testClassWithSoftDelete::get(1)->delete(true)); + $this->assertNull(testClassWithSoftDelete::get(1)); + } + + public function testSoftDestroy() + { + $this->assertEquals(5, testClassWithSoftDelete::destroy([1, 2, 3, 4, 5, 6])); + $this->assertNotNull(testClassWithSoftDelete::withTrashed()->find(2)->getData('delete_time')); + $this->assertNotEquals(self::TEST_TIME, testClassWithSoftDelete::withTrashed()->find(2)->getData('delete_time')); + $this->assertNotEquals(self::TEST_TIME, testClassWithSoftDelete::withTrashed()->find(3)->getData('delete_time')); + $this->assertNotNull(testClassWithSoftDelete::withTrashed()->find(4)->getData('delete_time')); + $this->assertNotNull(testClassWithSoftDelete::withTrashed()->find(5)->getData('delete_time')); + } + + public function testForceDestroy() + { + $this->assertEquals(5, testClassWithSoftDelete::destroy([1, 2, 3, 4, 5, 6], true)); + $this->assertNull(testClassWithSoftDelete::withTrashed()->find(1)); + $this->assertNull(testClassWithSoftDelete::withTrashed()->find(2)); + $this->assertNull(testClassWithSoftDelete::withTrashed()->find(3)); + $this->assertNull(testClassWithSoftDelete::withTrashed()->find(4)); + $this->assertNull(testClassWithSoftDelete::withTrashed()->find(5)); + } + + public function testRestore() + { + /** @var testClassWithSoftDelete[] $selections */ + $selections = testClassWithSoftDelete::withTrashed()->select(); + + $this->assertEquals(0, $selections[0]->restore()); + $this->assertEquals(1, $selections[1]->restore()); + $this->assertEquals(1, $selections[2]->restore()); + $this->assertEquals(0, $selections[3]->restore()); + $this->assertEquals(0, $selections[4]->restore()); + + $this->assertNull(testClassWithSoftDelete::withTrashed()->find(1)->getData('delete_time')); + $this->assertNull(testClassWithSoftDelete::withTrashed()->find(2)->getData('delete_time')); + } + + public function testGetDeleteTimeField() + { + $testClass = new testClassWithSoftDelete(); + + $this->assertEquals('delete_time', $testClass->getDeleteTimeField()); + + $testClass->deleteTime = 'create_time'; + $this->assertEquals('create_time', $testClass->getDeleteTimeField()); + + $testClass->deleteTime = 'test.create_time'; + $this->assertEquals('create_time', $testClass->getDeleteTimeField()); + + $testClass->deleteTime = 'create_time'; + $this->assertEquals('__TABLE__.create_time', $testClass->getDeleteTimeField(true)); + } +} + +class testClassWithSoftDelete extends Model +{ + public $table = 'tp_soft_delete'; + + public $deleteTime = 'delete_time'; + + public $connection = [ + // 数据库类型 + 'type' => 'mysql', + // 服务器地址 + 'hostname' => '127.0.0.1', + // 数据库名 + 'database' => 'test', + // 用户名 + 'username' => 'root', + // 密码 + 'password' => '', + // 端口 + 'hostport' => '', + // 连接dsn + 'dsn' => '', + // 数据库连接参数 + 'params' => [], + // 数据库编码默认采用utf8 + 'charset' => 'utf8', + // 数据库表前缀 + 'prefix' => '', + // 数据库调试模式 + 'debug' => true, + // 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器) + 'deploy' => 0, + // 数据库读写是否分离 主从式有效 + 'rw_separate' => false, + // 读写分离后 主服务器数量 + 'master_num' => 1, + // 指定从服务器序号 + 'slave_no' => '', + // 是否严格检查字段是否存在 + 'fields_strict' => true, + // 数据集返回类型 array 数组 collection Collection对象 + 'resultset_type' => 'array', + // 是否自动写入时间戳字段 + 'auto_timestamp' => false, + // 是否需要进行SQL性能分析 + 'sql_explain' => false, + ]; + + use SoftDelete { + getDeleteTimeField as public; + } +} diff --git a/thinkphp/tests/thinkphp/library/traits/think/instanceTest.php b/thinkphp/tests/thinkphp/library/traits/think/instanceTest.php new file mode 100644 index 0000000..f93f22b --- /dev/null +++ b/thinkphp/tests/thinkphp/library/traits/think/instanceTest.php @@ -0,0 +1,60 @@ +assertInstanceOf('\tests\thinkphp\library\traits\think\InstanceTestFather', $father); + $this->assertEquals([], $father->options); + + $son = InstanceTestFather::instance(['son']); + $this->assertSame($father, $son); + } + + public function testCallStatic() + { + $father = InstanceTestFather::instance(); + $this->assertEquals([], $father->options); + + $this->assertEquals($father::__protectedStaticFunc(['thinkphp']), 'protectedStaticFunc["thinkphp"]'); + + try { + $father::_protectedStaticFunc(); + $this->setExpectedException('\think\Exception'); + } catch (\Exception $e) { + $this->assertInstanceOf('\think\Exception', $e); + } + } + + protected function tearDown() + { + call_user_func(\Closure::bind(function () { + InstanceTestFather::$instance = null; + }, null, '\tests\thinkphp\library\traits\think\InstanceTestFather')); + } +} + +class InstanceTestFather +{ + use Instance; + + public $options = null; + + public function __construct($options) + { + $this->options = $options; + } + + protected static function _protectedStaticFunc($params) + { + return 'protectedStaticFunc' . json_encode($params); + } +} + +class InstanceTestSon extends InstanceTestFather +{ +} diff --git a/thinkphp/tpl/default_index.tpl b/thinkphp/tpl/default_index.tpl new file mode 100644 index 0000000..8538b4d --- /dev/null +++ b/thinkphp/tpl/default_index.tpl @@ -0,0 +1,10 @@ +*{ padding: 0; margin: 0; } div{ padding: 4px 48px;} a{color:#2E5CD5;cursor: pointer;text-decoration: none} a:hover{text-decoration:underline; } body{ background: #fff; font-family: "Century Gothic","Microsoft yahei"; color: #333;font-size:18px;} h1{ font-size: 100px; font-weight: normal; margin-bottom: 12px; } p{ line-height: 1.6em; font-size: 42px }

    :)

    ThinkPHP V5
    十年磨一剑 - 为API开发设计的高性能框架

    [ V5.0 版本由 七牛云 独家赞助发布 ]
    '; + } +} diff --git a/thinkphp/tpl/dispatch_jump.tpl b/thinkphp/tpl/dispatch_jump.tpl new file mode 100644 index 0000000..583376b --- /dev/null +++ b/thinkphp/tpl/dispatch_jump.tpl @@ -0,0 +1,49 @@ +{__NOLAYOUT__} + + + + + 跳转提示 + + + +
    + + +

    :)

    +

    + + +

    :(

    +

    + + +

    +

    + 页面自动 跳转 等待时间: +

    +
    + + + diff --git a/thinkphp/tpl/page_trace.tpl b/thinkphp/tpl/page_trace.tpl new file mode 100644 index 0000000..7c5df6f --- /dev/null +++ b/thinkphp/tpl/page_trace.tpl @@ -0,0 +1,71 @@ +
    + + +
    +
    +
    + +
    + + diff --git a/thinkphp/tpl/think_exception.tpl b/thinkphp/tpl/think_exception.tpl new file mode 100644 index 0000000..1033eca --- /dev/null +++ b/thinkphp/tpl/think_exception.tpl @@ -0,0 +1,537 @@ +'.end($names).''; + } + } + + if(!function_exists('parse_file')){ + function parse_file($file, $line) + { + return ''.basename($file)." line {$line}".''; + } + } + + if(!function_exists('parse_args')){ + function parse_args($args) + { + $result = []; + + foreach ($args as $key => $item) { + switch (true) { + case is_object($item): + $value = sprintf('object(%s)', parse_class(get_class($item))); + break; + case is_array($item): + if(count($item) > 3){ + $value = sprintf('[%s, ...]', parse_args(array_slice($item, 0, 3))); + } else { + $value = sprintf('[%s]', parse_args($item)); + } + break; + case is_string($item): + if(strlen($item) > 20){ + $value = sprintf( + '\'%s...\'', + htmlentities($item), + htmlentities(substr($item, 0, 20)) + ); + } else { + $value = sprintf("'%s'", htmlentities($item)); + } + break; + case is_int($item): + case is_float($item): + $value = $item; + break; + case is_null($item): + $value = 'null'; + break; + case is_bool($item): + $value = '' . ($item ? 'true' : 'false') . ''; + break; + case is_resource($item): + $value = 'resource'; + break; + default: + $value = htmlentities(str_replace("\n", '', var_export(strval($item), true))); + break; + } + + $result[] = is_int($key) ? $value : sprintf('\'%s\' => %s', htmlentities($key), $value); + } + + return implode(', ', $result); + } + } +?> + + + + + <?php echo \think\Lang::get('System Error'); ?> + + + + + +
    + +
    + +
    +
    + +
    +
    +

    [

    +
    +

    +
    + +
    + +
    +
      $value) { ?>
    +
    + +
    +

    Call Stack

    +
      +
    1. + +
    2. + +
    3. + +
    +
    +
    + +
    + +

    + +
    + + + +
    +

    Exception Datas

    + $value) { ?> + + + + + + + $val) { ?> + + + + + + + +
    empty
    + +
    + +
    + + + +
    +

    Environment Variables

    + $value) { ?> +
    + +
    +
    +
    empty
    +
    + +

    +
    + $val) { ?> +
    +
    +
    + +
    +
    + +
    + +
    + +
    + + + + + + + + diff --git a/vendor/vendor/adbario/php-dot-notation/LICENSE.md b/vendor/vendor/adbario/php-dot-notation/LICENSE.md new file mode 100644 index 0000000..fe01323 --- /dev/null +++ b/vendor/vendor/adbario/php-dot-notation/LICENSE.md @@ -0,0 +1,21 @@ +# The MIT License (MIT) + +Copyright (c) 2016-2019 Riku Särkinen + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/vendor/vendor/adbario/php-dot-notation/composer.json b/vendor/vendor/adbario/php-dot-notation/composer.json new file mode 100644 index 0000000..cea7126 --- /dev/null +++ b/vendor/vendor/adbario/php-dot-notation/composer.json @@ -0,0 +1,29 @@ +{ + "name": "adbario/php-dot-notation", + "description": "PHP dot notation access to arrays", + "keywords": ["dotnotation", "arrayaccess"], + "homepage": "https://github.com/adbario/php-dot-notation", + "license": "MIT", + "authors": [ + { + "name": "Riku Särkinen", + "email": "riku@adbar.io" + } + ], + "require": { + "php": "^5.5 || ^7.0 || ^8.0", + "ext-json": "*" + }, + "require-dev": { + "phpunit/phpunit": "^4.8|^5.7|^6.6|^7.5|^8.5|^9.5", + "squizlabs/php_codesniffer": "^3.6" + }, + "autoload": { + "files": [ + "src/helpers.php" + ], + "psr-4": { + "Adbar\\": "src" + } + } +} diff --git a/vendor/vendor/adbario/php-dot-notation/src/Dot.php b/vendor/vendor/adbario/php-dot-notation/src/Dot.php new file mode 100644 index 0000000..3cd1c50 --- /dev/null +++ b/vendor/vendor/adbario/php-dot-notation/src/Dot.php @@ -0,0 +1,623 @@ + + * @link https://github.com/adbario/php-dot-notation + * @license https://github.com/adbario/php-dot-notation/blob/2.x/LICENSE.md (MIT License) + */ +namespace Adbar; + +use Countable; +use ArrayAccess; +use ArrayIterator; +use JsonSerializable; +use IteratorAggregate; + +/** + * Dot + * + * This class provides a dot notation access and helper functions for + * working with arrays of data. Inspired by Laravel Collection. + */ +class Dot implements ArrayAccess, Countable, IteratorAggregate, JsonSerializable +{ + /** + * The stored items + * + * @var array + */ + protected $items = []; + + + /** + * The delimiter (alternative to a '.') to be used. + * + * @var string + */ + protected $delimiter = '.'; + + + /** + * Create a new Dot instance + * + * @param mixed $items + * @param string $delimiter + */ + public function __construct($items = [], $delimiter = '.') + { + $this->items = $this->getArrayItems($items); + $this->delimiter = strlen($delimiter) ? $delimiter : '.'; + } + + /** + * Set a given key / value pair or pairs + * if the key doesn't exist already + * + * @param array|int|string $keys + * @param mixed $value + */ + public function add($keys, $value = null) + { + if (is_array($keys)) { + foreach ($keys as $key => $value) { + $this->add($key, $value); + } + } elseif (is_null($this->get($keys))) { + $this->set($keys, $value); + } + } + + /** + * Return all the stored items + * + * @return array + */ + public function all() + { + return $this->items; + } + + /** + * Delete the contents of a given key or keys + * + * @param array|int|string|null $keys + */ + public function clear($keys = null) + { + if (is_null($keys)) { + $this->items = []; + + return; + } + + $keys = (array) $keys; + + foreach ($keys as $key) { + $this->set($key, []); + } + } + + /** + * Delete the given key or keys + * + * @param array|int|string $keys + */ + public function delete($keys) + { + $keys = (array) $keys; + + foreach ($keys as $key) { + if ($this->exists($this->items, $key)) { + unset($this->items[$key]); + + continue; + } + + $items = &$this->items; + $segments = explode($this->delimiter, $key); + $lastSegment = array_pop($segments); + + foreach ($segments as $segment) { + if (!isset($items[$segment]) || !is_array($items[$segment])) { + continue 2; + } + + $items = &$items[$segment]; + } + + unset($items[$lastSegment]); + } + } + + /** + * Checks if the given key exists in the provided array. + * + * @param array $array Array to validate + * @param int|string $key The key to look for + * + * @return bool + */ + protected function exists($array, $key) + { + return array_key_exists($key, $array); + } + + /** + * Flatten an array with the given character as a key delimiter + * + * @param string $delimiter + * @param array|null $items + * @param string $prepend + * @return array + */ + public function flatten($delimiter = '.', $items = null, $prepend = '') + { + $flatten = []; + + if (is_null($items)) { + $items = $this->items; + } + + if (!func_num_args()) { + $delimiter = $this->delimiter; + } + + foreach ($items as $key => $value) { + if (is_array($value) && !empty($value)) { + $flatten = array_merge( + $flatten, + $this->flatten($delimiter, $value, $prepend.$key.$delimiter) + ); + } else { + $flatten[$prepend.$key] = $value; + } + } + + return $flatten; + } + + /** + * Return the value of a given key + * + * @param int|string|null $key + * @param mixed $default + * @return mixed + */ + public function get($key = null, $default = null) + { + if (is_null($key)) { + return $this->items; + } + + if ($this->exists($this->items, $key)) { + return $this->items[$key]; + } + + if (strpos($key, $this->delimiter) === false) { + return $default; + } + + $items = $this->items; + + foreach (explode($this->delimiter, $key) as $segment) { + if (!is_array($items) || !$this->exists($items, $segment)) { + return $default; + } + + $items = &$items[$segment]; + } + + return $items; + } + + /** + * Return the given items as an array + * + * @param mixed $items + * @return array + */ + protected function getArrayItems($items) + { + if (is_array($items)) { + return $items; + } elseif ($items instanceof self) { + return $items->all(); + } + + return (array) $items; + } + + /** + * Check if a given key or keys exists + * + * @param array|int|string $keys + * @return bool + */ + public function has($keys) + { + $keys = (array) $keys; + + if (!$this->items || $keys === []) { + return false; + } + + foreach ($keys as $key) { + $items = $this->items; + + if ($this->exists($items, $key)) { + continue; + } + + foreach (explode($this->delimiter, $key) as $segment) { + if (!is_array($items) || !$this->exists($items, $segment)) { + return false; + } + + $items = $items[$segment]; + } + } + + return true; + } + + /** + * Check if a given key or keys are empty + * + * @param array|int|string|null $keys + * @return bool + */ + public function isEmpty($keys = null) + { + if (is_null($keys)) { + return empty($this->items); + } + + $keys = (array) $keys; + + foreach ($keys as $key) { + if (!empty($this->get($key))) { + return false; + } + } + + return true; + } + + /** + * Merge a given array or a Dot object with the given key + * or with the whole Dot object + * + * @param array|string|self $key + * @param array|self $value + */ + public function merge($key, $value = []) + { + if (is_array($key)) { + $this->items = array_merge($this->items, $key); + } elseif (is_string($key)) { + $items = (array) $this->get($key); + $value = array_merge($items, $this->getArrayItems($value)); + + $this->set($key, $value); + } elseif ($key instanceof self) { + $this->items = array_merge($this->items, $key->all()); + } + } + + /** + * Recursively merge a given array or a Dot object with the given key + * or with the whole Dot object. + * + * Duplicate keys are converted to arrays. + * + * @param array|string|self $key + * @param array|self $value + */ + public function mergeRecursive($key, $value = []) + { + if (is_array($key)) { + $this->items = array_merge_recursive($this->items, $key); + } elseif (is_string($key)) { + $items = (array) $this->get($key); + $value = array_merge_recursive($items, $this->getArrayItems($value)); + + $this->set($key, $value); + } elseif ($key instanceof self) { + $this->items = array_merge_recursive($this->items, $key->all()); + } + } + + /** + * Recursively merge a given array or a Dot object with the given key + * or with the whole Dot object. + * + * Instead of converting duplicate keys to arrays, the value from + * given array will replace the value in Dot object. + * + * @param array|string|self $key + * @param array|self $value + */ + public function mergeRecursiveDistinct($key, $value = []) + { + if (is_array($key)) { + $this->items = $this->arrayMergeRecursiveDistinct($this->items, $key); + } elseif (is_string($key)) { + $items = (array) $this->get($key); + $value = $this->arrayMergeRecursiveDistinct($items, $this->getArrayItems($value)); + + $this->set($key, $value); + } elseif ($key instanceof self) { + $this->items = $this->arrayMergeRecursiveDistinct($this->items, $key->all()); + } + } + + /** + * Merges two arrays recursively. In contrast to array_merge_recursive, + * duplicate keys are not converted to arrays but rather overwrite the + * value in the first array with the duplicate value in the second array. + * + * @param array $array1 Initial array to merge + * @param array $array2 Array to recursively merge + * @return array + */ + protected function arrayMergeRecursiveDistinct(array $array1, array $array2) + { + $merged = &$array1; + + foreach ($array2 as $key => $value) { + if (is_array($value) && isset($merged[$key]) && is_array($merged[$key])) { + $merged[$key] = $this->arrayMergeRecursiveDistinct($merged[$key], $value); + } else { + $merged[$key] = $value; + } + } + + return $merged; + } + + /** + * Return the value of a given key and + * delete the key + * + * @param int|string|null $key + * @param mixed $default + * @return mixed + */ + public function pull($key = null, $default = null) + { + if (is_null($key)) { + $value = $this->all(); + $this->clear(); + + return $value; + } + + $value = $this->get($key, $default); + $this->delete($key); + + return $value; + } + + /** + * Push a given value to the end of the array + * in a given key + * + * @param mixed $key + * @param mixed $value + */ + public function push($key, $value = null) + { + if (is_null($value)) { + $this->items[] = $key; + + return; + } + + $items = $this->get($key); + + if (is_array($items) || is_null($items)) { + $items[] = $value; + $this->set($key, $items); + } + } + + /** + * Replace all values or values within the given key + * with an array or Dot object + * + * @param array|string|self $key + * @param array|self $value + */ + public function replace($key, $value = []) + { + if (is_array($key)) { + $this->items = array_replace($this->items, $key); + } elseif (is_string($key)) { + $items = (array) $this->get($key); + $value = array_replace($items, $this->getArrayItems($value)); + + $this->set($key, $value); + } elseif ($key instanceof self) { + $this->items = array_replace($this->items, $key->all()); + } + } + + /** + * Set a given key / value pair or pairs + * + * @param array|int|string $keys + * @param mixed $value + */ + public function set($keys, $value = null) + { + if (is_array($keys)) { + foreach ($keys as $key => $value) { + $this->set($key, $value); + } + + return; + } + + $items = &$this->items; + + foreach (explode($this->delimiter, $keys) as $key) { + if (!isset($items[$key]) || !is_array($items[$key])) { + $items[$key] = []; + } + + $items = &$items[$key]; + } + + $items = $value; + } + + /** + * Replace all items with a given array + * + * @param mixed $items + */ + public function setArray($items) + { + $this->items = $this->getArrayItems($items); + } + + /** + * Replace all items with a given array as a reference + * + * @param array $items + */ + public function setReference(array &$items) + { + $this->items = &$items; + } + + /** + * Return the value of a given key or all the values as JSON + * + * @param mixed $key + * @param int $options + * @return string + */ + public function toJson($key = null, $options = 0) + { + if (is_string($key)) { + return json_encode($this->get($key), $options); + } + + $options = $key === null ? 0 : $key; + + return json_encode($this->items, $options); + } + + /* + * -------------------------------------------------------------- + * ArrayAccess interface + * -------------------------------------------------------------- + */ + + /** + * Check if a given key exists + * + * @param int|string $key + * @return bool + */ + #[\ReturnTypeWillChange] + public function offsetExists($key) + { + return $this->has($key); + } + + /** + * Return the value of a given key + * + * @param int|string $key + * @return mixed + */ + #[\ReturnTypeWillChange] + public function offsetGet($key) + { + return $this->get($key); + } + + /** + * Set a given value to the given key + * + * @param int|string|null $key + * @param mixed $value + */ + #[\ReturnTypeWillChange] + public function offsetSet($key, $value) + { + if (is_null($key)) { + $this->items[] = $value; + + return; + } + + $this->set($key, $value); + } + + /** + * Delete the given key + * + * @param int|string $key + */ + #[\ReturnTypeWillChange] + public function offsetUnset($key) + { + $this->delete($key); + } + + /* + * -------------------------------------------------------------- + * Countable interface + * -------------------------------------------------------------- + */ + + /** + * Return the number of items in a given key + * + * @param int|string|null $key + * @return int + */ + #[\ReturnTypeWillChange] + public function count($key = null) + { + return count($this->get($key)); + } + + /* + * -------------------------------------------------------------- + * IteratorAggregate interface + * -------------------------------------------------------------- + */ + + /** + * Get an iterator for the stored items + * + * @return \ArrayIterator + */ + #[\ReturnTypeWillChange] + public function getIterator() + { + return new ArrayIterator($this->items); + } + + /* + * -------------------------------------------------------------- + * JsonSerializable interface + * -------------------------------------------------------------- + */ + + /** + * Return items for JSON serialization + * + * @return array + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return $this->items; + } +} diff --git a/vendor/vendor/adbario/php-dot-notation/src/helpers.php b/vendor/vendor/adbario/php-dot-notation/src/helpers.php new file mode 100644 index 0000000..bebb952 --- /dev/null +++ b/vendor/vendor/adbario/php-dot-notation/src/helpers.php @@ -0,0 +1,24 @@ + + * @link https://github.com/adbario/php-dot-notation + * @license https://github.com/adbario/php-dot-notation/blob/2.x/LICENSE.md (MIT License) + */ + +use Adbar\Dot; + +if (! function_exists('dot')) { + /** + * Create a new Dot object with the given items and optional delimiter + * + * @param mixed $items + * @param string $delimiter + * @return \Adbar\Dot + */ + function dot($items, $delimiter = '.') + { + return new Dot($items, $delimiter); + } +} diff --git a/vendor/vendor/alibabacloud/credentials/CHANGELOG.md b/vendor/vendor/alibabacloud/credentials/CHANGELOG.md new file mode 100644 index 0000000..703a558 --- /dev/null +++ b/vendor/vendor/alibabacloud/credentials/CHANGELOG.md @@ -0,0 +1,18 @@ +# CHANGELOG + +## 1.2.0 - 2024-10-17 + +- Refactor all credentials providers. + +## 1.1.3 - 2020-12-24 + +- Require guzzle ^6.3|^7.0 + +## 1.0.2 - 2020-02-14 +- Update Tea. + +## 1.0.1 - 2019-12-30 +- Supported get `Role Name` automatically. + +## 1.0.0 - 2019-09-01 +- Initial release of the Alibaba Cloud Credentials for PHP Version 1.0.0 on Packagist See for more information. diff --git a/vendor/vendor/alibabacloud/credentials/CONTRIBUTING.md b/vendor/vendor/alibabacloud/credentials/CONTRIBUTING.md new file mode 100644 index 0000000..8ed9330 --- /dev/null +++ b/vendor/vendor/alibabacloud/credentials/CONTRIBUTING.md @@ -0,0 +1,30 @@ +# CONTRIBUTING + +We work hard to provide a high-quality and useful SDK for Alibaba Cloud, and +we greatly value feedback and contributions from our community. Please submit +your [issues][issues] or [pull requests][pull-requests] through GitHub. + +## Tips + +- The SDK is released under the [Apache license][license]. Any code you submit + will be released under that license. For substantial contributions, we may + ask you to sign a [Alibaba Documentation Corporate Contributor License + Agreement (CLA)][cla]. +- We follow all of the relevant PSR recommendations from the [PHP Framework + Interop Group][php-fig]. Please submit code that follows these standards. + The [PHP CS Fixer][cs-fixer] tool can be helpful for formatting your code. + Your can use `composer fixer` to fix code. +- We maintain a high percentage of code coverage in our unit tests. If you make + changes to the code, please add, update, and/or remove tests as appropriate. +- If your code does not conform to the PSR standards, does not include adequate + tests, or does not contain a changelog document, we may ask you to update + your pull requests before we accept them. We also reserve the right to deny + any pull requests that do not align with our standards or goals. + +[issues]: https://github.com/aliyun/credentials-php/issues +[pull-requests]: https://github.com/aliyun/credentials-php/pulls +[license]: http://www.apache.org/licenses/LICENSE-2.0 +[cla]: https://alibaba-cla-2018.oss-cn-beijing.aliyuncs.com/Alibaba_Documentation_Open_Source_Corporate_CLA.pdf +[php-fig]: http://php-fig.org +[cs-fixer]: http://cs.sensiolabs.org/ +[docs-readme]: https://github.com/aliyun/credentials-php/blob/master/README.md diff --git a/vendor/vendor/alibabacloud/credentials/LICENSE.md b/vendor/vendor/alibabacloud/credentials/LICENSE.md new file mode 100644 index 0000000..ec13fcc --- /dev/null +++ b/vendor/vendor/alibabacloud/credentials/LICENSE.md @@ -0,0 +1,13 @@ +Copyright (c) 2009-present, Alibaba Cloud All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/vendor/vendor/alibabacloud/credentials/NOTICE.md b/vendor/vendor/alibabacloud/credentials/NOTICE.md new file mode 100644 index 0000000..97db193 --- /dev/null +++ b/vendor/vendor/alibabacloud/credentials/NOTICE.md @@ -0,0 +1,88 @@ +# NOTICE + + + +Copyright (c) 2009-present, Alibaba Cloud All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"). +You may not use this file except in compliance with the License. +A copy of the License is located at + + + +or in the "license" file accompanying this file. This file is distributed +on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +express or implied. See the License for the specific language governing +permissions and limitations under the License. + +# Guzzle + + + +Copyright (c) 2011-2018 Michael Dowling, https://github.com/mtdowling + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +# jmespath.php + + + +Copyright (c) 2014 Michael Dowling, https://github.com/mtdowling + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +# Dot + + + +Copyright (c) 2016-2019 Riku Särkinen + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/vendor/vendor/alibabacloud/credentials/README-zh-CN.md b/vendor/vendor/alibabacloud/credentials/README-zh-CN.md new file mode 100644 index 0000000..5ef6ecd --- /dev/null +++ b/vendor/vendor/alibabacloud/credentials/README-zh-CN.md @@ -0,0 +1,423 @@ +[English](/README.md) | 简体中文 + +![](https://aliyunsdk-pages.alicdn.com/icons/AlibabaCloud.svg) + +# Alibaba Cloud Credentials for PHP + +[![PHP CI](https://github.com/aliyun/credentials-php/actions/workflows/ci.yml/badge.svg)](https://github.com/aliyun/credentials-php/actions/workflows/ci.yml) +[![codecov](https://codecov.io/gh/aliyun/credentials-php/graph/badge.svg?token=YIkSjtfKbB)](https://codecov.io/gh/aliyun/credentials-php) +[![Latest Stable Version](https://poser.pugx.org/alibabacloud/credentials/v/stable)](https://packagist.org/packages/alibabacloud/credentials) +[![composer.lock](https://poser.pugx.org/alibabacloud/credentials/composerlock)](https://packagist.org/packages/alibabacloud/credentials) +[![Total Downloads](https://poser.pugx.org/alibabacloud/credentials/downloads)](https://packagist.org/packages/alibabacloud/credentials) +[![License](https://poser.pugx.org/alibabacloud/credentials/license)](https://packagist.org/packages/alibabacloud/credentials) + +Alibaba Cloud Credentials for PHP 是帮助 PHP 开发者管理凭据的工具。 + +## 先决条件 + +您的系统需要满足[先决条件](/docs/zh-CN/0-Prerequisites.md),包括 PHP> = 5.6。 我们强烈建议使用cURL扩展,并使用TLS后端编译cURL 7.16.2+。 + +## 安装依赖 + +如果已在系统上[全局安装 Composer](https://getcomposer.org/doc/00-intro.md#globally),请直接在项目目录中运行以下内容来安装 Alibaba Cloud Credentials for PHP 作为依赖项: + +```sh +composer require alibabacloud/credentials +``` + +> 一些用户可能由于网络问题无法安装,可以使用[阿里云 Composer 全量镜像](https://developer.aliyun.com/composer)。 + +请看[安装](/docs/zh-CN/1-Installation.md)有关通过 Composer 和其他方式安装的详细信息。 + +## 快速使用 + +在您开始之前,您需要注册阿里云帐户并获取您的[凭证](https://usercenter.console.aliyun.com/#/manage/ak)。 + +### 凭证类型 + +#### 使用默认凭据链 +当您在初始化凭据客户端不传入任何参数时,Credentials工具会使用默认凭据链方式初始化客户端。默认凭据的读取逻辑请参见[默认凭据链](#默认凭证提供程序链)。 + +```php +getCredential(); +$credential->getAccessKeyId(); +$credential->getAccessKeySecret(); +$credential->getSecurityToken(); +``` + +#### AccessKey + +通过[用户信息管理][ak]设置 access_key,它们具有该账户完全的权限,请妥善保管。有时出于安全考虑,您不能把具有完全访问权限的主账户 AccessKey 交于一个项目的开发者使用,您可以[创建RAM子账户][ram]并为子账户[授权][permissions],使用RAM子用户的 AccessKey 来进行API调用。 + +```php + 'access_key', + 'accessKeyId' => '', + 'accessKeySecret' => '', +]); +$client = new Credential($config); + +$credential = $client->getCredential(); +$credential->getAccessKeyId(); +$credential->getAccessKeySecret(); +``` + +#### STS + +通过安全令牌服务(Security Token Service,简称 STS),申请临时安全凭证(Temporary Security Credentials,简称 TSC),创建临时安全凭证。 + +```php + 'sts', + 'accessKeyId' => '', + 'accessKeySecret' => '', + 'securityToken' => '', +]); +$client = new Credential($config); + +$credential = $client->getCredential(); +$credential->getAccessKeyId(); +$credential->getAccessKeySecret(); +$credential->getSecurityToken(); +``` + +#### RamRoleArn + +通过指定RAM角色的ARN(Alibabacloud Resource Name),Credentials工具可以帮助开发者前往STS换取STS Token。您也可以通过为 `Policy` 赋值来限制RAM角色到一个更小的权限集合。 + +```php + 'ram_role_arn', + 'accessKeyId' => '', + 'accessKeySecret' => '', + // 要扮演的RAM角色ARN,示例值:acs:ram::123456789012****:role/adminrole,可以通过环境变量ALIBABA_CLOUD_ROLE_ARN设置role_arn + 'roleArn' => '', + // 角色会话名称,可以通过环境变量ALIBABA_CLOUD_ROLE_SESSION_NAME设置role_session_name + 'roleSessionName' => '', + // 设置更小的权限策略,非必填。示例值:{"Statement": [{"Action": ["*"],"Effect": "Allow","Resource": ["*"]}],"Version":"1"} + 'policy' => '', + // 设置session过期时间,非必填。 + 'roleSessionExpiration' => 3600, +]); +$client = new Credential($config); + +$credential = $client->getCredential(); +$credential->getAccessKeyId(); +$credential->getAccessKeySecret(); +$credential->getSecurityToken(); +``` + +#### EcsRamRole + +ECS和ECI实例均支持绑定实例RAM角色,当在实例中使用Credentials工具时,将自动获取实例绑定的RAM角色,并通过访问元数据服务获取RAM角色的STS Token,以完成凭据客户端的初始化。 + +实例元数据服务器支持加固模式和普通模式两种访问方式,Credentials工具默认使用加固模式(IMDSv2)获取访问凭据。若使用加固模式时发生异常,您可以通过设置disableIMDSv1来执行不同的异常处理逻辑: + +- 当值为false(默认值)时,会使用普通模式继续获取访问凭据。 + +- 当值为true时,表示只能使用加固模式获取访问凭据,会抛出异常。 + +服务端是否支持IMDSv2,取决于您在服务器的配置。 + +```php + 'ecs_ram_role', + // 选填,该ECS角色的角色名称,不填会自动获取,但是建议加上以减少请求次数,可以通过环境变量ALIBABA_CLOUD_ECS_METADATA设置role_name + 'roleName' => '', + // 选填,是否强制关闭IMDSv1,即必须使用IMDSv2加固模式,可以通过环境变量ALIBABA_CLOUD_IMDSV1_DISABLED设置 + 'disableIMDSv1' => true, +]); +$client = new Credential($config); + +$credential = $client->getCredential(); +$credential->getAccessKeyId(); +$credential->getAccessKeySecret(); +$credential->getSecurityToken(); +``` + +#### OIDCRoleArn + +在容器服务 Kubernetes 版中设置了Worker节点RAM角色后,对应节点内的Pod中的应用也就可以像ECS上部署的应用一样,通过元数据服务(Meta Data Server)获取关联角色的STS Token。但如果容器集群上部署的是不可信的应用(比如部署您的客户提交的应用,代码也没有对您开放),您可能并不希望它们能通过元数据服务获取Worker节点关联实例RAM角色的STS Token。为了避免影响云上资源的安全,同时又能让这些不可信的应用安全地获取所需的 STS Token,实现应用级别的权限最小化,您可以使用RRSA(RAM Roles for Service Account)功能。阿里云容器集群会为不同的应用Pod创建和挂载相应的服务账户OIDC Token文件,并将相关配置信息注入到环境变量中,Credentials工具通过获取环境变量的配置信息,调用STS服务的AssumeRoleWithOIDC - OIDC角色SSO时获取扮演角色的临时身份凭证接口换取绑定角色的STS Token。详情请参见[通过RRSA配置ServiceAccount的RAM权限实现Pod权限隔离](https://help.aliyun.com/zh/ack/ack-managed-and-ack-dedicated/user-guide/use-rrsa-to-authorize-pods-to-access-different-cloud-services#task-2142941)。 + +```php + 'oidc_role_arn', + // OIDC提供商ARN,可以通过环境变量ALIBABA_CLOUD_OIDC_PROVIDER_ARN设置oidc_provider_arn + 'oidcProviderArn' => '', + // OIDC Token文件路径,可以通过环境变量ALIBABA_CLOUD_OIDC_TOKEN_FILE设置oidc_token_file_path + 'oidcTokenFilePath' => '', + // 要扮演的RAM角色ARN,示例值:acs:ram::123456789012****:role/adminrole,可以通过环境变量ALIBABA_CLOUD_ROLE_ARN设置role_arn + 'roleArn' => '', + // 角色会话名称,可以通过环境变量ALIBABA_CLOUD_ROLE_SESSION_NAME设置role_session_name + 'roleSessionName' => '', + // 设置更小的权限策略,非必填。示例值:{"Statement": [{"Action": ["*"],"Effect": "Allow","Resource": ["*"]}],"Version":"1"} + 'policy' => '', + # 设置session过期时间 + 'roleSessionExpiration' => 3600, +]); +$client = new Credential($config); + +$credential = $client->getCredential(); +$credential->getAccessKeyId(); +$credential->getAccessKeySecret(); +$credential->getSecurityToken(); +``` + +#### Credentials URI + +通过指定提供凭证的自定义网络服务地址,让凭证自动申请维护 STS Token。 + +```php + 'credentials_uri', + // 凭证的 URI,格式为http://local_or_remote_uri/,可以通过环境变量ALIBABA_CLOUD_CREDENTIALS_URI设置credentials_uri + 'credentialsURI' => '', +]); +$client = new Credential($config); + +$credential = $client->getCredential(); +$credential->getAccessKeyId(); +$credential->getAccessKeySecret(); +$credential->getSecurityToken(); +``` + +#### Bearer Token + +目前只有云呼叫中心 CCC 这款产品支持 Bearer Token 的凭据初始化方式。 + +```php + 'bearer', + // 填入您的Bearer Token + 'bearerToken' => '', +]); +$client = new Credential($config); + +$credential = $client->getCredential(); +$credential->getBearerToken(); +``` + +## 默认凭证提供程序链 + +当您的程序开发环境和生产环境采用不同的凭据类型,常见做法是在代码中获取当前环境信息,编写获取不同凭据的分支代码。借助Credentials工具的默认凭据链,您可以用同一套代码,通过程序之外的配置来控制不同环境下的凭据获取方式。当您在不传入参数的情况下,直接使用$credential = new Credential();初始化凭据客户端时,阿里云SDK将会尝试按照如下顺序查找相关凭据信息。 + +### 1. 使用环境变量 + +Credentials工具会优先在环境变量中获取凭据信息。 + +- 如果系统环境变量 `ALIBABA_CLOUD_ACCESS_KEY_ID`(密钥Key) 和 `ALIBABA_CLOUD_ACCESS_KEY_SECRET`(密钥Value) 不为空,Credentials工具会优先使用它们作为默认凭据。 + +- 如果系统环境变量 `ALIBABA_CLOUD_ACCESS_KEY_ID`(密钥Key)、`ALIBABA_CLOUD_ACCESS_KEY_SECRET`(密钥Value)、`ALIBABA_CLOUD_SECURITY_TOKEN`(Token)均不为空,Credentials工具会优先使用STS Token作为默认凭据。 + +### 2. 使用OIDC RAM角色 +若不存在优先级更高的凭据信息,Credentials工具会在环境变量中获取如下内容: + +`ALIBABA_CLOUD_ROLE_ARN`:RAM角色名称ARN; + +`ALIBABA_CLOUD_OIDC_PROVIDER_ARN`:OIDC提供商ARN; + +`ALIBABA_CLOUD_OIDC_TOKEN_FILE`:OIDC Token文件路径; + +若以上三个环境变量都已设置内容,Credentials将会使用变量内容调用STS服务的[AssumeRoleWithOIDC - OIDC角色SSO时获取扮演角色的临时身份凭证](https://help.aliyun.com/zh/ram/developer-reference/api-sts-2015-04-01-assumerolewithoidc)接口换取STS Token作为默认凭据。 + +### 3. 使用 Aliyun CLI 工具的 config.json 配置文件 + +若不存在优先级更高的凭据信息,Credentials工具会优先在如下位置查找 `config.json` 文件是否存在: +Linux系统:`~/.aliyun/config.json` +Windows系统: `C:\Users\USER_NAME\.aliyun\config.json` +如果文件存在,程序将会使用配置文件中 `current` 指定的凭据信息初始化凭据客户端。当然,您也可以通过环境变量 `ALIBABA_CLOUD_PROFILE` 来指定凭据信息,例如设置 `ALIBABA_CLOUD_PROFILE` 的值为 `AK`。 + +在config.json配置文件中每个module的值代表了不同的凭据信息获取方式: + +- AK:使用用户的Access Key作为凭据信息; +- RamRoleArn:使用RAM角色的ARN来获取凭据信息; +- EcsRamRole:利用ECS绑定的RAM角色来获取凭据信息; +- OIDC:通过OIDC ARN和OIDC Token来获取凭据信息; +- ChainableRamRoleArn:采用角色链的方式,通过指定JSON文件中的其他凭据,以重新获取新的凭据信息。 + +配置示例信息如下: + +```json +{ + "current": "AK", + "profiles": [ + { + "name": "AK", + "mode": "AK", + "access_key_id": "access_key_id", + "access_key_secret": "access_key_secret" + }, + { + "name": "RamRoleArn", + "mode": "RamRoleArn", + "access_key_id": "access_key_id", + "access_key_secret": "access_key_secret", + "ram_role_arn": "ram_role_arn", + "ram_session_name": "ram_session_name", + "expired_seconds": 3600, + "sts_region": "cn-hangzhou" + }, + { + "name": "EcsRamRole", + "mode": "EcsRamRole", + "ram_role_name": "ram_role_name" + }, + { + "name": "OIDC", + "mode": "OIDC", + "ram_role_arn": "ram_role_arn", + "oidc_token_file": "path/to/oidc/file", + "oidc_provider_arn": "oidc_provider_arn", + "ram_session_name": "ram_session_name", + "expired_seconds": 3600, + "sts_region": "cn-hangzhou" + }, + { + "name": "ChainableRamRoleArn", + "mode": "ChainableRamRoleArn", + "source_profile": "AK", + "ram_role_arn": "ram_role_arn", + "ram_session_name": "ram_session_name", + "expired_seconds": 3600, + "sts_region": "cn-hangzhou" + } + ] +} +``` + +### 4. 使用配置文件 +> +> 如果用户主目录存在默认文件 `~/.alibabacloud/credentials` (Windows 为 `C:\Users\USER_NAME\.alibabacloud\credentials`),程序会自动创建指定类型和名称的凭证。您也可通过环境变量 `ALIBABA_CLOUD_CREDENTIALS_FILE` 指定配置文件路径。如果文件存在,程序将会使用配置文件中 default 指定的凭据信息初始化凭据客户端。当然,您也可以通过环境变量 `ALIBABA_CLOUD_PROFILE` 来指定凭据信息,例如设置 `ALIBABA_CLOUD_PROFILE` 的值为 `client1`。 + +配置示例信息如下: + +```ini +[default] +type = access_key # 认证方式为 access_key +access_key_id = foo # Key +access_key_secret = bar # Secret + +[project1] +type = ecs_ram_role # 认证方式为 ecs_ram_role +role_name = EcsRamRoleTest # Role Name,非必填,不填则自动获取,建议设置,可以减少网络请求。 + +[project2] +type = ram_role_arn # 认证方式为 ram_role_arn +access_key_id = foo +access_key_secret = bar +role_arn = role_arn +role_session_name = session_name + +[project3] +type=oidc_role_arn # 认证方式为 oidc_role_arn +oidc_provider_arn=oidc_provider_arn +oidc_token_file_path=oidc_token_file_path +role_arn=role_arn +role_session_name=session_name +``` + +### 5. 使用 ECS 实例RAM角色 + +若不存在优先级更高的凭据信息,Credentials工具将通过环境变量获取ALIBABA_CLOUD_ECS_METADATA(ECS实例RAM角色名称)的值。若该变量的值存在,程序将采用加固模式(IMDSv2)访问ECS的元数据服务(Meta Data Server),以获取ECS实例RAM角色的STS Token作为默认凭据信息。在使用加固模式时若发生异常,将使用普通模式兜底来获取访问凭据。您也可以通过设置环境变量ALIBABA_CLOUD_IMDSV1_DISABLED,执行不同的异常处理逻辑: + +- 当值为false时,会使用普通模式继续获取访问凭据。 + +- 当值为true时,表示只能使用加固模式获取访问凭据,会抛出异常。 + +服务端是否支持IMDSv2,取决于您在服务器的配置。 + +### 6. 使用外部服务 Credentials URI + +若不存在优先级更高的凭据信息,Credentials工具会在环境变量中获取ALIBABA_CLOUD_CREDENTIALS_URI,若存在,程序将请求该URI地址,获取临时安全凭证作为默认凭据信息。 + +外部服务响应结构应如下: + +```json +{ + "Code": "Success", + "AccessKeyId": "AccessKeyId", + "AccessKeySecret": "AccessKeySecret", + "SecurityToken": "SecurityToken", + "Expiration": "2024-10-26T03:46:38Z" +} +``` + +## 文档 + +* [先决条件](/docs/zh-CN/0-Prerequisites.md) +* [安装](/docs/zh-CN/1-Installation.md) + +## 问题 + +[提交 Issue](https://github.com/aliyun/credentials-php/issues/new/choose),不符合指南的问题可能会立即关闭。 + +## 发行说明 + +每个版本的详细更改记录在[发行说明](/CHANGELOG.md)中。 + +## 贡献 + +提交 Pull Request 之前请阅读[贡献指南](/CONTRIBUTING.md)。 + +## 相关 + +* [OpenAPI 开发者门户][open-api] +* [Packagist][packagist] +* [Composer][composer] +* [Guzzle中文文档][guzzle-docs] +* [最新源码][latest-release] + +## 许可证 + +[Apache-2.0](/LICENSE.md) + +Copyright (c) 2009-present, Alibaba Cloud All rights reserved. + +[open-api]: https://api.aliyun.com +[latest-release]: https://github.com/aliyun/credentials-php +[guzzle-docs]: https://guzzle-cn.readthedocs.io/zh_CN/latest/request-options.html +[composer]: https://getcomposer.org +[packagist]: https://packagist.org/packages/alibabacloud/credentials diff --git a/vendor/vendor/alibabacloud/credentials/README.md b/vendor/vendor/alibabacloud/credentials/README.md new file mode 100644 index 0000000..e646999 --- /dev/null +++ b/vendor/vendor/alibabacloud/credentials/README.md @@ -0,0 +1,422 @@ +English | [简体中文](/README-zh-CN.md) + +![](https://aliyunsdk-pages.alicdn.com/icons/AlibabaCloud.svg) + +# Alibaba Cloud Credentials for PHP + +[![PHP CI](https://github.com/aliyun/credentials-php/actions/workflows/ci.yml/badge.svg)](https://github.com/aliyun/credentials-php/actions/workflows/ci.yml) +[![codecov](https://codecov.io/gh/aliyun/credentials-php/graph/badge.svg?token=YIkSjtfKbB)](https://codecov.io/gh/aliyun/credentials-php) +[![Latest Stable Version](https://poser.pugx.org/alibabacloud/credentials/v/stable)](https://packagist.org/packages/alibabacloud/credentials) +[![composer.lock](https://poser.pugx.org/alibabacloud/credentials/composerlock)](https://packagist.org/packages/alibabacloud/credentials) +[![Total Downloads](https://poser.pugx.org/alibabacloud/credentials/downloads)](https://packagist.org/packages/alibabacloud/credentials) +[![License](https://poser.pugx.org/alibabacloud/credentials/license)](https://packagist.org/packages/alibabacloud/credentials) + +Alibaba Cloud Credentials for PHP is a tool that helps PHP developers manage their credentials. + +## Prerequisites + +Your system needs to meet [Prerequisites](/docs/zh-CN/0-Prerequisites.md), including PHP> = 5.6. We strongly recommend using the cURL extension and compiling cURL 7.16.2+ using the TLS backend. + +## Installation + +If you have [Globally Install Composer](https://getcomposer.org/doc/00-intro.md#globally) on your system, install Alibaba Cloud Credentials for PHP as a dependency by running the following directly in the project directory: + +```sh +composer require alibabacloud/credentials +``` + +> Some users may not be able to install due to network problems, you can switch to the [Alibaba Cloud Composer Mirror](https://developer.aliyun.com/composer). + +See [Installation](/docs/zh-CN/1-Installation.md) for details on installing through Composer and other means. + +## Quick Examples + +Before you begin, you need to sign up for an Alibaba Cloud account and retrieve your [Credentials](https://usercenter.console.aliyun.com/#/manage/ak). + +### Credential Type + +#### Default credential provider chain + +If you do not specify a method to initialize a Credentials client, the default credential provider chain is used. For more information, see the Default credential provider chain section of this topic. + +```php +getCredential(); +$credential->getAccessKeyId(); +$credential->getAccessKeySecret(); +$credential->getSecurityToken(); +``` + +#### AccessKey + +Setup access_key credential through [User Information Management][ak], it have full authority over the account, please keep it safe. Sometimes for security reasons, you cannot hand over a primary account AccessKey with full access to the developer of a project. You may create a sub-account [RAM Sub-account][ram] , grant its [authorization][permissions],and use the AccessKey of RAM Sub-account. + +```php + 'access_key', + 'accessKeyId' => '', + 'accessKeySecret' => '', +]); +$client = new Credential($config); + +$credential = $client->getCredential(); +$credential->getAccessKeyId(); +$credential->getAccessKeySecret(); +``` + +#### STS + +Create a temporary security credential by applying Temporary Security Credentials (TSC) through the Security Token Service (STS). + +```php + 'sts', + 'accessKeyId' => '', + 'accessKeySecret' => '', + 'securityToken' => '', +]); +$client = new Credential($config); + +$credential = $client->getCredential(); +$credential->getAccessKeyId(); +$credential->getAccessKeySecret(); +$credential->getSecurityToken(); +``` + +#### RamRoleArn + +By specifying [RAM Role][RAM Role], the credential will be able to automatically request maintenance of STS Token. If you want to limit the permissions([How to make a policy][policy]) of STS Token, you can assign value for `Policy`. + +```php + 'ram_role_arn', + 'accessKeyId' => '', + 'accessKeySecret' => '', + // Specify the ARN of the RAM role to be assumed. Example: acs:ram::123456789012****:role/adminrole. + 'roleArn' => '', + // Specify the name of the role session. + 'roleSessionName' => '', + // Optional. Specify limited permissions for the RAM role. Example: {"Statement": [{"Action": ["*"],"Effect": "Allow","Resource": ["*"]}],"Version":"1"}. + 'policy' => '', + // Optional. Specify the expiration of the session + 'roleSessionExpiration' => 3600, +]); +$client = new Credential($config); + +$credential = $client->getCredential(); +$credential->getAccessKeyId(); +$credential->getAccessKeySecret(); +$credential->getSecurityToken(); +``` + +#### EcsRamRole + +Both ECS and ECI instances support binding instance RAM roles. When the Credentials tool is used in an instance, the RAM role bound to the instance will be automatically obtained, and the STS Token of the RAM role will be obtained by accessing the metadata service to complete the initialization of the credential client. + +The instance metadata server supports two access modes: hardened mode and normal mode. The Credentials tool uses hardened mode (IMDSv2) by default to obtain access credentials. If an exception occurs when using hardened mode, you can set disableIMDSv1 to perform different exception handling logic: + +- When the value is false (default value), the normal mode will continue to be used to obtain access credentials. + +- When the value is true, it means that only hardened mode can be used to obtain access credentials, and an exception will be thrown. + +Whether the server supports IMDSv2 depends on your configuration on the server. + +```php + 'ecs_ram_role', + // Optional. Specify the name of the RAM role of the ECS instance. If you do not specify this parameter, its value is automatically obtained. To reduce the number of requests, we recommend that you specify this parameter. + 'roleName' => '', + //Optional, whether to forcibly disable IMDSv1, that is, to use IMDSv2 hardening mode, which can be set by the environment variable ALIBABA_CLOUD_IMDSV1_DISABLED + 'disableIMDSv1' => true, +]); +$client = new Credential($config); + +$credential = $client->getCredential(); +$credential->getAccessKeyId(); +$credential->getAccessKeySecret(); +$credential->getSecurityToken(); +``` + +#### OIDCRoleArn + +After you attach a RAM role to a worker node in an Container Service for Kubernetes, applications in the pods on the worker node can use the metadata server to obtain an STS token the same way in which applications on ECS instances do. However, if an untrusted application is deployed on the worker node, such as an application that is submitted by your customer and whose code is unavailable to you, you may not want the application to use the metadata server to obtain an STS token of the RAM role attached to the worker node. To ensure the security of cloud resources and enable untrusted applications to securely obtain required STS tokens, you can use the RAM Roles for Service Accounts (RRSA) feature to grant minimum necessary permissions to an application. In this case, the ACK cluster creates a service account OpenID Connect (OIDC) token file, associates the token file with a pod, and then injects relevant environment variables into the pod. Then, the Credentials tool uses the environment variables to call the AssumeRoleWithOIDC operation of STS and obtains an STS token of the RAM role. For more information about the RRSA feature, see [Use RRSA to authorize different pods to access different cloud services](https://www.alibabacloud.com/help/en/ack/ack-managed-and-ack-dedicated/user-guide/use-rrsa-to-authorize-pods-to-access-different-cloud-services#task-2142941). + +```php + 'oidc_role_arn', + // Specify the ARN of the OIDC IdP by specifying the ALIBABA_CLOUD_OIDC_PROVIDER_ARN environment variable. + 'oidcProviderArn' => '', + // Specify the path of the OIDC token file by specifying the ALIBABA_CLOUD_OIDC_TOKEN_FILE environment variable. + 'oidcTokenFilePath' => '', + // Specify the ARN of the RAM role by specifying the ALIBABA_CLOUD_ROLE_ARN environment variable. + 'roleArn' => '', + // Specify the role session name by specifying the ALIBABA_CLOUD_ROLE_SESSION_NAME environment variable. + 'roleSessionName' => '', + // Optional. Specify limited permissions for the RAM role. Example: {"Statement": [{"Action": ["*"],"Effect": "Allow","Resource": ["*"]}],"Version":"1"}. + 'policy' => '', + // Optional. Specify the validity period of the session. + 'roleSessionExpiration' => 3600, +]); +$client = new Credential($config); + +$credential = $client->getCredential(); +$credential->getAccessKeyId(); +$credential->getAccessKeySecret(); +$credential->getSecurityToken(); +``` + +#### Credentials URI + +By specifying the url, the credential will be able to automatically request maintenance of STS Token. + +```php + 'credentials_uri', + // Format: http url. `credentialsURI` can be replaced by setting environment variable: ALIBABA_CLOUD_CREDENTIALS_URI + 'credentialsURI' => '', +]); +$client = new Credential($config); + +$credential = $client->getCredential(); +$credential->getAccessKeyId(); +$credential->getAccessKeySecret(); +$credential->getSecurityToken(); +``` + +#### Bearer Token + +If credential is required by the Cloud Call Centre (CCC), please apply for Bearer Token maintenance by yourself. + +```php + 'bearer', + 'bearerToken' => '', +]); +$client = new Credential($config); + +$credential = $client->getCredential(); +$credential->getBearerToken(); +``` + +## Default credential provider chain + +If you want to use different types of credentials in the development and production environments of your application, you generally need to obtain the environment information from the code and write code branches to obtain different credentials for the development and production environments. The default credential provider chain of the Credentials tool allows you to use the same code to obtain credentials for different environments based on configurations independent of the application. If you use $credential = new Credential(); to initialize a Credentials client without specifying an initialization method, the Credentials tool obtains the credential information in the following order: + +### 1. Environmental certificate + +Look for environment credentials in environment variable. +- If the `ALIBABA_CLOUD_ACCESS_KEY_ID` and `ALIBABA_CLOUD_ACCESS_KEY_SECRET` environment variables are defined and are not empty, the program will use them to create default credentials. +- If the `ALIBABA_CLOUD_ACCESS_KEY_ID`, `ALIBABA_CLOUD_ACCESS_KEY_SECRET` and `ALIBABA_CLOUD_SECURITY_TOKEN` environment variables are defined and are not empty, the program will use them to create temporary security credentials(STS). Note: This token has an expiration time, it is recommended to use it in a temporary environment. + +### 2. The RAM role of an OIDC IdP + +If no credentials are found in the previous step, the Credentials tool obtains the values of the following environment variables: + +`ALIBABA_CLOUD_ROLE_ARN`: the ARN of the RAM role. + +`ALIBABA_CLOUD_OIDC_PROVIDER_ARN`: the ARN of the OIDC IdP. + +`ALIBABA_CLOUD_OIDC_TOKEN_FILE`: the path of the OIDC token file. + +If the preceding three environment variables are specified, the Credentials tool uses the environment variables to call the [AssumeRoleWithOIDC](https://www.alibabacloud.com/help/en/ram/developer-reference/api-sts-2015-04-01-assumerolewithoidc) operation of STS to obtain an STS token as the default credential. + +### 3. Using the config.json Configuration File of Aliyun CLI Tool +If there is no higher-priority credential information, the Credentials tool will first check the following locations to see if the config.json file exists: + +Linux system: `~/.aliyun/config.json` +Windows system: `C:\Users\USER_NAME\.aliyun\config.json` +If the file exists, the program will use the credential information specified by `current` in the configuration file to initialize the credentials client. Of course, you can also use the environment variable `ALIBABA_CLOUD_PROFILE` to specify the credential information, for example by setting the value of `ALIBABA_CLOUD_PROFILE` to `AK`. + +In the config.json configuration file, the value of each module represents different ways to obtain credential information: + +- AK: Use the Access Key of the user as credential information; +- RamRoleArn: Use the ARN of the RAM role to obtain credential information; +- EcsRamRole: Use the RAM role bound to the ECS to obtain credential information; +- OIDC: Obtain credential information through OIDC ARN and OIDC Token; +- ChainableRamRoleArn: Use the role chaining method to obtain new credential information by specifying other credentials in the JSON file. + +The configuration example information is as follows: + +```json +{ + "current": "AK", + "profiles": [ + { + "name": "AK", + "mode": "AK", + "access_key_id": "access_key_id", + "access_key_secret": "access_key_secret" + }, + { + "name": "RamRoleArn", + "mode": "RamRoleArn", + "access_key_id": "access_key_id", + "access_key_secret": "access_key_secret", + "ram_role_arn": "ram_role_arn", + "ram_session_name": "ram_session_name", + "expired_seconds": 3600, + "sts_region": "cn-hangzhou" + }, + { + "name": "EcsRamRole", + "mode": "EcsRamRole", + "ram_role_name": "ram_role_name" + }, + { + "name": "OIDC", + "mode": "OIDC", + "ram_role_arn": "ram_role_arn", + "oidc_token_file": "path/to/oidc/file", + "oidc_provider_arn": "oidc_provider_arn", + "ram_session_name": "ram_session_name", + "expired_seconds": 3600, + "sts_region": "cn-hangzhou" + }, + { + "name": "ChainableRamRoleArn", + "mode": "ChainableRamRoleArn", + "source_profile": "AK", + "ram_role_arn": "ram_role_arn", + "ram_session_name": "ram_session_name", + "expired_seconds": 3600, + "sts_region": "cn-hangzhou" + } + ] +} +``` + +### 4. Configuration file +> +> If the user's home directory has the default file `~/.alibabacloud/credentials` (Windows is `C:\Users\USER_NAME\.alibabacloud\credentials`), the program will automatically create credentials with the specified type and name. You can also specify the configuration file path by configuring the `ALIBABA_CLOUD_CREDENTIALS_FILE` environment variable. If the configuration file exists, the application initializes a Credentials client by using the credential information that is specified by default in the configuration file. You can also configure the `ALIBABA_CLOUD_PROFILE` environment variable to modify the default credential information that is read. + +Configuration example: +```ini +[default] +type = access_key # Authentication method is access_key +access_key_id = foo # Key +access_key_secret = bar # Secret + +[project1] +type = ecs_ram_role # Authentication method is ecs_ram_role +role_name = EcsRamRoleTest # Role name, optional. It will be retrieved automatically if not set. It is highly recommended to set it up to reduce requests. + +[project2] +type = ram_role_arn # Authentication method is ram_role_arn +access_key_id = foo +access_key_secret = bar +role_arn = role_arn +role_session_name = session_name + +[project3] +type=oidc_role_arn # Authentication method is oidc_role_arn +oidc_provider_arn=oidc_provider_arn +oidc_token_file_path=oidc_token_file_path +role_arn=role_arn +role_session_name=session_name +``` + +### 5. Instance RAM role + +If there is no credential information with a higher priority, the Credentials tool will obtain the value of ALIBABA_CLOUD_ECS_METADATA (ECS instance RAM role name) through the environment variable. If the value of this variable exists, the program will use the hardened mode (IMDSv2) to access the metadata service (Meta Data Server) of ECS to obtain the STS Token of the ECS instance RAM role as the default credential information. If an exception occurs when using the hardened mode, the normal mode will be used as a fallback to obtain access credentials. You can also set the environment variable ALIBABA_CLOUD_IMDSV1_DISABLED to perform different exception handling logic: + +- When the value is false, the normal mode will continue to obtain access credentials. + +- When the value is true, it means that only the hardened mode can be used to obtain access credentials, and an exception will be thrown. + +Whether the server supports IMDSv2 depends on your configuration on the server. + +### 6. Using External Service Credentials URI + +If there are no higher-priority credential information, the Credentials tool will obtain the `ALIBABA_CLOUD_CREDENTIALS_URI` from the environment variables. If it exists, the program will request the URI address to obtain temporary security credentials as the default credential information. + +The external service response structure should be as follows: + +```json +{ + "Code": "Success", + "AccessKeyId": "AccessKeyId", + "AccessKeySecret": "AccessKeySecret", + "SecurityToken": "SecurityToken", + "Expiration": "2024-10-26T03:46:38Z" +} +``` + +## Documentation + +* [Prerequisites](/docs/zh-CN/0-Prerequisites.md) +* [Installation](/docs/zh-CN/1-Installation.md) + +## Issue + +[Submit Issue](https://github.com/aliyun/credentials-php/issues/new/choose), Problems that do not meet the guidelines may close immediately. + +## Release notes + +Detailed changes for each version are recorded in the [Release Notes](/CHANGELOG.md). + +## Contribution + +Please read the [Contribution Guide](/CONTRIBUTING.md) before submitting a Pull Request. + +## Related + +* [OpenAPI Developer Portal][open-api] +* [Packagist][packagist] +* [Composer][composer] +* [Guzzle Doc][guzzle-docs] +* [Latest Release][latest-release] + +## License + +[Apache-2.0](/LICENSE.md) + +Copyright (c) 2009-present, Alibaba Cloud All rights reserved. + +[open-api]: https://api.alibabacloud.com +[latest-release]: https://github.com/aliyun/credentials-php +[guzzle-docs]: http://docs.guzzlephp.org/en/stable/request-options.html +[composer]: https://getcomposer.org +[packagist]: https://packagist.org/packages/alibabacloud/credentials diff --git a/vendor/vendor/alibabacloud/credentials/SECURITY.md b/vendor/vendor/alibabacloud/credentials/SECURITY.md new file mode 100644 index 0000000..034e848 --- /dev/null +++ b/vendor/vendor/alibabacloud/credentials/SECURITY.md @@ -0,0 +1,21 @@ +# Security Policy + +## Supported Versions + +Use this section to tell people about which versions of your project are +currently being supported with security updates. + +| Version | Supported | +| ------- | ------------------ | +| 5.1.x | :white_check_mark: | +| 5.0.x | :x: | +| 4.0.x | :white_check_mark: | +| < 4.0 | :x: | + +## Reporting a Vulnerability + +Use this section to tell people how to report a vulnerability. + +Tell them where to go, how often they can expect to get an update on a +reported vulnerability, what to expect if the vulnerability is accepted or +declined, etc. diff --git a/vendor/vendor/alibabacloud/credentials/UPGRADING.md b/vendor/vendor/alibabacloud/credentials/UPGRADING.md new file mode 100644 index 0000000..f084ed6 --- /dev/null +++ b/vendor/vendor/alibabacloud/credentials/UPGRADING.md @@ -0,0 +1,6 @@ +Upgrading Guide +=============== + +1.x +----------------------- +- This is the first version. See for more information. diff --git a/vendor/vendor/alibabacloud/credentials/composer.json b/vendor/vendor/alibabacloud/credentials/composer.json new file mode 100644 index 0000000..81f9745 --- /dev/null +++ b/vendor/vendor/alibabacloud/credentials/composer.json @@ -0,0 +1,107 @@ +{ + "name": "alibabacloud/credentials", + "homepage": "https://www.alibabacloud.com/", + "description": "Alibaba Cloud Credentials for PHP", + "keywords": [ + "sdk", + "tool", + "cloud", + "client", + "aliyun", + "library", + "alibaba", + "Credentials", + "alibabacloud" + ], + "type": "library", + "license": "Apache-2.0", + "support": { + "source": "https://github.com/aliyun/credentials-php", + "issues": "https://github.com/aliyun/credentials-php/issues" + }, + "authors": [ + { + "name": "Alibaba Cloud SDK", + "email": "sdk-team@alibabacloud.com", + "homepage": "http://www.alibabacloud.com" + } + ], + "require": { + "php": ">=5.6", + "ext-curl": "*", + "ext-json": "*", + "ext-libxml": "*", + "ext-openssl": "*", + "ext-mbstring": "*", + "ext-simplexml": "*", + "ext-xmlwriter": "*", + "guzzlehttp/guzzle": "^6.3|^7.0", + "adbario/php-dot-notation": "^2.2", + "alibabacloud/tea": "^3.0" + }, + "require-dev": { + "ext-spl": "*", + "ext-dom": "*", + "ext-pcre": "*", + "psr/cache": "^1.0", + "ext-sockets": "*", + "drupal/coder": "^8.3", + "symfony/dotenv": "^3.4", + "phpunit/phpunit": "^5.7|^6.6|^9.3", + "monolog/monolog": "^1.24", + "composer/composer": "^1.8", + "mikey179/vfsstream": "^1.6", + "symfony/var-dumper": "^3.4" + }, + "suggest": { + "ext-sockets": "To use client-side monitoring" + }, + "autoload": { + "psr-4": { + "AlibabaCloud\\Credentials\\": "src" + } + }, + "autoload-dev": { + "psr-4": { + "AlibabaCloud\\Credentials\\Tests\\": "tests/" + } + }, + "config": { + "preferred-install": "dist", + "optimize-autoloader": true, + "allow-plugins": { + "dealerdirect/phpcodesniffer-composer-installer": true + } + }, + "minimum-stability": "dev", + "prefer-stable": true, + "scripts-descriptions": { + "cs": "Tokenizes PHP, JavaScript and CSS files to detect violations of a defined coding standard.", + "cbf": "Automatically correct coding standard violations.", + "fixer": "Fixes code to follow standards.", + "test": "Run all tests.", + "unit": "Run Unit tests.", + "feature": "Run Feature tests.", + "clearCache": "Clear cache like coverage.", + "coverage": "Show Coverage html.", + "endpoints": "Update endpoints from OSS." + }, + "scripts": { + "cs": "phpcs --standard=PSR2 -n ./", + "cbf": "phpcbf --standard=PSR2 -n ./", + "fixer": "php-cs-fixer fix ./", + "test": [ + "phpunit --colors=always" + ], + "unit": [ + "@clearCache", + "phpunit --testsuite=Unit --colors=always" + ], + "feature": [ + "@clearCache", + "phpunit --testsuite=Feature --colors=always" + ], + "coverage": "open cache/coverage/index.html", + "clearCache": "rm -rf cache/*" + } +} diff --git a/vendor/vendor/alibabacloud/credentials/src/AccessKeyCredential.php b/vendor/vendor/alibabacloud/credentials/src/AccessKeyCredential.php new file mode 100644 index 0000000..05a0132 --- /dev/null +++ b/vendor/vendor/alibabacloud/credentials/src/AccessKeyCredential.php @@ -0,0 +1,86 @@ +accessKeyId = $access_key_id; + $this->accessKeySecret = $access_key_secret; + } + + /** + * @return string + */ + public function getAccessKeyId() + { + return $this->accessKeyId; + } + + /** + * @return string + */ + public function getAccessKeySecret() + { + return $this->accessKeySecret; + } + + /** + * @return string + */ + public function __toString() + { + return "$this->accessKeyId#$this->accessKeySecret"; + } + + /** + * @return ShaHmac1Signature + */ + public function getSignature() + { + return new ShaHmac1Signature(); + } + + public function getSecurityToken() + { + return ''; + } + /** + * @inheritDoc + */ + public function getCredential() + { + return new CredentialModel([ + 'accessKeyId' => $this->accessKeyId, + 'accessKeySecret' => $this->accessKeySecret, + 'type' => 'access_key', + ]); + } +} diff --git a/vendor/vendor/alibabacloud/credentials/src/BearerTokenCredential.php b/vendor/vendor/alibabacloud/credentials/src/BearerTokenCredential.php new file mode 100644 index 0000000..34fab6f --- /dev/null +++ b/vendor/vendor/alibabacloud/credentials/src/BearerTokenCredential.php @@ -0,0 +1,67 @@ +bearerToken = $bearer_token; + } + + /** + * @return string + */ + public function getBearerToken() + { + return $this->bearerToken; + } + + /** + * @return string + */ + public function __toString() + { + return "bearerToken#$this->bearerToken"; + } + + /** + * @return BearerTokenSignature + */ + public function getSignature() + { + return new BearerTokenSignature(); + } + + /** + * @inheritDoc + */ + public function getCredential() + { + return new CredentialModel([ + 'bearerToken' => $this->bearerToken, + 'type' => 'bearer', + ]); + } + +} diff --git a/vendor/vendor/alibabacloud/credentials/src/Credential.php b/vendor/vendor/alibabacloud/credentials/src/Credential.php new file mode 100644 index 0000000..fb89018 --- /dev/null +++ b/vendor/vendor/alibabacloud/credentials/src/Credential.php @@ -0,0 +1,268 @@ +config = null; + } else { + $this->config = new Config($this->parseConfig($config)); + } + } else { + $this->config = $config; + } + $this->credential = $this->getCredentials($this->config); + } + + /** + * @param array $config + * + * @return array + */ + private function parseConfig($config) + { + $res = []; + foreach (\array_change_key_case($config) as $key => $value) { + $res[Helper::snakeToCamelCase($key)] = $value; + } + return $res; + } + + + + /** + * Credentials getter. + * + * @param Config $config + * @return CredentialsInterface + * + */ + private function getCredentials($config) + { + if (is_null($config)) { + return new CredentialsProviderWrap('default', new DefaultCredentialsProvider()); + } + switch ($config->type) { + case 'access_key': + $provider = new StaticAKCredentialsProvider([ + 'accessKeyId' => $config->accessKeyId, + 'accessKeySecret' => $config->accessKeySecret, + ]); + return new CredentialsProviderWrap('access_key', $provider); + case 'sts': + $provider = new StaticSTSCredentialsProvider([ + 'accessKeyId' => $config->accessKeyId, + 'accessKeySecret' => $config->accessKeySecret, + 'securityToken' => $config->securityToken, + ]); + return new CredentialsProviderWrap('sts', $provider); + case 'bearer': + return new BearerTokenCredential($config->bearerToken); + case 'ram_role_arn': + if (!is_null($config->securityToken) && $config->securityToken !== '') { + $innerProvider = new StaticSTSCredentialsProvider([ + 'accessKeyId' => $config->accessKeyId, + 'accessKeySecret' => $config->accessKeySecret, + 'securityToken' => $config->securityToken, + ]); + } else { + $innerProvider = new StaticAKCredentialsProvider([ + 'accessKeyId' => $config->accessKeyId, + 'accessKeySecret' => $config->accessKeySecret, + ]); + } + $provider = new RamRoleArnCredentialsProvider([ + 'credentialsProvider' => $innerProvider, + 'roleArn' => $config->roleArn, + 'roleSessionName' => $config->roleSessionName, + 'policy' => $config->policy, + 'durationSeconds' => $config->roleSessionExpiration, + 'externalId' => $config->externalId, + 'stsEndpoint' => $config->STSEndpoint, + ], [ + 'connectTimeout' => $config->connectTimeout, + 'readTimeout' => $config->readTimeout, + ]); + return new CredentialsProviderWrap('ram_role_arn', $provider); + case 'rsa_key_pair': + $provider = new RsaKeyPairCredentialsProvider([ + 'publicKeyId' => $config->publicKeyId, + 'privateKeyFile' => $config->privateKeyFile, + 'durationSeconds' => $config->roleSessionExpiration, + 'stsEndpoint' => $config->STSEndpoint, + ], [ + 'connectTimeout' => $config->connectTimeout, + 'readTimeout' => $config->readTimeout, + ]); + return new CredentialsProviderWrap('rsa_key_pair', $provider); + case 'ecs_ram_role': + $provider = new EcsRamRoleCredentialsProvider([ + 'roleName' => $config->roleName, + 'disableIMDSv1' => $config->disableIMDSv1, + ], [ + 'connectTimeout' => $config->connectTimeout, + 'readTimeout' => $config->readTimeout, + ]); + return new CredentialsProviderWrap('ecs_ram_role', $provider); + case 'oidc_role_arn': + $provider = new OIDCRoleArnCredentialsProvider([ + 'roleArn' => $config->roleArn, + 'oidcProviderArn' => $config->oidcProviderArn, + 'oidcTokenFilePath' => $config->oidcTokenFilePath, + 'roleSessionName' => $config->roleSessionName, + 'policy' => $config->policy, + 'durationSeconds' => $config->roleSessionExpiration, + 'stsEndpoint' => $config->STSEndpoint, + ], [ + 'connectTimeout' => $config->connectTimeout, + 'readTimeout' => $config->readTimeout, + ]); + return new CredentialsProviderWrap('oidc_role_arn', $provider); + case "credentials_uri": + $provider = new URLCredentialsProvider([ + 'credentialsURI' => $config->credentialsURI, + ], [ + 'connectTimeout' => $config->connectTimeout, + 'readTimeout' => $config->readTimeout, + ]); + return new CredentialsProviderWrap('credentials_uri', $provider); + default: + throw new InvalidArgumentException('Unsupported credential type option: ' . $config->type . ', support: access_key, sts, bearer, ecs_ram_role, ram_role_arn, rsa_key_pair, oidc_role_arn, credentials_uri'); + } + } + + /** + * @return CredentialModel + * @throws RuntimeException + * @throws GuzzleException + */ + public function getCredential() + { + return $this->credential->getCredential(); + } + + /** + * @return array + */ + public function getConfig() + { + return $this->config->toMap(); + } + + /** + * @deprecated use getCredential() instead + * + * @return string + * @throws RuntimeException + * @throws GuzzleException + */ + public function getType() + { + return $this->credential->getCredential()->getType(); + } + + /** + * @deprecated use getCredential() instead + * + * @return string + * @throws RuntimeException + * @throws GuzzleException + */ + public function getAccessKeyId() + { + return $this->credential->getCredential()->getAccessKeyId(); + } + + /** + * @deprecated use getCredential() instead + * + * @return string + * @throws RuntimeException + * @throws GuzzleException + */ + public function getAccessKeySecret() + { + return $this->credential->getCredential()->getAccessKeySecret(); + } + + /** + * @deprecated use getCredential() instead + * + * @return string + * @throws RuntimeException + * @throws GuzzleException + */ + public function getSecurityToken() + { + return $this->credential->getCredential()->getSecurityToken(); + } + + /** + * @deprecated use getCredential() instead + * + * @return string + * @throws RuntimeException + * @throws GuzzleException + */ + public function getBearerToken() + { + return $this->credential->getCredential()->getBearerToken(); + } + + /** + * @param string $name + * @param array $arguments + * + * @return mixed + */ + public function __call($name, $arguments) + { + return $this->credential->$name($arguments); + } +} diff --git a/vendor/vendor/alibabacloud/credentials/src/Credential/Config.php b/vendor/vendor/alibabacloud/credentials/src/Credential/Config.php new file mode 100644 index 0000000..1fb57e3 --- /dev/null +++ b/vendor/vendor/alibabacloud/credentials/src/Credential/Config.php @@ -0,0 +1,270 @@ +accessKeyId) { + $res['accessKeyId'] = $this->accessKeyId; + } + if (null !== $this->accessKeySecret) { + $res['accessKeySecret'] = $this->accessKeySecret; + } + if (null !== $this->securityToken) { + $res['securityToken'] = $this->securityToken; + } + if (null !== $this->bearerToken) { + $res['bearerToken'] = $this->bearerToken; + } + if (null !== $this->durationSeconds) { + $res['durationSeconds'] = $this->durationSeconds; + } + if (null !== $this->roleArn) { + $res['roleArn'] = $this->roleArn; + } + if (null !== $this->policy) { + $res['policy'] = $this->policy; + } + if (null !== $this->roleSessionExpiration) { + $res['roleSessionExpiration'] = $this->roleSessionExpiration; + } + if (null !== $this->roleSessionName) { + $res['roleSessionName'] = $this->roleSessionName; + } + if (null !== $this->publicKeyId) { + $res['publicKeyId'] = $this->publicKeyId; + } + if (null !== $this->privateKeyFile) { + $res['privateKeyFile'] = $this->privateKeyFile; + } + if (null !== $this->roleName) { + $res['roleName'] = $this->roleName; + } + if (null !== $this->credentialsURI) { + $res['credentialsURI'] = $this->credentialsURI; + } + if (null !== $this->type) { + $res['type'] = $this->type; + } + if (null !== $this->STSEndpoint) { + $res['STSEndpoint'] = $this->STSEndpoint; + } + if (null !== $this->externalId) { + $res['externalId'] = $this->externalId; + } + return $res; + } + /** + * @param array $map + * @return Config + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['accessKeyId'])) { + $model->accessKeyId = $map['accessKeyId']; + } + if (isset($map['accessKeySecret'])) { + $model->accessKeySecret = $map['accessKeySecret']; + } + if (isset($map['securityToken'])) { + $model->securityToken = $map['securityToken']; + } + if (isset($map['bearerToken'])) { + $model->bearerToken = $map['bearerToken']; + } + if (isset($map['durationSeconds'])) { + $model->durationSeconds = $map['durationSeconds']; + } + if (isset($map['roleArn'])) { + $model->roleArn = $map['roleArn']; + } + if (isset($map['policy'])) { + $model->policy = $map['policy']; + } + if (isset($map['roleSessionExpiration'])) { + $model->roleSessionExpiration = $map['roleSessionExpiration']; + } + if (isset($map['roleSessionName'])) { + $model->roleSessionName = $map['roleSessionName']; + } + if (isset($map['publicKeyId'])) { + $model->publicKeyId = $map['publicKeyId']; + } + if (isset($map['privateKeyFile'])) { + $model->privateKeyFile = $map['privateKeyFile']; + } + if (isset($map['roleName'])) { + $model->roleName = $map['roleName']; + } + if (isset($map['credentialsURI'])) { + $model->credentialsURI = $map['credentialsURI']; + } + if (isset($map['type'])) { + $model->type = $map['type']; + } + if (isset($map['STSEndpoint'])) { + $model->STSEndpoint = $map['STSEndpoint']; + } + if (isset($map['externalId'])) { + $model->externalId = $map['externalId']; + } + return $model; + } + /** + * @description credential type + * @example access_key + * @var string + */ + public $type = 'default'; + + /** + * @description accesskey id + * @var string + */ + public $accessKeyId; + + /** + * @description accesskey secret + * @var string + */ + public $accessKeySecret; + + /** + * @description security token + * @var string + */ + public $securityToken; + + /** + * @description bearer token + * @var string + */ + public $bearerToken; + + /** + * @description role name + * @var string + */ + public $roleName; + + /** + * @description role arn + * @var string + */ + public $roleArn; + + /** + * @description oidc provider arn + * @var string + */ + public $oidcProviderArn; + + /** + * @description oidc token file path + * @var string + */ + public $oidcTokenFilePath; + + /** + * @description role session expiration + * @example 3600 + * @var int + */ + public $roleSessionExpiration; + + /** + * @description role session name + * @var string + */ + public $roleSessionName; + + /** + * @description role arn policy + * @var string + */ + public $policy; + + /** + * @description external id for ram role arn + * @var string + */ + public $externalId; + + /** + * @description sts endpoint + * @var string + */ + public $STSEndpoint; + + public $publicKeyId; + + public $privateKeyFile; + + /** + * @description read timeout + * @var int + */ + public $readTimeout; + + /** + * @description connection timeout + * @var int + */ + public $connectTimeout; + + /** + * @description disable IMDS v1 + * @var bool + */ + public $disableIMDSv1; + + /** + * @description credentials URI + * @var string + */ + public $credentialsURI; + + /** + * @deprecated + */ + public $metadataTokenDuration; + + /** + * @deprecated + */ + public $durationSeconds; + + /** + * @deprecated + */ + public $host; + + /** + * @deprecated + */ + public $expiration; + + /** + * @deprecated + */ + public $certFile = ""; + + /** + * @deprecated + */ + public $certPassword = ""; + + /** + * @internal + */ + public $proxy; +} diff --git a/vendor/vendor/alibabacloud/credentials/src/Credential/CredentialModel.php b/vendor/vendor/alibabacloud/credentials/src/Credential/CredentialModel.php new file mode 100644 index 0000000..8d516d9 --- /dev/null +++ b/vendor/vendor/alibabacloud/credentials/src/Credential/CredentialModel.php @@ -0,0 +1,143 @@ +accessKeyId) { + $res['accessKeyId'] = $this->accessKeyId; + } + if (null !== $this->accessKeySecret) { + $res['accessKeySecret'] = $this->accessKeySecret; + } + if (null !== $this->securityToken) { + $res['securityToken'] = $this->securityToken; + } + if (null !== $this->bearerToken) { + $res['bearerToken'] = $this->bearerToken; + } + if (null !== $this->type) { + $res['type'] = $this->type; + } + if (null !== $this->providerName) { + $res['providerName'] = $this->providerName; + } + return $res; + } + /** + * @param array $map + * @return CredentialModel + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['accessKeyId'])) { + $model->accessKeyId = $map['accessKeyId']; + } + if (isset($map['accessKeySecret'])) { + $model->accessKeySecret = $map['accessKeySecret']; + } + if (isset($map['securityToken'])) { + $model->securityToken = $map['securityToken']; + } + if (isset($map['bearerToken'])) { + $model->bearerToken = $map['bearerToken']; + } + if (isset($map['type'])) { + $model->type = $map['type']; + } + if(isset($map['providerName'])){ + $model->providerName = $map['providerName']; + } + return $model; + } + /** + * @description accesskey id + * @var string + */ + public $accessKeyId; + + /** + * @description accesskey secret + * @var string + */ + public $accessKeySecret; + + /** + * @description security token + * @var string + */ + public $securityToken; + + /** + * @description bearer token + * @var string + */ + public $bearerToken; + + /** + * @description type + * @example access_key + * @var string + */ + public $type; + + /** + * @description provider name + * @example cli_profile/static_ak + * @var string + */ + public $providerName; + + /** + * @return string + */ + public function getAccessKeyId() + { + return $this->accessKeyId; + } + + /** + * @return string + */ + public function getAccessKeySecret() + { + return $this->accessKeySecret; + } + + /** + * @return string + */ + public function getSecurityToken() + { + return $this->securityToken; + } + + /** + * @return string + */ + public function getBearerToken() + { + return $this->bearerToken; + } + + public function getType() + { + return $this->type; + } + + public function getProviderName() + { + return $this->providerName; + } + +} diff --git a/vendor/vendor/alibabacloud/credentials/src/Credential/RefreshResult.php b/vendor/vendor/alibabacloud/credentials/src/Credential/RefreshResult.php new file mode 100644 index 0000000..af1c202 --- /dev/null +++ b/vendor/vendor/alibabacloud/credentials/src/Credential/RefreshResult.php @@ -0,0 +1,97 @@ +credentials = $credentials; + $this->staleTime = $staleTime; + $this->prefetchTime = $prefetchTime; + } + public function validate() {} + public function toMap() + { + $res = []; + if (null !== $this->staleTime) { + $res['staleTime'] = $this->staleTime; + } + if (null !== $this->prefetchTime) { + $res['prefetchTime'] = $this->prefetchTime; + } + if (null !== $this->credentials) { + $res['credentials'] = $this->credentials; + } + return $res; + } + /** + * @param array $map + * @return RefreshResult + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['staleTime'])) { + $model->staleTime = $map['staleTime']; + } + if (isset($map['prefetchTime'])) { + $model->staleTime = $map['prefetchTime']; + } + if (isset($map['credentials'])) { + $model->staleTime = $map['credentials']; + } + return $model; + } + /** + * @description staleTime + * @var int + */ + public $staleTime; + + /** + * @description prefetchTime + * @var int + */ + public $prefetchTime; + + /** + * @description credentials + * @var Credentials + */ + public $credentials; + + + /** + * @return Credentials + */ + public function credentials() + { + return $this->credentials; + } + + /** + * @var int + */ + public function staleTime() + { + return $this->staleTime; + } + + /** + * @var int + */ + public function prefetchTime() + { + return $this->prefetchTime; + } +} diff --git a/vendor/vendor/alibabacloud/credentials/src/Credentials.php b/vendor/vendor/alibabacloud/credentials/src/Credentials.php new file mode 100644 index 0000000..f064b86 --- /dev/null +++ b/vendor/vendor/alibabacloud/credentials/src/Credentials.php @@ -0,0 +1,104 @@ +typeName = $typeName; + $this->credentialsProvider = $credentialsProvider; + } + + /** + * @inheritDoc + */ + public function getCredential() + { + $credentials = $this->credentialsProvider->getCredentials(); + return new CredentialModel([ + 'accessKeyId' => $credentials->getAccessKeyId(), + 'accessKeySecret' => $credentials->getAccessKeySecret(), + 'securityToken' => $credentials->getSecurityToken(), + 'type' => $this->typeName, + 'providerName' => $credentials->getProviderName(), + ]); + } + + /** + * @param string $name + * @param array $arguments + * + * @return mixed + */ + public function __call($name, $arguments) + { + return $this->credentialsProvider->$name($arguments); + } + + public function __toString() + { + return "credentialsProviderWrap#$this->typeName"; + } + + /** + * @return ShaHmac1Signature + */ + public function getSignature() + { + return null; + } +} \ No newline at end of file diff --git a/vendor/vendor/alibabacloud/credentials/src/EcsRamRoleCredential.php b/vendor/vendor/alibabacloud/credentials/src/EcsRamRoleCredential.php new file mode 100644 index 0000000..ba66c0d --- /dev/null +++ b/vendor/vendor/alibabacloud/credentials/src/EcsRamRoleCredential.php @@ -0,0 +1,199 @@ +roleName = $role_name; + + Filter::disableIMDSv1($disable_imdsv1); + + $this->disableIMDSv1 = $disable_imdsv1; + + $this->metadataTokenDuration = $metadata_token_duration; + } + + /** + * @return string + * @throws GuzzleException + * @throws Exception + */ + public function getRoleName() + { + if ($this->roleName !== null) { + return $this->roleName; + } + + $this->roleName = $this->getRoleNameFromMeta(); + + return $this->roleName; + } + + /** + * @return string + * @throws Exception + */ + public function getRoleNameFromMeta() + { + $options = [ + 'http_errors' => false, + 'timeout' => 1, + 'connect_timeout' => 1, + ]; + + $result = Request::createClient()->request( + 'GET', + 'http://100.100.100.200/latest/meta-data/ram/security-credentials/', + $options + ); + + if ($result->getStatusCode() === 404) { + throw new InvalidArgumentException('The role name was not found in the instance'); + } + + if ($result->getStatusCode() !== 200) { + throw new RuntimeException('Error retrieving credentials from result: ' . $result->getBody()); + } + + $role_name = (string) $result; + if (!$role_name) { + throw new RuntimeException('Error retrieving credentials from result is empty'); + } + + return $role_name; + } + + /** + * @return string + */ + public function __toString() + { + return "roleName#$this->roleName"; + } + + /** + * @return ShaHmac1Signature + */ + public function getSignature() + { + return new ShaHmac1Signature(); + } + + /** + * @return string + * @throws Exception + * @throws GuzzleException + */ + public function getAccessKeyId() + { + return $this->getSessionCredential()->getAccessKeyId(); + } + + /** + * @return AlibabaCloud\Credentials\Providers\Credentials + * @throws Exception + * @throws GuzzleException + */ + protected function getSessionCredential() + { + $params = [ + "roleName" => $this->roleName, + 'disableIMDSv1' => $this->disableIMDSv1, + 'metadataTokenDuration' => $this->metadataTokenDuration, + ]; + return (new EcsRamRoleCredentialsProvider($params))->getCredentials(); + } + + /** + * @return string + * @throws Exception + * @throws GuzzleException + */ + public function getAccessKeySecret() + { + return $this->getSessionCredential()->getAccessKeySecret(); + } + + /** + * @return string + * @throws Exception + * @throws GuzzleException + */ + public function getSecurityToken() + { + return $this->getSessionCredential()->getSecurityToken(); + } + + /** + * @return int + * @throws Exception + * @throws GuzzleException + */ + public function getExpiration() + { + return $this->getSessionCredential()->getExpiration(); + } + + /** + * @return bool + */ + public function isDisableIMDSv1() + { + return $this->disableIMDSv1; + } + + /** + * @inheritDoc + */ + public function getCredential() + { + $credentials = $this->getSessionCredential(); + return new CredentialModel([ + 'accessKeyId' => $credentials->getAccessKeyId(), + 'accessKeySecret' => $credentials->getAccessKeySecret(), + 'securityToken' => $credentials->getSecurityToken(), + 'type' => 'ecs_ram_role', + ]); + } + +} diff --git a/vendor/vendor/alibabacloud/credentials/src/Providers/CLIProfileCredentialsProvider.php b/vendor/vendor/alibabacloud/credentials/src/Providers/CLIProfileCredentialsProvider.php new file mode 100644 index 0000000..1d73396 --- /dev/null +++ b/vendor/vendor/alibabacloud/credentials/src/Providers/CLIProfileCredentialsProvider.php @@ -0,0 +1,193 @@ +filterProfileName($params); + } + + private function filterProfileName(array $params) + { + if (Helper::envNotEmpty('ALIBABA_CLOUD_PROFILE')) { + $this->profileName = Helper::env('ALIBABA_CLOUD_PROFILE'); + } + + if (isset($params['profileName'])) { + $this->profileName = $params['profileName']; + } + } + + /** + * @return bool + */ + private function shouldReloadCredentialsProvider() + { + if (is_null($this->credentialsProvider)) { + return true; + } + + return false; + } + + /** + * @return CredentialsProvider + */ + protected function reloadCredentialsProvider($profileFile, $profileName) + { + if (!Helper::inOpenBasedir($profileFile)) { + throw new RuntimeException('Unable to open credentials file: ' . $profileFile); + } + + if (!\is_readable($profileFile) || !\is_file($profileFile)) { + throw new RuntimeException('Credentials file is not readable: ' . $profileFile); + } + + $jsonContent = \file_get_contents($profileFile); + $fileArray = json_decode($jsonContent, true); + + if (\is_array($fileArray) && !empty($fileArray)) { + if (is_null($profileName) || $profileName === '') { + $profileName = $fileArray['current']; + } + if (isset($fileArray['profiles'])) { + foreach ($fileArray['profiles'] as $profile) { + if (Helper::unsetReturnNull($profile, 'name') === $profileName) { + switch (Helper::unsetReturnNull($profile, 'mode')) { + case 'AK': + return new StaticAKCredentialsProvider([ + 'accessKeyId' => Helper::unsetReturnNull($profile, 'access_key_id'), + 'accessKeySecret' => Helper::unsetReturnNull($profile, 'access_key_secret'), + ]); + case 'StsToken': + return new StaticSTSCredentialsProvider([ + 'accessKeyId' => Helper::unsetReturnNull($profile, 'access_key_id'), + 'accessKeySecret' => Helper::unsetReturnNull($profile, 'access_key_secret'), + 'securityToken' => Helper::unsetReturnNull($profile, 'sts_token'), + ]); + case 'RamRoleArn': + $innerProvider = new StaticAKCredentialsProvider([ + 'accessKeyId' => Helper::unsetReturnNull($profile, 'access_key_id'), + 'accessKeySecret' => Helper::unsetReturnNull($profile, 'access_key_secret'), + ]); + return new RamRoleArnCredentialsProvider([ + 'credentialsProvider' => $innerProvider, + 'roleArn' => Helper::unsetReturnNull($profile, 'ram_role_arn'), + 'roleSessionName' => Helper::unsetReturnNull($profile, 'ram_session_name'), + 'durationSeconds' => Helper::unsetReturnNull($profile, 'expired_seconds'), + 'policy' => Helper::unsetReturnNull($profile, 'policy'), + 'externalId' => Helper::unsetReturnNull($profile, 'external_id'), + 'stsRegionId' => Helper::unsetReturnNull($profile, 'sts_region'), + 'enableVpc' => Helper::unsetReturnNull($profile, 'enable_vpc'), + ]); + case 'EcsRamRole': + return new EcsRamRoleCredentialsProvider([ + 'roleName' => Helper::unsetReturnNull($profile, 'ram_role_name'), + ]); + case 'OIDC': + return new OIDCRoleArnCredentialsProvider([ + 'roleArn' => Helper::unsetReturnNull($profile, 'ram_role_arn'), + 'oidcProviderArn' => Helper::unsetReturnNull($profile, 'oidc_provider_arn'), + 'oidcTokenFilePath' => Helper::unsetReturnNull($profile, 'oidc_token_file'), + 'roleSessionName' => Helper::unsetReturnNull($profile, 'ram_session_name'), + 'durationSeconds' => Helper::unsetReturnNull($profile, 'expired_seconds'), + 'policy' => Helper::unsetReturnNull($profile, 'policy'), + 'stsRegionId' => Helper::unsetReturnNull($profile, 'sts_region'), + 'enableVpc' => Helper::unsetReturnNull($profile, 'enable_vpc'), + ]); + case 'ChainableRamRoleArn': + $previousProvider = $this->reloadCredentialsProvider($profileFile, Helper::unsetReturnNull($profile, 'source_profile')); + return new RamRoleArnCredentialsProvider([ + 'credentialsProvider' => $previousProvider, + 'roleArn' => Helper::unsetReturnNull($profile, 'ram_role_arn'), + 'roleSessionName' => Helper::unsetReturnNull($profile, 'ram_session_name'), + 'durationSeconds' => Helper::unsetReturnNull($profile, 'expired_seconds'), + 'policy' => Helper::unsetReturnNull($profile, 'policy'), + 'externalId' => Helper::unsetReturnNull($profile, 'external_id'), + 'stsRegionId' => Helper::unsetReturnNull($profile, 'sts_region'), + 'enableVpc' => Helper::unsetReturnNull($profile, 'enable_vpc'), + ]); + default: + throw new RuntimeException('Unsupported credential mode from CLI credentials file: ' . Helper::unsetReturnNull($profile, 'mode')); + } + } + } + } + } + throw new RuntimeException('Failed to get credential from CLI credentials file: ' . $profileFile); + } + /** + * Get credential. + * + * @return Credentials + * @throws RuntimeException + */ + public function getCredentials() + { + if (Helper::envNotEmpty('ALIBABA_CLOUD_CLI_PROFILE_DISABLED') && Helper::env('ALIBABA_CLOUD_CLI_PROFILE_DISABLED') === true) { + throw new RuntimeException('CLI credentials file is disabled'); + } + $cliProfileFile = self::getDefaultFile(); + if ($this->shouldReloadCredentialsProvider()) { + $this->credentialsProvider = $this->reloadCredentialsProvider($cliProfileFile, $this->profileName); + } + + $credentials = $this->credentialsProvider->getCredentials(); + return new Credentials([ + 'accessKeyId' => $credentials->getAccessKeyId(), + 'accessKeySecret' => $credentials->getAccessKeySecret(), + 'securityToken' => $credentials->getSecurityToken(), + 'providerName' => $this->getProviderName() . '/' . $this->credentialsProvider->getProviderName(), + ]); + } + + /** + * Get the default credential file. + * + * @return string + */ + private function getDefaultFile() + { + return Helper::getHomeDirectory() . + DIRECTORY_SEPARATOR . + '.aliyun' . + DIRECTORY_SEPARATOR . + 'config.json'; + } + + /** + * @return string + */ + public function getProviderName() + { + return 'cli_profile'; + } +} diff --git a/vendor/vendor/alibabacloud/credentials/src/Providers/ChainProvider.php b/vendor/vendor/alibabacloud/credentials/src/Providers/ChainProvider.php new file mode 100644 index 0000000..d6c1540 --- /dev/null +++ b/vendor/vendor/alibabacloud/credentials/src/Providers/ChainProvider.php @@ -0,0 +1,188 @@ + 'access_key', + 'access_key_id' => $accessKeyId, + 'access_key_secret' => $accessKeySecret, + ] + ); + } + }; + } + + /** + * @return string + */ + public static function getDefaultName() + { + $name = Helper::envNotEmpty('ALIBABA_CLOUD_PROFILE'); + + if ($name) { + return $name; + } + + return 'default'; + } + + /** + * @return Closure + */ + public static function ini() + { + return static function () { + $filename = Helper::envNotEmpty('ALIBABA_CLOUD_CREDENTIALS_FILE'); + if (!$filename) { + $filename = self::getDefaultFile(); + } + + if (!Helper::inOpenBasedir($filename)) { + return; + } + + if ($filename !== self::getDefaultFile() && (!\is_readable($filename) || !\is_file($filename))) { + throw new RuntimeException( + 'Credentials file is not readable: ' . $filename + ); + } + + $file_array = \parse_ini_file($filename, true); + + if (\is_array($file_array) && !empty($file_array)) { + foreach (\array_change_key_case($file_array) as $name => $configures) { + Credentials::set($name, $configures); + } + } + }; + } + + /** + * Get the default credential file. + * + * @return string + */ + public static function getDefaultFile() + { + return Helper::getHomeDirectory() . + DIRECTORY_SEPARATOR . + '.alibabacloud' . + DIRECTORY_SEPARATOR . + 'credentials'; + } + + /** + * @return Closure + */ + public static function instance() + { + return static function () { + $instance = Helper::envNotEmpty('ALIBABA_CLOUD_ECS_METADATA'); + if ($instance) { + Credentials::set( + self::getDefaultName(), + [ + 'type' => 'ecs_ram_role', + 'role_name' => $instance, + ] + ); + } + }; + } +} \ No newline at end of file diff --git a/vendor/vendor/alibabacloud/credentials/src/Providers/Credentials.php b/vendor/vendor/alibabacloud/credentials/src/Providers/Credentials.php new file mode 100644 index 0000000..bfd4fe3 --- /dev/null +++ b/vendor/vendor/alibabacloud/credentials/src/Providers/Credentials.php @@ -0,0 +1,87 @@ + $v) { + $this->{$k} = $v; + } + } + } + + /** + * @return string + */ + public function getAccessKeyId() + { + return $this->accessKeyId; + } + + /** + * @return string + */ + public function getAccessKeySecret() + { + return $this->accessKeySecret; + } + + /** + * @return string + */ + public function getSecurityToken() + { + return $this->securityToken; + } + + /** + * @return int + */ + public function getExpiration() + { + return $this->expiration; + } + + /** + * @return string + */ + public function getProviderName() + { + return $this->providerName; + } +} diff --git a/vendor/vendor/alibabacloud/credentials/src/Providers/CredentialsProvider.php b/vendor/vendor/alibabacloud/credentials/src/Providers/CredentialsProvider.php new file mode 100644 index 0000000..ddbd1a1 --- /dev/null +++ b/vendor/vendor/alibabacloud/credentials/src/Providers/CredentialsProvider.php @@ -0,0 +1,24 @@ +filterReuseLastProviderEnabled($params); + $this->createDefaultChain(); + Filter::reuseLastProviderEnabled($this->reuseLastProviderEnabled); + } + + private function filterReuseLastProviderEnabled(array $params) + { + $this->reuseLastProviderEnabled = true; + if (isset($params['reuseLastProviderEnabled'])) { + $this->reuseLastProviderEnabled = $params['reuseLastProviderEnabled']; + } + } + + private function createDefaultChain() + { + self::$defaultProviders = [ + new EnvironmentVariableCredentialsProvider(), + ]; + if ( + Helper::envNotEmpty('ALIBABA_CLOUD_ROLE_ARN') + && Helper::envNotEmpty('ALIBABA_CLOUD_OIDC_PROVIDER_ARN') + && Helper::envNotEmpty('ALIBABA_CLOUD_OIDC_TOKEN_FILE') + ) { + array_push( + self::$defaultProviders, + new OIDCRoleArnCredentialsProvider() + ); + } + array_push( + self::$defaultProviders, + new CLIProfileCredentialsProvider() + ); + array_push( + self::$defaultProviders, + new ProfileCredentialsProvider() + ); + array_push( + self::$defaultProviders, + new EcsRamRoleCredentialsProvider() + ); + if (Helper::envNotEmpty('ALIBABA_CLOUD_CREDENTIALS_URI')) { + array_push( + self::$defaultProviders, + new URLCredentialsProvider() + ); + } + } + + /** + * @param CredentialsProvider ...$providers + */ + public static function set(...$providers) + { + if (empty($providers)) { + throw new InvalidArgumentException('No providers in chain'); + } + + foreach ($providers as $provider) { + if (!$provider instanceof CredentialsProvider) { + throw new InvalidArgumentException('Providers must all be CredentialsProvider'); + } + } + + self::$customChain = $providers; + } + + /** + * @return bool + */ + public static function hasCustomChain() + { + return (bool) self::$customChain; + } + + public static function flush() + { + self::$customChain = []; + } + + /** + * Get credential. + * + * @return Credentials + * @throws RuntimeException + */ + public function getCredentials() + { + if ($this->reuseLastProviderEnabled && !is_null($this->lastUsedCredentialsProvider)) { + $credentials = $this->lastUsedCredentialsProvider->getCredentials(); + return new Credentials([ + 'accessKeyId' => $credentials->getAccessKeyId(), + 'accessKeySecret' => $credentials->getAccessKeySecret(), + 'securityToken' => $credentials->getSecurityToken(), + 'providerName' => $this->getProviderName() . '/' . $this->lastUsedCredentialsProvider->getProviderName(), + ]); + } + + $providerChain = array_merge( + self::$customChain, + self::$defaultProviders + ); + + $exceptionMessages = []; + + foreach ($providerChain as $provider) { + try { + $credentials = $provider->getCredentials(); + $this->lastUsedCredentialsProvider = $provider; + return new Credentials([ + 'accessKeyId' => $credentials->getAccessKeyId(), + 'accessKeySecret' => $credentials->getAccessKeySecret(), + 'securityToken' => $credentials->getSecurityToken(), + 'providerName' => $this->getProviderName() . '/' . $provider->getProviderName(), + ]); + } catch (Exception $exception) { + array_push($exceptionMessages, basename(str_replace('\\', '/', get_class($provider))) . ': ' . $exception->getMessage()); + } + } + throw new RuntimeException('Unable to load credentials from any of the providers in the chain: ' . implode(', ', $exceptionMessages)); + + } + + /** + * @inheritDoc + */ + public function getProviderName() + { + return "default"; + } +} \ No newline at end of file diff --git a/vendor/vendor/alibabacloud/credentials/src/Providers/EcsRamRoleCredentialsProvider.php b/vendor/vendor/alibabacloud/credentials/src/Providers/EcsRamRoleCredentialsProvider.php new file mode 100644 index 0000000..8dffb50 --- /dev/null +++ b/vendor/vendor/alibabacloud/credentials/src/Providers/EcsRamRoleCredentialsProvider.php @@ -0,0 +1,276 @@ +filterOptions($options); + $this->filterRoleName($params); + $this->filterDisableECSIMDSv1($params); + Filter::roleName($this->roleName); + Filter::disableIMDSv1($this->disableIMDSv1); + } + + private function filterOptions(array $options) + { + if (isset($options['connectTimeout'])) { + $this->connectTimeout = $options['connectTimeout']; + } + + if (isset($options['readTimeout'])) { + $this->readTimeout = $options['readTimeout']; + } + + Filter::timeout($this->connectTimeout, $this->readTimeout); + } + + private function filterRoleName(array $params) + { + if (Helper::envNotEmpty('ALIBABA_CLOUD_ECS_METADATA')) { + $this->roleName = Helper::env('ALIBABA_CLOUD_ECS_METADATA'); + } + + if (isset($params['roleName'])) { + $this->roleName = $params['roleName']; + } + } + + private function filterDisableECSIMDSv1($params) + { + if (Helper::envNotEmpty('ALIBABA_CLOUD_IMDSV1_DISABLED')) { + $this->disableIMDSv1 = Helper::env('ALIBABA_CLOUD_IMDSV1_DISABLED') === true ? true : false; + } + + if (isset($params['disableIMDSv1'])) { + $this->disableIMDSv1 = $params['disableIMDSv1']; + } + } + + /** + * Get credentials by request. + * + * @return RefreshResult + * @throws InvalidArgumentException + * @throws RuntimeException + * @throws GuzzleException + */ + public function refreshCredentials() + { + if (Helper::envNotEmpty('ALIBABA_CLOUD_ECS_METADATA_DISABLED') && Helper::env('ALIBABA_CLOUD_ECS_METADATA_DISABLED') === true) { + throw new RuntimeException('IMDS credentials is disabled'); + } + + if (is_null($this->roleName) || $this->roleName === '') { + $this->roleName = $this->getRoleNameFromMeta(); + } + + $url = $this->metadataHost . $this->ecsUri . $this->roleName; + $options = Request::commonOptions(); + $options['read_timeout'] = $this->readTimeout; + $options['connect_timeout'] = $this->connectTimeout; + + $metadataToken = $this->getMetadataToken(); + if (!is_null($metadataToken)) { + $options['headers']['X-aliyun-ecs-metadata-token'] = $metadataToken; + } + + $result = Request::createClient()->request('GET', $url, $options); + + if ($result->getStatusCode() === 404) { + throw new InvalidArgumentException('The role was not found in the instance' . (string) $result); + } + + if ($result->getStatusCode() !== 200) { + throw new RuntimeException('Error refreshing credentials from IMDS, statusCode: ' . $result->getStatusCode() . ', result: ' . (string) $result); + } + + $credentials = $result->toArray(); + + if (!isset($credentials['AccessKeyId']) || !isset($credentials['AccessKeySecret']) || !isset($credentials['SecurityToken'])) { + throw new RuntimeException('Error retrieving credentials from IMDS result:' . $result->toJson()); + } + + if (!isset($credentials['Code']) || $credentials['Code'] !== 'Success') { + throw new RuntimeException('Error retrieving credentials from IMDS result, Code is not Success:' . $result->toJson()); + } + + return new RefreshResult(new Credentials([ + 'accessKeyId' => $credentials['AccessKeyId'], + 'accessKeySecret' => $credentials['AccessKeySecret'], + 'securityToken' => $credentials['SecurityToken'], + 'expiration' => \strtotime($credentials['Expiration']), + 'providerName' => $this->getProviderName(), + ]), $this->getStaleTime(strtotime($credentials["Expiration"])), $this->getPrefetchTime(strtotime($credentials["Expiration"]))); + } + + /** + * @return string + * @throws InvalidArgumentException + * @throws RuntimeException + * @throws GuzzleException + */ + private function getRoleNameFromMeta() + { + $options = Request::commonOptions(); + $options['read_timeout'] = $this->readTimeout; + $options['connect_timeout'] = $this->connectTimeout; + + $metadataToken = $this->getMetadataToken(); + if (!is_null($metadataToken)) { + $options['headers']['X-aliyun-ecs-metadata-token'] = $metadataToken; + } + + $result = Request::createClient()->request( + 'GET', + 'http://100.100.100.200/latest/meta-data/ram/security-credentials/', + $options + ); + + if ($result->getStatusCode() === 404) { + throw new InvalidArgumentException('The role name was not found in the instance' . (string) $result); + } + + if ($result->getStatusCode() !== 200) { + throw new RuntimeException('Error retrieving role name from result: ' . (string) $result); + } + + $role_name = (string) $result; + if (!$role_name) { + throw new RuntimeException('Error retrieving role name from result is empty'); + } + + return $role_name; + } + + /** + * Get metadata token by request. + * + * @return string + * @throws RuntimeException + * @throws GuzzleException + */ + private function getMetadataToken() + { + $url = $this->metadataHost . $this->metadataTokenUri; + $options = Request::commonOptions(); + $options['read_timeout'] = $this->readTimeout; + $options['connect_timeout'] = $this->connectTimeout; + $options['headers']['X-aliyun-ecs-metadata-token-ttl-seconds'] = $this->metadataTokenDuration; + + $result = Request::createClient()->request('PUT', $url, $options); + + if ($result->getStatusCode() != 200) { + if ($this->disableIMDSv1) { + throw new RuntimeException('Failed to get token from ECS Metadata Service. HttpCode= ' . $result->getStatusCode()); + } + return null; + } + return (string) $result; + } + + /** + * @var int + */ + public function getPrefetchTime($expiration) + { + return $expiration <= 0 ? + time() + (5 * 60) : + time() + (60 * 60); + } + + /** + * @return string + */ + public function key() + { + return 'ecs_ram_role#roleName#' . $this->roleName; + } + + /** + * @return string + */ + public function getProviderName() + { + return 'ecs_ram_role'; + } + + /** + * @return string + */ + public function getRoleName() + { + return $this->roleName; + } + + /** + * @return bool + */ + public function isDisableIMDSv1() + { + return $this->disableIMDSv1; + } +} diff --git a/vendor/vendor/alibabacloud/credentials/src/Providers/EnvironmentVariableCredentialsProvider.php b/vendor/vendor/alibabacloud/credentials/src/Providers/EnvironmentVariableCredentialsProvider.php new file mode 100644 index 0000000..b6dd579 --- /dev/null +++ b/vendor/vendor/alibabacloud/credentials/src/Providers/EnvironmentVariableCredentialsProvider.php @@ -0,0 +1,65 @@ + $accessKeyId, + 'accessKeySecret' => $accessKeySecret, + 'securityToken' => $securityToken, + 'providerName' => $this->getProviderName(), + ]); + } + + return new Credentials([ + 'accessKeyId' => $accessKeyId, + 'accessKeySecret' => $accessKeySecret, + 'providerName' => $this->getProviderName(), + ]); + } + + /** + * @inheritDoc + */ + public function getProviderName() + { + return "env"; + } +} diff --git a/vendor/vendor/alibabacloud/credentials/src/Providers/OIDCRoleArnCredentialsProvider.php b/vendor/vendor/alibabacloud/credentials/src/Providers/OIDCRoleArnCredentialsProvider.php new file mode 100644 index 0000000..18fe6ec --- /dev/null +++ b/vendor/vendor/alibabacloud/credentials/src/Providers/OIDCRoleArnCredentialsProvider.php @@ -0,0 +1,268 @@ +filterOptions($options); + $this->filterRoleArn($params); + $this->filterOIDCProviderArn($params); + $this->filterOIDCTokenFilePath($params); + $this->filterRoleSessionName($params); + $this->filterDurationSeconds($params); + $this->filterPolicy($params); + $this->filterSTSEndpoint($params); + } + + private function filterRoleArn(array $params) + { + if (Helper::envNotEmpty('ALIBABA_CLOUD_ROLE_ARN')) { + $this->roleArn = Helper::env('ALIBABA_CLOUD_ROLE_ARN'); + } + + if (isset($params['roleArn'])) { + $this->roleArn = $params['roleArn']; + } + + Filter::roleArn($this->roleArn); + } + + private function filterOIDCProviderArn(array $params) + { + if (Helper::envNotEmpty('ALIBABA_CLOUD_OIDC_PROVIDER_ARN')) { + $this->oidcProviderArn = Helper::env('ALIBABA_CLOUD_OIDC_PROVIDER_ARN'); + } + + if (isset($params['oidcProviderArn'])) { + $this->oidcProviderArn = $params['oidcProviderArn']; + } + + Filter::oidcProviderArn($this->oidcProviderArn); + } + + private function filterOIDCTokenFilePath(array $params) + { + if (Helper::envNotEmpty('ALIBABA_CLOUD_OIDC_TOKEN_FILE')) { + $this->oidcTokenFilePath = Helper::env('ALIBABA_CLOUD_OIDC_TOKEN_FILE'); + } + + if (isset($params['oidcTokenFilePath'])) { + $this->oidcTokenFilePath = $params['oidcTokenFilePath']; + } + + Filter::oidcTokenFilePath($this->oidcTokenFilePath); + } + + private function filterRoleSessionName(array $params) + { + if (Helper::envNotEmpty('ALIBABA_CLOUD_ROLE_SESSION_NAME')) { + $this->roleSessionName = Helper::env('ALIBABA_CLOUD_ROLE_SESSION_NAME'); + } + + if (isset($params['roleSessionName'])) { + $this->roleSessionName = $params['roleSessionName']; + } + + if (is_null($this->roleSessionName) || $this->roleSessionName === '') { + $this->roleSessionName = 'phpSdkRoleSessionName'; + } + } + + private function filterDurationSeconds(array $params) + { + if (isset($params['durationSeconds'])) { + if (is_int($params['durationSeconds'])) { + $this->durationSeconds = $params['durationSeconds']; + } + } + if ($this->durationSeconds < 900) { + throw new InvalidArgumentException('Role session expiration should be in the range of 900s - max session duration'); + } + } + + private function filterPolicy(array $params) + { + if (isset($params['policy'])) { + if (is_string($params['policy'])) { + $this->policy = $params['policy']; + } + + if (is_array($params['policy'])) { + $this->policy = json_encode($params['policy']); + } + } + } + + private function filterSTSEndpoint(array $params) + { + $prefix = 'sts'; + if (Helper::envNotEmpty('ALIBABA_CLOUD_VPC_ENDPOINT_ENABLED') || (isset($params['enableVpc']) && $params['enableVpc'] === true)) { + $prefix = 'sts-vpc'; + } + if (Helper::envNotEmpty('ALIBABA_CLOUD_STS_REGION')) { + $this->stsEndpoint = $prefix . '.' . Helper::env('ALIBABA_CLOUD_STS_REGION') . '.aliyuncs.com'; + } + + if (isset($params['stsRegionId'])) { + $this->stsEndpoint = $prefix . '.' . $params['stsRegionId'] . '.aliyuncs.com'; + } + + if (isset($params['stsEndpoint'])) { + $this->stsEndpoint = $params['stsEndpoint']; + } + + if (is_null($this->stsEndpoint) || $this->stsEndpoint === '') { + $this->stsEndpoint = 'sts.aliyuncs.com'; + } + } + + private function filterOptions(array $options) + { + if (isset($options['connectTimeout'])) { + $this->connectTimeout = $options['connectTimeout']; + } + + if (isset($options['readTimeout'])) { + $this->readTimeout = $options['readTimeout']; + } + + Filter::timeout($this->connectTimeout, $this->readTimeout); + } + + /** + * Get credentials by request. + * + * @return RefreshResult + * @throws RuntimeException + * @throws GuzzleException + */ + public function refreshCredentials() + { + $options = Request::commonOptions(); + $options['read_timeout'] = $this->readTimeout; + $options['connect_timeout'] = $this->connectTimeout; + + $options['query']['Action'] = 'AssumeRoleWithOIDC'; + $options['query']['Version'] = '2015-04-01'; + $options['query']['Format'] = 'JSON'; + $options['query']['Timestamp'] = gmdate('Y-m-d\TH:i:s\Z'); + $options['query']['RoleArn'] = $this->roleArn; + $options['query']['OIDCProviderArn'] = $this->oidcProviderArn; + try { + $oidcToken = file_get_contents($this->oidcTokenFilePath); + $options['query']['OIDCToken'] = $oidcToken; + } catch (Exception $exception) { + throw new InvalidArgumentException($exception->getMessage()); + } + $options['query']['RoleSessionName'] = $this->roleSessionName; + $options['query']['DurationSeconds'] = (string) $this->durationSeconds; + if (!is_null($this->policy)) { + $options['query']['Policy'] = $this->policy; + } + + $url = (new Uri())->withScheme('https')->withHost($this->stsEndpoint); + + $result = Request::createClient()->request('POST', $url, $options); + + if ($result->getStatusCode() !== 200) { + throw new RuntimeException('Error refreshing credentials from OIDC, statusCode: ' . $result->getStatusCode() . ', result: ' . (string) $result); + } + + $json = $result->toArray(); + $credentials = $json['Credentials']; + + if (!isset($credentials['AccessKeyId']) || !isset($credentials['AccessKeySecret']) || !isset($credentials['SecurityToken'])) { + throw new RuntimeException('Error retrieving credentials from OIDC result:' . $result->toJson()); + } + + return new RefreshResult(new Credentials([ + 'accessKeyId' => $credentials['AccessKeyId'], + 'accessKeySecret' => $credentials['AccessKeySecret'], + 'securityToken' => $credentials['SecurityToken'], + 'expiration' => \strtotime($credentials['Expiration']), + 'providerName' => $this->getProviderName(), + ]), $this->getStaleTime(strtotime($credentials['Expiration']))); + } + + public function key() + { + return 'oidc_role_arn#roleArn#' . $this->roleArn . '#oidcProviderArn#' . $this->oidcProviderArn . '#roleSessionName#' . $this->roleSessionName; + } + + public function getProviderName() + { + return 'oidc_role_arn'; + } +} diff --git a/vendor/vendor/alibabacloud/credentials/src/Providers/ProfileCredentialsProvider.php b/vendor/vendor/alibabacloud/credentials/src/Providers/ProfileCredentialsProvider.php new file mode 100644 index 0000000..ab07efe --- /dev/null +++ b/vendor/vendor/alibabacloud/credentials/src/Providers/ProfileCredentialsProvider.php @@ -0,0 +1,188 @@ +filterProfileName($params); + $this->filterProfileFile(); + } + + private function filterProfileName(array $params) + { + if (Helper::envNotEmpty('ALIBABA_CLOUD_PROFILE')) { + $this->profileName = Helper::env('ALIBABA_CLOUD_PROFILE'); + } + + if (isset($params['profileName'])) { + $this->profileName = $params['profileName']; + } + + if (is_null($this->profileName) || $this->profileName === '') { + $this->profileName = 'default'; + } + } + + private function filterProfileFile() + { + $this->profileFile = Helper::envNotEmpty('ALIBABA_CLOUD_CREDENTIALS_FILE'); + + if (!$this->profileFile) { + $this->profileFile = self::getDefaultFile(); + } + } + + /** + * @return bool + */ + private function shouldReloadCredentialsProvider() + { + if (is_null($this->credentialsProvider)) { + return true; + } + + return false; + } + + /** + * @return CredentialsProvider + */ + private function reloadCredentialsProvider($profileFile, $profileName) + { + if (!Helper::inOpenBasedir($profileFile)) { + throw new RuntimeException('Unable to open credentials file: ' . $profileFile); + } + + if (!\is_readable($profileFile) || !\is_file($profileFile)) { + throw new RuntimeException('Credentials file is not readable: ' . $profileFile); + } + + $fileArray = \parse_ini_file($profileFile, true); + + if (\is_array($fileArray) && !empty($fileArray)) { + $credentialsConfigures = []; + foreach (\array_change_key_case($fileArray) as $name => $configures) { + if ($name === $profileName) { + $credentialsConfigures = $configures; + break; + } + } + if (\is_array($credentialsConfigures) && !empty($credentialsConfigures)) { + switch (Helper::unsetReturnNull($credentialsConfigures, 'type')) { + case 'access_key': + return new StaticAKCredentialsProvider([ + 'accessKeyId' => Helper::unsetReturnNull($credentialsConfigures, 'access_key_id'), + 'accessKeySecret' => Helper::unsetReturnNull($credentialsConfigures, 'access_key_secret'), + ]); + case 'ram_role_arn': + $innerProvider = new StaticAKCredentialsProvider([ + 'accessKeyId' => Helper::unsetReturnNull($credentialsConfigures, 'access_key_id'), + 'accessKeySecret' => Helper::unsetReturnNull($credentialsConfigures, 'access_key_secret'), + ]); + return new RamRoleArnCredentialsProvider([ + 'credentialsProvider' => $innerProvider, + 'roleArn' => Helper::unsetReturnNull($credentialsConfigures, 'role_arn'), + 'roleSessionName' => Helper::unsetReturnNull($credentialsConfigures, 'role_session_name'), + 'policy' => Helper::unsetReturnNull($credentialsConfigures, 'policy'), + ]); + case 'ecs_ram_role': + return new EcsRamRoleCredentialsProvider([ + 'roleName' => Helper::unsetReturnNull($credentialsConfigures, 'role_name'), + ]); + case 'oidc_role_arn': + return new OIDCRoleArnCredentialsProvider([ + 'roleArn' => Helper::unsetReturnNull($credentialsConfigures, 'role_arn'), + 'oidcProviderArn' => Helper::unsetReturnNull($credentialsConfigures, 'oidc_provider_arn'), + 'oidcTokenFilePath' => Helper::unsetReturnNull($credentialsConfigures, 'oidc_token_file_path'), + 'roleSessionName' => Helper::unsetReturnNull($credentialsConfigures, 'role_session_name'), + 'policy' => Helper::unsetReturnNull($credentialsConfigures, 'policy'), + ]); + case 'rsa_key_pair': + return new RsaKeyPairCredentialsProvider([ + 'publicKeyId' => Helper::unsetReturnNull($credentialsConfigures, 'public_key_id'), + 'privateKeyFile' => Helper::unsetReturnNull($credentialsConfigures, 'private_key_file'), + ]); + default: + throw new RuntimeException('Unsupported credential type from credentials file: ' . Helper::unsetReturnNull($credentialsConfigures, 'type')); + } + } + } + throw new RuntimeException('Failed to get credential from credentials file: ' . $profileFile); + } + /** + * Get credential. + * + * @return Credentials + * @throws RuntimeException + */ + public function getCredentials() + { + if ($this->shouldReloadCredentialsProvider()) { + $this->credentialsProvider = $this->reloadCredentialsProvider($this->profileFile, $this->profileName); + } + + $credentials = $this->credentialsProvider->getCredentials(); + return new Credentials([ + 'accessKeyId' => $credentials->getAccessKeyId(), + 'accessKeySecret' => $credentials->getAccessKeySecret(), + 'securityToken' => $credentials->getSecurityToken(), + 'providerName' => $this->getProviderName() . '/' . $this->credentialsProvider->getProviderName(), + ]); + + } + + /** + * Get the default credential file. + * + * @return string + */ + private function getDefaultFile() + { + return Helper::getHomeDirectory() . + DIRECTORY_SEPARATOR . + '.alibabacloud' . + DIRECTORY_SEPARATOR . + 'credentials'; + } + + /** + * @return string + */ + public function getProviderName() + { + return 'profile'; + } +} diff --git a/vendor/vendor/alibabacloud/credentials/src/Providers/RamRoleArnCredentialsProvider.php b/vendor/vendor/alibabacloud/credentials/src/Providers/RamRoleArnCredentialsProvider.php new file mode 100644 index 0000000..b69f6c5 --- /dev/null +++ b/vendor/vendor/alibabacloud/credentials/src/Providers/RamRoleArnCredentialsProvider.php @@ -0,0 +1,321 @@ +filterOptions($options); + $this->filterCredentials($params); + $this->filterRoleArn($params); + $this->filterRoleSessionName($params); + $this->filterDurationSeconds($params); + $this->filterPolicy($params); + $this->filterExternalId($params); + $this->filterSTSEndpoint($params); + } + + private function filterRoleArn(array $params) + { + if (Helper::envNotEmpty('ALIBABA_CLOUD_ROLE_ARN')) { + $this->roleArn = Helper::env('ALIBABA_CLOUD_ROLE_ARN'); + } + + if (isset($params['roleArn'])) { + $this->roleArn = $params['roleArn']; + } + + Filter::roleArn($this->roleArn); + } + + private function filterRoleSessionName(array $params) + { + if (Helper::envNotEmpty('ALIBABA_CLOUD_ROLE_SESSION_NAME')) { + $this->roleSessionName = Helper::env('ALIBABA_CLOUD_ROLE_SESSION_NAME'); + } + + if (isset($params['roleSessionName'])) { + $this->roleSessionName = $params['roleSessionName']; + } + + if (is_null($this->roleSessionName) || $this->roleSessionName === '') { + $this->roleSessionName = 'phpSdkRoleSessionName'; + } + } + + private function filterDurationSeconds(array $params) + { + if (isset($params['durationSeconds'])) { + if (is_int($params['durationSeconds'])) { + $this->durationSeconds = $params['durationSeconds']; + } + } + if ($this->durationSeconds < 900) { + throw new InvalidArgumentException('Role session expiration should be in the range of 900s - max session duration'); + } + } + + private function filterPolicy(array $params) + { + if (isset($params['policy'])) { + if (is_string($params['policy'])) { + $this->policy = $params['policy']; + } + + if (is_array($params['policy'])) { + $this->policy = json_encode($params['policy']); + } + } + } + + private function filterExternalId(array $params) + { + if (isset($params['externalId'])) { + if (is_string($params['externalId'])) { + $this->externalId = $params['externalId']; + } + } + } + + private function filterSTSEndpoint(array $params) + { + $prefix = 'sts'; + if (Helper::envNotEmpty('ALIBABA_CLOUD_VPC_ENDPOINT_ENABLED') || (isset($params['enableVpc']) && $params['enableVpc'] === true)) { + $prefix = 'sts-vpc'; + } + if (Helper::envNotEmpty('ALIBABA_CLOUD_STS_REGION')) { + $this->stsEndpoint = $prefix . '.' . Helper::env('ALIBABA_CLOUD_STS_REGION') . '.aliyuncs.com'; + } + + if (isset($params['stsRegionId'])) { + $this->stsEndpoint = $prefix . '.' . $params['stsRegionId'] . '.aliyuncs.com'; + } + + if (isset($params['stsEndpoint'])) { + $this->stsEndpoint = $params['stsEndpoint']; + } + + if (is_null($this->stsEndpoint) || $this->stsEndpoint === '') { + $this->stsEndpoint = 'sts.aliyuncs.com'; + } + } + + private function filterCredentials(array $params) + { + if (isset($params['credentialsProvider'])) { + if (!($params['credentialsProvider'] instanceof CredentialsProvider)) { + throw new InvalidArgumentException('Invalid credentialsProvider option for ram_role_arn'); + } + $this->credentialsProvider = $params['credentialsProvider']; + } else if (isset($params['accessKeyId']) && isset($params['accessKeySecret']) && isset($params['securityToken'])) { + Filter::accessKey($params['accessKeyId'], $params['accessKeySecret']); + Filter::securityToken($params['securityToken']); + $this->credentialsProvider = new StaticSTSCredentialsProvider($params); + } else if (isset($params['accessKeyId']) && isset($params['accessKeySecret'])) { + Filter::accessKey($params['accessKeyId'], $params['accessKeySecret']); + $this->credentialsProvider = new StaticAKCredentialsProvider($params); + } else { + throw new InvalidArgumentException('Missing required credentials option for ram_role_arn'); + } + } + + private function filterOptions(array $options) + { + if (isset($options['connectTimeout'])) { + $this->connectTimeout = $options['connectTimeout']; + } + + if (isset($options['readTimeout'])) { + $this->readTimeout = $options['readTimeout']; + } + + Filter::timeout($this->connectTimeout, $this->readTimeout); + } + + /** + * Get credentials by request. + * + * @return RefreshResult + * @throws RuntimeException + * @throws GuzzleException + */ + public function refreshCredentials() + { + $options = Request::commonOptions(); + $options['read_timeout'] = $this->readTimeout; + $options['connect_timeout'] = $this->connectTimeout; + + $options['query']['Action'] = 'AssumeRole'; + $options['query']['Version'] = '2015-04-01'; + $options['query']['Format'] = 'JSON'; + $options['query']['Timestamp'] = gmdate('Y-m-d\TH:i:s\Z'); + $options['query']['SignatureMethod'] = 'HMAC-SHA1'; + $options['query']['SignatureVersion'] = '1.0'; + $options['query']['SignatureNonce'] = Request::uuid(json_encode($options['query'])); + $options['query']['RoleArn'] = $this->roleArn; + $options['query']['RoleSessionName'] = $this->roleSessionName; + $options['query']['DurationSeconds'] = (string) $this->durationSeconds; + if (!is_null($this->policy) && $this->policy !== '') { + $options['query']['Policy'] = $this->policy; + } + if (!is_null($this->externalId) && $this->externalId !== '') { + $options['query']['ExternalId'] = $this->externalId; + } + + $sessionCredentials = $this->credentialsProvider->getCredentials(); + $options['query']['AccessKeyId'] = $sessionCredentials->getAccessKeyId(); + if (!is_null($sessionCredentials->getSecurityToken())) { + $options['query']['SecurityToken'] = $sessionCredentials->getSecurityToken(); + } + $options['query']['Signature'] = Request::shaHmac1sign( + Request::signString('GET', $options['query']), + $sessionCredentials->getAccessKeySecret() . '&' + ); + + $url = (new Uri())->withScheme('https')->withHost($this->stsEndpoint); + + $result = Request::createClient()->request('GET', $url, $options); + + if ($result->getStatusCode() !== 200) { + throw new RuntimeException('Error refreshing credentials from RamRoleArn, statusCode: ' . $result->getStatusCode() . ', result: ' . (string) $result); + } + + $json = $result->toArray(); + $credentials = $json['Credentials']; + + if (!isset($credentials['AccessKeyId']) || !isset($credentials['AccessKeySecret']) || !isset($credentials['SecurityToken'])) { + throw new RuntimeException('Error retrieving credentials from RamRoleArn result:' . $result->toJson()); + } + + return new RefreshResult(new Credentials([ + 'accessKeyId' => $credentials['AccessKeyId'], + 'accessKeySecret' => $credentials['AccessKeySecret'], + 'securityToken' => $credentials['SecurityToken'], + 'expiration' => \strtotime($credentials['Expiration']), + 'providerName' => $this->getProviderName(), + ]), $this->getStaleTime(strtotime($credentials['Expiration']))); + } + + public function key() + { + $credentials = $this->credentialsProvider->getCredentials(); + return 'ram_role_arn#credential#' . $credentials->getAccessKeyId() . '#roleArn#' . $this->roleArn . '#roleSessionName#' . $this->roleSessionName; + } + + public function getProviderName() + { + return 'ram_role_arn/' . $this->credentialsProvider->getProviderName(); + } + + /** + * @return string + */ + public function getRoleArn() + { + return $this->roleArn; + } + + /** + * @return string + */ + public function getRoleSessionName() + { + return $this->roleSessionName; + } + + /** + * @return string + */ + public function getPolicy() + { + return $this->policy; + } + + /** + * @deprecated + * @return string + */ + public function getOriginalAccessKeyId() + { + return $this->credentialsProvider->getCredentials()->getAccessKeyId(); + } + + /** + * @deprecated + * @return string + */ + public function getOriginalAccessKeySecret() + { + return $this->credentialsProvider->getCredentials()->getAccessKeySecret(); + } +} diff --git a/vendor/vendor/alibabacloud/credentials/src/Providers/RsaKeyPairCredentialsProvider.php b/vendor/vendor/alibabacloud/credentials/src/Providers/RsaKeyPairCredentialsProvider.php new file mode 100644 index 0000000..8c85db6 --- /dev/null +++ b/vendor/vendor/alibabacloud/credentials/src/Providers/RsaKeyPairCredentialsProvider.php @@ -0,0 +1,200 @@ +filterOptions($options); + $this->filterDurationSeconds($params); + $this->filterSTSEndpoint($params); + $this->publicKeyId = isset($params['publicKeyId']) ? $params['publicKeyId'] : null; + $privateKeyFile = isset($params['privateKeyFile']) ? $params['privateKeyFile'] : null; + Filter::publicKeyId($this->publicKeyId); + Filter::privateKeyFile($privateKeyFile); + + try { + $this->privateKey = file_get_contents($privateKeyFile); + } catch (Exception $exception) { + throw new InvalidArgumentException($exception->getMessage()); + } + } + + private function filterOptions(array $options) + { + if (isset($options['connectTimeout'])) { + $this->connectTimeout = $options['connectTimeout']; + } + + if (isset($options['readTimeout'])) { + $this->readTimeout = $options['readTimeout']; + } + + Filter::timeout($this->connectTimeout, $this->readTimeout); + } + + private function filterDurationSeconds(array $params) + { + if (isset($params['durationSeconds'])) { + if (is_int($params['durationSeconds'])) { + $this->durationSeconds = $params['durationSeconds']; + } + } + if ($this->durationSeconds < 900) { + throw new InvalidArgumentException('Role session expiration should be in the range of 900s - max session duration'); + } + } + + private function filterSTSEndpoint(array $params) + { + if (isset($params['stsEndpoint'])) { + $this->stsEndpoint = $params['stsEndpoint']; + } + + if (is_null($this->stsEndpoint) || $this->stsEndpoint === '') { + $this->stsEndpoint = 'sts.ap-northeast-1.aliyuncs.com'; + } + } + + + /** + * Get credentials by request. + * + * @return RefreshResult + * @throws RuntimeException + * @throws GuzzleException + */ + public function refreshCredentials() + { + $options = Request::commonOptions(); + $options['read_timeout'] = $this->readTimeout; + $options['connect_timeout'] = $this->connectTimeout; + + $options['query']['Action'] = 'GenerateSessionAccessKey'; + $options['query']['Version'] = '2015-04-01'; + $options['query']['Format'] = 'JSON'; + $options['query']['Timestamp'] = gmdate('Y-m-d\TH:i:s\Z'); + $options['query']['SignatureMethod'] = 'SHA256withRSA'; + $options['query']['SignatureType'] = 'PRIVATEKEY'; + $options['query']['SignatureVersion'] = '1.0'; + $options['query']['SignatureNonce'] = Request::uuid(json_encode($options['query'])); + $options['query']['DurationSeconds'] = (string) $this->durationSeconds; + $options['query']['AccessKeyId'] = $this->publicKeyId; + $options['query']['Signature'] = Request::shaHmac256WithRsasign( + Request::signString('GET', $options['query']), + $this->privateKey + ); + + $url = (new Uri())->withScheme('https')->withHost($this->stsEndpoint); + + $result = Request::createClient()->request('GET', $url, $options); + + if ($result->getStatusCode() !== 200) { + throw new RuntimeException('Error refreshing credentials from RsaKeyPair, statusCode: ' . $result->getStatusCode() . ', result: ' . (string) $result); + } + + $json = $result->toArray(); + + if (!isset($json['SessionAccessKey']['SessionAccessKeyId']) || !isset($json['SessionAccessKey']['SessionAccessKeySecret'])) { + throw new RuntimeException('Error retrieving credentials from RsaKeyPair result:' . $result->toJson()); + } + + $credentials = []; + $credentials['AccessKeyId'] = $json['SessionAccessKey']['SessionAccessKeyId']; + $credentials['AccessKeySecret'] = $json['SessionAccessKey']['SessionAccessKeySecret']; + $credentials['Expiration'] = $json['SessionAccessKey']['Expiration']; + $credentials['SecurityToken'] = null; + + + return new RefreshResult(new Credentials([ + 'accessKeyId' => $credentials['AccessKeyId'], + 'accessKeySecret' => $credentials['AccessKeySecret'], + 'securityToken' => $credentials['SecurityToken'], + 'expiration' => \strtotime($credentials['Expiration']), + 'providerName' => $this->getProviderName(), + ]), $this->getStaleTime(strtotime($credentials['Expiration']))); + } + + public function key() + { + return 'rsa_key_pair#publicKeyId#' . $this->publicKeyId; + } + + public function getProviderName() + { + return 'rsa_key_pair'; + } + + /** + * @return string + */ + public function getPublicKeyId() + { + return $this->publicKeyId; + } + + /** + * @return mixed + */ + public function getPrivateKey() + { + return $this->privateKey; + } +} diff --git a/vendor/vendor/alibabacloud/credentials/src/Providers/SessionCredentialsProvider.php b/vendor/vendor/alibabacloud/credentials/src/Providers/SessionCredentialsProvider.php new file mode 100644 index 0000000..60b92de --- /dev/null +++ b/vendor/vendor/alibabacloud/credentials/src/Providers/SessionCredentialsProvider.php @@ -0,0 +1,161 @@ +key()])) { + $result = self::$credentialsCache[$this->key()]; + return $result; + } + return null; + } + + /** + * Cache credentials. + * + * @param RefreshResult $credential + */ + protected function cache(RefreshResult $credential) + { + self::$credentialsCache[$this->key()] = $credential; + } + + /** + * Get credential. + * + * @return Credentials + */ + public function getCredentials() + { + if ($this->cacheIsStale() || $this->shouldInitiateCachePrefetch()) { + $result = $this->refreshCache(); + $this->cache($result); + } + + $result = $this->getCredentialsInCache(); + + return $result->credentials(); + } + + /** + * @return RefreshResult + */ + protected function refreshCache() + { + try { + return $this->handleFetchedSuccess($this->refreshCredentials()); + } catch (\Exception $e) { + return $this->handleFetchedFailure($e); + } + } + + /** + * @return RefreshResult + * @throws \Exception + */ + protected function handleFetchedFailure(\Exception $e) + { + $currentCachedValue = $this->getCredentialsInCache(); + if (is_null($currentCachedValue)) { + throw $e; + } + + if (time() < $currentCachedValue->staleTime()) { + return $currentCachedValue; + } + + throw $e; + } + /** + * @return RefreshResult + */ + protected function handleFetchedSuccess(RefreshResult $value) + { + $now = time(); + // 过期时间大于15分钟,不用管 + if ($now < $value->staleTime()) { + return $value; + } + // 不足或等于15分钟,但未过期,下次会再次刷新 + if ($now < $value->staleTime() + 15 * 60) { + $value->staleTime = $now; + return $value; + } + // 已过期,看缓存,缓存若大于15分钟,返回缓存,若小于15分钟,则稍后重试 + if (is_null($this->getCredentialsInCache())) { + throw new \Exception("The fetched credentials have expired and no cache is available."); + } else if ($now < $this->getCredentialsInCache()->staleTime()) { + return $this->getCredentialsInCache(); + } else { + // 返回成功,延长有效期 1 分钟 + $expectation = mt_rand(50, 70); + $value->staleTime = time() + $expectation; + return $value; + } + } + + /** + * @return bool + */ + protected function cacheIsStale() + { + return is_null($this->getCredentialsInCache()) || time() >= $this->getCredentialsInCache()->staleTime(); + } + + /** + * @return bool + */ + protected function shouldInitiateCachePrefetch() + { + return is_null($this->getCredentialsInCache()) || time() >= $this->getCredentialsInCache()->prefetchTime(); + } + + /** + * @return int + */ + public function getStaleTime($expiration) + { + return $expiration <= 0 ? + time() + (60 * 60) : + $expiration - (15 * 60); + } + + /** + * @return RefreshResult + */ + abstract function refreshCredentials(); + + /** + * Get the toString of the credentials provider as the key. + * + * @return string + */ + abstract function key(); +} diff --git a/vendor/vendor/alibabacloud/credentials/src/Providers/StaticAKCredentialsProvider.php b/vendor/vendor/alibabacloud/credentials/src/Providers/StaticAKCredentialsProvider.php new file mode 100644 index 0000000..7e73cd0 --- /dev/null +++ b/vendor/vendor/alibabacloud/credentials/src/Providers/StaticAKCredentialsProvider.php @@ -0,0 +1,78 @@ +filterAK($params); + } + + private function filterAK(array $params) + { + if (Helper::envNotEmpty('ALIBABA_CLOUD_ACCESS_KEY_ID')) { + $this->accessKeyId = Helper::env('ALIBABA_CLOUD_ACCESS_KEY_ID'); + } + + if (Helper::envNotEmpty('ALIBABA_CLOUD_ACCESS_KEY_SECRET')) { + $this->accessKeySecret = Helper::env('ALIBABA_CLOUD_ACCESS_KEY_SECRET'); + } + + if (isset($params['accessKeyId'])) { + $this->accessKeyId = $params['accessKeyId']; + } + if (isset($params['accessKeySecret'])) { + $this->accessKeySecret = $params['accessKeySecret']; + } + + Filter::accessKey($this->accessKeyId, $this->accessKeySecret); + } + + /** + * Get credential. + * + * @return Credentials + */ + public function getCredentials() + { + return new Credentials([ + 'accessKeyId' => $this->accessKeyId, + 'accessKeySecret' => $this->accessKeySecret, + 'providerName' => $this->getProviderName(), + ]); + } + + /** + * @inheritDoc + */ + public function getProviderName() + { + return "static_ak"; + } +} \ No newline at end of file diff --git a/vendor/vendor/alibabacloud/credentials/src/Providers/StaticSTSCredentialsProvider.php b/vendor/vendor/alibabacloud/credentials/src/Providers/StaticSTSCredentialsProvider.php new file mode 100644 index 0000000..957b25d --- /dev/null +++ b/vendor/vendor/alibabacloud/credentials/src/Providers/StaticSTSCredentialsProvider.php @@ -0,0 +1,92 @@ +filterSTS($params); + } + + private function filterSTS(array $params) + { + if (Helper::envNotEmpty('ALIBABA_CLOUD_ACCESS_KEY_ID')) { + $this->accessKeyId = Helper::env('ALIBABA_CLOUD_ACCESS_KEY_ID'); + } + + if (Helper::envNotEmpty('ALIBABA_CLOUD_ACCESS_KEY_SECRET')) { + $this->accessKeySecret = Helper::env('ALIBABA_CLOUD_ACCESS_KEY_SECRET'); + } + + if (Helper::envNotEmpty('ALIBABA_CLOUD_SECURITY_TOKEN')) { + $this->securityToken = Helper::env('ALIBABA_CLOUD_SECURITY_TOKEN'); + } + + if (isset($params['accessKeyId'])) { + $this->accessKeyId = $params['accessKeyId']; + } + if (isset($params['accessKeySecret'])) { + $this->accessKeySecret = $params['accessKeySecret']; + } + if (isset($params['securityToken'])) { + $this->securityToken = $params['securityToken']; + } + + Filter::accessKey($this->accessKeyId, $this->accessKeySecret); + Filter::securityToken($this->securityToken); + } + + /** + * Get credential. + * + * @return Credentials + */ + public function getCredentials() + { + return new Credentials([ + 'accessKeyId' => $this->accessKeyId, + 'accessKeySecret' => $this->accessKeySecret, + 'securityToken' => $this->securityToken, + 'providerName' => $this->getProviderName(), + ]); + } + + /** + * @inheritDoc + */ + public function getProviderName() + { + return "static_sts"; + } +} \ No newline at end of file diff --git a/vendor/vendor/alibabacloud/credentials/src/Providers/URLCredentialsProvider.php b/vendor/vendor/alibabacloud/credentials/src/Providers/URLCredentialsProvider.php new file mode 100644 index 0000000..617c19f --- /dev/null +++ b/vendor/vendor/alibabacloud/credentials/src/Providers/URLCredentialsProvider.php @@ -0,0 +1,126 @@ +filterOptions($options); + $this->filterCredentialsURI($params); + } + + private function filterOptions(array $options) + { + if (isset($options['connectTimeout'])) { + $this->connectTimeout = $options['connectTimeout']; + } + + if (isset($options['readTimeout'])) { + $this->readTimeout = $options['readTimeout']; + } + + Filter::timeout($this->connectTimeout, $this->readTimeout); + } + + private function filterCredentialsURI(array $params) + { + if (Helper::envNotEmpty('ALIBABA_CLOUD_CREDENTIALS_URI')) { + $this->credentialsURI = Helper::env('ALIBABA_CLOUD_CREDENTIALS_URI'); + } + + if (isset($params['credentialsURI'])) { + $this->credentialsURI = $params['credentialsURI']; + } + + Filter::credentialsURI($this->credentialsURI); + } + + /** + * Get credentials by request. + * + * @return RefreshResult + * @throws InvalidArgumentException + * @throws RuntimeException + * @throws GuzzleException + */ + public function refreshCredentials() + { + $options = Request::commonOptions(); + $options['read_timeout'] = $this->readTimeout; + $options['connect_timeout'] = $this->connectTimeout; + + $result = Request::createClient()->request('GET', $this->credentialsURI, $options); + + if ($result->getStatusCode() !== 200) { + throw new RuntimeException('Error refreshing credentials from credentialsURI, statusCode: ' . $result->getStatusCode() . ', result: ' . (string) $result); + } + + $credentials = $result->toArray(); + + if (!isset($credentials['AccessKeyId']) || !isset($credentials['AccessKeySecret']) || !isset($credentials['SecurityToken']) || !isset($credentials['Expiration'])) { + throw new RuntimeException('Error retrieving credentials from credentialsURI result:' . $result->toJson()); + } + + return new RefreshResult(new Credentials([ + 'accessKeyId' => $credentials['AccessKeyId'], + 'accessKeySecret' => $credentials['AccessKeySecret'], + 'securityToken' => $credentials['SecurityToken'], + 'expiration' => \strtotime($credentials['Expiration']), + 'providerName' => $this->getProviderName(), + ]), $this->getStaleTime(strtotime($credentials['Expiration']))); + } + + + /** + * @return string + */ + public function key() + { + return 'credential_uri#' . $this->credentialsURI; + } + + /** + * @return string + */ + public function getProviderName() + { + return 'credential_uri'; + } +} diff --git a/vendor/vendor/alibabacloud/credentials/src/RamRoleArnCredential.php b/vendor/vendor/alibabacloud/credentials/src/RamRoleArnCredential.php new file mode 100644 index 0000000..ed75640 --- /dev/null +++ b/vendor/vendor/alibabacloud/credentials/src/RamRoleArnCredential.php @@ -0,0 +1,242 @@ +filterParameters($credential); + $this->filterPolicy($credential); + + Filter::accessKey($credential['access_key_id'], $credential['access_key_secret']); + + $this->config = $config; + $this->accessKeyId = $credential['access_key_id']; + $this->accessKeySecret = $credential['access_key_secret']; + $this->roleArn = $credential['role_arn']; + $this->roleSessionName = $credential['role_session_name']; + } + + /** + * @param array $credential + */ + private function filterParameters(array $credential) + { + if (!isset($credential['access_key_id'])) { + throw new InvalidArgumentException('Missing required access_key_id option in config for ram_role_arn'); + } + + if (!isset($credential['access_key_secret'])) { + throw new InvalidArgumentException('Missing required access_key_secret option in config for ram_role_arn'); + } + + if (!isset($credential['role_arn'])) { + throw new InvalidArgumentException('Missing required role_arn option in config for ram_role_arn'); + } + + if (!isset($credential['role_session_name'])) { + throw new InvalidArgumentException('Missing required role_session_name option in config for ram_role_arn'); + } + } + + /** + * @param array $credential + */ + private function filterPolicy(array $credential) + { + if (isset($credential['policy'])) { + if (is_string($credential['policy'])) { + $this->policy = $credential['policy']; + } + + if (is_array($credential['policy'])) { + $this->policy = json_encode($credential['policy']); + } + } + } + + /** + * @return array + */ + public function getConfig() + { + return $this->config; + } + + /** + * @return string + */ + public function getRoleArn() + { + return $this->roleArn; + } + + /** + * @return string + */ + public function getRoleSessionName() + { + return $this->roleSessionName; + } + + /** + * @return string + */ + public function getPolicy() + { + return $this->policy; + } + + /** + * @return string + */ + public function __toString() + { + return "$this->accessKeyId#$this->accessKeySecret#$this->roleArn#$this->roleSessionName"; + } + + /** + * @return ShaHmac1Signature + */ + public function getSignature() + { + return new ShaHmac1Signature(); + } + + /** + * @return string + */ + public function getOriginalAccessKeyId() + { + return $this->accessKeyId; + } + + /** + * @return string + */ + public function getOriginalAccessKeySecret() + { + return $this->accessKeySecret; + } + + /** + * @return string + * @throws Exception + * @throws GuzzleException + */ + public function getAccessKeyId() + { + return $this->getSessionCredential()->getAccessKeyId(); + } + + /** + * @return AlibabaCloud\Credentials\Providers\Credentials + * @throws Exception + * @throws GuzzleException + */ + protected function getSessionCredential() + { + $params = [ + 'accessKeyId' => $this->accessKeyId, + 'accessKeySecret' => $this->accessKeyId, + 'roleArn' => $this->roleArn, + 'roleSessionName' => $this->roleSessionName, + 'policy' => $this->policy, + ]; + return (new RamRoleArnCredentialsProvider($params))->getCredentials(); + } + + /** + * @return string + * @throws Exception + * @throws GuzzleException + */ + public function getAccessKeySecret() + { + return $this->getSessionCredential()->getAccessKeySecret(); + } + + /** + * @return string + * @throws Exception + * @throws GuzzleException + */ + public function getSecurityToken() + { + return $this->getSessionCredential()->getSecurityToken(); + } + + /** + * @return string + * @throws Exception + * @throws GuzzleException + */ + public function getExpiration() + { + return $this->getSessionCredential()->getExpiration(); + } + + /** + * @inheritDoc + */ + public function getCredential() + { + $credentials = $this->getSessionCredential(); + return new CredentialModel([ + 'accessKeyId' => $credentials->getAccessKeyId(), + 'accessKeySecret' => $credentials->getAccessKeySecret(), + 'securityToken' => $credentials->getSecurityToken(), + 'type' => 'ram_role_arn', + ]); + } +} diff --git a/vendor/vendor/alibabacloud/credentials/src/Request/Request.php b/vendor/vendor/alibabacloud/credentials/src/Request/Request.php new file mode 100644 index 0000000..f0ba62f --- /dev/null +++ b/vendor/vendor/alibabacloud/credentials/src/Request/Request.php @@ -0,0 +1,167 @@ + $value) { + $canonicalized .= '&' . self::percentEncode($key) . '=' . self::percentEncode($value); + } + + return $method . '&%2F&' . self::percentEncode(substr($canonicalized, 1)); + } + + /** + * @param string $string + * @param string $accessKeySecret + * + * @return string + */ + public static function shaHmac1sign($string, $accessKeySecret) + { + return base64_encode(hash_hmac('sha1', $string, $accessKeySecret, true)); + } + + /** + * @param string $string + * @param string $accessKeySecret + * + * @return string + */ + public static function shaHmac256sign($string, $accessKeySecret) + { + return base64_encode(hash_hmac('sha256', $string, $accessKeySecret, true)); + } + + /** + * @param string $string + * @param string $privateKey + * + * @return string + */ + public static function shaHmac256WithRsasign($string, $privateKey) + { + $binarySignature = ''; + try { + openssl_sign( + $string, + $binarySignature, + $privateKey, + \OPENSSL_ALGO_SHA256 + ); + } catch (Exception $exception) { + throw new InvalidArgumentException( + $exception->getMessage() + ); + } + + return base64_encode($binarySignature); + } + + /** + * @param string $string + * + * @return null|string|string[] + */ + private static function percentEncode($string) + { + $result = rawurlencode($string); + $result = str_replace(['+', '*'], ['%20', '%2A'], $result); + $result = preg_replace('/%7E/', '~', $result); + + return $result; + } + + /** + * @return Client + * @throws Exception + */ + public static function createClient() + { + if (Credentials::hasMock()) { + $stack = HandlerStack::create(Credentials::getMock()); + $history = Credentials::getHandlerHistory(); + $stack->push($history); + } else { + $stack = HandlerStack::create(); + } + + $stack->push(Middleware::mapResponse(static function (ResponseInterface $response) { + return new Response($response); + })); + + self::$config['handler'] = $stack; + + return new Client(self::$config); + } +} diff --git a/vendor/vendor/alibabacloud/credentials/src/RsaKeyPairCredential.php b/vendor/vendor/alibabacloud/credentials/src/RsaKeyPairCredential.php new file mode 100644 index 0000000..12e719e --- /dev/null +++ b/vendor/vendor/alibabacloud/credentials/src/RsaKeyPairCredential.php @@ -0,0 +1,185 @@ +publicKeyId = $public_key_id; + $this->privateKeyFile = $private_key_file; + $this->config = $config; + try { + $this->privateKey = file_get_contents($private_key_file); + } catch (Exception $exception) { + throw new InvalidArgumentException($exception->getMessage()); + } + } + + /** + * @return array + */ + public function getConfig() + { + return $this->config; + } + + /** + * @return string + */ + public function getOriginalAccessKeyId() + { + return $this->getPublicKeyId(); + } + + /** + * @return string + */ + public function getPublicKeyId() + { + return $this->publicKeyId; + } + + /** + * @return string + */ + public function getOriginalAccessKeySecret() + { + return $this->getPrivateKey(); + } + + /** + * @return mixed + */ + public function getPrivateKey() + { + return $this->privateKey; + } + + /** + * @return string + */ + public function __toString() + { + return "publicKeyId#$this->publicKeyId"; + } + + /** + * @return ShaHmac1Signature + */ + public function getSignature() + { + return new ShaHmac1Signature(); + } + + /** + * @return string + * @throws Exception + * @throws GuzzleException + */ + public function getAccessKeyId() + { + return $this->getSessionCredential()->getAccessKeyId(); + } + + /** + * @return AlibabaCloud\Credentials\Providers\Credentials + * @throws Exception + * @throws GuzzleException + */ + protected function getSessionCredential() + { + $params = [ + 'publicKeyId' => $this->publicKeyId, + 'privateKeyFile' => $this->privateKeyFile, + ]; + return (new RsaKeyPairCredentialsProvider($params))->getCredentials(); + } + + /** + * @return string + * @throws Exception + * @throws GuzzleException + */ + public function getAccessKeySecret() + { + return $this->getSessionCredential()->getAccessKeySecret(); + } + + /** + * @return string + * @throws Exception + * @throws GuzzleException + */ + public function getSecurityToken() + { + return $this->getSessionCredential()->getSecurityToken(); + } + + /** + * @return int + * @throws Exception + * @throws GuzzleException + */ + public function getExpiration() + { + return $this->getSessionCredential()->getExpiration(); + } + + /** + * @inheritDoc + */ + public function getCredential() + { + $credentials = $this->getSessionCredential(); + return new CredentialModel([ + 'accessKeyId' => $credentials->getAccessKeyId(), + 'accessKeySecret' => $credentials->getAccessKeySecret(), + 'securityToken' => $credentials->getSecurityToken(), + 'type' => 'rsa_key_pair', + ]); + } +} diff --git a/vendor/vendor/alibabacloud/credentials/src/Signature/BearerTokenSignature.php b/vendor/vendor/alibabacloud/credentials/src/Signature/BearerTokenSignature.php new file mode 100644 index 0000000..1d67a80 --- /dev/null +++ b/vendor/vendor/alibabacloud/credentials/src/Signature/BearerTokenSignature.php @@ -0,0 +1,47 @@ +getMessage() + ); + } + + return base64_encode($binarySignature); + } +} diff --git a/vendor/vendor/alibabacloud/credentials/src/Signature/SignatureInterface.php b/vendor/vendor/alibabacloud/credentials/src/Signature/SignatureInterface.php new file mode 100644 index 0000000..9dfb73b --- /dev/null +++ b/vendor/vendor/alibabacloud/credentials/src/Signature/SignatureInterface.php @@ -0,0 +1,34 @@ +accessKeyId = $access_key_id; + $this->accessKeySecret = $access_key_secret; + $this->expiration = $expiration; + $this->securityToken = $security_token; + } + + /** + * @return int + */ + public function getExpiration() + { + return $this->expiration; + } + + /** + * @return string + */ + public function getAccessKeyId() + { + return $this->accessKeyId; + } + + /** + * @return string + */ + public function getAccessKeySecret() + { + return $this->accessKeySecret; + } + + /** + * @return string + */ + public function getSecurityToken() + { + return $this->securityToken; + } + + /** + * @return string + */ + public function __toString() + { + return "$this->accessKeyId#$this->accessKeySecret#$this->securityToken"; + } + + /** + * @return ShaHmac1Signature + */ + public function getSignature() + { + return new ShaHmac1Signature(); + } + + /** + * @inheritDoc + */ + public function getCredential() + { + return new CredentialModel([ + 'accessKeyId' => $this->accessKeyId, + 'accessKeySecret' => $this->accessKeySecret, + 'securityToken' => $this->securityToken, + 'type' => 'sts', + ]); + } + +} diff --git a/vendor/vendor/alibabacloud/credentials/src/Utils/Filter.php b/vendor/vendor/alibabacloud/credentials/src/Utils/Filter.php new file mode 100644 index 0000000..959fd8f --- /dev/null +++ b/vendor/vendor/alibabacloud/credentials/src/Utils/Filter.php @@ -0,0 +1,233 @@ + $value) { + if (is_int($key)) { + $result[] = $value; + continue; + } + + if (isset($result[$key]) && is_array($result[$key])) { + $result[$key] = self::merge( + [$result[$key], $value] + ); + continue; + } + + $result[$key] = $value; + } + } + + return $result; + } + + /** + * @param $filename + * + * @return bool + */ + public static function inOpenBasedir($filename) + { + $open_basedir = ini_get('open_basedir'); + if (!$open_basedir) { + return true; + } + if (0 === strpos($filename, vfsStream::SCHEME)) { + // 虚拟文件忽略 + return true; + } + + $dirs = explode(PATH_SEPARATOR, $open_basedir); + + return empty($dirs) || self::inDir($filename, $dirs); + } + + /** + * @param string $filename + * @param array $dirs + * + * @return bool + */ + public static function inDir($filename, array $dirs) + { + foreach ($dirs as $dir) { + if ($dir[strlen($dir) - 1] !== DIRECTORY_SEPARATOR) { + $dir .= DIRECTORY_SEPARATOR; + } + + if (0 === strpos($filename, $dir)) { + return true; + } + } + + return false; + } + + /** + * @return bool + */ + public static function isWindows() + { + return PATH_SEPARATOR === ';'; + } + + /** + * @param $key + * + * @return bool|mixed + */ + public static function envNotEmpty($key) + { + $value = self::env($key, false); + if ($value) { + return $value; + } + + return false; + } + + /** + * Gets the value of an environment variable. + * + * @param string $key + * @param mixed $default + * + * @return mixed + */ + public static function env($key, $default = null) + { + $value = getenv($key); + + if ($value === false) { + return self::value($default); + } + + if (self::envSubstr($value)) { + return substr($value, 1, -1); + } + + return self::envConversion($value); + } + + /** + * Return the default value of the given value. + * + * @param mixed $value + * + * @return mixed + */ + public static function value($value) + { + return $value instanceof Closure ? $value() : $value; + } + + /** + * @param $value + * + * @return bool + */ + public static function envSubstr($value) + { + return ($valueLength = strlen($value)) > 1 + && strpos($value, '"') === 0 + && $value[$valueLength - 1] === '"'; + } + + /** + * @param $value + * + * @return bool|string|null + */ + public static function envConversion($value) + { + $key = strtolower($value); + + if ($key === 'null' || $key === '(null)') { + return null; + } + + $list = [ + 'true' => true, + '(true)' => true, + 'false' => false, + '(false)' => false, + 'empty' => '', + '(empty)' => '', + ]; + + return isset($list[$key]) ? $list[$key] : $value; + } + + /** + * Gets the environment's HOME directory. + * + * @return null|string + */ + public static function getHomeDirectory() + { + if (getenv('HOME')) { + return getenv('HOME'); + } + + return (getenv('HOMEDRIVE') && getenv('HOMEPATH')) + ? getenv('HOMEDRIVE') . getenv('HOMEPATH') + : null; + } + + /** + * @param mixed ...$parameters + * + * @codeCoverageIgnore + */ + public static function dd(...$parameters) + { + dump(...$parameters); + exit; + } + + /** + * Snake to camel case. + * + * @param string $str + * + * @return string + */ + public static function snakeToCamelCase($str) + { + $components = explode('_', $str); + $camelCaseStr = $components[0]; + for ($i = 1; $i < count($components); $i++) { + $camelCaseStr .= ucfirst($components[$i]); + } + return $camelCaseStr; + } + + /** + * Get user agent. + * + * @param string $userAgent + * + * @return string + */ + public static function getUserAgent() + { + return sprintf('AlibabaCloud (%s; %s) PHP/%s Credentials/%s TeaDSL/1', PHP_OS, \PHP_SAPI, PHP_VERSION, Credential::VERSION); + } + + /** + * @param array $arrays + * @param string $key + * + * @return mix + */ + public static function unsetReturnNull(array $arrays, $key) + { + if(isset($arrays[$key])) { + return $arrays[$key]; + } + return null; + } +} diff --git a/vendor/vendor/alibabacloud/credentials/src/Utils/MockTrait.php b/vendor/vendor/alibabacloud/credentials/src/Utils/MockTrait.php new file mode 100644 index 0000000..cc07119 --- /dev/null +++ b/vendor/vendor/alibabacloud/credentials/src/Utils/MockTrait.php @@ -0,0 +1,120 @@ +setRiskyAllowed(true) + ->setIndent(' ') + ->setRules([ + '@PSR2' => true, + '@PhpCsFixer' => true, + '@Symfony:risky' => true, + 'concat_space' => ['spacing' => 'one'], + 'array_syntax' => ['syntax' => 'short'], + 'array_indentation' => true, + 'combine_consecutive_unsets' => true, + 'method_separation' => true, + 'single_quote' => true, + 'declare_equal_normalize' => true, + 'function_typehint_space' => true, + 'hash_to_slash_comment' => true, + 'include' => true, + 'lowercase_cast' => true, + 'no_multiline_whitespace_before_semicolons' => true, + 'no_leading_import_slash' => true, + 'no_multiline_whitespace_around_double_arrow' => true, + 'no_spaces_around_offset' => true, + 'no_unneeded_control_parentheses' => true, + 'no_unused_imports' => true, + 'no_whitespace_before_comma_in_array' => true, + 'no_whitespace_in_blank_line' => true, + 'object_operator_without_whitespace' => true, + 'single_blank_line_before_namespace' => true, + 'single_class_element_per_statement' => true, + 'space_after_semicolon' => true, + 'standardize_not_equals' => true, + 'ternary_operator_spaces' => true, + 'trailing_comma_in_multiline_array' => true, + 'trim_array_spaces' => true, + 'unary_operator_spaces' => true, + 'whitespace_after_comma_in_array' => true, + 'no_extra_consecutive_blank_lines' => [ + 'curly_brace_block', + 'extra', + 'parenthesis_brace_block', + 'square_brace_block', + 'throw', + 'use', + ], + 'binary_operator_spaces' => [ + 'align_double_arrow' => true, + 'align_equals' => true, + ], + 'braces' => [ + 'allow_single_line_closure' => true, + ], + ]) + ->setFinder( + PhpCsFixer\Finder::create() + ->exclude('vendor') + ->exclude('tests') + ->in(__DIR__) + ); diff --git a/vendor/vendor/alibabacloud/darabonba-openapi/README-CN.md b/vendor/vendor/alibabacloud/darabonba-openapi/README-CN.md new file mode 100644 index 0000000..b70255c --- /dev/null +++ b/vendor/vendor/alibabacloud/darabonba-openapi/README-CN.md @@ -0,0 +1,31 @@ +[English](README.md) | 简体中文 + +![](https://aliyunsdk-pages.alicdn.com/icons/AlibabaCloud.svg) + +## Alibaba Cloud OpenApi Client + +## 安装 + +### Composer + +```bash +composer require alibabacloud/darabonba-openapi +``` + +## 问题 + +[提交 Issue](https://github.com/aliyun/darabonba-openapi/issues/new),不符合指南的问题可能会立即关闭。 + +## 发行说明 + +每个版本的详细更改记录在[发行说明](./ChangeLog.txt)中。 + +## 相关 + +* [最新源码](https://github.com/aliyun/darabonba-openapi) + +## 许可证 + +[Apache-2.0](http://www.apache.org/licenses/LICENSE-2.0) + +Copyright (c) 2009-present, Alibaba Cloud All rights reserved. diff --git a/vendor/vendor/alibabacloud/darabonba-openapi/README.md b/vendor/vendor/alibabacloud/darabonba-openapi/README.md new file mode 100644 index 0000000..9770627 --- /dev/null +++ b/vendor/vendor/alibabacloud/darabonba-openapi/README.md @@ -0,0 +1,31 @@ +English | [简体中文](README-CN.md) + +![](https://aliyunsdk-pages.alicdn.com/icons/AlibabaCloud.svg) + +## Alibaba Cloud OpenApi Client + +## Installation + +### Composer + +```bash +composer require alibabacloud/darabonba-openapi +``` + +## Issues + +[Opening an Issue](https://github.com/aliyun/darabonba-openapi/issues/new), Issues not conforming to the guidelines may be closed immediately. + +## Changelog + +Detailed changes for each release are documented in the [release notes](./ChangeLog.txt). + +## References + +* [Latest Release](https://github.com/aliyun/darabonba-openapi) + +## License + +[Apache-2.0](http://www.apache.org/licenses/LICENSE-2.0) + +Copyright (c) 2009-present, Alibaba Cloud All rights reserved. diff --git a/vendor/vendor/alibabacloud/darabonba-openapi/autoload.php b/vendor/vendor/alibabacloud/darabonba-openapi/autoload.php new file mode 100644 index 0000000..526c188 --- /dev/null +++ b/vendor/vendor/alibabacloud/darabonba-openapi/autoload.php @@ -0,0 +1,15 @@ +5.5", + "alibabacloud/tea-utils": "^0.2.21", + "alibabacloud/credentials": "^1.2.2", + "alibabacloud/openapi-util": "^0.1.10|^0.2.1", + "alibabacloud/gateway-spi": "^1", + "alibabacloud/tea-xml": "^0.2" + }, + "autoload": { + "psr-4": { + "Darabonba\\OpenApi\\": "src" + } + }, + "scripts": { + "fixer": "php-cs-fixer fix ./" + }, + "config": { + "sort-packages": true, + "preferred-install": "dist", + "optimize-autoloader": true + }, + "prefer-stable": true +} \ No newline at end of file diff --git a/vendor/vendor/alibabacloud/darabonba-openapi/phpunit.xml b/vendor/vendor/alibabacloud/darabonba-openapi/phpunit.xml new file mode 100644 index 0000000..796384a --- /dev/null +++ b/vendor/vendor/alibabacloud/darabonba-openapi/phpunit.xml @@ -0,0 +1,31 @@ + + + + + + tests + + + ./tests/Unit + + + + + + integration + + + + + + + + + + + ./src + + + diff --git a/vendor/vendor/alibabacloud/darabonba-openapi/src/Models/Config.php b/vendor/vendor/alibabacloud/darabonba-openapi/src/Models/Config.php new file mode 100644 index 0000000..7976310 --- /dev/null +++ b/vendor/vendor/alibabacloud/darabonba-openapi/src/Models/Config.php @@ -0,0 +1,463 @@ + '', + 'accessKeySecret' => '', + 'securityToken' => '', + 'bearerToken' => '', + 'protocol' => 'http', + 'method' => '', + 'regionId' => '', + 'readTimeout' => '', + 'connectTimeout' => '', + 'httpProxy' => '', + 'httpsProxy' => '', + 'credential' => '', + 'endpoint' => '', + 'noProxy' => '', + 'maxIdleConns' => '', + 'network' => '', + 'userAgent' => '', + 'suffix' => '', + 'socks5Proxy' => '', + 'socks5NetWork' => '', + 'endpointType' => '', + 'openPlatformEndpoint' => '', + 'type' => '', + 'signatureVersion' => '', + 'signatureAlgorithm' => '', + 'key' => '', + 'cert' => '', + 'ca' => '', + 'tlsMinVersion' => '', + ]; + public function validate() {} + public function toMap() + { + $res = []; + if (null !== $this->accessKeyId) { + $res['accessKeyId'] = $this->accessKeyId; + } + if (null !== $this->accessKeySecret) { + $res['accessKeySecret'] = $this->accessKeySecret; + } + if (null !== $this->securityToken) { + $res['securityToken'] = $this->securityToken; + } + if (null !== $this->bearerToken) { + $res['bearerToken'] = $this->bearerToken; + } + if (null !== $this->protocol) { + $res['protocol'] = $this->protocol; + } + if (null !== $this->method) { + $res['method'] = $this->method; + } + if (null !== $this->regionId) { + $res['regionId'] = $this->regionId; + } + if (null !== $this->readTimeout) { + $res['readTimeout'] = $this->readTimeout; + } + if (null !== $this->connectTimeout) { + $res['connectTimeout'] = $this->connectTimeout; + } + if (null !== $this->httpProxy) { + $res['httpProxy'] = $this->httpProxy; + } + if (null !== $this->httpsProxy) { + $res['httpsProxy'] = $this->httpsProxy; + } + if (null !== $this->credential) { + $res['credential'] = null !== $this->credential ? $this->credential->toMap() : null; + } + if (null !== $this->endpoint) { + $res['endpoint'] = $this->endpoint; + } + if (null !== $this->noProxy) { + $res['noProxy'] = $this->noProxy; + } + if (null !== $this->maxIdleConns) { + $res['maxIdleConns'] = $this->maxIdleConns; + } + if (null !== $this->network) { + $res['network'] = $this->network; + } + if (null !== $this->userAgent) { + $res['userAgent'] = $this->userAgent; + } + if (null !== $this->suffix) { + $res['suffix'] = $this->suffix; + } + if (null !== $this->socks5Proxy) { + $res['socks5Proxy'] = $this->socks5Proxy; + } + if (null !== $this->socks5NetWork) { + $res['socks5NetWork'] = $this->socks5NetWork; + } + if (null !== $this->endpointType) { + $res['endpointType'] = $this->endpointType; + } + if (null !== $this->openPlatformEndpoint) { + $res['openPlatformEndpoint'] = $this->openPlatformEndpoint; + } + if (null !== $this->type) { + $res['type'] = $this->type; + } + if (null !== $this->signatureVersion) { + $res['signatureVersion'] = $this->signatureVersion; + } + if (null !== $this->signatureAlgorithm) { + $res['signatureAlgorithm'] = $this->signatureAlgorithm; + } + if (null !== $this->globalParameters) { + $res['globalParameters'] = null !== $this->globalParameters ? $this->globalParameters->toMap() : null; + } + if (null !== $this->key) { + $res['key'] = $this->key; + } + if (null !== $this->cert) { + $res['cert'] = $this->cert; + } + if (null !== $this->ca) { + $res['ca'] = $this->ca; + } + if (null !== $this->disableHttp2) { + $res['disableHttp2'] = $this->disableHttp2; + } + if (null !== $this->tlsMinVersion) { + $res['tlsMinVersion'] = $this->tlsMinVersion; + } + return $res; + } + /** + * @param array $map + * @return Config + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['accessKeyId'])) { + $model->accessKeyId = $map['accessKeyId']; + } + if (isset($map['accessKeySecret'])) { + $model->accessKeySecret = $map['accessKeySecret']; + } + if (isset($map['securityToken'])) { + $model->securityToken = $map['securityToken']; + } + if (isset($map['bearerToken'])) { + $model->bearerToken = $map['bearerToken']; + } + if (isset($map['protocol'])) { + $model->protocol = $map['protocol']; + } + if (isset($map['method'])) { + $model->method = $map['method']; + } + if (isset($map['regionId'])) { + $model->regionId = $map['regionId']; + } + if (isset($map['readTimeout'])) { + $model->readTimeout = $map['readTimeout']; + } + if (isset($map['connectTimeout'])) { + $model->connectTimeout = $map['connectTimeout']; + } + if (isset($map['httpProxy'])) { + $model->httpProxy = $map['httpProxy']; + } + if (isset($map['httpsProxy'])) { + $model->httpsProxy = $map['httpsProxy']; + } + if (isset($map['credential'])) { + $model->credential = Credential::fromMap($map['credential']); + } + if (isset($map['endpoint'])) { + $model->endpoint = $map['endpoint']; + } + if (isset($map['noProxy'])) { + $model->noProxy = $map['noProxy']; + } + if (isset($map['maxIdleConns'])) { + $model->maxIdleConns = $map['maxIdleConns']; + } + if (isset($map['network'])) { + $model->network = $map['network']; + } + if (isset($map['userAgent'])) { + $model->userAgent = $map['userAgent']; + } + if (isset($map['suffix'])) { + $model->suffix = $map['suffix']; + } + if (isset($map['socks5Proxy'])) { + $model->socks5Proxy = $map['socks5Proxy']; + } + if (isset($map['socks5NetWork'])) { + $model->socks5NetWork = $map['socks5NetWork']; + } + if (isset($map['endpointType'])) { + $model->endpointType = $map['endpointType']; + } + if (isset($map['openPlatformEndpoint'])) { + $model->openPlatformEndpoint = $map['openPlatformEndpoint']; + } + if (isset($map['type'])) { + $model->type = $map['type']; + } + if (isset($map['signatureVersion'])) { + $model->signatureVersion = $map['signatureVersion']; + } + if (isset($map['signatureAlgorithm'])) { + $model->signatureAlgorithm = $map['signatureAlgorithm']; + } + if (isset($map['globalParameters'])) { + $model->globalParameters = GlobalParameters::fromMap($map['globalParameters']); + } + if (isset($map['key'])) { + $model->key = $map['key']; + } + if (isset($map['cert'])) { + $model->cert = $map['cert']; + } + if (isset($map['ca'])) { + $model->ca = $map['ca']; + } + if (isset($map['disableHttp2'])) { + $model->disableHttp2 = $map['disableHttp2']; + } + if (isset($map['tlsMinVersion'])) { + $model->tlsMinVersion = $map['tlsMinVersion']; + } + return $model; + } + /** + * @description accesskey id + * @var string + */ + public $accessKeyId; + + /** + * @description accesskey secret + * @var string + */ + public $accessKeySecret; + + /** + * @description security token + * @example a.txt + * @var string + */ + public $securityToken; + + /** + * @description bearer token + * @example the-bearer-token + * @var string + */ + public $bearerToken; + + /** + * @description http protocol + * @example http + * @var string + */ + public $protocol; + + /** + * @description http method + * @example GET + * @var string + */ + public $method; + + /** + * @description region id + * @example cn-hangzhou + * @var string + */ + public $regionId; + + /** + * @description read timeout + * @example 10 + * @var int + */ + public $readTimeout; + + /** + * @description connect timeout + * @example 10 + * @var int + */ + public $connectTimeout; + + /** + * @description http proxy + * @example http://localhost + * @var string + */ + public $httpProxy; + + /** + * @description https proxy + * @example https://localhost + * @var string + */ + public $httpsProxy; + + /** + * @description credential + * @example + * @var Credential + */ + public $credential; + + /** + * @description endpoint + * @example cs.aliyuncs.com + * @var string + */ + public $endpoint; + + /** + * @description proxy white list + * @example http://localhost + * @var string + */ + public $noProxy; + + /** + * @description max idle conns + * @example 3 + * @var int + */ + public $maxIdleConns; + + /** + * @description network for endpoint + * @example public + * @var string + */ + public $network; + + /** + * @description user agent + * @example Alibabacloud/1 + * @var string + */ + public $userAgent; + + /** + * @description suffix for endpoint + * @example aliyun + * @var string + */ + public $suffix; + + /** + * @description socks5 proxy + * @var string + */ + public $socks5Proxy; + + /** + * @description socks5 network + * @example TCP + * @var string + */ + public $socks5NetWork; + + /** + * @description endpoint type + * @example internal + * @var string + */ + public $endpointType; + + /** + * @description OpenPlatform endpoint + * @example openplatform.aliyuncs.com + * @var string + */ + public $openPlatformEndpoint; + + /** + * @description credential type + * @example access_key + * @deprecated + * @var string + */ + public $type; + + /** + * @description Signature Version + * @example v1 + * @var string + */ + public $signatureVersion; + + /** + * @description Signature Algorithm + * @example ACS3-HMAC-SHA256 + * @var string + */ + public $signatureAlgorithm; + + /** + * @description Global Parameters + * @var GlobalParameters + */ + public $globalParameters; + + /** + * @description privite key for client certificate + * @example MIIEvQ + * @var string + */ + public $key; + + /** + * @description client certificate + * @example -----BEGIN CERTIFICATE----- +xxx-----END CERTIFICATE----- + * @var string + */ + public $cert; + + /** + * @description server certificate + * @example -----BEGIN CERTIFICATE----- +xxx-----END CERTIFICATE----- + * @var string + */ + public $ca; + + /** + * @description disable HTTP/2 + * @example false + * @var bool + */ + public $disableHttp2; + + /** + * @description TLS Minimum Version + * @example TLSv1, TLSv1.1, TLSv1.2, TLSv1.3 + * @var string + */ + public $tlsMinVersion; +} diff --git a/vendor/vendor/alibabacloud/darabonba-openapi/src/Models/GlobalParameters.php b/vendor/vendor/alibabacloud/darabonba-openapi/src/Models/GlobalParameters.php new file mode 100644 index 0000000..d0d5fa3 --- /dev/null +++ b/vendor/vendor/alibabacloud/darabonba-openapi/src/Models/GlobalParameters.php @@ -0,0 +1,40 @@ +headers) { + $res['headers'] = $this->headers; + } + if (null !== $this->queries) { + $res['queries'] = $this->queries; + } + return $res; + } + /** + * @param array $map + * @return GlobalParameters + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['headers'])) { + $model->headers = $map['headers']; + } + if (isset($map['queries'])) { + $model->queries = $map['queries']; + } + return $model; + } + public $headers; + + public $queries; +} diff --git a/vendor/vendor/alibabacloud/darabonba-openapi/src/Models/OpenApiRequest.php b/vendor/vendor/alibabacloud/darabonba-openapi/src/Models/OpenApiRequest.php new file mode 100644 index 0000000..5ffe1bb --- /dev/null +++ b/vendor/vendor/alibabacloud/darabonba-openapi/src/Models/OpenApiRequest.php @@ -0,0 +1,72 @@ +headers) { + $res['headers'] = $this->headers; + } + if (null !== $this->query) { + $res['query'] = $this->query; + } + if (null !== $this->body) { + $res['body'] = $this->body; + } + if (null !== $this->stream) { + $res['stream'] = $this->stream; + } + if (null !== $this->hostMap) { + $res['hostMap'] = $this->hostMap; + } + if (null !== $this->endpointOverride) { + $res['endpointOverride'] = $this->endpointOverride; + } + return $res; + } + /** + * @param array $map + * @return OpenApiRequest + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['headers'])) { + $model->headers = $map['headers']; + } + if (isset($map['query'])) { + $model->query = $map['query']; + } + if (isset($map['body'])) { + $model->body = $map['body']; + } + if (isset($map['stream'])) { + $model->stream = $map['stream']; + } + if (isset($map['hostMap'])) { + $model->hostMap = $map['hostMap']; + } + if (isset($map['endpointOverride'])) { + $model->endpointOverride = $map['endpointOverride']; + } + return $model; + } + public $headers; + + public $query; + + public $body; + + public $stream; + + public $hostMap; + + public $endpointOverride; +} diff --git a/vendor/vendor/alibabacloud/darabonba-openapi/src/Models/Params.php b/vendor/vendor/alibabacloud/darabonba-openapi/src/Models/Params.php new file mode 100644 index 0000000..3838659 --- /dev/null +++ b/vendor/vendor/alibabacloud/darabonba-openapi/src/Models/Params.php @@ -0,0 +1,130 @@ +action, true); + Model::validateRequired('version', $this->version, true); + Model::validateRequired('protocol', $this->protocol, true); + Model::validateRequired('pathname', $this->pathname, true); + Model::validateRequired('method', $this->method, true); + Model::validateRequired('authType', $this->authType, true); + Model::validateRequired('bodyType', $this->bodyType, true); + Model::validateRequired('reqBodyType', $this->reqBodyType, true); + } + public function toMap() + { + $res = []; + if (null !== $this->action) { + $res['action'] = $this->action; + } + if (null !== $this->version) { + $res['version'] = $this->version; + } + if (null !== $this->protocol) { + $res['protocol'] = $this->protocol; + } + if (null !== $this->pathname) { + $res['pathname'] = $this->pathname; + } + if (null !== $this->method) { + $res['method'] = $this->method; + } + if (null !== $this->authType) { + $res['authType'] = $this->authType; + } + if (null !== $this->bodyType) { + $res['bodyType'] = $this->bodyType; + } + if (null !== $this->reqBodyType) { + $res['reqBodyType'] = $this->reqBodyType; + } + if (null !== $this->style) { + $res['style'] = $this->style; + } + return $res; + } + /** + * @param array $map + * @return Params + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['action'])) { + $model->action = $map['action']; + } + if (isset($map['version'])) { + $model->version = $map['version']; + } + if (isset($map['protocol'])) { + $model->protocol = $map['protocol']; + } + if (isset($map['pathname'])) { + $model->pathname = $map['pathname']; + } + if (isset($map['method'])) { + $model->method = $map['method']; + } + if (isset($map['authType'])) { + $model->authType = $map['authType']; + } + if (isset($map['bodyType'])) { + $model->bodyType = $map['bodyType']; + } + if (isset($map['reqBodyType'])) { + $model->reqBodyType = $map['reqBodyType']; + } + if (isset($map['style'])) { + $model->style = $map['style']; + } + return $model; + } + /** + * @var string + */ + public $action; + + /** + * @var string + */ + public $version; + + /** + * @var string + */ + public $protocol; + + /** + * @var string + */ + public $pathname; + + /** + * @var string + */ + public $method; + + /** + * @var string + */ + public $authType; + + /** + * @var string + */ + public $bodyType; + + /** + * @var string + */ + public $reqBodyType; + + public $style; +} diff --git a/vendor/vendor/alibabacloud/darabonba-openapi/src/OpenApiClient.php b/vendor/vendor/alibabacloud/darabonba-openapi/src/OpenApiClient.php new file mode 100644 index 0000000..cfab565 --- /dev/null +++ b/vendor/vendor/alibabacloud/darabonba-openapi/src/OpenApiClient.php @@ -0,0 +1,1345 @@ + "ParameterMissing", + "message" => "'config' can not be unset" + ]); + } + if (!Utils::empty_($config->accessKeyId) && !Utils::empty_($config->accessKeySecret)) { + if (!Utils::empty_($config->securityToken)) { + $config->type = "sts"; + } else { + $config->type = "access_key"; + } + $credentialConfig = new Config([ + "accessKeyId" => $config->accessKeyId, + "type" => $config->type, + "accessKeySecret" => $config->accessKeySecret + ]); + $credentialConfig->securityToken = $config->securityToken; + $this->_credential = new Credential($credentialConfig); + } else if (!Utils::empty_($config->bearerToken)) { + $cc = new Config([ + "type" => "bearer", + "bearerToken" => $config->bearerToken + ]); + $this->_credential = new Credential($cc); + } else if (!Utils::isUnset($config->credential)) { + $this->_credential = $config->credential; + } + $this->_endpoint = $config->endpoint; + $this->_endpointType = $config->endpointType; + $this->_network = $config->network; + $this->_suffix = $config->suffix; + $this->_protocol = $config->protocol; + $this->_method = $config->method; + $this->_regionId = $config->regionId; + $this->_userAgent = $config->userAgent; + $this->_readTimeout = $config->readTimeout; + $this->_connectTimeout = $config->connectTimeout; + $this->_httpProxy = $config->httpProxy; + $this->_httpsProxy = $config->httpsProxy; + $this->_noProxy = $config->noProxy; + $this->_socks5Proxy = $config->socks5Proxy; + $this->_socks5NetWork = $config->socks5NetWork; + $this->_maxIdleConns = $config->maxIdleConns; + $this->_signatureVersion = $config->signatureVersion; + $this->_signatureAlgorithm = $config->signatureAlgorithm; + $this->_globalParameters = $config->globalParameters; + $this->_key = $config->key; + $this->_cert = $config->cert; + $this->_ca = $config->ca; + $this->_disableHttp2 = $config->disableHttp2; + $this->_tlsMinVersion = $config->tlsMinVersion; + } + + /** + * Encapsulate the request and invoke the network + * @param string $action api name + * @param string $version product version + * @param string $protocol http or https + * @param string $method e.g. GET + * @param string $authType authorization type e.g. AK + * @param string $bodyType response body type e.g. String + * @param OpenApiRequest $request object of OpenApiRequest + * @param RuntimeOptions $runtime which controls some details of call api, such as retry times + * @return array the response + * @throws TeaError + * @throws Exception + * @throws TeaUnableRetryError + */ + public function doRPCRequest($action, $version, $protocol, $method, $authType, $bodyType, $request, $runtime) + { + $request->validate(); + $runtime->validate(); + $_runtime = [ + "timeouted" => "retry", + "key" => Utils::defaultString($runtime->key, $this->_key), + "cert" => Utils::defaultString($runtime->cert, $this->_cert), + "ca" => Utils::defaultString($runtime->ca, $this->_ca), + "readTimeout" => Utils::defaultNumber($runtime->readTimeout, $this->_readTimeout), + "connectTimeout" => Utils::defaultNumber($runtime->connectTimeout, $this->_connectTimeout), + "httpProxy" => Utils::defaultString($runtime->httpProxy, $this->_httpProxy), + "httpsProxy" => Utils::defaultString($runtime->httpsProxy, $this->_httpsProxy), + "noProxy" => Utils::defaultString($runtime->noProxy, $this->_noProxy), + "socks5Proxy" => Utils::defaultString($runtime->socks5Proxy, $this->_socks5Proxy), + "socks5NetWork" => Utils::defaultString($runtime->socks5NetWork, $this->_socks5NetWork), + "maxIdleConns" => Utils::defaultNumber($runtime->maxIdleConns, $this->_maxIdleConns), + "retry" => [ + "retryable" => $runtime->autoretry, + "maxAttempts" => Utils::defaultNumber($runtime->maxAttempts, 3) + ], + "backoff" => [ + "policy" => Utils::defaultString($runtime->backoffPolicy, "no"), + "period" => Utils::defaultNumber($runtime->backoffPeriod, 1) + ], + "ignoreSSL" => $runtime->ignoreSSL, + "tlsMinVersion" => $this->_tlsMinVersion + ]; + $_lastRequest = null; + $_lastException = null; + $_now = time(); + $_retryTimes = 0; + while (Tea::allowRetry(@$_runtime["retry"], $_retryTimes, $_now)) { + if ($_retryTimes > 0) { + $_backoffTime = Tea::getBackoffTime(@$_runtime["backoff"], $_retryTimes); + if ($_backoffTime > 0) { + Tea::sleep($_backoffTime); + } + } + $_retryTimes = $_retryTimes + 1; + try { + $_request = new Request(); + $_request->protocol = Utils::defaultString($this->_protocol, $protocol); + $_request->method = $method; + $_request->pathname = "/"; + $globalQueries = []; + $globalHeaders = []; + if (!Utils::isUnset($this->_globalParameters)) { + $globalParams = $this->_globalParameters; + if (!Utils::isUnset($globalParams->queries)) { + $globalQueries = $globalParams->queries; + } + if (!Utils::isUnset($globalParams->headers)) { + $globalHeaders = $globalParams->headers; + } + } + $extendsHeaders = []; + $extendsQueries = []; + if (!Utils::isUnset($runtime->extendsParameters)) { + $extendsParameters = $runtime->extendsParameters; + if (!Utils::isUnset($extendsParameters->headers)) { + $extendsHeaders = $extendsParameters->headers; + } + if (!Utils::isUnset($extendsParameters->queries)) { + $extendsQueries = $extendsParameters->queries; + } + } + $_request->query = Tea::merge([ + "Action" => $action, + "Format" => "json", + "Version" => $version, + "Timestamp" => OpenApiUtilClient::getTimestamp(), + "SignatureNonce" => Utils::getNonce() + ], $globalQueries, $extendsQueries, $request->query); + $headers = $this->getRpcHeaders(); + if (Utils::isUnset($headers)) { + // endpoint is setted in product client + $_request->headers = Tea::merge([ + "host" => $this->_endpoint, + "x-acs-version" => $version, + "x-acs-action" => $action, + "user-agent" => $this->getUserAgent() + ], $globalHeaders, $extendsHeaders, $request->headers); + } else { + $_request->headers = Tea::merge([ + "host" => $this->_endpoint, + "x-acs-version" => $version, + "x-acs-action" => $action, + "user-agent" => $this->getUserAgent() + ], $globalHeaders, $extendsHeaders, $request->headers, $headers); + } + if (!Utils::isUnset($request->body)) { + $m = Utils::assertAsMap($request->body); + $tmp = Utils::anyifyMapValue(OpenApiUtilClient::query($m)); + $_request->body = Utils::toFormString($tmp); + $_request->headers["content-type"] = "application/x-www-form-urlencoded"; + } + if (!Utils::equalString($authType, "Anonymous")) { + if (Utils::isUnset($this->_credential)) { + throw new TeaError([ + "code" => "InvalidCredentials", + "message" => "Please set up the credentials correctly. If you are setting them through environment variables, please ensure that ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET are set correctly. See https://help.aliyun.com/zh/sdk/developer-reference/configure-the-alibaba-cloud-accesskey-environment-variable-on-linux-macos-and-windows-systems for more details." + ]); + } + $credentialModel = $this->_credential->getCredential(); + if (!Utils::empty_($credentialModel->providerName)) { + $_request->headers["x-acs-credentials-provider"] = $credentialModel->providerName; + } + $credentialType = $credentialModel->type; + if (Utils::equalString($credentialType, "bearer")) { + $bearerToken = $credentialModel->bearerToken; + $_request->query["BearerToken"] = $bearerToken; + $_request->query["SignatureType"] = "BEARERTOKEN"; + } else if (Utils::equalString($credentialType, "id_token")) { + $idToken = $credentialModel->securityToken; + $_request->headers["x-acs-zero-trust-idtoken"] = $idToken; + } else { + $accessKeyId = $credentialModel->accessKeyId; + $accessKeySecret = $credentialModel->accessKeySecret; + $securityToken = $credentialModel->securityToken; + if (!Utils::empty_($securityToken)) { + $_request->query["SecurityToken"] = $securityToken; + } + $_request->query["SignatureMethod"] = "HMAC-SHA1"; + $_request->query["SignatureVersion"] = "1.0"; + $_request->query["AccessKeyId"] = $accessKeyId; + $t = null; + if (!Utils::isUnset($request->body)) { + $t = Utils::assertAsMap($request->body); + } + $signedParam = Tea::merge($_request->query, OpenApiUtilClient::query($t)); + $_request->query["Signature"] = OpenApiUtilClient::getRPCSignature($signedParam, $_request->method, $accessKeySecret); + } + } + $_lastRequest = $_request; + $_response = Tea::send($_request, $_runtime); + if (Utils::is4xx($_response->statusCode) || Utils::is5xx($_response->statusCode)) { + $_res = Utils::readAsJSON($_response->body); + $err = Utils::assertAsMap($_res); + $requestId = self::defaultAny(@$err["RequestId"], @$err["requestId"]); + @$err["statusCode"] = $_response->statusCode; + throw new TeaError([ + "code" => "" . (string) (self::defaultAny(@$err["Code"], @$err["code"])) . "", + "message" => "code: " . (string) ($_response->statusCode) . ", " . (string) (self::defaultAny(@$err["Message"], @$err["message"])) . " request id: " . (string) ($requestId) . "", + "data" => $err, + "description" => "" . (string) (self::defaultAny(@$err["Description"], @$err["description"])) . "", + "accessDeniedDetail" => self::defaultAny(@$err["AccessDeniedDetail"], @$err["accessDeniedDetail"]) + ]); + } + if (Utils::equalString($bodyType, "binary")) { + $resp = [ + "body" => $_response->body, + "headers" => $_response->headers, + "statusCode" => $_response->statusCode + ]; + return $resp; + } else if (Utils::equalString($bodyType, "byte")) { + $byt = Utils::readAsBytes($_response->body); + return [ + "body" => $byt, + "headers" => $_response->headers, + "statusCode" => $_response->statusCode + ]; + } else if (Utils::equalString($bodyType, "string")) { + $str = Utils::readAsString($_response->body); + return [ + "body" => $str, + "headers" => $_response->headers, + "statusCode" => $_response->statusCode + ]; + } else if (Utils::equalString($bodyType, "json")) { + $obj = Utils::readAsJSON($_response->body); + $res = Utils::assertAsMap($obj); + return [ + "body" => $res, + "headers" => $_response->headers, + "statusCode" => $_response->statusCode + ]; + } else if (Utils::equalString($bodyType, "array")) { + $arr = Utils::readAsJSON($_response->body); + return [ + "body" => $arr, + "headers" => $_response->headers, + "statusCode" => $_response->statusCode + ]; + } else { + return [ + "headers" => $_response->headers, + "statusCode" => $_response->statusCode + ]; + } + } catch (Exception $e) { + if (!($e instanceof TeaError)) { + $e = new TeaError([], $e->getMessage(), $e->getCode(), $e); + } + if (Tea::isRetryable($e)) { + $_lastException = $e; + continue; + } + throw $e; + } + } + throw new TeaUnableRetryError($_lastRequest, $_lastException); + } + + /** + * Encapsulate the request and invoke the network + * @param string $action api name + * @param string $version product version + * @param string $protocol http or https + * @param string $method e.g. GET + * @param string $authType authorization type e.g. AK + * @param string $pathname pathname of every api + * @param string $bodyType response body type e.g. String + * @param OpenApiRequest $request object of OpenApiRequest + * @param RuntimeOptions $runtime which controls some details of call api, such as retry times + * @return array the response + * @throws TeaError + * @throws Exception + * @throws TeaUnableRetryError + */ + public function doROARequest($action, $version, $protocol, $method, $authType, $pathname, $bodyType, $request, $runtime) + { + $request->validate(); + $runtime->validate(); + $_runtime = [ + "timeouted" => "retry", + "key" => Utils::defaultString($runtime->key, $this->_key), + "cert" => Utils::defaultString($runtime->cert, $this->_cert), + "ca" => Utils::defaultString($runtime->ca, $this->_ca), + "readTimeout" => Utils::defaultNumber($runtime->readTimeout, $this->_readTimeout), + "connectTimeout" => Utils::defaultNumber($runtime->connectTimeout, $this->_connectTimeout), + "httpProxy" => Utils::defaultString($runtime->httpProxy, $this->_httpProxy), + "httpsProxy" => Utils::defaultString($runtime->httpsProxy, $this->_httpsProxy), + "noProxy" => Utils::defaultString($runtime->noProxy, $this->_noProxy), + "socks5Proxy" => Utils::defaultString($runtime->socks5Proxy, $this->_socks5Proxy), + "socks5NetWork" => Utils::defaultString($runtime->socks5NetWork, $this->_socks5NetWork), + "maxIdleConns" => Utils::defaultNumber($runtime->maxIdleConns, $this->_maxIdleConns), + "retry" => [ + "retryable" => $runtime->autoretry, + "maxAttempts" => Utils::defaultNumber($runtime->maxAttempts, 3) + ], + "backoff" => [ + "policy" => Utils::defaultString($runtime->backoffPolicy, "no"), + "period" => Utils::defaultNumber($runtime->backoffPeriod, 1) + ], + "ignoreSSL" => $runtime->ignoreSSL, + "tlsMinVersion" => $this->_tlsMinVersion + ]; + $_lastRequest = null; + $_lastException = null; + $_now = time(); + $_retryTimes = 0; + while (Tea::allowRetry(@$_runtime["retry"], $_retryTimes, $_now)) { + if ($_retryTimes > 0) { + $_backoffTime = Tea::getBackoffTime(@$_runtime["backoff"], $_retryTimes); + if ($_backoffTime > 0) { + Tea::sleep($_backoffTime); + } + } + $_retryTimes = $_retryTimes + 1; + try { + $_request = new Request(); + $_request->protocol = Utils::defaultString($this->_protocol, $protocol); + $_request->method = $method; + $_request->pathname = $pathname; + $globalQueries = []; + $globalHeaders = []; + if (!Utils::isUnset($this->_globalParameters)) { + $globalParams = $this->_globalParameters; + if (!Utils::isUnset($globalParams->queries)) { + $globalQueries = $globalParams->queries; + } + if (!Utils::isUnset($globalParams->headers)) { + $globalHeaders = $globalParams->headers; + } + } + $extendsHeaders = []; + $extendsQueries = []; + if (!Utils::isUnset($runtime->extendsParameters)) { + $extendsParameters = $runtime->extendsParameters; + if (!Utils::isUnset($extendsParameters->headers)) { + $extendsHeaders = $extendsParameters->headers; + } + if (!Utils::isUnset($extendsParameters->queries)) { + $extendsQueries = $extendsParameters->queries; + } + } + $_request->headers = Tea::merge([ + "date" => Utils::getDateUTCString(), + "host" => $this->_endpoint, + "accept" => "application/json", + "x-acs-signature-nonce" => Utils::getNonce(), + "x-acs-signature-method" => "HMAC-SHA1", + "x-acs-signature-version" => "1.0", + "x-acs-version" => $version, + "x-acs-action" => $action, + "user-agent" => Utils::getUserAgent($this->_userAgent) + ], $globalHeaders, $extendsHeaders, $request->headers); + if (!Utils::isUnset($request->body)) { + $_request->body = Utils::toJSONString($request->body); + $_request->headers["content-type"] = "application/json; charset=utf-8"; + } + $_request->query = Tea::merge($globalQueries, $extendsQueries); + if (!Utils::isUnset($request->query)) { + $_request->query = Tea::merge($_request->query, $request->query); + } + if (!Utils::equalString($authType, "Anonymous")) { + if (Utils::isUnset($this->_credential)) { + throw new TeaError([ + "code" => "InvalidCredentials", + "message" => "Please set up the credentials correctly. If you are setting them through environment variables, please ensure that ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET are set correctly. See https://help.aliyun.com/zh/sdk/developer-reference/configure-the-alibaba-cloud-accesskey-environment-variable-on-linux-macos-and-windows-systems for more details." + ]); + } + $credentialModel = $this->_credential->getCredential(); + if (!Utils::empty_($credentialModel->providerName)) { + $_request->headers["x-acs-credentials-provider"] = $credentialModel->providerName; + } + $credentialType = $credentialModel->type; + if (Utils::equalString($credentialType, "bearer")) { + $bearerToken = $credentialModel->bearerToken; + $_request->headers["x-acs-bearer-token"] = $bearerToken; + $_request->headers["x-acs-signature-type"] = "BEARERTOKEN"; + } else if (Utils::equalString($credentialType, "id_token")) { + $idToken = $credentialModel->securityToken; + $_request->headers["x-acs-zero-trust-idtoken"] = $idToken; + } else { + $accessKeyId = $credentialModel->accessKeyId; + $accessKeySecret = $credentialModel->accessKeySecret; + $securityToken = $credentialModel->securityToken; + if (!Utils::empty_($securityToken)) { + $_request->headers["x-acs-accesskey-id"] = $accessKeyId; + $_request->headers["x-acs-security-token"] = $securityToken; + } + $stringToSign = OpenApiUtilClient::getStringToSign($_request); + $_request->headers["authorization"] = "acs " . $accessKeyId . ":" . OpenApiUtilClient::getROASignature($stringToSign, $accessKeySecret) . ""; + } + } + $_lastRequest = $_request; + $_response = Tea::send($_request, $_runtime); + if (Utils::equalNumber($_response->statusCode, 204)) { + return [ + "headers" => $_response->headers + ]; + } + if (Utils::is4xx($_response->statusCode) || Utils::is5xx($_response->statusCode)) { + $_res = Utils::readAsJSON($_response->body); + $err = Utils::assertAsMap($_res); + $requestId = self::defaultAny(@$err["RequestId"], @$err["requestId"]); + $requestId = self::defaultAny($requestId, @$err["requestid"]); + @$err["statusCode"] = $_response->statusCode; + throw new TeaError([ + "code" => "" . (string) (self::defaultAny(@$err["Code"], @$err["code"])) . "", + "message" => "code: " . (string) ($_response->statusCode) . ", " . (string) (self::defaultAny(@$err["Message"], @$err["message"])) . " request id: " . (string) ($requestId) . "", + "data" => $err, + "description" => "" . (string) (self::defaultAny(@$err["Description"], @$err["description"])) . "", + "accessDeniedDetail" => self::defaultAny(@$err["AccessDeniedDetail"], @$err["accessDeniedDetail"]) + ]); + } + if (Utils::equalString($bodyType, "binary")) { + $resp = [ + "body" => $_response->body, + "headers" => $_response->headers, + "statusCode" => $_response->statusCode + ]; + return $resp; + } else if (Utils::equalString($bodyType, "byte")) { + $byt = Utils::readAsBytes($_response->body); + return [ + "body" => $byt, + "headers" => $_response->headers, + "statusCode" => $_response->statusCode + ]; + } else if (Utils::equalString($bodyType, "string")) { + $str = Utils::readAsString($_response->body); + return [ + "body" => $str, + "headers" => $_response->headers, + "statusCode" => $_response->statusCode + ]; + } else if (Utils::equalString($bodyType, "json")) { + $obj = Utils::readAsJSON($_response->body); + $res = Utils::assertAsMap($obj); + return [ + "body" => $res, + "headers" => $_response->headers, + "statusCode" => $_response->statusCode + ]; + } else if (Utils::equalString($bodyType, "array")) { + $arr = Utils::readAsJSON($_response->body); + return [ + "body" => $arr, + "headers" => $_response->headers, + "statusCode" => $_response->statusCode + ]; + } else { + return [ + "headers" => $_response->headers, + "statusCode" => $_response->statusCode + ]; + } + } catch (Exception $e) { + if (!($e instanceof TeaError)) { + $e = new TeaError([], $e->getMessage(), $e->getCode(), $e); + } + if (Tea::isRetryable($e)) { + $_lastException = $e; + continue; + } + throw $e; + } + } + throw new TeaUnableRetryError($_lastRequest, $_lastException); + } + + /** + * Encapsulate the request and invoke the network with form body + * @param string $action api name + * @param string $version product version + * @param string $protocol http or https + * @param string $method e.g. GET + * @param string $authType authorization type e.g. AK + * @param string $pathname pathname of every api + * @param string $bodyType response body type e.g. String + * @param OpenApiRequest $request object of OpenApiRequest + * @param RuntimeOptions $runtime which controls some details of call api, such as retry times + * @return array the response + * @throws TeaError + * @throws Exception + * @throws TeaUnableRetryError + */ + public function doROARequestWithForm($action, $version, $protocol, $method, $authType, $pathname, $bodyType, $request, $runtime) + { + $request->validate(); + $runtime->validate(); + $_runtime = [ + "timeouted" => "retry", + "key" => Utils::defaultString($runtime->key, $this->_key), + "cert" => Utils::defaultString($runtime->cert, $this->_cert), + "ca" => Utils::defaultString($runtime->ca, $this->_ca), + "readTimeout" => Utils::defaultNumber($runtime->readTimeout, $this->_readTimeout), + "connectTimeout" => Utils::defaultNumber($runtime->connectTimeout, $this->_connectTimeout), + "httpProxy" => Utils::defaultString($runtime->httpProxy, $this->_httpProxy), + "httpsProxy" => Utils::defaultString($runtime->httpsProxy, $this->_httpsProxy), + "noProxy" => Utils::defaultString($runtime->noProxy, $this->_noProxy), + "socks5Proxy" => Utils::defaultString($runtime->socks5Proxy, $this->_socks5Proxy), + "socks5NetWork" => Utils::defaultString($runtime->socks5NetWork, $this->_socks5NetWork), + "maxIdleConns" => Utils::defaultNumber($runtime->maxIdleConns, $this->_maxIdleConns), + "retry" => [ + "retryable" => $runtime->autoretry, + "maxAttempts" => Utils::defaultNumber($runtime->maxAttempts, 3) + ], + "backoff" => [ + "policy" => Utils::defaultString($runtime->backoffPolicy, "no"), + "period" => Utils::defaultNumber($runtime->backoffPeriod, 1) + ], + "ignoreSSL" => $runtime->ignoreSSL, + "tlsMinVersion" => $this->_tlsMinVersion + ]; + $_lastRequest = null; + $_lastException = null; + $_now = time(); + $_retryTimes = 0; + while (Tea::allowRetry(@$_runtime["retry"], $_retryTimes, $_now)) { + if ($_retryTimes > 0) { + $_backoffTime = Tea::getBackoffTime(@$_runtime["backoff"], $_retryTimes); + if ($_backoffTime > 0) { + Tea::sleep($_backoffTime); + } + } + $_retryTimes = $_retryTimes + 1; + try { + $_request = new Request(); + $_request->protocol = Utils::defaultString($this->_protocol, $protocol); + $_request->method = $method; + $_request->pathname = $pathname; + $globalQueries = []; + $globalHeaders = []; + if (!Utils::isUnset($this->_globalParameters)) { + $globalParams = $this->_globalParameters; + if (!Utils::isUnset($globalParams->queries)) { + $globalQueries = $globalParams->queries; + } + if (!Utils::isUnset($globalParams->headers)) { + $globalHeaders = $globalParams->headers; + } + } + $extendsHeaders = []; + $extendsQueries = []; + if (!Utils::isUnset($runtime->extendsParameters)) { + $extendsParameters = $runtime->extendsParameters; + if (!Utils::isUnset($extendsParameters->headers)) { + $extendsHeaders = $extendsParameters->headers; + } + if (!Utils::isUnset($extendsParameters->queries)) { + $extendsQueries = $extendsParameters->queries; + } + } + $_request->headers = Tea::merge([ + "date" => Utils::getDateUTCString(), + "host" => $this->_endpoint, + "accept" => "application/json", + "x-acs-signature-nonce" => Utils::getNonce(), + "x-acs-signature-method" => "HMAC-SHA1", + "x-acs-signature-version" => "1.0", + "x-acs-version" => $version, + "x-acs-action" => $action, + "user-agent" => Utils::getUserAgent($this->_userAgent) + ], $globalHeaders, $extendsHeaders, $request->headers); + if (!Utils::isUnset($request->body)) { + $m = Utils::assertAsMap($request->body); + $_request->body = OpenApiUtilClient::toForm($m); + $_request->headers["content-type"] = "application/x-www-form-urlencoded"; + } + $_request->query = Tea::merge($globalQueries, $extendsQueries); + if (!Utils::isUnset($request->query)) { + $_request->query = Tea::merge($_request->query, $request->query); + } + if (!Utils::equalString($authType, "Anonymous")) { + if (Utils::isUnset($this->_credential)) { + throw new TeaError([ + "code" => "InvalidCredentials", + "message" => "Please set up the credentials correctly. If you are setting them through environment variables, please ensure that ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET are set correctly. See https://help.aliyun.com/zh/sdk/developer-reference/configure-the-alibaba-cloud-accesskey-environment-variable-on-linux-macos-and-windows-systems for more details." + ]); + } + $credentialModel = $this->_credential->getCredential(); + if (!Utils::empty_($credentialModel->providerName)) { + $_request->headers["x-acs-credentials-provider"] = $credentialModel->providerName; + } + $credentialType = $credentialModel->type; + if (Utils::equalString($credentialType, "bearer")) { + $bearerToken = $credentialModel->bearerToken; + $_request->headers["x-acs-bearer-token"] = $bearerToken; + $_request->headers["x-acs-signature-type"] = "BEARERTOKEN"; + } else if (Utils::equalString($credentialType, "id_token")) { + $idToken = $credentialModel->securityToken; + $_request->headers["x-acs-zero-trust-idtoken"] = $idToken; + } else { + $accessKeyId = $credentialModel->accessKeyId; + $accessKeySecret = $credentialModel->accessKeySecret; + $securityToken = $credentialModel->securityToken; + if (!Utils::empty_($securityToken)) { + $_request->headers["x-acs-accesskey-id"] = $accessKeyId; + $_request->headers["x-acs-security-token"] = $securityToken; + } + $stringToSign = OpenApiUtilClient::getStringToSign($_request); + $_request->headers["authorization"] = "acs " . $accessKeyId . ":" . OpenApiUtilClient::getROASignature($stringToSign, $accessKeySecret) . ""; + } + } + $_lastRequest = $_request; + $_response = Tea::send($_request, $_runtime); + if (Utils::equalNumber($_response->statusCode, 204)) { + return [ + "headers" => $_response->headers + ]; + } + if (Utils::is4xx($_response->statusCode) || Utils::is5xx($_response->statusCode)) { + $_res = Utils::readAsJSON($_response->body); + $err = Utils::assertAsMap($_res); + @$err["statusCode"] = $_response->statusCode; + throw new TeaError([ + "code" => "" . (string) (self::defaultAny(@$err["Code"], @$err["code"])) . "", + "message" => "code: " . (string) ($_response->statusCode) . ", " . (string) (self::defaultAny(@$err["Message"], @$err["message"])) . " request id: " . (string) (self::defaultAny(@$err["RequestId"], @$err["requestId"])) . "", + "data" => $err, + "description" => "" . (string) (self::defaultAny(@$err["Description"], @$err["description"])) . "", + "accessDeniedDetail" => self::defaultAny(@$err["AccessDeniedDetail"], @$err["accessDeniedDetail"]) + ]); + } + if (Utils::equalString($bodyType, "binary")) { + $resp = [ + "body" => $_response->body, + "headers" => $_response->headers, + "statusCode" => $_response->statusCode + ]; + return $resp; + } else if (Utils::equalString($bodyType, "byte")) { + $byt = Utils::readAsBytes($_response->body); + return [ + "body" => $byt, + "headers" => $_response->headers, + "statusCode" => $_response->statusCode + ]; + } else if (Utils::equalString($bodyType, "string")) { + $str = Utils::readAsString($_response->body); + return [ + "body" => $str, + "headers" => $_response->headers, + "statusCode" => $_response->statusCode + ]; + } else if (Utils::equalString($bodyType, "json")) { + $obj = Utils::readAsJSON($_response->body); + $res = Utils::assertAsMap($obj); + return [ + "body" => $res, + "headers" => $_response->headers, + "statusCode" => $_response->statusCode + ]; + } else if (Utils::equalString($bodyType, "array")) { + $arr = Utils::readAsJSON($_response->body); + return [ + "body" => $arr, + "headers" => $_response->headers, + "statusCode" => $_response->statusCode + ]; + } else { + return [ + "headers" => $_response->headers, + "statusCode" => $_response->statusCode + ]; + } + } catch (Exception $e) { + if (!($e instanceof TeaError)) { + $e = new TeaError([], $e->getMessage(), $e->getCode(), $e); + } + if (Tea::isRetryable($e)) { + $_lastException = $e; + continue; + } + throw $e; + } + } + throw new TeaUnableRetryError($_lastRequest, $_lastException); + } + + /** + * Encapsulate the request and invoke the network + * @param Params $params + * @param OpenApiRequest $request object of OpenApiRequest + * @param RuntimeOptions $runtime which controls some details of call api, such as retry times + * @return array the response + * @throws TeaError + * @throws Exception + * @throws TeaUnableRetryError + */ + public function doRequest($params, $request, $runtime) + { + $params->validate(); + $request->validate(); + $runtime->validate(); + $_runtime = [ + "timeouted" => "retry", + "key" => Utils::defaultString($runtime->key, $this->_key), + "cert" => Utils::defaultString($runtime->cert, $this->_cert), + "ca" => Utils::defaultString($runtime->ca, $this->_ca), + "readTimeout" => Utils::defaultNumber($runtime->readTimeout, $this->_readTimeout), + "connectTimeout" => Utils::defaultNumber($runtime->connectTimeout, $this->_connectTimeout), + "httpProxy" => Utils::defaultString($runtime->httpProxy, $this->_httpProxy), + "httpsProxy" => Utils::defaultString($runtime->httpsProxy, $this->_httpsProxy), + "noProxy" => Utils::defaultString($runtime->noProxy, $this->_noProxy), + "socks5Proxy" => Utils::defaultString($runtime->socks5Proxy, $this->_socks5Proxy), + "socks5NetWork" => Utils::defaultString($runtime->socks5NetWork, $this->_socks5NetWork), + "maxIdleConns" => Utils::defaultNumber($runtime->maxIdleConns, $this->_maxIdleConns), + "retry" => [ + "retryable" => $runtime->autoretry, + "maxAttempts" => Utils::defaultNumber($runtime->maxAttempts, 3) + ], + "backoff" => [ + "policy" => Utils::defaultString($runtime->backoffPolicy, "no"), + "period" => Utils::defaultNumber($runtime->backoffPeriod, 1) + ], + "ignoreSSL" => $runtime->ignoreSSL, + "tlsMinVersion" => $this->_tlsMinVersion + ]; + $_lastRequest = null; + $_lastException = null; + $_now = time(); + $_retryTimes = 0; + while (Tea::allowRetry(@$_runtime["retry"], $_retryTimes, $_now)) { + if ($_retryTimes > 0) { + $_backoffTime = Tea::getBackoffTime(@$_runtime["backoff"], $_retryTimes); + if ($_backoffTime > 0) { + Tea::sleep($_backoffTime); + } + } + $_retryTimes = $_retryTimes + 1; + try { + $_request = new Request(); + $_request->protocol = Utils::defaultString($this->_protocol, $params->protocol); + $_request->method = $params->method; + $_request->pathname = $params->pathname; + $globalQueries = []; + $globalHeaders = []; + if (!Utils::isUnset($this->_globalParameters)) { + $globalParams = $this->_globalParameters; + if (!Utils::isUnset($globalParams->queries)) { + $globalQueries = $globalParams->queries; + } + if (!Utils::isUnset($globalParams->headers)) { + $globalHeaders = $globalParams->headers; + } + } + $extendsHeaders = []; + $extendsQueries = []; + if (!Utils::isUnset($runtime->extendsParameters)) { + $extendsParameters = $runtime->extendsParameters; + if (!Utils::isUnset($extendsParameters->headers)) { + $extendsHeaders = $extendsParameters->headers; + } + if (!Utils::isUnset($extendsParameters->queries)) { + $extendsQueries = $extendsParameters->queries; + } + } + $_request->query = Tea::merge($globalQueries, $extendsQueries, $request->query); + // endpoint is setted in product client + $_request->headers = Tea::merge([ + "host" => $this->_endpoint, + "x-acs-version" => $params->version, + "x-acs-action" => $params->action, + "user-agent" => $this->getUserAgent(), + "x-acs-date" => OpenApiUtilClient::getTimestamp(), + "x-acs-signature-nonce" => Utils::getNonce(), + "accept" => "application/json" + ], $globalHeaders, $extendsHeaders, $request->headers); + if (Utils::equalString($params->style, "RPC")) { + $headers = $this->getRpcHeaders(); + if (!Utils::isUnset($headers)) { + $_request->headers = Tea::merge($_request->headers, $headers); + } + } + $signatureAlgorithm = Utils::defaultString($this->_signatureAlgorithm, "ACS3-HMAC-SHA256"); + $hashedRequestPayload = OpenApiUtilClient::hexEncode(OpenApiUtilClient::hash(Utils::toBytes(""), $signatureAlgorithm)); + if (!Utils::isUnset($request->stream)) { + $tmp = Utils::readAsBytes($request->stream); + $hashedRequestPayload = OpenApiUtilClient::hexEncode(OpenApiUtilClient::hash($tmp, $signatureAlgorithm)); + $_request->body = $tmp; + $_request->headers["content-type"] = "application/octet-stream"; + } else { + if (!Utils::isUnset($request->body)) { + if (Utils::equalString($params->reqBodyType, "byte")) { + $byteObj = Utils::assertAsBytes($request->body); + $hashedRequestPayload = OpenApiUtilClient::hexEncode(OpenApiUtilClient::hash($byteObj, $signatureAlgorithm)); + $_request->body = $byteObj; + } else if (Utils::equalString($params->reqBodyType, "json")) { + $jsonObj = Utils::toJSONString($request->body); + $hashedRequestPayload = OpenApiUtilClient::hexEncode(OpenApiUtilClient::hash(Utils::toBytes($jsonObj), $signatureAlgorithm)); + $_request->body = $jsonObj; + $_request->headers["content-type"] = "application/json; charset=utf-8"; + } else { + $m = Utils::assertAsMap($request->body); + $formObj = OpenApiUtilClient::toForm($m); + $hashedRequestPayload = OpenApiUtilClient::hexEncode(OpenApiUtilClient::hash(Utils::toBytes($formObj), $signatureAlgorithm)); + $_request->body = $formObj; + $_request->headers["content-type"] = "application/x-www-form-urlencoded"; + } + } + } + $_request->headers["x-acs-content-sha256"] = $hashedRequestPayload; + if (!Utils::equalString($params->authType, "Anonymous")) { + if (Utils::isUnset($this->_credential)) { + throw new TeaError([ + "code" => "InvalidCredentials", + "message" => "Please set up the credentials correctly. If you are setting them through environment variables, please ensure that ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET are set correctly. See https://help.aliyun.com/zh/sdk/developer-reference/configure-the-alibaba-cloud-accesskey-environment-variable-on-linux-macos-and-windows-systems for more details." + ]); + } + $credentialModel = $this->_credential->getCredential(); + if (!Utils::empty_($credentialModel->providerName)) { + $_request->headers["x-acs-credentials-provider"] = $credentialModel->providerName; + } + $authType = $credentialModel->type; + if (Utils::equalString($authType, "bearer")) { + $bearerToken = $credentialModel->bearerToken; + $_request->headers["x-acs-bearer-token"] = $bearerToken; + if (Utils::equalString($params->style, "RPC")) { + $_request->query["SignatureType"] = "BEARERTOKEN"; + } else { + $_request->headers["x-acs-signature-type"] = "BEARERTOKEN"; + } + } else if (Utils::equalString($authType, "id_token")) { + $idToken = $credentialModel->securityToken; + $_request->headers["x-acs-zero-trust-idtoken"] = $idToken; + } else { + $accessKeyId = $credentialModel->accessKeyId; + $accessKeySecret = $credentialModel->accessKeySecret; + $securityToken = $credentialModel->securityToken; + if (!Utils::empty_($securityToken)) { + $_request->headers["x-acs-accesskey-id"] = $accessKeyId; + $_request->headers["x-acs-security-token"] = $securityToken; + } + $_request->headers["Authorization"] = OpenApiUtilClient::getAuthorization($_request, $signatureAlgorithm, $hashedRequestPayload, $accessKeyId, $accessKeySecret); + } + } + $_lastRequest = $_request; + $_response = Tea::send($_request, $_runtime); + if (Utils::is4xx($_response->statusCode) || Utils::is5xx($_response->statusCode)) { + $err = []; + if (!Utils::isUnset(@$_response->headers["content-type"]) && Utils::equalString(@$_response->headers["content-type"], "text/xml;charset=utf-8")) { + $_str = Utils::readAsString($_response->body); + $respMap = XML::parseXml($_str, null); + $err = Utils::assertAsMap(@$respMap["Error"]); + } else { + $_res = Utils::readAsJSON($_response->body); + $err = Utils::assertAsMap($_res); + } + @$err["statusCode"] = $_response->statusCode; + throw new TeaError([ + "code" => "" . (string) (self::defaultAny(@$err["Code"], @$err["code"])) . "", + "message" => "code: " . (string) ($_response->statusCode) . ", " . (string) (self::defaultAny(@$err["Message"], @$err["message"])) . " request id: " . (string) (self::defaultAny(@$err["RequestId"], @$err["requestId"])) . "", + "data" => $err, + "description" => "" . (string) (self::defaultAny(@$err["Description"], @$err["description"])) . "", + "accessDeniedDetail" => self::defaultAny(@$err["AccessDeniedDetail"], @$err["accessDeniedDetail"]) + ]); + } + if (Utils::equalString($params->bodyType, "binary")) { + $resp = [ + "body" => $_response->body, + "headers" => $_response->headers, + "statusCode" => $_response->statusCode + ]; + return $resp; + } else if (Utils::equalString($params->bodyType, "byte")) { + $byt = Utils::readAsBytes($_response->body); + return [ + "body" => $byt, + "headers" => $_response->headers, + "statusCode" => $_response->statusCode + ]; + } else if (Utils::equalString($params->bodyType, "string")) { + $str = Utils::readAsString($_response->body); + return [ + "body" => $str, + "headers" => $_response->headers, + "statusCode" => $_response->statusCode + ]; + } else if (Utils::equalString($params->bodyType, "json")) { + $obj = Utils::readAsJSON($_response->body); + $res = Utils::assertAsMap($obj); + return [ + "body" => $res, + "headers" => $_response->headers, + "statusCode" => $_response->statusCode + ]; + } else if (Utils::equalString($params->bodyType, "array")) { + $arr = Utils::readAsJSON($_response->body); + return [ + "body" => $arr, + "headers" => $_response->headers, + "statusCode" => $_response->statusCode + ]; + } else { + $anything = Utils::readAsString($_response->body); + return [ + "body" => $anything, + "headers" => $_response->headers, + "statusCode" => $_response->statusCode + ]; + } + } catch (Exception $e) { + if (!($e instanceof TeaError)) { + $e = new TeaError([], $e->getMessage(), $e->getCode(), $e); + } + if (Tea::isRetryable($e)) { + $_lastException = $e; + continue; + } + throw $e; + } + } + throw new TeaUnableRetryError($_lastRequest, $_lastException); + } + + /** + * Encapsulate the request and invoke the network + * @param Params $params + * @param OpenApiRequest $request object of OpenApiRequest + * @param RuntimeOptions $runtime which controls some details of call api, such as retry times + * @return array the response + * @throws TeaError + * @throws Exception + * @throws TeaUnableRetryError + */ + public function execute($params, $request, $runtime) + { + $params->validate(); + $request->validate(); + $runtime->validate(); + $_runtime = [ + "timeouted" => "retry", + "key" => Utils::defaultString($runtime->key, $this->_key), + "cert" => Utils::defaultString($runtime->cert, $this->_cert), + "ca" => Utils::defaultString($runtime->ca, $this->_ca), + "readTimeout" => Utils::defaultNumber($runtime->readTimeout, $this->_readTimeout), + "connectTimeout" => Utils::defaultNumber($runtime->connectTimeout, $this->_connectTimeout), + "httpProxy" => Utils::defaultString($runtime->httpProxy, $this->_httpProxy), + "httpsProxy" => Utils::defaultString($runtime->httpsProxy, $this->_httpsProxy), + "noProxy" => Utils::defaultString($runtime->noProxy, $this->_noProxy), + "socks5Proxy" => Utils::defaultString($runtime->socks5Proxy, $this->_socks5Proxy), + "socks5NetWork" => Utils::defaultString($runtime->socks5NetWork, $this->_socks5NetWork), + "maxIdleConns" => Utils::defaultNumber($runtime->maxIdleConns, $this->_maxIdleConns), + "retry" => [ + "retryable" => $runtime->autoretry, + "maxAttempts" => Utils::defaultNumber($runtime->maxAttempts, 3) + ], + "backoff" => [ + "policy" => Utils::defaultString($runtime->backoffPolicy, "no"), + "period" => Utils::defaultNumber($runtime->backoffPeriod, 1) + ], + "ignoreSSL" => $runtime->ignoreSSL, + "disableHttp2" => self::defaultAny($this->_disableHttp2, false), + "tlsMinVersion" => $this->_tlsMinVersion + ]; + $_lastRequest = null; + $_lastException = null; + $_now = time(); + $_retryTimes = 0; + while (Tea::allowRetry(@$_runtime["retry"], $_retryTimes, $_now)) { + if ($_retryTimes > 0) { + $_backoffTime = Tea::getBackoffTime(@$_runtime["backoff"], $_retryTimes); + if ($_backoffTime > 0) { + Tea::sleep($_backoffTime); + } + } + $_retryTimes = $_retryTimes + 1; + try { + $_request = new Request(); + // spi = new Gateway();//Gateway implements SPI,这一步在产品 SDK 中实例化 + $headers = $this->getRpcHeaders(); + $globalQueries = []; + $globalHeaders = []; + if (!Utils::isUnset($this->_globalParameters)) { + $globalParams = $this->_globalParameters; + if (!Utils::isUnset($globalParams->queries)) { + $globalQueries = $globalParams->queries; + } + if (!Utils::isUnset($globalParams->headers)) { + $globalHeaders = $globalParams->headers; + } + } + $extendsHeaders = []; + $extendsQueries = []; + if (!Utils::isUnset($runtime->extendsParameters)) { + $extendsParameters = $runtime->extendsParameters; + if (!Utils::isUnset($extendsParameters->headers)) { + $extendsHeaders = $extendsParameters->headers; + } + if (!Utils::isUnset($extendsParameters->queries)) { + $extendsQueries = $extendsParameters->queries; + } + } + $requestContext = new \Darabonba\GatewaySpi\Models\InterceptorContext\request([ + "headers" => Tea::merge($globalHeaders, $extendsHeaders, $request->headers, $headers), + "query" => Tea::merge($globalQueries, $extendsQueries, $request->query), + "body" => $request->body, + "stream" => $request->stream, + "hostMap" => $request->hostMap, + "pathname" => $params->pathname, + "productId" => $this->_productId, + "action" => $params->action, + "version" => $params->version, + "protocol" => Utils::defaultString($this->_protocol, $params->protocol), + "method" => Utils::defaultString($this->_method, $params->method), + "authType" => $params->authType, + "bodyType" => $params->bodyType, + "reqBodyType" => $params->reqBodyType, + "style" => $params->style, + "credential" => $this->_credential, + "signatureVersion" => $this->_signatureVersion, + "signatureAlgorithm" => $this->_signatureAlgorithm, + "userAgent" => $this->getUserAgent() + ]); + $configurationContext = new configuration([ + "regionId" => $this->_regionId, + "endpoint" => Utils::defaultString($request->endpointOverride, $this->_endpoint), + "endpointRule" => $this->_endpointRule, + "endpointMap" => $this->_endpointMap, + "endpointType" => $this->_endpointType, + "network" => $this->_network, + "suffix" => $this->_suffix + ]); + $interceptorContext = new InterceptorContext([ + "request" => $requestContext, + "configuration" => $configurationContext + ]); + $attributeMap = new AttributeMap([]); + // 1. spi.modifyConfiguration(context: SPI.InterceptorContext, attributeMap: SPI.AttributeMap); + $this->_spi->modifyConfiguration($interceptorContext, $attributeMap); + // 2. spi.modifyRequest(context: SPI.InterceptorContext, attributeMap: SPI.AttributeMap); + $this->_spi->modifyRequest($interceptorContext, $attributeMap); + $_request->protocol = $interceptorContext->request->protocol; + $_request->method = $interceptorContext->request->method; + $_request->pathname = $interceptorContext->request->pathname; + $_request->query = $interceptorContext->request->query; + $_request->body = $interceptorContext->request->stream; + $_request->headers = $interceptorContext->request->headers; + $_lastRequest = $_request; + $_response = Tea::send($_request, $_runtime); + $responseContext = new response([ + "statusCode" => $_response->statusCode, + "headers" => $_response->headers, + "body" => $_response->body + ]); + $interceptorContext->response = $responseContext; + // 3. spi.modifyResponse(context: SPI.InterceptorContext, attributeMap: SPI.AttributeMap); + $this->_spi->modifyResponse($interceptorContext, $attributeMap); + return [ + "headers" => $interceptorContext->response->headers, + "statusCode" => $interceptorContext->response->statusCode, + "body" => $interceptorContext->response->deserializedBody + ]; + } catch (Exception $e) { + if (!($e instanceof TeaError)) { + $e = new TeaError([], $e->getMessage(), $e->getCode(), $e); + } + if (Tea::isRetryable($e)) { + $_lastException = $e; + continue; + } + throw $e; + } + } + throw new TeaUnableRetryError($_lastRequest, $_lastException); + } + + /** + * @param Params $params + * @param OpenApiRequest $request + * @param RuntimeOptions $runtime + * @return array + * @throws TeaError + */ + public function callApi($params, $request, $runtime) + { + if (Utils::isUnset($params)) { + throw new TeaError([ + "code" => "ParameterMissing", + "message" => "'params' can not be unset" + ]); + } + if (Utils::isUnset($this->_signatureVersion) || !Utils::equalString($this->_signatureVersion, "v4")) { + if (Utils::isUnset($this->_signatureAlgorithm) || !Utils::equalString($this->_signatureAlgorithm, "v2")) { + return $this->doRequest($params, $request, $runtime); + } else if (Utils::equalString($params->style, "ROA") && Utils::equalString($params->reqBodyType, "json")) { + return $this->doROARequest($params->action, $params->version, $params->protocol, $params->method, $params->authType, $params->pathname, $params->bodyType, $request, $runtime); + } else if (Utils::equalString($params->style, "ROA")) { + return $this->doROARequestWithForm($params->action, $params->version, $params->protocol, $params->method, $params->authType, $params->pathname, $params->bodyType, $request, $runtime); + } else { + return $this->doRPCRequest($params->action, $params->version, $params->protocol, $params->method, $params->authType, $params->bodyType, $request, $runtime); + } + } else { + return $this->execute($params, $request, $runtime); + } + } + + /** + * Get user agent + * @return string user agent + */ + public function getUserAgent() + { + $userAgent = Utils::getUserAgent($this->_userAgent); + return $userAgent; + } + + /** + * Get accesskey id by using credential + * @return string accesskey id + */ + public function getAccessKeyId() + { + if (Utils::isUnset($this->_credential)) { + return ''; + } + $accessKeyId = $this->_credential->getAccessKeyId(); + return $accessKeyId; + } + + /** + * Get accesskey secret by using credential + * @return string accesskey secret + */ + public function getAccessKeySecret() + { + if (Utils::isUnset($this->_credential)) { + return ''; + } + $secret = $this->_credential->getAccessKeySecret(); + return $secret; + } + + /** + * Get security token by using credential + * @return string security token + */ + public function getSecurityToken() + { + if (Utils::isUnset($this->_credential)) { + return ''; + } + $token = $this->_credential->getSecurityToken(); + return $token; + } + + /** + * Get bearer token by credential + * @return string bearer token + */ + public function getBearerToken() + { + if (Utils::isUnset($this->_credential)) { + return ''; + } + $token = $this->_credential->getBearerToken(); + return $token; + } + + /** + * Get credential type by credential + * @return string credential type e.g. access_key + */ + public function getType() + { + if (Utils::isUnset($this->_credential)) { + return ''; + } + $authType = $this->_credential->getType(); + return $authType; + } + + /** + * If inputValue is not null, return it or return defaultValue + * @param mixed $inputValue users input value + * @param mixed $defaultValue default value + * @return any the final result + */ + public static function defaultAny($inputValue, $defaultValue) + { + if (Utils::isUnset($inputValue)) { + return $defaultValue; + } + return $inputValue; + } + + /** + * If the endpointRule and config.endpoint are empty, throw error + * @param \Darabonba\OpenApi\Models\Config $config config contains the necessary information to create a client + * @return void + * @throws TeaError + */ + public function checkConfig($config) + { + if (Utils::empty_($this->_endpointRule) && Utils::empty_($config->endpoint)) { + throw new TeaError([ + "code" => "ParameterMissing", + "message" => "'config.endpoint' can not be empty" + ]); + } + } + + /** + * set gateway client + * @param Client $spi + * @return void + */ + public function setGatewayClient($spi) + { + $this->_spi = $spi; + } + + /** + * set RPC header for debug + * @param string[] $headers headers for debug, this header can be used only once. + * @return void + */ + public function setRpcHeaders($headers) + { + $this->_headers = $headers; + } + + /** + * get RPC header for debug + * @return array + */ + public function getRpcHeaders() + { + $headers = $this->_headers; + $this->_headers = null; + return $headers; + } +} diff --git a/vendor/vendor/alibabacloud/darabonba-openapi/tests/OpenApiClientTest.php b/vendor/vendor/alibabacloud/darabonba-openapi/tests/OpenApiClientTest.php new file mode 100644 index 0000000..8d5d96e --- /dev/null +++ b/vendor/vendor/alibabacloud/darabonba-openapi/tests/OpenApiClientTest.php @@ -0,0 +1,329 @@ + [ + "global-key" => "global-value" + ], + "queries" => [ + "global-query" => "global-value" + ] + ]); + $config = new Config([ + "endpoint" => "config.endpoint", + "endpointType" => "regional", + "network" => "config.network", + "suffix" => "config.suffix", + "protocol" => "config.protocol", + "method" => "config.method", + "regionId" => "config.regionId", + "userAgent" => "config.userAgent", + "readTimeout" => 3000, + "connectTimeout" => 3000, + "httpProxy" => "config.httpProxy", + "httpsProxy" => "config.httpsProxy", + "noProxy" => "config.noProxy", + "socks5Proxy" => "config.socks5Proxy", + "socks5NetWork" => "config.socks5NetWork", + "maxIdleConns" => 128, + "signatureVersion" => "config.signatureVersion", + "signatureAlgorithm" => "config.signatureAlgorithm", + "globalParameters" => $globalParameters + ]); + $creConfig = new \AlibabaCloud\Credentials\Credential\Config([ + "accessKeyId" => "accessKeyId", + "accessKeySecret" => "accessKeySecret", + "securityToken" => "securityToken", + "type" => "sts" + ]); + $credential = new Credential($creConfig); + $config->credential = $credential; + $client = new OpenApiClient($config); + $config->accessKeyId = "ak"; + $config->accessKeySecret = "secret"; + $config->securityToken = "token"; + $config->type = "sts"; + $client = new OpenApiClient($config); + } + + /** + * @return Config + */ + public static function createConfig(){ + $globalParameters = new GlobalParameters([ + "headers" => [ + "global-key" => "global-value" + ], + "queries" => [ + "global-query" => "global-value" + ] + ]); + $config = new Config([ + "accessKeyId" => "ak", + "accessKeySecret" => "secret", + "securityToken" => "token", + "type" => "sts", + "userAgent" => "config.userAgent", + "readTimeout" => 3000, + "connectTimeout" => 3000, + "maxIdleConns" => 128, + "signatureVersion" => "config.signatureVersion", + "signatureAlgorithm" => "ACS3-HMAC-SHA256", + "globalParameters" => $globalParameters, + "tlsMinVersion" => "TLSv1.2" + ]); + return $config; + } + + /** + * @return RuntimeOptions + */ + public static function createRuntimeOptions(){ + $runtime = new RuntimeOptions([ + "readTimeout" => 4000, + "connectTimeout" => 4000, + "maxIdleConns" => 100, + "autoretry" => true, + "maxAttempts" => 1, + "backoffPolicy" => "no", + "backoffPeriod" => 1, + "ignoreSSL" => true + ]); + return $runtime; + } + + /** + * @return OpenApiRequest + */ + public static function createOpenApiRequest(){ + $query = []; + $query["key1"] = "value"; + $query["key2"] = 1; + $query["key3"] = true; + $body = []; + $body["key1"] = "value"; + $body["key2"] = 1; + $body["key3"] = true; + $headers = [ + "for-test" => "sdk" + ]; + $req = new OpenApiRequest([ + "headers" => $headers, + "query" => OpenApiUtilClient::query($query), + "body" => OpenApiUtilClient::parseToMap($body) + ]); + return $req; + } + + public function testCallApiForRPCWithV2Sign_AK_Form(){ + $config = self::createConfig(); + $runtime = self::createRuntimeOptions(); + $config->protocol = "HTTP"; + $config->signatureAlgorithm = "v2"; + $config->endpoint = "test.aliyuncs.com"; + $client = new OpenApiClient($config); + $request = self::createOpenApiRequest(); + $params = new Params([ + "action" => "TestAPI", + "version" => "2022-06-01", + "protocol" => "HTTPS", + "pathname" => "/", + "method" => "POST", + "authType" => "AK", + "style" => "RPC", + "reqBodyType" => "formData", + "bodyType" => "json" + ]); + $client->callApi($params, $request, $runtime); + } + + public function testCallApiForRPCWithV2Sign_Anonymous_JSON(){ + $config = self::createConfig(); + $runtime = self::createRuntimeOptions(); + $config->protocol = "HTTP"; + $config->signatureAlgorithm = "v2"; + $config->endpoint = "test.aliyuncs.com"; + $client = new OpenApiClient($config); + $request = self::createOpenApiRequest(); + $params = new Params([ + "action" => "TestAPI", + "version" => "2022-06-01", + "protocol" => "HTTPS", + "pathname" => "/", + "method" => "POST", + "authType" => "Anonymous", + "style" => "RPC", + "reqBodyType" => "json", + "bodyType" => "json" + ]); + $client->callApi($params, $request, $runtime); + } + + public function testCallApiForROAWithV2Sign_HTTPS_AK_Form(){ + $config = self::createConfig(); + $runtime = self::createRuntimeOptions(); + $config->signatureAlgorithm = "v2"; + $config->endpoint = "test.aliyuncs.com"; + $client = new OpenApiClient($config); + $request = self::createOpenApiRequest(); + $params = new Params([ + "action" => "TestAPI", + "version" => "2022-06-01", + "protocol" => "HTTPS", + "pathname" => "/test", + "method" => "POST", + "authType" => "AK", + "style" => "ROA", + "reqBodyType" => "formData", + "bodyType" => "json" + ]); + $client->callApi($params, $request, $runtime); + } + + public function testCallApiForROAWithV2Sign_Anonymous_JSON(){ + $config = self::createConfig(); + $runtime = self::createRuntimeOptions(); + $config->protocol = "HTTP"; + $config->signatureAlgorithm = "v2"; + $config->endpoint = "test.aliyuncs.com"; + $client = new OpenApiClient($config); + $request = self::createOpenApiRequest(); + $params = new Params([ + "action" => "TestAPI", + "version" => "2022-06-01", + "protocol" => "HTTPS", + "pathname" => "/test", + "method" => "POST", + "authType" => "Anonymous", + "style" => "ROA", + "reqBodyType" => "json", + "bodyType" => "json" + ]); + $client->callApi($params, $request, $runtime); + } + + public function testCallApiForRPCWithV3Sign_AK_Form(){ + $config = self::createConfig(); + $runtime = self::createRuntimeOptions(); + $config->protocol = "HTTP"; + $config->endpoint = "test.aliyuncs.com"; + $client = new OpenApiClient($config); + $request = self::createOpenApiRequest(); + $params = new Params([ + "action" => "TestAPI", + "version" => "2022-06-01", + "protocol" => "HTTPS", + "pathname" => "/", + "method" => "POST", + "authType" => "AK", + "style" => "RPC", + "reqBodyType" => "formData", + "bodyType" => "json" + ]); + $client->callApi($params, $request, $runtime); + } + + public function testCallApiForRPCWithV3Sign_Anonymous_JSON(){ + $config = self::createConfig(); + $runtime = self::createRuntimeOptions(); + $config->protocol = "HTTP"; + $config->endpoint = "test.aliyuncs.com"; + $client = new OpenApiClient($config); + $request = self::createOpenApiRequest(); + $params = new Params([ + "action" => "TestAPI", + "version" => "2022-06-01", + "protocol" => "HTTPS", + "pathname" => "/", + "method" => "POST", + "authType" => "Anonymous", + "style" => "RPC", + "reqBodyType" => "json", + "bodyType" => "json" + ]); + $client->callApi($params, $request, $runtime); + } + + public function testCallApiForROAWithV3Sign_AK_Form(){ + $config = self::createConfig(); + $runtime = self::createRuntimeOptions(); + $config->protocol = "HTTP"; + $config->endpoint = "test.aliyuncs.com"; + $client = new OpenApiClient($config); + $request = self::createOpenApiRequest(); + $params = new Params([ + "action" => "TestAPI", + "version" => "2022-06-01", + "protocol" => "HTTPS", + "pathname" => "/test", + "method" => "POST", + "authType" => "AK", + "style" => "ROA", + "reqBodyType" => "formData", + "bodyType" => "json" + ]); + $client->callApi($params, $request, $runtime); + } + + public function testCallApiForROAWithV3Sign_Anonymous_JSON(){ + $config = self::createConfig(); + $runtime = self::createRuntimeOptions(); + $config->protocol = "HTTP"; + $config->endpoint = "test.aliyuncs.com"; + $client = new OpenApiClient($config); + $request = self::createOpenApiRequest(); + $params = new Params([ + "action" => "TestAPI", + "version" => "2022-06-01", + "protocol" => "HTTPS", + "pathname" => "/test", + "method" => "POST", + "authType" => "Anonymous", + "style" => "ROA", + "reqBodyType" => "json", + "bodyType" => "json" + ]); + $client->callApi($params, $request, $runtime); + } + + public function testResponseBodyType(){ + $config = self::createConfig(); + $runtime = self::createRuntimeOptions(); + $config->protocol = "HTTP"; + $config->endpoint = "test.aliyuncs.com"; + $client = new OpenApiClient($config); + $request = self::createOpenApiRequest(); + $params = new Params([ + "action" => "TestAPI", + "version" => "2022-06-01", + "protocol" => "HTTPS", + "pathname" => "/test", + "method" => "POST", + "authType" => "AK", + "style" => "ROA", + "reqBodyType" => "formData", + "bodyType" => "json" + ]); + $client->callApi($params, $request, $runtime); + $params->bodyType = "array"; + $client->callApi($params, $request, $runtime); + $params->bodyType = "string"; + $client->callApi($params, $request, $runtime); + $params->bodyType = "byte"; + $client->callApi($params, $request, $runtime); + } +} diff --git a/vendor/vendor/alibabacloud/darabonba-openapi/tests/bootstrap.php b/vendor/vendor/alibabacloud/darabonba-openapi/tests/bootstrap.php new file mode 100644 index 0000000..c62c4e8 --- /dev/null +++ b/vendor/vendor/alibabacloud/darabonba-openapi/tests/bootstrap.php @@ -0,0 +1,3 @@ +setRiskyAllowed(true) + ->setIndent(' ') + ->setRules([ + '@PSR2' => true, + '@PhpCsFixer' => true, + '@Symfony:risky' => true, + 'concat_space' => ['spacing' => 'one'], + 'array_syntax' => ['syntax' => 'short'], + 'array_indentation' => true, + 'combine_consecutive_unsets' => true, + 'method_separation' => true, + 'single_quote' => true, + 'declare_equal_normalize' => true, + 'function_typehint_space' => true, + 'hash_to_slash_comment' => true, + 'include' => true, + 'lowercase_cast' => true, + 'no_multiline_whitespace_before_semicolons' => true, + 'no_leading_import_slash' => true, + 'no_multiline_whitespace_around_double_arrow' => true, + 'no_spaces_around_offset' => true, + 'no_unneeded_control_parentheses' => true, + 'no_unused_imports' => true, + 'no_whitespace_before_comma_in_array' => true, + 'no_whitespace_in_blank_line' => true, + 'object_operator_without_whitespace' => true, + 'single_blank_line_before_namespace' => true, + 'single_class_element_per_statement' => true, + 'space_after_semicolon' => true, + 'standardize_not_equals' => true, + 'ternary_operator_spaces' => true, + 'trailing_comma_in_multiline_array' => true, + 'trim_array_spaces' => true, + 'unary_operator_spaces' => true, + 'whitespace_after_comma_in_array' => true, + 'no_extra_consecutive_blank_lines' => [ + 'curly_brace_block', + 'extra', + 'parenthesis_brace_block', + 'square_brace_block', + 'throw', + 'use', + ], + 'binary_operator_spaces' => [ + 'align_double_arrow' => true, + 'align_equals' => true, + ], + 'braces' => [ + 'allow_single_line_closure' => true, + ], + ]) + ->setFinder( + PhpCsFixer\Finder::create() + ->exclude('vendor') + ->exclude('tests') + ->in(__DIR__) + ); diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/ChangeLog.md b/vendor/vendor/alibabacloud/dypnsapi-20170525/ChangeLog.md new file mode 100644 index 0000000..dfeea5d --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/ChangeLog.md @@ -0,0 +1,59 @@ +2024-10-24 Version: 1.1.3 +- Update API CreateVerifyScheme: add param HmAppIdentifier. +- Update API CreateVerifyScheme: add param HmPackageName. +- Update API CreateVerifyScheme: add param HmSignName. +- Update API GetAuthToken: add param BizType. +- Update API GetAuthToken: add param CmApiCode. +- Update API GetAuthToken: add param CtApiCode. +- Update API GetAuthToken: add param CuApiCode. +- Update API GetAuthToken: add param Version. + + +2024-10-18 Version: 1.1.3 +- Update API CreateVerifyScheme: add param HmAppIdentifier. +- Update API CreateVerifyScheme: add param HmPackageName. +- Update API CreateVerifyScheme: add param HmSignName. + + +2024-01-04 Version: 1.1.2 +- Generated php 2017-05-25 for Dypnsapi. + +2023-12-29 Version: 1.2.0 +- Generated php 2017-05-25 for Dypnsapi. + +2023-09-21 Version: 1.1.0 +- Generated php 2017-05-25 for Dypnsapi. + +2023-04-14 Version: 1.0.10 +- Supported Fusion Auth. + +2022-12-27 Version: 1.0.9 +- Support Sms Verification for Dypnsapi. + +2022-11-30 Version: 1.0.8 +- Support Sms Verification for Dypnsapi. + +2022-02-08 Version: 1.0.7 +- Supported New Features. + +2022-01-19 Version: 1.0.6 +- Supported New Features. + +2022-01-13 Version: 1.0.5 +- Supported New Features. + +2022-01-07 Version: 1.0.4 +- Supported New Features. + +2021-09-22 Version: 1.0.3 +- Support Sms Verification for Dypnsapi. + +2021-09-22 Version: 1.0.2 +- Support Sms Verification for Dypnsapi. + +2021-03-17 Version: 1.0.1 +- Generated php 2017-05-25 for Dypnsapi. + +2020-12-30 Version: 1.0.0 +- AMP Version Change. + diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/LICENSE b/vendor/vendor/alibabacloud/dypnsapi-20170525/LICENSE new file mode 100644 index 0000000..0c44dce --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright (c) 2009-present, Alibaba Cloud All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/README-CN.md b/vendor/vendor/alibabacloud/dypnsapi-20170525/README-CN.md new file mode 100644 index 0000000..e9bfe72 --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/README-CN.md @@ -0,0 +1,35 @@ +[English](README.md) | 简体中文 + +![](https://aliyunsdk-pages.alicdn.com/icons/AlibabaCloud.svg) + +# Alibaba Cloud Dypnsapi SDK for PHP + +## 安装 + +### Composer + +```bash +composer require alibabacloud/dypnsapi-20170525 +``` + +## 问题 + +[提交 Issue](https://github.com/aliyun/alibabacloud-php-sdk/issues/new),不符合指南的问题可能会立即关闭。 + +## 使用说明 + +[快速使用](https://github.com/aliyun/alibabacloud-php-sdk/blob/master/docs/0-Examples-CN.md#%E5%BF%AB%E9%80%9F%E4%BD%BF%E7%94%A8) + +## 发行说明 + +每个版本的详细更改记录在[发行说明](./ChangeLog.txt)中。 + +## 相关 + +* [最新源码](https://github.com/aliyun/alibabacloud-php-sdk/) + +## 许可证 + +[Apache-2.0](http://www.apache.org/licenses/LICENSE-2.0) + +Copyright (c) 2009-present, Alibaba Cloud All rights reserved. diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/README.md b/vendor/vendor/alibabacloud/dypnsapi-20170525/README.md new file mode 100644 index 0000000..f99bf5c --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/README.md @@ -0,0 +1,35 @@ +English | [简体中文](README-CN.md) + +![](https://aliyunsdk-pages.alicdn.com/icons/AlibabaCloud.svg) + +# Alibaba Cloud Dypnsapi SDK for PHP + +## Installation + +### Composer + +```bash +composer require alibabacloud/dypnsapi-20170525 +``` + +## Issues + +[Opening an Issue](https://github.com/aliyun/alibabacloud-php-sdk/issues/new), Issues not conforming to the guidelines may be closed immediately. + +## Usage + +[Quick Examples](https://github.com/aliyun/alibabacloud-php-sdk/blob/master/docs/0-Examples-EN.md#quick-examples) + +## Changelog + +Detailed changes for each release are documented in the [release notes](./ChangeLog.txt). + +## References + +* [Latest Release](https://github.com/aliyun/alibabacloud-php-sdk/) + +## License + +[Apache-2.0](http://www.apache.org/licenses/LICENSE-2.0) + +Copyright (c) 2009-present, Alibaba Cloud All rights reserved. diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/autoload.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/autoload.php new file mode 100644 index 0000000..cce9a41 --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/autoload.php @@ -0,0 +1,17 @@ +5.5", + "alibabacloud/tea-utils": "^0.2.21", + "alibabacloud/darabonba-openapi": "^0.2.13", + "alibabacloud/openapi-util": "^0.1.10|^0.2.1", + "alibabacloud/endpoint-util": "^0.1.0" + }, + "autoload": { + "psr-4": { + "AlibabaCloud\\SDK\\Dypnsapi\\V20170525\\": "src" + } + }, + "scripts": { + "fixer": "php-cs-fixer fix ./" + }, + "config": { + "sort-packages": true, + "preferred-install": "dist", + "optimize-autoloader": true + }, + "prefer-stable": true +} \ No newline at end of file diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Dypnsapi.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Dypnsapi.php new file mode 100644 index 0000000..d2ba137 --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Dypnsapi.php @@ -0,0 +1,1658 @@ +_signatureAlgorithm = 'v2'; + $this->_endpointRule = 'central'; + $this->checkConfig($config); + $this->_endpoint = $this->getEndpoint('dypnsapi', $this->_regionId, $this->_endpointRule, $this->_network, $this->_suffix, $this->_endpointMap, $this->_endpoint); + } + + /** + * @param string $productId + * @param string $regionId + * @param string $endpointRule + * @param string $network + * @param string $suffix + * @param string[] $endpointMap + * @param string $endpoint + * + * @return string + */ + public function getEndpoint($productId, $regionId, $endpointRule, $network, $suffix, $endpointMap, $endpoint) + { + if (!Utils::empty_($endpoint)) { + return $endpoint; + } + if (!Utils::isUnset($endpointMap) && !Utils::empty_(@$endpointMap[$regionId])) { + return @$endpointMap[$regionId]; + } + + return Endpoint::getEndpointRules($productId, $regionId, $endpointRule, $network, $suffix); + } + + /** + * @summary Verifies SMS verification codes. + * * + * @param CheckSmsVerifyCodeRequest $request CheckSmsVerifyCodeRequest + * @param RuntimeOptions $runtime runtime options for this request RuntimeOptions + * + * @return CheckSmsVerifyCodeResponse CheckSmsVerifyCodeResponse + */ + public function checkSmsVerifyCodeWithOptions($request, $runtime) + { + Utils::validateModel($request); + $query = []; + if (!Utils::isUnset($request->caseAuthPolicy)) { + $query['CaseAuthPolicy'] = $request->caseAuthPolicy; + } + if (!Utils::isUnset($request->countryCode)) { + $query['CountryCode'] = $request->countryCode; + } + if (!Utils::isUnset($request->outId)) { + $query['OutId'] = $request->outId; + } + if (!Utils::isUnset($request->ownerId)) { + $query['OwnerId'] = $request->ownerId; + } + if (!Utils::isUnset($request->phoneNumber)) { + $query['PhoneNumber'] = $request->phoneNumber; + } + if (!Utils::isUnset($request->resourceOwnerAccount)) { + $query['ResourceOwnerAccount'] = $request->resourceOwnerAccount; + } + if (!Utils::isUnset($request->resourceOwnerId)) { + $query['ResourceOwnerId'] = $request->resourceOwnerId; + } + if (!Utils::isUnset($request->schemeName)) { + $query['SchemeName'] = $request->schemeName; + } + if (!Utils::isUnset($request->verifyCode)) { + $query['VerifyCode'] = $request->verifyCode; + } + $req = new OpenApiRequest([ + 'query' => OpenApiUtilClient::query($query), + ]); + $params = new Params([ + 'action' => 'CheckSmsVerifyCode', + 'version' => '2017-05-25', + 'protocol' => 'HTTPS', + 'pathname' => '/', + 'method' => 'POST', + 'authType' => 'AK', + 'style' => 'RPC', + 'reqBodyType' => 'formData', + 'bodyType' => 'json', + ]); + + return CheckSmsVerifyCodeResponse::fromMap($this->callApi($params, $req, $runtime)); + } + + /** + * @summary Verifies SMS verification codes. + * * + * @param CheckSmsVerifyCodeRequest $request CheckSmsVerifyCodeRequest + * + * @return CheckSmsVerifyCodeResponse CheckSmsVerifyCodeResponse + */ + public function checkSmsVerifyCode($request) + { + $runtime = new RuntimeOptions([]); + + return $this->checkSmsVerifyCodeWithOptions($request, $runtime); + } + + /** + * @summary Creates a code for a converged communication authentication service. + * * + * @param CreateSchemeConfigRequest $request CreateSchemeConfigRequest + * @param RuntimeOptions $runtime runtime options for this request RuntimeOptions + * + * @return CreateSchemeConfigResponse CreateSchemeConfigResponse + */ + public function createSchemeConfigWithOptions($request, $runtime) + { + Utils::validateModel($request); + $query = []; + if (!Utils::isUnset($request->androidPackageName)) { + $query['AndroidPackageName'] = $request->androidPackageName; + } + if (!Utils::isUnset($request->androidPackageSign)) { + $query['AndroidPackageSign'] = $request->androidPackageSign; + } + if (!Utils::isUnset($request->appName)) { + $query['AppName'] = $request->appName; + } + if (!Utils::isUnset($request->h5Origin)) { + $query['H5Origin'] = $request->h5Origin; + } + if (!Utils::isUnset($request->h5Url)) { + $query['H5Url'] = $request->h5Url; + } + if (!Utils::isUnset($request->iosBundleId)) { + $query['IosBundleId'] = $request->iosBundleId; + } + if (!Utils::isUnset($request->ownerId)) { + $query['OwnerId'] = $request->ownerId; + } + if (!Utils::isUnset($request->platform)) { + $query['Platform'] = $request->platform; + } + if (!Utils::isUnset($request->resourceOwnerAccount)) { + $query['ResourceOwnerAccount'] = $request->resourceOwnerAccount; + } + if (!Utils::isUnset($request->resourceOwnerId)) { + $query['ResourceOwnerId'] = $request->resourceOwnerId; + } + if (!Utils::isUnset($request->schemeName)) { + $query['SchemeName'] = $request->schemeName; + } + $req = new OpenApiRequest([ + 'query' => OpenApiUtilClient::query($query), + ]); + $params = new Params([ + 'action' => 'CreateSchemeConfig', + 'version' => '2017-05-25', + 'protocol' => 'HTTPS', + 'pathname' => '/', + 'method' => 'POST', + 'authType' => 'AK', + 'style' => 'RPC', + 'reqBodyType' => 'formData', + 'bodyType' => 'json', + ]); + + return CreateSchemeConfigResponse::fromMap($this->callApi($params, $req, $runtime)); + } + + /** + * @summary Creates a code for a converged communication authentication service. + * * + * @param CreateSchemeConfigRequest $request CreateSchemeConfigRequest + * + * @return CreateSchemeConfigResponse CreateSchemeConfigResponse + */ + public function createSchemeConfig($request) + { + $runtime = new RuntimeOptions([]); + + return $this->createSchemeConfigWithOptions($request, $runtime); + } + + /** + * @summary Creates a verification service. + * * + * @description ### [](#qps)QPS limits + * You can call this operation up to 100 times per second per account. If the number of calls per second exceeds the limit, throttling is triggered. As a result, your business may be affected. We recommend that you take note of the limit when you call this operation. + * * + * @param CreateVerifySchemeRequest $request CreateVerifySchemeRequest + * @param RuntimeOptions $runtime runtime options for this request RuntimeOptions + * + * @return CreateVerifySchemeResponse CreateVerifySchemeResponse + */ + public function createVerifySchemeWithOptions($request, $runtime) + { + Utils::validateModel($request); + $query = []; + if (!Utils::isUnset($request->appName)) { + $query['AppName'] = $request->appName; + } + if (!Utils::isUnset($request->authType)) { + $query['AuthType'] = $request->authType; + } + if (!Utils::isUnset($request->bundleId)) { + $query['BundleId'] = $request->bundleId; + } + if (!Utils::isUnset($request->cmApiCode)) { + $query['CmApiCode'] = $request->cmApiCode; + } + if (!Utils::isUnset($request->ctApiCode)) { + $query['CtApiCode'] = $request->ctApiCode; + } + if (!Utils::isUnset($request->cuApiCode)) { + $query['CuApiCode'] = $request->cuApiCode; + } + if (!Utils::isUnset($request->email)) { + $query['Email'] = $request->email; + } + if (!Utils::isUnset($request->hmAppIdentifier)) { + $query['HmAppIdentifier'] = $request->hmAppIdentifier; + } + if (!Utils::isUnset($request->hmPackageName)) { + $query['HmPackageName'] = $request->hmPackageName; + } + if (!Utils::isUnset($request->hmSignName)) { + $query['HmSignName'] = $request->hmSignName; + } + if (!Utils::isUnset($request->ipWhiteList)) { + $query['IpWhiteList'] = $request->ipWhiteList; + } + if (!Utils::isUnset($request->origin)) { + $query['Origin'] = $request->origin; + } + if (!Utils::isUnset($request->osType)) { + $query['OsType'] = $request->osType; + } + if (!Utils::isUnset($request->ownerId)) { + $query['OwnerId'] = $request->ownerId; + } + if (!Utils::isUnset($request->packName)) { + $query['PackName'] = $request->packName; + } + if (!Utils::isUnset($request->packSign)) { + $query['PackSign'] = $request->packSign; + } + if (!Utils::isUnset($request->resourceOwnerAccount)) { + $query['ResourceOwnerAccount'] = $request->resourceOwnerAccount; + } + if (!Utils::isUnset($request->resourceOwnerId)) { + $query['ResourceOwnerId'] = $request->resourceOwnerId; + } + if (!Utils::isUnset($request->sceneType)) { + $query['SceneType'] = $request->sceneType; + } + if (!Utils::isUnset($request->schemeName)) { + $query['SchemeName'] = $request->schemeName; + } + if (!Utils::isUnset($request->smsSignName)) { + $query['SmsSignName'] = $request->smsSignName; + } + if (!Utils::isUnset($request->url)) { + $query['Url'] = $request->url; + } + $req = new OpenApiRequest([ + 'query' => OpenApiUtilClient::query($query), + ]); + $params = new Params([ + 'action' => 'CreateVerifyScheme', + 'version' => '2017-05-25', + 'protocol' => 'HTTPS', + 'pathname' => '/', + 'method' => 'POST', + 'authType' => 'AK', + 'style' => 'RPC', + 'reqBodyType' => 'formData', + 'bodyType' => 'json', + ]); + + return CreateVerifySchemeResponse::fromMap($this->callApi($params, $req, $runtime)); + } + + /** + * @summary Creates a verification service. + * * + * @description ### [](#qps)QPS limits + * You can call this operation up to 100 times per second per account. If the number of calls per second exceeds the limit, throttling is triggered. As a result, your business may be affected. We recommend that you take note of the limit when you call this operation. + * * + * @param CreateVerifySchemeRequest $request CreateVerifySchemeRequest + * + * @return CreateVerifySchemeResponse CreateVerifySchemeResponse + */ + public function createVerifyScheme($request) + { + $runtime = new RuntimeOptions([]); + + return $this->createVerifySchemeWithOptions($request, $runtime); + } + + /** + * @summary Deletes a verification service. + * * + * @description ### [](#qps)QPS limits + * You can call this operation up to 100 times per second per account. If the number of calls per second exceeds the limit, throttling is triggered. As a result, your business may be affected. We recommend that you take note of the limit when you call this operation. + * * + * @param DeleteVerifySchemeRequest $request DeleteVerifySchemeRequest + * @param RuntimeOptions $runtime runtime options for this request RuntimeOptions + * + * @return DeleteVerifySchemeResponse DeleteVerifySchemeResponse + */ + public function deleteVerifySchemeWithOptions($request, $runtime) + { + Utils::validateModel($request); + $query = []; + if (!Utils::isUnset($request->customerId)) { + $query['CustomerId'] = $request->customerId; + } + if (!Utils::isUnset($request->ownerId)) { + $query['OwnerId'] = $request->ownerId; + } + if (!Utils::isUnset($request->resourceOwnerAccount)) { + $query['ResourceOwnerAccount'] = $request->resourceOwnerAccount; + } + if (!Utils::isUnset($request->resourceOwnerId)) { + $query['ResourceOwnerId'] = $request->resourceOwnerId; + } + if (!Utils::isUnset($request->schemeCode)) { + $query['SchemeCode'] = $request->schemeCode; + } + $req = new OpenApiRequest([ + 'query' => OpenApiUtilClient::query($query), + ]); + $params = new Params([ + 'action' => 'DeleteVerifyScheme', + 'version' => '2017-05-25', + 'protocol' => 'HTTPS', + 'pathname' => '/', + 'method' => 'POST', + 'authType' => 'AK', + 'style' => 'RPC', + 'reqBodyType' => 'formData', + 'bodyType' => 'json', + ]); + + return DeleteVerifySchemeResponse::fromMap($this->callApi($params, $req, $runtime)); + } + + /** + * @summary Deletes a verification service. + * * + * @description ### [](#qps)QPS limits + * You can call this operation up to 100 times per second per account. If the number of calls per second exceeds the limit, throttling is triggered. As a result, your business may be affected. We recommend that you take note of the limit when you call this operation. + * * + * @param DeleteVerifySchemeRequest $request DeleteVerifySchemeRequest + * + * @return DeleteVerifySchemeResponse DeleteVerifySchemeResponse + */ + public function deleteVerifyScheme($request) + { + $runtime = new RuntimeOptions([]); + + return $this->deleteVerifySchemeWithOptions($request, $runtime); + } + + /** + * @summary Queries the details of a verification service. + * * + * @description ### [](#qps)QPS limits + * You can call this operation up to 100 times per second per account. If the number of calls per second exceeds the limit, throttling is triggered. As a result, your business may be affected. We recommend that you take note of the limit when you call this operation. + * * + * @param DescribeVerifySchemeRequest $request DescribeVerifySchemeRequest + * @param RuntimeOptions $runtime runtime options for this request RuntimeOptions + * + * @return DescribeVerifySchemeResponse DescribeVerifySchemeResponse + */ + public function describeVerifySchemeWithOptions($request, $runtime) + { + Utils::validateModel($request); + $query = []; + if (!Utils::isUnset($request->customerId)) { + $query['CustomerId'] = $request->customerId; + } + if (!Utils::isUnset($request->ownerId)) { + $query['OwnerId'] = $request->ownerId; + } + if (!Utils::isUnset($request->resourceOwnerAccount)) { + $query['ResourceOwnerAccount'] = $request->resourceOwnerAccount; + } + if (!Utils::isUnset($request->resourceOwnerId)) { + $query['ResourceOwnerId'] = $request->resourceOwnerId; + } + if (!Utils::isUnset($request->schemeCode)) { + $query['SchemeCode'] = $request->schemeCode; + } + $req = new OpenApiRequest([ + 'query' => OpenApiUtilClient::query($query), + ]); + $params = new Params([ + 'action' => 'DescribeVerifyScheme', + 'version' => '2017-05-25', + 'protocol' => 'HTTPS', + 'pathname' => '/', + 'method' => 'POST', + 'authType' => 'AK', + 'style' => 'RPC', + 'reqBodyType' => 'formData', + 'bodyType' => 'json', + ]); + + return DescribeVerifySchemeResponse::fromMap($this->callApi($params, $req, $runtime)); + } + + /** + * @summary Queries the details of a verification service. + * * + * @description ### [](#qps)QPS limits + * You can call this operation up to 100 times per second per account. If the number of calls per second exceeds the limit, throttling is triggered. As a result, your business may be affected. We recommend that you take note of the limit when you call this operation. + * * + * @param DescribeVerifySchemeRequest $request DescribeVerifySchemeRequest + * + * @return DescribeVerifySchemeResponse DescribeVerifySchemeResponse + */ + public function describeVerifyScheme($request) + { + $runtime = new RuntimeOptions([]); + + return $this->describeVerifySchemeWithOptions($request, $runtime); + } + + /** + * @summary Obtains the authorization token used for the authentication of the phone number verification for HTML5 pages. You can obtain AccessToken and JwtToken after a successful call. + * * + * @description ### [](#)Preparations + * You must register an Alibaba Cloud account, obtain an Alibaba Cloud AccessKey pair, and create a verification service. For more information, see [Use the phone number verification feature for HTML5 pages](https://help.aliyun.com/document_detail/169786.html). + * ### [](#qps)QPS limits + * You can call this operation up to 1,000 times per second per account. If the number of calls per second exceeds the limit, throttling is triggered. As a result, your business may be affected. We recommend that you take note of the limit when you call this operation. + * * + * @param GetAuthTokenRequest $request GetAuthTokenRequest + * @param RuntimeOptions $runtime runtime options for this request RuntimeOptions + * + * @return GetAuthTokenResponse GetAuthTokenResponse + */ + public function getAuthTokenWithOptions($request, $runtime) + { + Utils::validateModel($request); + $query = []; + if (!Utils::isUnset($request->bizType)) { + $query['BizType'] = $request->bizType; + } + if (!Utils::isUnset($request->cmApiCode)) { + $query['CmApiCode'] = $request->cmApiCode; + } + if (!Utils::isUnset($request->ctApiCode)) { + $query['CtApiCode'] = $request->ctApiCode; + } + if (!Utils::isUnset($request->cuApiCode)) { + $query['CuApiCode'] = $request->cuApiCode; + } + if (!Utils::isUnset($request->origin)) { + $query['Origin'] = $request->origin; + } + if (!Utils::isUnset($request->ownerId)) { + $query['OwnerId'] = $request->ownerId; + } + if (!Utils::isUnset($request->resourceOwnerAccount)) { + $query['ResourceOwnerAccount'] = $request->resourceOwnerAccount; + } + if (!Utils::isUnset($request->resourceOwnerId)) { + $query['ResourceOwnerId'] = $request->resourceOwnerId; + } + if (!Utils::isUnset($request->sceneCode)) { + $query['SceneCode'] = $request->sceneCode; + } + if (!Utils::isUnset($request->url)) { + $query['Url'] = $request->url; + } + if (!Utils::isUnset($request->version)) { + $query['Version'] = $request->version; + } + $req = new OpenApiRequest([ + 'query' => OpenApiUtilClient::query($query), + ]); + $params = new Params([ + 'action' => 'GetAuthToken', + 'version' => '2017-05-25', + 'protocol' => 'HTTPS', + 'pathname' => '/', + 'method' => 'POST', + 'authType' => 'AK', + 'style' => 'RPC', + 'reqBodyType' => 'formData', + 'bodyType' => 'json', + ]); + + return GetAuthTokenResponse::fromMap($this->callApi($params, $req, $runtime)); + } + + /** + * @summary Obtains the authorization token used for the authentication of the phone number verification for HTML5 pages. You can obtain AccessToken and JwtToken after a successful call. + * * + * @description ### [](#)Preparations + * You must register an Alibaba Cloud account, obtain an Alibaba Cloud AccessKey pair, and create a verification service. For more information, see [Use the phone number verification feature for HTML5 pages](https://help.aliyun.com/document_detail/169786.html). + * ### [](#qps)QPS limits + * You can call this operation up to 1,000 times per second per account. If the number of calls per second exceeds the limit, throttling is triggered. As a result, your business may be affected. We recommend that you take note of the limit when you call this operation. + * * + * @param GetAuthTokenRequest $request GetAuthTokenRequest + * + * @return GetAuthTokenResponse GetAuthTokenResponse + */ + public function getAuthToken($request) + { + $runtime = new RuntimeOptions([]); + + return $this->getAuthTokenWithOptions($request, $runtime); + } + + /** + * @summary Obtains the URL for the Alipay account authorization. + * * + * @description ### [](#)Preparations + * You must register an Alibaba Cloud account and obtain an Alibaba Cloud AccessKey pair. For more information, see [Process of communication authorization](https://help.aliyun.com/document_detail/196922.html). + * ### [](#qps)QPS limits + * You can call this operation up to 1,000 times per second per account. If the number of calls per second exceeds the limit, throttling is triggered. As a result, your business may be affected. We recommend that you take note of the limit when you call this operation. + * * + * @param GetAuthorizationUrlRequest $request GetAuthorizationUrlRequest + * @param RuntimeOptions $runtime runtime options for this request RuntimeOptions + * + * @return GetAuthorizationUrlResponse GetAuthorizationUrlResponse + */ + public function getAuthorizationUrlWithOptions($request, $runtime) + { + Utils::validateModel($request); + $query = []; + if (!Utils::isUnset($request->endDate)) { + $query['EndDate'] = $request->endDate; + } + if (!Utils::isUnset($request->ownerId)) { + $query['OwnerId'] = $request->ownerId; + } + if (!Utils::isUnset($request->phoneNo)) { + $query['PhoneNo'] = $request->phoneNo; + } + if (!Utils::isUnset($request->resourceOwnerAccount)) { + $query['ResourceOwnerAccount'] = $request->resourceOwnerAccount; + } + if (!Utils::isUnset($request->resourceOwnerId)) { + $query['ResourceOwnerId'] = $request->resourceOwnerId; + } + if (!Utils::isUnset($request->schemeId)) { + $query['SchemeId'] = $request->schemeId; + } + $req = new OpenApiRequest([ + 'query' => OpenApiUtilClient::query($query), + ]); + $params = new Params([ + 'action' => 'GetAuthorizationUrl', + 'version' => '2017-05-25', + 'protocol' => 'HTTPS', + 'pathname' => '/', + 'method' => 'POST', + 'authType' => 'AK', + 'style' => 'RPC', + 'reqBodyType' => 'formData', + 'bodyType' => 'json', + ]); + + return GetAuthorizationUrlResponse::fromMap($this->callApi($params, $req, $runtime)); + } + + /** + * @summary Obtains the URL for the Alipay account authorization. + * * + * @description ### [](#)Preparations + * You must register an Alibaba Cloud account and obtain an Alibaba Cloud AccessKey pair. For more information, see [Process of communication authorization](https://help.aliyun.com/document_detail/196922.html). + * ### [](#qps)QPS limits + * You can call this operation up to 1,000 times per second per account. If the number of calls per second exceeds the limit, throttling is triggered. As a result, your business may be affected. We recommend that you take note of the limit when you call this operation. + * * + * @param GetAuthorizationUrlRequest $request GetAuthorizationUrlRequest + * + * @return GetAuthorizationUrlResponse GetAuthorizationUrlResponse + */ + public function getAuthorizationUrl($request) + { + $runtime = new RuntimeOptions([]); + + return $this->getAuthorizationUrlWithOptions($request, $runtime); + } + + /** + * @summary Obtains the verification results by using the token that is obtained from the client SDKs. + * * + * @param GetFusionAuthTokenRequest $request GetFusionAuthTokenRequest + * @param RuntimeOptions $runtime runtime options for this request RuntimeOptions + * + * @return GetFusionAuthTokenResponse GetFusionAuthTokenResponse + */ + public function getFusionAuthTokenWithOptions($request, $runtime) + { + Utils::validateModel($request); + $query = []; + if (!Utils::isUnset($request->bundleId)) { + $query['BundleId'] = $request->bundleId; + } + if (!Utils::isUnset($request->durationSeconds)) { + $query['DurationSeconds'] = $request->durationSeconds; + } + if (!Utils::isUnset($request->ownerId)) { + $query['OwnerId'] = $request->ownerId; + } + if (!Utils::isUnset($request->packageName)) { + $query['PackageName'] = $request->packageName; + } + if (!Utils::isUnset($request->packageSign)) { + $query['PackageSign'] = $request->packageSign; + } + if (!Utils::isUnset($request->platform)) { + $query['Platform'] = $request->platform; + } + if (!Utils::isUnset($request->resourceOwnerAccount)) { + $query['ResourceOwnerAccount'] = $request->resourceOwnerAccount; + } + if (!Utils::isUnset($request->resourceOwnerId)) { + $query['ResourceOwnerId'] = $request->resourceOwnerId; + } + if (!Utils::isUnset($request->schemeCode)) { + $query['SchemeCode'] = $request->schemeCode; + } + $req = new OpenApiRequest([ + 'query' => OpenApiUtilClient::query($query), + ]); + $params = new Params([ + 'action' => 'GetFusionAuthToken', + 'version' => '2017-05-25', + 'protocol' => 'HTTPS', + 'pathname' => '/', + 'method' => 'POST', + 'authType' => 'AK', + 'style' => 'RPC', + 'reqBodyType' => 'formData', + 'bodyType' => 'json', + ]); + + return GetFusionAuthTokenResponse::fromMap($this->callApi($params, $req, $runtime)); + } + + /** + * @summary Obtains the verification results by using the token that is obtained from the client SDKs. + * * + * @param GetFusionAuthTokenRequest $request GetFusionAuthTokenRequest + * + * @return GetFusionAuthTokenResponse GetFusionAuthTokenResponse + */ + public function getFusionAuthToken($request) + { + $runtime = new RuntimeOptions([]); + + return $this->getFusionAuthTokenWithOptions($request, $runtime); + } + + /** + * @summary Obtains a phone number for one-click logon. + * * + * @description ### [](#)Preparations + * You must register an Alibaba Cloud account, obtain an Alibaba Cloud AccessKey pair, and create a verification service. For more information, see [Getting Started](https://help.aliyun.com/document_detail/84541.html). + * > This operation is applicable only to one-click logon or registration. You can call this operation only after you confirm the authorization on the authorization page provided by the SDK for one-click logon. You are prohibited from simulating or bypassing the authorization process. Alibaba Cloud reserves the right to terminate our services and take legal actions against such violations. + * ### [](#qps)QPS limits + * You can call this operation up to 5,000 times per second per account. If the number of calls per second exceeds the limit, throttling is triggered. As a result, your business may be affected. We recommend that you take note of the limit when you call this operation. + * * + * @param GetMobileRequest $request GetMobileRequest + * @param RuntimeOptions $runtime runtime options for this request RuntimeOptions + * + * @return GetMobileResponse GetMobileResponse + */ + public function getMobileWithOptions($request, $runtime) + { + Utils::validateModel($request); + $query = []; + if (!Utils::isUnset($request->accessToken)) { + $query['AccessToken'] = $request->accessToken; + } + if (!Utils::isUnset($request->outId)) { + $query['OutId'] = $request->outId; + } + if (!Utils::isUnset($request->ownerId)) { + $query['OwnerId'] = $request->ownerId; + } + if (!Utils::isUnset($request->resourceOwnerAccount)) { + $query['ResourceOwnerAccount'] = $request->resourceOwnerAccount; + } + if (!Utils::isUnset($request->resourceOwnerId)) { + $query['ResourceOwnerId'] = $request->resourceOwnerId; + } + $req = new OpenApiRequest([ + 'query' => OpenApiUtilClient::query($query), + ]); + $params = new Params([ + 'action' => 'GetMobile', + 'version' => '2017-05-25', + 'protocol' => 'HTTPS', + 'pathname' => '/', + 'method' => 'POST', + 'authType' => 'AK', + 'style' => 'RPC', + 'reqBodyType' => 'formData', + 'bodyType' => 'json', + ]); + + return GetMobileResponse::fromMap($this->callApi($params, $req, $runtime)); + } + + /** + * @summary Obtains a phone number for one-click logon. + * * + * @description ### [](#)Preparations + * You must register an Alibaba Cloud account, obtain an Alibaba Cloud AccessKey pair, and create a verification service. For more information, see [Getting Started](https://help.aliyun.com/document_detail/84541.html). + * > This operation is applicable only to one-click logon or registration. You can call this operation only after you confirm the authorization on the authorization page provided by the SDK for one-click logon. You are prohibited from simulating or bypassing the authorization process. Alibaba Cloud reserves the right to terminate our services and take legal actions against such violations. + * ### [](#qps)QPS limits + * You can call this operation up to 5,000 times per second per account. If the number of calls per second exceeds the limit, throttling is triggered. As a result, your business may be affected. We recommend that you take note of the limit when you call this operation. + * * + * @param GetMobileRequest $request GetMobileRequest + * + * @return GetMobileResponse GetMobileResponse + */ + public function getMobile($request) + { + $runtime = new RuntimeOptions([]); + + return $this->getMobileWithOptions($request, $runtime); + } + + /** + * @summary Obtains a phone number for one-click logon. This operation is exclusive to HTML5 pages. + * * + * @description ### [](#)Preparations + * You must register an Alibaba Cloud account, obtain an Alibaba Cloud AccessKey pair, and create a verification service. For more information, see [Getting Started](https://help.aliyun.com/document_detail/84541.html). + * > This operation is applicable only to one-click logon or registration in HTML5 pages. You can call this operation only after you confirm the authorization on the authorization page provided by the JavaScript SDK. You are prohibited from simulating or bypassing the authorization process. Alibaba Cloud reserves the right to terminate our services and take legal actions against such violations. + * ### [](#qps)QPS limits + * You can call this operation up to 500 times per second per account. If the number of calls per second exceeds the limit, throttling is triggered. As a result, your business may be affected. We recommend that you take note of the limit when you call this operation. + * * + * @param GetPhoneWithTokenRequest $request GetPhoneWithTokenRequest + * @param RuntimeOptions $runtime runtime options for this request RuntimeOptions + * + * @return GetPhoneWithTokenResponse GetPhoneWithTokenResponse + */ + public function getPhoneWithTokenWithOptions($request, $runtime) + { + Utils::validateModel($request); + $query = []; + if (!Utils::isUnset($request->ownerId)) { + $query['OwnerId'] = $request->ownerId; + } + if (!Utils::isUnset($request->resourceOwnerAccount)) { + $query['ResourceOwnerAccount'] = $request->resourceOwnerAccount; + } + if (!Utils::isUnset($request->resourceOwnerId)) { + $query['ResourceOwnerId'] = $request->resourceOwnerId; + } + if (!Utils::isUnset($request->spToken)) { + $query['SpToken'] = $request->spToken; + } + $req = new OpenApiRequest([ + 'query' => OpenApiUtilClient::query($query), + ]); + $params = new Params([ + 'action' => 'GetPhoneWithToken', + 'version' => '2017-05-25', + 'protocol' => 'HTTPS', + 'pathname' => '/', + 'method' => 'POST', + 'authType' => 'AK', + 'style' => 'RPC', + 'reqBodyType' => 'formData', + 'bodyType' => 'json', + ]); + + return GetPhoneWithTokenResponse::fromMap($this->callApi($params, $req, $runtime)); + } + + /** + * @summary Obtains a phone number for one-click logon. This operation is exclusive to HTML5 pages. + * * + * @description ### [](#)Preparations + * You must register an Alibaba Cloud account, obtain an Alibaba Cloud AccessKey pair, and create a verification service. For more information, see [Getting Started](https://help.aliyun.com/document_detail/84541.html). + * > This operation is applicable only to one-click logon or registration in HTML5 pages. You can call this operation only after you confirm the authorization on the authorization page provided by the JavaScript SDK. You are prohibited from simulating or bypassing the authorization process. Alibaba Cloud reserves the right to terminate our services and take legal actions against such violations. + * ### [](#qps)QPS limits + * You can call this operation up to 500 times per second per account. If the number of calls per second exceeds the limit, throttling is triggered. As a result, your business may be affected. We recommend that you take note of the limit when you call this operation. + * * + * @param GetPhoneWithTokenRequest $request GetPhoneWithTokenRequest + * + * @return GetPhoneWithTokenResponse GetPhoneWithTokenResponse + */ + public function getPhoneWithToken($request) + { + $runtime = new RuntimeOptions([]); + + return $this->getPhoneWithTokenWithOptions($request, $runtime); + } + + /** + * @summary Obtains the authorization token for an SMS verification code. + * * + * @description ### [](#)Preparations + * You must register an Alibaba Cloud account, obtain an Alibaba Cloud AccessKey pair, and create a verification service. For more information, see [Use the SMS verification feature](https://help.aliyun.com/document_detail/313209.html). + * ### [](#qps)QPS limits + * You can call this operation up to 5,000 times per second per account. If the number of calls per second exceeds the limit, throttling is triggered. As a result, your business may be affected. We recommend that you take note of the limit when you call this operation. + * * + * @param GetSmsAuthTokensRequest $request GetSmsAuthTokensRequest + * @param RuntimeOptions $runtime runtime options for this request RuntimeOptions + * + * @return GetSmsAuthTokensResponse GetSmsAuthTokensResponse + */ + public function getSmsAuthTokensWithOptions($request, $runtime) + { + Utils::validateModel($request); + $query = []; + if (!Utils::isUnset($request->bundleId)) { + $query['BundleId'] = $request->bundleId; + } + if (!Utils::isUnset($request->expire)) { + $query['Expire'] = $request->expire; + } + if (!Utils::isUnset($request->osType)) { + $query['OsType'] = $request->osType; + } + if (!Utils::isUnset($request->ownerId)) { + $query['OwnerId'] = $request->ownerId; + } + if (!Utils::isUnset($request->packageName)) { + $query['PackageName'] = $request->packageName; + } + if (!Utils::isUnset($request->resourceOwnerAccount)) { + $query['ResourceOwnerAccount'] = $request->resourceOwnerAccount; + } + if (!Utils::isUnset($request->resourceOwnerId)) { + $query['ResourceOwnerId'] = $request->resourceOwnerId; + } + if (!Utils::isUnset($request->sceneCode)) { + $query['SceneCode'] = $request->sceneCode; + } + if (!Utils::isUnset($request->signName)) { + $query['SignName'] = $request->signName; + } + if (!Utils::isUnset($request->smsCodeExpire)) { + $query['SmsCodeExpire'] = $request->smsCodeExpire; + } + if (!Utils::isUnset($request->smsTemplateCode)) { + $query['SmsTemplateCode'] = $request->smsTemplateCode; + } + $req = new OpenApiRequest([ + 'query' => OpenApiUtilClient::query($query), + ]); + $params = new Params([ + 'action' => 'GetSmsAuthTokens', + 'version' => '2017-05-25', + 'protocol' => 'HTTPS', + 'pathname' => '/', + 'method' => 'POST', + 'authType' => 'AK', + 'style' => 'RPC', + 'reqBodyType' => 'formData', + 'bodyType' => 'json', + ]); + + return GetSmsAuthTokensResponse::fromMap($this->callApi($params, $req, $runtime)); + } + + /** + * @summary Obtains the authorization token for an SMS verification code. + * * + * @description ### [](#)Preparations + * You must register an Alibaba Cloud account, obtain an Alibaba Cloud AccessKey pair, and create a verification service. For more information, see [Use the SMS verification feature](https://help.aliyun.com/document_detail/313209.html). + * ### [](#qps)QPS limits + * You can call this operation up to 5,000 times per second per account. If the number of calls per second exceeds the limit, throttling is triggered. As a result, your business may be affected. We recommend that you take note of the limit when you call this operation. + * * + * @param GetSmsAuthTokensRequest $request GetSmsAuthTokensRequest + * + * @return GetSmsAuthTokensResponse GetSmsAuthTokensResponse + */ + public function getSmsAuthTokens($request) + { + $runtime = new RuntimeOptions([]); + + return $this->getSmsAuthTokensWithOptions($request, $runtime); + } + + /** + * @deprecated openAPI JyCreateVerifyScheme is deprecated, please use Dypnsapi::2017-05-25::CreateVerifyScheme instead + * * + * @summary 创建方案号(为极意临时定制) + * * + * Deprecated + * + * @param JyCreateVerifySchemeRequest $request JyCreateVerifySchemeRequest + * @param RuntimeOptions $runtime runtime options for this request RuntimeOptions + * + * @return JyCreateVerifySchemeResponse JyCreateVerifySchemeResponse + */ + public function jyCreateVerifySchemeWithOptions($request, $runtime) + { + Utils::validateModel($request); + $query = []; + if (!Utils::isUnset($request->appName)) { + $query['AppName'] = $request->appName; + } + if (!Utils::isUnset($request->bundleId)) { + $query['BundleId'] = $request->bundleId; + } + if (!Utils::isUnset($request->cmApiCode)) { + $query['CmApiCode'] = $request->cmApiCode; + } + if (!Utils::isUnset($request->ctApiCode)) { + $query['CtApiCode'] = $request->ctApiCode; + } + if (!Utils::isUnset($request->cuApiCode)) { + $query['CuApiCode'] = $request->cuApiCode; + } + if (!Utils::isUnset($request->osType)) { + $query['OsType'] = $request->osType; + } + if (!Utils::isUnset($request->ownerId)) { + $query['OwnerId'] = $request->ownerId; + } + if (!Utils::isUnset($request->packName)) { + $query['PackName'] = $request->packName; + } + if (!Utils::isUnset($request->packSign)) { + $query['PackSign'] = $request->packSign; + } + if (!Utils::isUnset($request->resourceOwnerAccount)) { + $query['ResourceOwnerAccount'] = $request->resourceOwnerAccount; + } + if (!Utils::isUnset($request->resourceOwnerId)) { + $query['ResourceOwnerId'] = $request->resourceOwnerId; + } + if (!Utils::isUnset($request->schemeName)) { + $query['SchemeName'] = $request->schemeName; + } + $req = new OpenApiRequest([ + 'query' => OpenApiUtilClient::query($query), + ]); + $params = new Params([ + 'action' => 'JyCreateVerifyScheme', + 'version' => '2017-05-25', + 'protocol' => 'HTTPS', + 'pathname' => '/', + 'method' => 'POST', + 'authType' => 'AK', + 'style' => 'RPC', + 'reqBodyType' => 'formData', + 'bodyType' => 'json', + ]); + + return JyCreateVerifySchemeResponse::fromMap($this->callApi($params, $req, $runtime)); + } + + /** + * @deprecated openAPI JyCreateVerifyScheme is deprecated, please use Dypnsapi::2017-05-25::CreateVerifyScheme instead + * * + * @summary 创建方案号(为极意临时定制) + * * + * Deprecated + * + * @param JyCreateVerifySchemeRequest $request JyCreateVerifySchemeRequest + * + * @return JyCreateVerifySchemeResponse JyCreateVerifySchemeResponse + */ + public function jyCreateVerifyScheme($request) + { + $runtime = new RuntimeOptions([]); + + return $this->jyCreateVerifySchemeWithOptions($request, $runtime); + } + + /** + * @deprecated openAPI JyQueryAppInfoBySceneCode is deprecated, please use Dypnsapi::2017-05-25::QueryAppInfoBySceneCode instead + * * + * @summary 根据方案号查询运营商APP信(为极意临时定制) + * * + * Deprecated + * + * @param JyQueryAppInfoBySceneCodeRequest $request JyQueryAppInfoBySceneCodeRequest + * @param RuntimeOptions $runtime runtime options for this request RuntimeOptions + * + * @return JyQueryAppInfoBySceneCodeResponse JyQueryAppInfoBySceneCodeResponse + */ + public function jyQueryAppInfoBySceneCodeWithOptions($request, $runtime) + { + Utils::validateModel($request); + $query = []; + if (!Utils::isUnset($request->ownerId)) { + $query['OwnerId'] = $request->ownerId; + } + if (!Utils::isUnset($request->resourceOwnerAccount)) { + $query['ResourceOwnerAccount'] = $request->resourceOwnerAccount; + } + if (!Utils::isUnset($request->resourceOwnerId)) { + $query['ResourceOwnerId'] = $request->resourceOwnerId; + } + if (!Utils::isUnset($request->sceneCode)) { + $query['SceneCode'] = $request->sceneCode; + } + $req = new OpenApiRequest([ + 'query' => OpenApiUtilClient::query($query), + ]); + $params = new Params([ + 'action' => 'JyQueryAppInfoBySceneCode', + 'version' => '2017-05-25', + 'protocol' => 'HTTPS', + 'pathname' => '/', + 'method' => 'POST', + 'authType' => 'AK', + 'style' => 'RPC', + 'reqBodyType' => 'formData', + 'bodyType' => 'json', + ]); + + return JyQueryAppInfoBySceneCodeResponse::fromMap($this->callApi($params, $req, $runtime)); + } + + /** + * @deprecated openAPI JyQueryAppInfoBySceneCode is deprecated, please use Dypnsapi::2017-05-25::QueryAppInfoBySceneCode instead + * * + * @summary 根据方案号查询运营商APP信(为极意临时定制) + * * + * Deprecated + * + * @param JyQueryAppInfoBySceneCodeRequest $request JyQueryAppInfoBySceneCodeRequest + * + * @return JyQueryAppInfoBySceneCodeResponse JyQueryAppInfoBySceneCodeResponse + */ + public function jyQueryAppInfoBySceneCode($request) + { + $runtime = new RuntimeOptions([]); + + return $this->jyQueryAppInfoBySceneCodeWithOptions($request, $runtime); + } + + /** + * @summary Queries the fees generated by a verification service. + * * + * @description ### [](#qps)QPS limits + * You can call this operation up to 500 times per second per account. If the number of calls per second exceeds the limit, throttling is triggered. As a result, your business may be affected. We recommend that you take note of the limit when you call this operation. + * * + * @param QueryGateVerifyBillingPublicRequest $request QueryGateVerifyBillingPublicRequest + * @param RuntimeOptions $runtime runtime options for this request RuntimeOptions + * + * @return QueryGateVerifyBillingPublicResponse QueryGateVerifyBillingPublicResponse + */ + public function queryGateVerifyBillingPublicWithOptions($request, $runtime) + { + Utils::validateModel($request); + $query = []; + if (!Utils::isUnset($request->authenticationType)) { + $query['AuthenticationType'] = $request->authenticationType; + } + if (!Utils::isUnset($request->month)) { + $query['Month'] = $request->month; + } + if (!Utils::isUnset($request->ownerId)) { + $query['OwnerId'] = $request->ownerId; + } + if (!Utils::isUnset($request->resourceOwnerAccount)) { + $query['ResourceOwnerAccount'] = $request->resourceOwnerAccount; + } + $req = new OpenApiRequest([ + 'query' => OpenApiUtilClient::query($query), + ]); + $params = new Params([ + 'action' => 'QueryGateVerifyBillingPublic', + 'version' => '2017-05-25', + 'protocol' => 'HTTPS', + 'pathname' => '/', + 'method' => 'POST', + 'authType' => 'AK', + 'style' => 'RPC', + 'reqBodyType' => 'formData', + 'bodyType' => 'json', + ]); + + return QueryGateVerifyBillingPublicResponse::fromMap($this->callApi($params, $req, $runtime)); + } + + /** + * @summary Queries the fees generated by a verification service. + * * + * @description ### [](#qps)QPS limits + * You can call this operation up to 500 times per second per account. If the number of calls per second exceeds the limit, throttling is triggered. As a result, your business may be affected. We recommend that you take note of the limit when you call this operation. + * * + * @param QueryGateVerifyBillingPublicRequest $request QueryGateVerifyBillingPublicRequest + * + * @return QueryGateVerifyBillingPublicResponse QueryGateVerifyBillingPublicResponse + */ + public function queryGateVerifyBillingPublic($request) + { + $runtime = new RuntimeOptions([]); + + return $this->queryGateVerifyBillingPublicWithOptions($request, $runtime); + } + + /** + * @summary Queries the calls of Phone Number Verification Service. + * * + * @description ### [](#qps)QPS limits + * You can call this operation up to 500 times per second per account. If the number of calls per second exceeds the limit, throttling is triggered. As a result, your business may be affected. We recommend that you take note of the limit when you call this operation. + * * + * @param QueryGateVerifyStatisticPublicRequest $request QueryGateVerifyStatisticPublicRequest + * @param RuntimeOptions $runtime runtime options for this request RuntimeOptions + * + * @return QueryGateVerifyStatisticPublicResponse QueryGateVerifyStatisticPublicResponse + */ + public function queryGateVerifyStatisticPublicWithOptions($request, $runtime) + { + Utils::validateModel($request); + $query = []; + if (!Utils::isUnset($request->authenticationType)) { + $query['AuthenticationType'] = $request->authenticationType; + } + if (!Utils::isUnset($request->endDate)) { + $query['EndDate'] = $request->endDate; + } + if (!Utils::isUnset($request->osType)) { + $query['OsType'] = $request->osType; + } + if (!Utils::isUnset($request->ownerId)) { + $query['OwnerId'] = $request->ownerId; + } + if (!Utils::isUnset($request->resourceOwnerAccount)) { + $query['ResourceOwnerAccount'] = $request->resourceOwnerAccount; + } + if (!Utils::isUnset($request->sceneCode)) { + $query['SceneCode'] = $request->sceneCode; + } + if (!Utils::isUnset($request->startDate)) { + $query['StartDate'] = $request->startDate; + } + $req = new OpenApiRequest([ + 'query' => OpenApiUtilClient::query($query), + ]); + $params = new Params([ + 'action' => 'QueryGateVerifyStatisticPublic', + 'version' => '2017-05-25', + 'protocol' => 'HTTPS', + 'pathname' => '/', + 'method' => 'POST', + 'authType' => 'AK', + 'style' => 'RPC', + 'reqBodyType' => 'formData', + 'bodyType' => 'json', + ]); + + return QueryGateVerifyStatisticPublicResponse::fromMap($this->callApi($params, $req, $runtime)); + } + + /** + * @summary Queries the calls of Phone Number Verification Service. + * * + * @description ### [](#qps)QPS limits + * You can call this operation up to 500 times per second per account. If the number of calls per second exceeds the limit, throttling is triggered. As a result, your business may be affected. We recommend that you take note of the limit when you call this operation. + * * + * @param QueryGateVerifyStatisticPublicRequest $request QueryGateVerifyStatisticPublicRequest + * + * @return QueryGateVerifyStatisticPublicResponse QueryGateVerifyStatisticPublicResponse + */ + public function queryGateVerifyStatisticPublic($request) + { + $runtime = new RuntimeOptions([]); + + return $this->queryGateVerifyStatisticPublicWithOptions($request, $runtime); + } + + /** + * @deprecated OpenAPI QuerySendDetails is deprecated + * * + * @summary Queries the delivery status of the SMS verification code. You can query only the delivery status of the SMS verification code that is sent by calling corresponding API operations. + * * + * Deprecated + * + * @param QuerySendDetailsRequest $request QuerySendDetailsRequest + * @param RuntimeOptions $runtime runtime options for this request RuntimeOptions + * + * @return QuerySendDetailsResponse QuerySendDetailsResponse + */ + public function querySendDetailsWithOptions($request, $runtime) + { + Utils::validateModel($request); + $query = []; + if (!Utils::isUnset($request->bizId)) { + $query['BizId'] = $request->bizId; + } + if (!Utils::isUnset($request->currentPage)) { + $query['CurrentPage'] = $request->currentPage; + } + if (!Utils::isUnset($request->ownerId)) { + $query['OwnerId'] = $request->ownerId; + } + if (!Utils::isUnset($request->pageSize)) { + $query['PageSize'] = $request->pageSize; + } + if (!Utils::isUnset($request->phoneNumber)) { + $query['PhoneNumber'] = $request->phoneNumber; + } + if (!Utils::isUnset($request->resourceOwnerAccount)) { + $query['ResourceOwnerAccount'] = $request->resourceOwnerAccount; + } + if (!Utils::isUnset($request->resourceOwnerId)) { + $query['ResourceOwnerId'] = $request->resourceOwnerId; + } + if (!Utils::isUnset($request->sendDate)) { + $query['SendDate'] = $request->sendDate; + } + $req = new OpenApiRequest([ + 'query' => OpenApiUtilClient::query($query), + ]); + $params = new Params([ + 'action' => 'QuerySendDetails', + 'version' => '2017-05-25', + 'protocol' => 'HTTPS', + 'pathname' => '/', + 'method' => 'POST', + 'authType' => 'AK', + 'style' => 'RPC', + 'reqBodyType' => 'formData', + 'bodyType' => 'json', + ]); + + return QuerySendDetailsResponse::fromMap($this->callApi($params, $req, $runtime)); + } + + /** + * @deprecated OpenAPI QuerySendDetails is deprecated + * * + * @summary Queries the delivery status of the SMS verification code. You can query only the delivery status of the SMS verification code that is sent by calling corresponding API operations. + * * + * Deprecated + * + * @param QuerySendDetailsRequest $request QuerySendDetailsRequest + * + * @return QuerySendDetailsResponse QuerySendDetailsResponse + */ + public function querySendDetails($request) + { + $runtime = new RuntimeOptions([]); + + return $this->querySendDetailsWithOptions($request, $runtime); + } + + /** + * @summary Sends SMS verification codes. + * * + * @param SendSmsVerifyCodeRequest $request SendSmsVerifyCodeRequest + * @param RuntimeOptions $runtime runtime options for this request RuntimeOptions + * + * @return SendSmsVerifyCodeResponse SendSmsVerifyCodeResponse + */ + public function sendSmsVerifyCodeWithOptions($request, $runtime) + { + Utils::validateModel($request); + $query = []; + if (!Utils::isUnset($request->codeLength)) { + $query['CodeLength'] = $request->codeLength; + } + if (!Utils::isUnset($request->codeType)) { + $query['CodeType'] = $request->codeType; + } + if (!Utils::isUnset($request->countryCode)) { + $query['CountryCode'] = $request->countryCode; + } + if (!Utils::isUnset($request->duplicatePolicy)) { + $query['DuplicatePolicy'] = $request->duplicatePolicy; + } + if (!Utils::isUnset($request->interval)) { + $query['Interval'] = $request->interval; + } + if (!Utils::isUnset($request->outId)) { + $query['OutId'] = $request->outId; + } + if (!Utils::isUnset($request->ownerId)) { + $query['OwnerId'] = $request->ownerId; + } + if (!Utils::isUnset($request->phoneNumber)) { + $query['PhoneNumber'] = $request->phoneNumber; + } + if (!Utils::isUnset($request->resourceOwnerAccount)) { + $query['ResourceOwnerAccount'] = $request->resourceOwnerAccount; + } + if (!Utils::isUnset($request->resourceOwnerId)) { + $query['ResourceOwnerId'] = $request->resourceOwnerId; + } + if (!Utils::isUnset($request->returnVerifyCode)) { + $query['ReturnVerifyCode'] = $request->returnVerifyCode; + } + if (!Utils::isUnset($request->schemeName)) { + $query['SchemeName'] = $request->schemeName; + } + if (!Utils::isUnset($request->signName)) { + $query['SignName'] = $request->signName; + } + if (!Utils::isUnset($request->smsUpExtendCode)) { + $query['SmsUpExtendCode'] = $request->smsUpExtendCode; + } + if (!Utils::isUnset($request->templateCode)) { + $query['TemplateCode'] = $request->templateCode; + } + if (!Utils::isUnset($request->templateParam)) { + $query['TemplateParam'] = $request->templateParam; + } + if (!Utils::isUnset($request->validTime)) { + $query['ValidTime'] = $request->validTime; + } + $req = new OpenApiRequest([ + 'query' => OpenApiUtilClient::query($query), + ]); + $params = new Params([ + 'action' => 'SendSmsVerifyCode', + 'version' => '2017-05-25', + 'protocol' => 'HTTPS', + 'pathname' => '/', + 'method' => 'POST', + 'authType' => 'AK', + 'style' => 'RPC', + 'reqBodyType' => 'formData', + 'bodyType' => 'json', + ]); + + return SendSmsVerifyCodeResponse::fromMap($this->callApi($params, $req, $runtime)); + } + + /** + * @summary Sends SMS verification codes. + * * + * @param SendSmsVerifyCodeRequest $request SendSmsVerifyCodeRequest + * + * @return SendSmsVerifyCodeResponse SendSmsVerifyCodeResponse + */ + public function sendSmsVerifyCode($request) + { + $runtime = new RuntimeOptions([]); + + return $this->sendSmsVerifyCodeWithOptions($request, $runtime); + } + + /** + * @summary Verifies the phone number that you use. + * * + * @description ### [](#)Preparations + * You must register an Alibaba Cloud account, obtain an Alibaba Cloud AccessKey pair, and create a verification service. For more information, see [Getting Started](https://help.aliyun.com/document_detail/84541.html). + * > This operation is applicable to only the verification of thephone number that you use. To obtain a phone number for one-click logon, call [GetMobile](https://help.aliyun.com/document_detail/189865.html). + * ### [](#qps)QPS limits + * You can call this operation up to 5,000 times per second per account. If the number of calls per second exceeds the limit, throttling is triggered. As a result, your business may be affected. We recommend that you take note of the limit when you call this operation. + * * + * @param VerifyMobileRequest $request VerifyMobileRequest + * @param RuntimeOptions $runtime runtime options for this request RuntimeOptions + * + * @return VerifyMobileResponse VerifyMobileResponse + */ + public function verifyMobileWithOptions($request, $runtime) + { + Utils::validateModel($request); + $query = []; + if (!Utils::isUnset($request->accessCode)) { + $query['AccessCode'] = $request->accessCode; + } + if (!Utils::isUnset($request->outId)) { + $query['OutId'] = $request->outId; + } + if (!Utils::isUnset($request->ownerId)) { + $query['OwnerId'] = $request->ownerId; + } + if (!Utils::isUnset($request->phoneNumber)) { + $query['PhoneNumber'] = $request->phoneNumber; + } + if (!Utils::isUnset($request->resourceOwnerAccount)) { + $query['ResourceOwnerAccount'] = $request->resourceOwnerAccount; + } + if (!Utils::isUnset($request->resourceOwnerId)) { + $query['ResourceOwnerId'] = $request->resourceOwnerId; + } + $req = new OpenApiRequest([ + 'query' => OpenApiUtilClient::query($query), + ]); + $params = new Params([ + 'action' => 'VerifyMobile', + 'version' => '2017-05-25', + 'protocol' => 'HTTPS', + 'pathname' => '/', + 'method' => 'POST', + 'authType' => 'AK', + 'style' => 'RPC', + 'reqBodyType' => 'formData', + 'bodyType' => 'json', + ]); + + return VerifyMobileResponse::fromMap($this->callApi($params, $req, $runtime)); + } + + /** + * @summary Verifies the phone number that you use. + * * + * @description ### [](#)Preparations + * You must register an Alibaba Cloud account, obtain an Alibaba Cloud AccessKey pair, and create a verification service. For more information, see [Getting Started](https://help.aliyun.com/document_detail/84541.html). + * > This operation is applicable to only the verification of thephone number that you use. To obtain a phone number for one-click logon, call [GetMobile](https://help.aliyun.com/document_detail/189865.html). + * ### [](#qps)QPS limits + * You can call this operation up to 5,000 times per second per account. If the number of calls per second exceeds the limit, throttling is triggered. As a result, your business may be affected. We recommend that you take note of the limit when you call this operation. + * * + * @param VerifyMobileRequest $request VerifyMobileRequest + * + * @return VerifyMobileResponse VerifyMobileResponse + */ + public function verifyMobile($request) + { + $runtime = new RuntimeOptions([]); + + return $this->verifyMobileWithOptions($request, $runtime); + } + + /** + * @summary Verifies the phone number used in HTML5 pages. + * * + * @description ### [](#)Preparations + * You must register an Alibaba Cloud account, obtain an Alibaba Cloud AccessKey pair, and create a verification service. For more information, see [Use the phone number verification feature for HTML5 pages](https://help.aliyun.com/document_detail/169786.html). + * ### [](#qps)QPS limits + * You can call this operation up to 1,000 times per second per account. If the number of calls per second exceeds the limit, throttling is triggered. As a result, your business may be affected. We recommend that you take note of the limit when you call this operation. + * * + * @param VerifyPhoneWithTokenRequest $request VerifyPhoneWithTokenRequest + * @param RuntimeOptions $runtime runtime options for this request RuntimeOptions + * + * @return VerifyPhoneWithTokenResponse VerifyPhoneWithTokenResponse + */ + public function verifyPhoneWithTokenWithOptions($request, $runtime) + { + Utils::validateModel($request); + $query = []; + if (!Utils::isUnset($request->ownerId)) { + $query['OwnerId'] = $request->ownerId; + } + if (!Utils::isUnset($request->phoneNumber)) { + $query['PhoneNumber'] = $request->phoneNumber; + } + if (!Utils::isUnset($request->resourceOwnerAccount)) { + $query['ResourceOwnerAccount'] = $request->resourceOwnerAccount; + } + if (!Utils::isUnset($request->resourceOwnerId)) { + $query['ResourceOwnerId'] = $request->resourceOwnerId; + } + if (!Utils::isUnset($request->spToken)) { + $query['SpToken'] = $request->spToken; + } + $req = new OpenApiRequest([ + 'query' => OpenApiUtilClient::query($query), + ]); + $params = new Params([ + 'action' => 'VerifyPhoneWithToken', + 'version' => '2017-05-25', + 'protocol' => 'HTTPS', + 'pathname' => '/', + 'method' => 'POST', + 'authType' => 'AK', + 'style' => 'RPC', + 'reqBodyType' => 'formData', + 'bodyType' => 'json', + ]); + + return VerifyPhoneWithTokenResponse::fromMap($this->callApi($params, $req, $runtime)); + } + + /** + * @summary Verifies the phone number used in HTML5 pages. + * * + * @description ### [](#)Preparations + * You must register an Alibaba Cloud account, obtain an Alibaba Cloud AccessKey pair, and create a verification service. For more information, see [Use the phone number verification feature for HTML5 pages](https://help.aliyun.com/document_detail/169786.html). + * ### [](#qps)QPS limits + * You can call this operation up to 1,000 times per second per account. If the number of calls per second exceeds the limit, throttling is triggered. As a result, your business may be affected. We recommend that you take note of the limit when you call this operation. + * * + * @param VerifyPhoneWithTokenRequest $request VerifyPhoneWithTokenRequest + * + * @return VerifyPhoneWithTokenResponse VerifyPhoneWithTokenResponse + */ + public function verifyPhoneWithToken($request) + { + $runtime = new RuntimeOptions([]); + + return $this->verifyPhoneWithTokenWithOptions($request, $runtime); + } + + /** + * @summary Verifies SMS verification codes. + * * + * @description ### [](#)Preparations + * You must register an Alibaba Cloud account, obtain an Alibaba Cloud AccessKey pair, and create a verification service. For more information, see [Use the SMS verification feature](https://help.aliyun.com/document_detail/313209.html). + * ### [](#qps)QPS limits + * You can call this operation up to 500 times per second per account. If the number of calls per second exceeds the limit, throttling is triggered. As a result, your business may be affected. We recommend that you take note of the limit when you call this operation. + * * + * @param VerifySmsCodeRequest $request VerifySmsCodeRequest + * @param RuntimeOptions $runtime runtime options for this request RuntimeOptions + * + * @return VerifySmsCodeResponse VerifySmsCodeResponse + */ + public function verifySmsCodeWithOptions($request, $runtime) + { + Utils::validateModel($request); + $query = []; + if (!Utils::isUnset($request->phoneNumber)) { + $query['PhoneNumber'] = $request->phoneNumber; + } + if (!Utils::isUnset($request->smsCode)) { + $query['SmsCode'] = $request->smsCode; + } + if (!Utils::isUnset($request->smsToken)) { + $query['SmsToken'] = $request->smsToken; + } + $req = new OpenApiRequest([ + 'query' => OpenApiUtilClient::query($query), + ]); + $params = new Params([ + 'action' => 'VerifySmsCode', + 'version' => '2017-05-25', + 'protocol' => 'HTTPS', + 'pathname' => '/', + 'method' => 'POST', + 'authType' => 'AK', + 'style' => 'RPC', + 'reqBodyType' => 'formData', + 'bodyType' => 'json', + ]); + + return VerifySmsCodeResponse::fromMap($this->callApi($params, $req, $runtime)); + } + + /** + * @summary Verifies SMS verification codes. + * * + * @description ### [](#)Preparations + * You must register an Alibaba Cloud account, obtain an Alibaba Cloud AccessKey pair, and create a verification service. For more information, see [Use the SMS verification feature](https://help.aliyun.com/document_detail/313209.html). + * ### [](#qps)QPS limits + * You can call this operation up to 500 times per second per account. If the number of calls per second exceeds the limit, throttling is triggered. As a result, your business may be affected. We recommend that you take note of the limit when you call this operation. + * * + * @param VerifySmsCodeRequest $request VerifySmsCodeRequest + * + * @return VerifySmsCodeResponse VerifySmsCodeResponse + */ + public function verifySmsCode($request) + { + $runtime = new RuntimeOptions([]); + + return $this->verifySmsCodeWithOptions($request, $runtime); + } + + /** + * @summary Obtains the verification results by using the verification token that is obtained by using the authentication token. + * * + * @param VerifyWithFusionAuthTokenRequest $request VerifyWithFusionAuthTokenRequest + * @param RuntimeOptions $runtime runtime options for this request RuntimeOptions + * + * @return VerifyWithFusionAuthTokenResponse VerifyWithFusionAuthTokenResponse + */ + public function verifyWithFusionAuthTokenWithOptions($request, $runtime) + { + Utils::validateModel($request); + $query = []; + if (!Utils::isUnset($request->ownerId)) { + $query['OwnerId'] = $request->ownerId; + } + if (!Utils::isUnset($request->resourceOwnerAccount)) { + $query['ResourceOwnerAccount'] = $request->resourceOwnerAccount; + } + if (!Utils::isUnset($request->resourceOwnerId)) { + $query['ResourceOwnerId'] = $request->resourceOwnerId; + } + if (!Utils::isUnset($request->verifyToken)) { + $query['VerifyToken'] = $request->verifyToken; + } + $req = new OpenApiRequest([ + 'query' => OpenApiUtilClient::query($query), + ]); + $params = new Params([ + 'action' => 'VerifyWithFusionAuthToken', + 'version' => '2017-05-25', + 'protocol' => 'HTTPS', + 'pathname' => '/', + 'method' => 'POST', + 'authType' => 'AK', + 'style' => 'RPC', + 'reqBodyType' => 'formData', + 'bodyType' => 'json', + ]); + + return VerifyWithFusionAuthTokenResponse::fromMap($this->callApi($params, $req, $runtime)); + } + + /** + * @summary Obtains the verification results by using the verification token that is obtained by using the authentication token. + * * + * @param VerifyWithFusionAuthTokenRequest $request VerifyWithFusionAuthTokenRequest + * + * @return VerifyWithFusionAuthTokenResponse VerifyWithFusionAuthTokenResponse + */ + public function verifyWithFusionAuthToken($request) + { + $runtime = new RuntimeOptions([]); + + return $this->verifyWithFusionAuthTokenWithOptions($request, $runtime); + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/CheckSmsVerifyCodeRequest.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/CheckSmsVerifyCodeRequest.php new file mode 100644 index 0000000..41437b0 --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/CheckSmsVerifyCodeRequest.php @@ -0,0 +1,172 @@ + 'CaseAuthPolicy', + 'countryCode' => 'CountryCode', + 'outId' => 'OutId', + 'ownerId' => 'OwnerId', + 'phoneNumber' => 'PhoneNumber', + 'resourceOwnerAccount' => 'ResourceOwnerAccount', + 'resourceOwnerId' => 'ResourceOwnerId', + 'schemeName' => 'SchemeName', + 'verifyCode' => 'VerifyCode', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->caseAuthPolicy) { + $res['CaseAuthPolicy'] = $this->caseAuthPolicy; + } + if (null !== $this->countryCode) { + $res['CountryCode'] = $this->countryCode; + } + if (null !== $this->outId) { + $res['OutId'] = $this->outId; + } + if (null !== $this->ownerId) { + $res['OwnerId'] = $this->ownerId; + } + if (null !== $this->phoneNumber) { + $res['PhoneNumber'] = $this->phoneNumber; + } + if (null !== $this->resourceOwnerAccount) { + $res['ResourceOwnerAccount'] = $this->resourceOwnerAccount; + } + if (null !== $this->resourceOwnerId) { + $res['ResourceOwnerId'] = $this->resourceOwnerId; + } + if (null !== $this->schemeName) { + $res['SchemeName'] = $this->schemeName; + } + if (null !== $this->verifyCode) { + $res['VerifyCode'] = $this->verifyCode; + } + + return $res; + } + + /** + * @param array $map + * + * @return CheckSmsVerifyCodeRequest + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['CaseAuthPolicy'])) { + $model->caseAuthPolicy = $map['CaseAuthPolicy']; + } + if (isset($map['CountryCode'])) { + $model->countryCode = $map['CountryCode']; + } + if (isset($map['OutId'])) { + $model->outId = $map['OutId']; + } + if (isset($map['OwnerId'])) { + $model->ownerId = $map['OwnerId']; + } + if (isset($map['PhoneNumber'])) { + $model->phoneNumber = $map['PhoneNumber']; + } + if (isset($map['ResourceOwnerAccount'])) { + $model->resourceOwnerAccount = $map['ResourceOwnerAccount']; + } + if (isset($map['ResourceOwnerId'])) { + $model->resourceOwnerId = $map['ResourceOwnerId']; + } + if (isset($map['SchemeName'])) { + $model->schemeName = $map['SchemeName']; + } + if (isset($map['VerifyCode'])) { + $model->verifyCode = $map['VerifyCode']; + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/CheckSmsVerifyCodeResponse.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/CheckSmsVerifyCodeResponse.php new file mode 100644 index 0000000..0f2f7ff --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/CheckSmsVerifyCodeResponse.php @@ -0,0 +1,71 @@ + 'headers', + 'statusCode' => 'statusCode', + 'body' => 'body', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->headers) { + $res['headers'] = $this->headers; + } + if (null !== $this->statusCode) { + $res['statusCode'] = $this->statusCode; + } + if (null !== $this->body) { + $res['body'] = null !== $this->body ? $this->body->toMap() : null; + } + + return $res; + } + + /** + * @param array $map + * + * @return CheckSmsVerifyCodeResponse + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['headers'])) { + $model->headers = $map['headers']; + } + if (isset($map['statusCode'])) { + $model->statusCode = $map['statusCode']; + } + if (isset($map['body'])) { + $model->body = CheckSmsVerifyCodeResponseBody::fromMap($map['body']); + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/CheckSmsVerifyCodeResponseBody.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/CheckSmsVerifyCodeResponseBody.php new file mode 100644 index 0000000..f993aeb --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/CheckSmsVerifyCodeResponseBody.php @@ -0,0 +1,120 @@ + 'AccessDeniedDetail', + 'code' => 'Code', + 'message' => 'Message', + 'model' => 'Model', + 'success' => 'Success', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->accessDeniedDetail) { + $res['AccessDeniedDetail'] = $this->accessDeniedDetail; + } + if (null !== $this->code) { + $res['Code'] = $this->code; + } + if (null !== $this->message) { + $res['Message'] = $this->message; + } + if (null !== $this->model) { + $res['Model'] = null !== $this->model ? $this->model->toMap() : null; + } + if (null !== $this->success) { + $res['Success'] = $this->success; + } + + return $res; + } + + /** + * @param array $map + * + * @return CheckSmsVerifyCodeResponseBody + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['AccessDeniedDetail'])) { + $model->accessDeniedDetail = $map['AccessDeniedDetail']; + } + if (isset($map['Code'])) { + $model->code = $map['Code']; + } + if (isset($map['Message'])) { + $model->message = $map['Message']; + } + if (isset($map['Model'])) { + $model->model = model_::fromMap($map['Model']); + } + if (isset($map['Success'])) { + $model->success = $map['Success']; + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/CheckSmsVerifyCodeResponseBody/model_.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/CheckSmsVerifyCodeResponseBody/model_.php new file mode 100644 index 0000000..ceff045 --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/CheckSmsVerifyCodeResponseBody/model_.php @@ -0,0 +1,70 @@ + 'OutId', + 'verifyResult' => 'VerifyResult', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->outId) { + $res['OutId'] = $this->outId; + } + if (null !== $this->verifyResult) { + $res['VerifyResult'] = $this->verifyResult; + } + + return $res; + } + + /** + * @param array $map + * + * @return model_ + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['OutId'])) { + $model->outId = $map['OutId']; + } + if (isset($map['VerifyResult'])) { + $model->verifyResult = $map['VerifyResult']; + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/CreateSchemeConfigRequest.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/CreateSchemeConfigRequest.php new file mode 100644 index 0000000..9a4c08e --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/CreateSchemeConfigRequest.php @@ -0,0 +1,206 @@ + 'AndroidPackageName', + 'androidPackageSign' => 'AndroidPackageSign', + 'appName' => 'AppName', + 'h5Origin' => 'H5Origin', + 'h5Url' => 'H5Url', + 'iosBundleId' => 'IosBundleId', + 'ownerId' => 'OwnerId', + 'platform' => 'Platform', + 'resourceOwnerAccount' => 'ResourceOwnerAccount', + 'resourceOwnerId' => 'ResourceOwnerId', + 'schemeName' => 'SchemeName', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->androidPackageName) { + $res['AndroidPackageName'] = $this->androidPackageName; + } + if (null !== $this->androidPackageSign) { + $res['AndroidPackageSign'] = $this->androidPackageSign; + } + if (null !== $this->appName) { + $res['AppName'] = $this->appName; + } + if (null !== $this->h5Origin) { + $res['H5Origin'] = $this->h5Origin; + } + if (null !== $this->h5Url) { + $res['H5Url'] = $this->h5Url; + } + if (null !== $this->iosBundleId) { + $res['IosBundleId'] = $this->iosBundleId; + } + if (null !== $this->ownerId) { + $res['OwnerId'] = $this->ownerId; + } + if (null !== $this->platform) { + $res['Platform'] = $this->platform; + } + if (null !== $this->resourceOwnerAccount) { + $res['ResourceOwnerAccount'] = $this->resourceOwnerAccount; + } + if (null !== $this->resourceOwnerId) { + $res['ResourceOwnerId'] = $this->resourceOwnerId; + } + if (null !== $this->schemeName) { + $res['SchemeName'] = $this->schemeName; + } + + return $res; + } + + /** + * @param array $map + * + * @return CreateSchemeConfigRequest + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['AndroidPackageName'])) { + $model->androidPackageName = $map['AndroidPackageName']; + } + if (isset($map['AndroidPackageSign'])) { + $model->androidPackageSign = $map['AndroidPackageSign']; + } + if (isset($map['AppName'])) { + $model->appName = $map['AppName']; + } + if (isset($map['H5Origin'])) { + $model->h5Origin = $map['H5Origin']; + } + if (isset($map['H5Url'])) { + $model->h5Url = $map['H5Url']; + } + if (isset($map['IosBundleId'])) { + $model->iosBundleId = $map['IosBundleId']; + } + if (isset($map['OwnerId'])) { + $model->ownerId = $map['OwnerId']; + } + if (isset($map['Platform'])) { + $model->platform = $map['Platform']; + } + if (isset($map['ResourceOwnerAccount'])) { + $model->resourceOwnerAccount = $map['ResourceOwnerAccount']; + } + if (isset($map['ResourceOwnerId'])) { + $model->resourceOwnerId = $map['ResourceOwnerId']; + } + if (isset($map['SchemeName'])) { + $model->schemeName = $map['SchemeName']; + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/CreateSchemeConfigResponse.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/CreateSchemeConfigResponse.php new file mode 100644 index 0000000..018528f --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/CreateSchemeConfigResponse.php @@ -0,0 +1,71 @@ + 'headers', + 'statusCode' => 'statusCode', + 'body' => 'body', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->headers) { + $res['headers'] = $this->headers; + } + if (null !== $this->statusCode) { + $res['statusCode'] = $this->statusCode; + } + if (null !== $this->body) { + $res['body'] = null !== $this->body ? $this->body->toMap() : null; + } + + return $res; + } + + /** + * @param array $map + * + * @return CreateSchemeConfigResponse + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['headers'])) { + $model->headers = $map['headers']; + } + if (isset($map['statusCode'])) { + $model->statusCode = $map['statusCode']; + } + if (isset($map['body'])) { + $model->body = CreateSchemeConfigResponseBody::fromMap($map['body']); + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/CreateSchemeConfigResponseBody.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/CreateSchemeConfigResponseBody.php new file mode 100644 index 0000000..7a24fb3 --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/CreateSchemeConfigResponseBody.php @@ -0,0 +1,120 @@ + 'Code', + 'message' => 'Message', + 'model' => 'Model', + 'requestId' => 'RequestId', + 'success' => 'Success', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->code) { + $res['Code'] = $this->code; + } + if (null !== $this->message) { + $res['Message'] = $this->message; + } + if (null !== $this->model) { + $res['Model'] = null !== $this->model ? $this->model->toMap() : null; + } + if (null !== $this->requestId) { + $res['RequestId'] = $this->requestId; + } + if (null !== $this->success) { + $res['Success'] = $this->success; + } + + return $res; + } + + /** + * @param array $map + * + * @return CreateSchemeConfigResponseBody + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['Code'])) { + $model->code = $map['Code']; + } + if (isset($map['Message'])) { + $model->message = $map['Message']; + } + if (isset($map['Model'])) { + $model->model = model_::fromMap($map['Model']); + } + if (isset($map['RequestId'])) { + $model->requestId = $map['RequestId']; + } + if (isset($map['Success'])) { + $model->success = $map['Success']; + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/CreateSchemeConfigResponseBody/model_.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/CreateSchemeConfigResponseBody/model_.php new file mode 100644 index 0000000..07e3862 --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/CreateSchemeConfigResponseBody/model_.php @@ -0,0 +1,51 @@ + 'SchemeCode', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->schemeCode) { + $res['SchemeCode'] = $this->schemeCode; + } + + return $res; + } + + /** + * @param array $map + * + * @return model_ + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['SchemeCode'])) { + $model->schemeCode = $map['SchemeCode']; + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/CreateVerifySchemeRequest.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/CreateVerifySchemeRequest.php new file mode 100644 index 0000000..6a7af9a --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/CreateVerifySchemeRequest.php @@ -0,0 +1,369 @@ + 'AppName', + 'authType' => 'AuthType', + 'bundleId' => 'BundleId', + 'cmApiCode' => 'CmApiCode', + 'ctApiCode' => 'CtApiCode', + 'cuApiCode' => 'CuApiCode', + 'email' => 'Email', + 'hmAppIdentifier' => 'HmAppIdentifier', + 'hmPackageName' => 'HmPackageName', + 'hmSignName' => 'HmSignName', + 'ipWhiteList' => 'IpWhiteList', + 'origin' => 'Origin', + 'osType' => 'OsType', + 'ownerId' => 'OwnerId', + 'packName' => 'PackName', + 'packSign' => 'PackSign', + 'resourceOwnerAccount' => 'ResourceOwnerAccount', + 'resourceOwnerId' => 'ResourceOwnerId', + 'sceneType' => 'SceneType', + 'schemeName' => 'SchemeName', + 'smsSignName' => 'SmsSignName', + 'url' => 'Url', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->appName) { + $res['AppName'] = $this->appName; + } + if (null !== $this->authType) { + $res['AuthType'] = $this->authType; + } + if (null !== $this->bundleId) { + $res['BundleId'] = $this->bundleId; + } + if (null !== $this->cmApiCode) { + $res['CmApiCode'] = $this->cmApiCode; + } + if (null !== $this->ctApiCode) { + $res['CtApiCode'] = $this->ctApiCode; + } + if (null !== $this->cuApiCode) { + $res['CuApiCode'] = $this->cuApiCode; + } + if (null !== $this->email) { + $res['Email'] = $this->email; + } + if (null !== $this->hmAppIdentifier) { + $res['HmAppIdentifier'] = $this->hmAppIdentifier; + } + if (null !== $this->hmPackageName) { + $res['HmPackageName'] = $this->hmPackageName; + } + if (null !== $this->hmSignName) { + $res['HmSignName'] = $this->hmSignName; + } + if (null !== $this->ipWhiteList) { + $res['IpWhiteList'] = $this->ipWhiteList; + } + if (null !== $this->origin) { + $res['Origin'] = $this->origin; + } + if (null !== $this->osType) { + $res['OsType'] = $this->osType; + } + if (null !== $this->ownerId) { + $res['OwnerId'] = $this->ownerId; + } + if (null !== $this->packName) { + $res['PackName'] = $this->packName; + } + if (null !== $this->packSign) { + $res['PackSign'] = $this->packSign; + } + if (null !== $this->resourceOwnerAccount) { + $res['ResourceOwnerAccount'] = $this->resourceOwnerAccount; + } + if (null !== $this->resourceOwnerId) { + $res['ResourceOwnerId'] = $this->resourceOwnerId; + } + if (null !== $this->sceneType) { + $res['SceneType'] = $this->sceneType; + } + if (null !== $this->schemeName) { + $res['SchemeName'] = $this->schemeName; + } + if (null !== $this->smsSignName) { + $res['SmsSignName'] = $this->smsSignName; + } + if (null !== $this->url) { + $res['Url'] = $this->url; + } + + return $res; + } + + /** + * @param array $map + * + * @return CreateVerifySchemeRequest + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['AppName'])) { + $model->appName = $map['AppName']; + } + if (isset($map['AuthType'])) { + $model->authType = $map['AuthType']; + } + if (isset($map['BundleId'])) { + $model->bundleId = $map['BundleId']; + } + if (isset($map['CmApiCode'])) { + $model->cmApiCode = $map['CmApiCode']; + } + if (isset($map['CtApiCode'])) { + $model->ctApiCode = $map['CtApiCode']; + } + if (isset($map['CuApiCode'])) { + $model->cuApiCode = $map['CuApiCode']; + } + if (isset($map['Email'])) { + $model->email = $map['Email']; + } + if (isset($map['HmAppIdentifier'])) { + $model->hmAppIdentifier = $map['HmAppIdentifier']; + } + if (isset($map['HmPackageName'])) { + $model->hmPackageName = $map['HmPackageName']; + } + if (isset($map['HmSignName'])) { + $model->hmSignName = $map['HmSignName']; + } + if (isset($map['IpWhiteList'])) { + $model->ipWhiteList = $map['IpWhiteList']; + } + if (isset($map['Origin'])) { + $model->origin = $map['Origin']; + } + if (isset($map['OsType'])) { + $model->osType = $map['OsType']; + } + if (isset($map['OwnerId'])) { + $model->ownerId = $map['OwnerId']; + } + if (isset($map['PackName'])) { + $model->packName = $map['PackName']; + } + if (isset($map['PackSign'])) { + $model->packSign = $map['PackSign']; + } + if (isset($map['ResourceOwnerAccount'])) { + $model->resourceOwnerAccount = $map['ResourceOwnerAccount']; + } + if (isset($map['ResourceOwnerId'])) { + $model->resourceOwnerId = $map['ResourceOwnerId']; + } + if (isset($map['SceneType'])) { + $model->sceneType = $map['SceneType']; + } + if (isset($map['SchemeName'])) { + $model->schemeName = $map['SchemeName']; + } + if (isset($map['SmsSignName'])) { + $model->smsSignName = $map['SmsSignName']; + } + if (isset($map['Url'])) { + $model->url = $map['Url']; + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/CreateVerifySchemeResponse.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/CreateVerifySchemeResponse.php new file mode 100644 index 0000000..725d738 --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/CreateVerifySchemeResponse.php @@ -0,0 +1,71 @@ + 'headers', + 'statusCode' => 'statusCode', + 'body' => 'body', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->headers) { + $res['headers'] = $this->headers; + } + if (null !== $this->statusCode) { + $res['statusCode'] = $this->statusCode; + } + if (null !== $this->body) { + $res['body'] = null !== $this->body ? $this->body->toMap() : null; + } + + return $res; + } + + /** + * @param array $map + * + * @return CreateVerifySchemeResponse + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['headers'])) { + $model->headers = $map['headers']; + } + if (isset($map['statusCode'])) { + $model->statusCode = $map['statusCode']; + } + if (isset($map['body'])) { + $model->body = CreateVerifySchemeResponseBody::fromMap($map['body']); + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/CreateVerifySchemeResponseBody.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/CreateVerifySchemeResponseBody.php new file mode 100644 index 0000000..2f0093e --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/CreateVerifySchemeResponseBody.php @@ -0,0 +1,136 @@ + 'Code', + 'gateVerifySchemeDTO' => 'GateVerifySchemeDTO', + 'httpStatusCode' => 'HttpStatusCode', + 'message' => 'Message', + 'requestId' => 'RequestId', + 'success' => 'Success', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->code) { + $res['Code'] = $this->code; + } + if (null !== $this->gateVerifySchemeDTO) { + $res['GateVerifySchemeDTO'] = null !== $this->gateVerifySchemeDTO ? $this->gateVerifySchemeDTO->toMap() : null; + } + if (null !== $this->httpStatusCode) { + $res['HttpStatusCode'] = $this->httpStatusCode; + } + if (null !== $this->message) { + $res['Message'] = $this->message; + } + if (null !== $this->requestId) { + $res['RequestId'] = $this->requestId; + } + if (null !== $this->success) { + $res['Success'] = $this->success; + } + + return $res; + } + + /** + * @param array $map + * + * @return CreateVerifySchemeResponseBody + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['Code'])) { + $model->code = $map['Code']; + } + if (isset($map['GateVerifySchemeDTO'])) { + $model->gateVerifySchemeDTO = gateVerifySchemeDTO::fromMap($map['GateVerifySchemeDTO']); + } + if (isset($map['HttpStatusCode'])) { + $model->httpStatusCode = $map['HttpStatusCode']; + } + if (isset($map['Message'])) { + $model->message = $map['Message']; + } + if (isset($map['RequestId'])) { + $model->requestId = $map['RequestId']; + } + if (isset($map['Success'])) { + $model->success = $map['Success']; + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/CreateVerifySchemeResponseBody/gateVerifySchemeDTO.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/CreateVerifySchemeResponseBody/gateVerifySchemeDTO.php new file mode 100644 index 0000000..c21d043 --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/CreateVerifySchemeResponseBody/gateVerifySchemeDTO.php @@ -0,0 +1,51 @@ + 'SchemeCode', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->schemeCode) { + $res['SchemeCode'] = $this->schemeCode; + } + + return $res; + } + + /** + * @param array $map + * + * @return gateVerifySchemeDTO + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['SchemeCode'])) { + $model->schemeCode = $map['SchemeCode']; + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/DeleteVerifySchemeRequest.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/DeleteVerifySchemeRequest.php new file mode 100644 index 0000000..33a60b5 --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/DeleteVerifySchemeRequest.php @@ -0,0 +1,104 @@ + 'CustomerId', + 'ownerId' => 'OwnerId', + 'resourceOwnerAccount' => 'ResourceOwnerAccount', + 'resourceOwnerId' => 'ResourceOwnerId', + 'schemeCode' => 'SchemeCode', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->customerId) { + $res['CustomerId'] = $this->customerId; + } + if (null !== $this->ownerId) { + $res['OwnerId'] = $this->ownerId; + } + if (null !== $this->resourceOwnerAccount) { + $res['ResourceOwnerAccount'] = $this->resourceOwnerAccount; + } + if (null !== $this->resourceOwnerId) { + $res['ResourceOwnerId'] = $this->resourceOwnerId; + } + if (null !== $this->schemeCode) { + $res['SchemeCode'] = $this->schemeCode; + } + + return $res; + } + + /** + * @param array $map + * + * @return DeleteVerifySchemeRequest + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['CustomerId'])) { + $model->customerId = $map['CustomerId']; + } + if (isset($map['OwnerId'])) { + $model->ownerId = $map['OwnerId']; + } + if (isset($map['ResourceOwnerAccount'])) { + $model->resourceOwnerAccount = $map['ResourceOwnerAccount']; + } + if (isset($map['ResourceOwnerId'])) { + $model->resourceOwnerId = $map['ResourceOwnerId']; + } + if (isset($map['SchemeCode'])) { + $model->schemeCode = $map['SchemeCode']; + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/DeleteVerifySchemeResponse.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/DeleteVerifySchemeResponse.php new file mode 100644 index 0000000..ccf321f --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/DeleteVerifySchemeResponse.php @@ -0,0 +1,71 @@ + 'headers', + 'statusCode' => 'statusCode', + 'body' => 'body', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->headers) { + $res['headers'] = $this->headers; + } + if (null !== $this->statusCode) { + $res['statusCode'] = $this->statusCode; + } + if (null !== $this->body) { + $res['body'] = null !== $this->body ? $this->body->toMap() : null; + } + + return $res; + } + + /** + * @param array $map + * + * @return DeleteVerifySchemeResponse + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['headers'])) { + $model->headers = $map['headers']; + } + if (isset($map['statusCode'])) { + $model->statusCode = $map['statusCode']; + } + if (isset($map['body'])) { + $model->body = DeleteVerifySchemeResponseBody::fromMap($map['body']); + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/DeleteVerifySchemeResponseBody.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/DeleteVerifySchemeResponseBody.php new file mode 100644 index 0000000..49cc585 --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/DeleteVerifySchemeResponseBody.php @@ -0,0 +1,102 @@ + 'Code', + 'message' => 'Message', + 'requestId' => 'RequestId', + 'result' => 'Result', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->code) { + $res['Code'] = $this->code; + } + if (null !== $this->message) { + $res['Message'] = $this->message; + } + if (null !== $this->requestId) { + $res['RequestId'] = $this->requestId; + } + if (null !== $this->result) { + $res['Result'] = $this->result; + } + + return $res; + } + + /** + * @param array $map + * + * @return DeleteVerifySchemeResponseBody + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['Code'])) { + $model->code = $map['Code']; + } + if (isset($map['Message'])) { + $model->message = $map['Message']; + } + if (isset($map['RequestId'])) { + $model->requestId = $map['RequestId']; + } + if (isset($map['Result'])) { + $model->result = $map['Result']; + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/DescribeVerifySchemeRequest.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/DescribeVerifySchemeRequest.php new file mode 100644 index 0000000..4b14dcc --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/DescribeVerifySchemeRequest.php @@ -0,0 +1,104 @@ + 'CustomerId', + 'ownerId' => 'OwnerId', + 'resourceOwnerAccount' => 'ResourceOwnerAccount', + 'resourceOwnerId' => 'ResourceOwnerId', + 'schemeCode' => 'SchemeCode', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->customerId) { + $res['CustomerId'] = $this->customerId; + } + if (null !== $this->ownerId) { + $res['OwnerId'] = $this->ownerId; + } + if (null !== $this->resourceOwnerAccount) { + $res['ResourceOwnerAccount'] = $this->resourceOwnerAccount; + } + if (null !== $this->resourceOwnerId) { + $res['ResourceOwnerId'] = $this->resourceOwnerId; + } + if (null !== $this->schemeCode) { + $res['SchemeCode'] = $this->schemeCode; + } + + return $res; + } + + /** + * @param array $map + * + * @return DescribeVerifySchemeRequest + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['CustomerId'])) { + $model->customerId = $map['CustomerId']; + } + if (isset($map['OwnerId'])) { + $model->ownerId = $map['OwnerId']; + } + if (isset($map['ResourceOwnerAccount'])) { + $model->resourceOwnerAccount = $map['ResourceOwnerAccount']; + } + if (isset($map['ResourceOwnerId'])) { + $model->resourceOwnerId = $map['ResourceOwnerId']; + } + if (isset($map['SchemeCode'])) { + $model->schemeCode = $map['SchemeCode']; + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/DescribeVerifySchemeResponse.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/DescribeVerifySchemeResponse.php new file mode 100644 index 0000000..6ac0dac --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/DescribeVerifySchemeResponse.php @@ -0,0 +1,71 @@ + 'headers', + 'statusCode' => 'statusCode', + 'body' => 'body', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->headers) { + $res['headers'] = $this->headers; + } + if (null !== $this->statusCode) { + $res['statusCode'] = $this->statusCode; + } + if (null !== $this->body) { + $res['body'] = null !== $this->body ? $this->body->toMap() : null; + } + + return $res; + } + + /** + * @param array $map + * + * @return DescribeVerifySchemeResponse + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['headers'])) { + $model->headers = $map['headers']; + } + if (isset($map['statusCode'])) { + $model->statusCode = $map['statusCode']; + } + if (isset($map['body'])) { + $model->body = DescribeVerifySchemeResponseBody::fromMap($map['body']); + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/DescribeVerifySchemeResponseBody.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/DescribeVerifySchemeResponseBody.php new file mode 100644 index 0000000..508750d --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/DescribeVerifySchemeResponseBody.php @@ -0,0 +1,98 @@ + 'Code', + 'message' => 'Message', + 'requestId' => 'RequestId', + 'schemeQueryResultDTO' => 'SchemeQueryResultDTO', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->code) { + $res['Code'] = $this->code; + } + if (null !== $this->message) { + $res['Message'] = $this->message; + } + if (null !== $this->requestId) { + $res['RequestId'] = $this->requestId; + } + if (null !== $this->schemeQueryResultDTO) { + $res['SchemeQueryResultDTO'] = null !== $this->schemeQueryResultDTO ? $this->schemeQueryResultDTO->toMap() : null; + } + + return $res; + } + + /** + * @param array $map + * + * @return DescribeVerifySchemeResponseBody + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['Code'])) { + $model->code = $map['Code']; + } + if (isset($map['Message'])) { + $model->message = $map['Message']; + } + if (isset($map['RequestId'])) { + $model->requestId = $map['RequestId']; + } + if (isset($map['SchemeQueryResultDTO'])) { + $model->schemeQueryResultDTO = schemeQueryResultDTO::fromMap($map['SchemeQueryResultDTO']); + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/DescribeVerifySchemeResponseBody/schemeQueryResultDTO.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/DescribeVerifySchemeResponseBody/schemeQueryResultDTO.php new file mode 100644 index 0000000..c29d1c8 --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/DescribeVerifySchemeResponseBody/schemeQueryResultDTO.php @@ -0,0 +1,51 @@ + 'AppEncryptInfo', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->appEncryptInfo) { + $res['AppEncryptInfo'] = $this->appEncryptInfo; + } + + return $res; + } + + /** + * @param array $map + * + * @return schemeQueryResultDTO + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['AppEncryptInfo'])) { + $model->appEncryptInfo = $map['AppEncryptInfo']; + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetAuthTokenRequest.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetAuthTokenRequest.php new file mode 100644 index 0000000..67c2080 --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetAuthTokenRequest.php @@ -0,0 +1,177 @@ + 'BizType', + 'cmApiCode' => 'CmApiCode', + 'ctApiCode' => 'CtApiCode', + 'cuApiCode' => 'CuApiCode', + 'origin' => 'Origin', + 'ownerId' => 'OwnerId', + 'resourceOwnerAccount' => 'ResourceOwnerAccount', + 'resourceOwnerId' => 'ResourceOwnerId', + 'sceneCode' => 'SceneCode', + 'url' => 'Url', + 'version' => 'Version', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->bizType) { + $res['BizType'] = $this->bizType; + } + if (null !== $this->cmApiCode) { + $res['CmApiCode'] = $this->cmApiCode; + } + if (null !== $this->ctApiCode) { + $res['CtApiCode'] = $this->ctApiCode; + } + if (null !== $this->cuApiCode) { + $res['CuApiCode'] = $this->cuApiCode; + } + if (null !== $this->origin) { + $res['Origin'] = $this->origin; + } + if (null !== $this->ownerId) { + $res['OwnerId'] = $this->ownerId; + } + if (null !== $this->resourceOwnerAccount) { + $res['ResourceOwnerAccount'] = $this->resourceOwnerAccount; + } + if (null !== $this->resourceOwnerId) { + $res['ResourceOwnerId'] = $this->resourceOwnerId; + } + if (null !== $this->sceneCode) { + $res['SceneCode'] = $this->sceneCode; + } + if (null !== $this->url) { + $res['Url'] = $this->url; + } + if (null !== $this->version) { + $res['Version'] = $this->version; + } + + return $res; + } + + /** + * @param array $map + * + * @return GetAuthTokenRequest + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['BizType'])) { + $model->bizType = $map['BizType']; + } + if (isset($map['CmApiCode'])) { + $model->cmApiCode = $map['CmApiCode']; + } + if (isset($map['CtApiCode'])) { + $model->ctApiCode = $map['CtApiCode']; + } + if (isset($map['CuApiCode'])) { + $model->cuApiCode = $map['CuApiCode']; + } + if (isset($map['Origin'])) { + $model->origin = $map['Origin']; + } + if (isset($map['OwnerId'])) { + $model->ownerId = $map['OwnerId']; + } + if (isset($map['ResourceOwnerAccount'])) { + $model->resourceOwnerAccount = $map['ResourceOwnerAccount']; + } + if (isset($map['ResourceOwnerId'])) { + $model->resourceOwnerId = $map['ResourceOwnerId']; + } + if (isset($map['SceneCode'])) { + $model->sceneCode = $map['SceneCode']; + } + if (isset($map['Url'])) { + $model->url = $map['Url']; + } + if (isset($map['Version'])) { + $model->version = $map['Version']; + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetAuthTokenResponse.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetAuthTokenResponse.php new file mode 100644 index 0000000..c13f7b6 --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetAuthTokenResponse.php @@ -0,0 +1,71 @@ + 'headers', + 'statusCode' => 'statusCode', + 'body' => 'body', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->headers) { + $res['headers'] = $this->headers; + } + if (null !== $this->statusCode) { + $res['statusCode'] = $this->statusCode; + } + if (null !== $this->body) { + $res['body'] = null !== $this->body ? $this->body->toMap() : null; + } + + return $res; + } + + /** + * @param array $map + * + * @return GetAuthTokenResponse + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['headers'])) { + $model->headers = $map['headers']; + } + if (isset($map['statusCode'])) { + $model->statusCode = $map['statusCode']; + } + if (isset($map['body'])) { + $model->body = GetAuthTokenResponseBody::fromMap($map['body']); + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetAuthTokenResponseBody.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetAuthTokenResponseBody.php new file mode 100644 index 0000000..8f5c756 --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetAuthTokenResponseBody.php @@ -0,0 +1,101 @@ + 'Code', + 'message' => 'Message', + 'requestId' => 'RequestId', + 'tokenInfo' => 'TokenInfo', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->code) { + $res['Code'] = $this->code; + } + if (null !== $this->message) { + $res['Message'] = $this->message; + } + if (null !== $this->requestId) { + $res['RequestId'] = $this->requestId; + } + if (null !== $this->tokenInfo) { + $res['TokenInfo'] = null !== $this->tokenInfo ? $this->tokenInfo->toMap() : null; + } + + return $res; + } + + /** + * @param array $map + * + * @return GetAuthTokenResponseBody + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['Code'])) { + $model->code = $map['Code']; + } + if (isset($map['Message'])) { + $model->message = $map['Message']; + } + if (isset($map['RequestId'])) { + $model->requestId = $map['RequestId']; + } + if (isset($map['TokenInfo'])) { + $model->tokenInfo = tokenInfo::fromMap($map['TokenInfo']); + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetAuthTokenResponseBody/tokenInfo.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetAuthTokenResponseBody/tokenInfo.php new file mode 100644 index 0000000..bcfb7a5 --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetAuthTokenResponseBody/tokenInfo.php @@ -0,0 +1,69 @@ + AccessToken is valid for 10 minutes and can be used repeatedly within its validity period. + * @example agag**** + * + * @var string + */ + public $accessToken; + + /** + * @description The API authentication token. + * + * > JwtToken is valid for 1 hour and can be used repeatedly within its validity period. + * @example aweghd**** + * + * @var string + */ + public $jwtToken; + protected $_name = [ + 'accessToken' => 'AccessToken', + 'jwtToken' => 'JwtToken', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->accessToken) { + $res['AccessToken'] = $this->accessToken; + } + if (null !== $this->jwtToken) { + $res['JwtToken'] = $this->jwtToken; + } + + return $res; + } + + /** + * @param array $map + * + * @return tokenInfo + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['AccessToken'])) { + $model->accessToken = $map['AccessToken']; + } + if (isset($map['JwtToken'])) { + $model->jwtToken = $map['JwtToken']; + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetAuthorizationUrlRequest.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetAuthorizationUrlRequest.php new file mode 100644 index 0000000..d5e1970 --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetAuthorizationUrlRequest.php @@ -0,0 +1,121 @@ + 'EndDate', + 'ownerId' => 'OwnerId', + 'phoneNo' => 'PhoneNo', + 'resourceOwnerAccount' => 'ResourceOwnerAccount', + 'resourceOwnerId' => 'ResourceOwnerId', + 'schemeId' => 'SchemeId', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->endDate) { + $res['EndDate'] = $this->endDate; + } + if (null !== $this->ownerId) { + $res['OwnerId'] = $this->ownerId; + } + if (null !== $this->phoneNo) { + $res['PhoneNo'] = $this->phoneNo; + } + if (null !== $this->resourceOwnerAccount) { + $res['ResourceOwnerAccount'] = $this->resourceOwnerAccount; + } + if (null !== $this->resourceOwnerId) { + $res['ResourceOwnerId'] = $this->resourceOwnerId; + } + if (null !== $this->schemeId) { + $res['SchemeId'] = $this->schemeId; + } + + return $res; + } + + /** + * @param array $map + * + * @return GetAuthorizationUrlRequest + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['EndDate'])) { + $model->endDate = $map['EndDate']; + } + if (isset($map['OwnerId'])) { + $model->ownerId = $map['OwnerId']; + } + if (isset($map['PhoneNo'])) { + $model->phoneNo = $map['PhoneNo']; + } + if (isset($map['ResourceOwnerAccount'])) { + $model->resourceOwnerAccount = $map['ResourceOwnerAccount']; + } + if (isset($map['ResourceOwnerId'])) { + $model->resourceOwnerId = $map['ResourceOwnerId']; + } + if (isset($map['SchemeId'])) { + $model->schemeId = $map['SchemeId']; + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetAuthorizationUrlResponse.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetAuthorizationUrlResponse.php new file mode 100644 index 0000000..59a31a6 --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetAuthorizationUrlResponse.php @@ -0,0 +1,71 @@ + 'headers', + 'statusCode' => 'statusCode', + 'body' => 'body', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->headers) { + $res['headers'] = $this->headers; + } + if (null !== $this->statusCode) { + $res['statusCode'] = $this->statusCode; + } + if (null !== $this->body) { + $res['body'] = null !== $this->body ? $this->body->toMap() : null; + } + + return $res; + } + + /** + * @param array $map + * + * @return GetAuthorizationUrlResponse + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['headers'])) { + $model->headers = $map['headers']; + } + if (isset($map['statusCode'])) { + $model->statusCode = $map['statusCode']; + } + if (isset($map['body'])) { + $model->body = GetAuthorizationUrlResponseBody::fromMap($map['body']); + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetAuthorizationUrlResponseBody.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetAuthorizationUrlResponseBody.php new file mode 100644 index 0000000..d362074 --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetAuthorizationUrlResponseBody.php @@ -0,0 +1,101 @@ + 'Code', + 'data' => 'Data', + 'message' => 'Message', + 'requestId' => 'RequestId', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->code) { + $res['Code'] = $this->code; + } + if (null !== $this->data) { + $res['Data'] = null !== $this->data ? $this->data->toMap() : null; + } + if (null !== $this->message) { + $res['Message'] = $this->message; + } + if (null !== $this->requestId) { + $res['RequestId'] = $this->requestId; + } + + return $res; + } + + /** + * @param array $map + * + * @return GetAuthorizationUrlResponseBody + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['Code'])) { + $model->code = $map['Code']; + } + if (isset($map['Data'])) { + $model->data = data::fromMap($map['Data']); + } + if (isset($map['Message'])) { + $model->message = $map['Message']; + } + if (isset($map['RequestId'])) { + $model->requestId = $map['RequestId']; + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetAuthorizationUrlResponseBody/data.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetAuthorizationUrlResponseBody/data.php new file mode 100644 index 0000000..510f022 --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetAuthorizationUrlResponseBody/data.php @@ -0,0 +1,51 @@ + 'AuthorizationUrl', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->authorizationUrl) { + $res['AuthorizationUrl'] = $this->authorizationUrl; + } + + return $res; + } + + /** + * @param array $map + * + * @return data + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['AuthorizationUrl'])) { + $model->authorizationUrl = $map['AuthorizationUrl']; + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetFusionAuthTokenRequest.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetFusionAuthTokenRequest.php new file mode 100644 index 0000000..29db913 --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetFusionAuthTokenRequest.php @@ -0,0 +1,170 @@ + 'BundleId', + 'durationSeconds' => 'DurationSeconds', + 'ownerId' => 'OwnerId', + 'packageName' => 'PackageName', + 'packageSign' => 'PackageSign', + 'platform' => 'Platform', + 'resourceOwnerAccount' => 'ResourceOwnerAccount', + 'resourceOwnerId' => 'ResourceOwnerId', + 'schemeCode' => 'SchemeCode', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->bundleId) { + $res['BundleId'] = $this->bundleId; + } + if (null !== $this->durationSeconds) { + $res['DurationSeconds'] = $this->durationSeconds; + } + if (null !== $this->ownerId) { + $res['OwnerId'] = $this->ownerId; + } + if (null !== $this->packageName) { + $res['PackageName'] = $this->packageName; + } + if (null !== $this->packageSign) { + $res['PackageSign'] = $this->packageSign; + } + if (null !== $this->platform) { + $res['Platform'] = $this->platform; + } + if (null !== $this->resourceOwnerAccount) { + $res['ResourceOwnerAccount'] = $this->resourceOwnerAccount; + } + if (null !== $this->resourceOwnerId) { + $res['ResourceOwnerId'] = $this->resourceOwnerId; + } + if (null !== $this->schemeCode) { + $res['SchemeCode'] = $this->schemeCode; + } + + return $res; + } + + /** + * @param array $map + * + * @return GetFusionAuthTokenRequest + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['BundleId'])) { + $model->bundleId = $map['BundleId']; + } + if (isset($map['DurationSeconds'])) { + $model->durationSeconds = $map['DurationSeconds']; + } + if (isset($map['OwnerId'])) { + $model->ownerId = $map['OwnerId']; + } + if (isset($map['PackageName'])) { + $model->packageName = $map['PackageName']; + } + if (isset($map['PackageSign'])) { + $model->packageSign = $map['PackageSign']; + } + if (isset($map['Platform'])) { + $model->platform = $map['Platform']; + } + if (isset($map['ResourceOwnerAccount'])) { + $model->resourceOwnerAccount = $map['ResourceOwnerAccount']; + } + if (isset($map['ResourceOwnerId'])) { + $model->resourceOwnerId = $map['ResourceOwnerId']; + } + if (isset($map['SchemeCode'])) { + $model->schemeCode = $map['SchemeCode']; + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetFusionAuthTokenResponse.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetFusionAuthTokenResponse.php new file mode 100644 index 0000000..5bebaa4 --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetFusionAuthTokenResponse.php @@ -0,0 +1,71 @@ + 'headers', + 'statusCode' => 'statusCode', + 'body' => 'body', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->headers) { + $res['headers'] = $this->headers; + } + if (null !== $this->statusCode) { + $res['statusCode'] = $this->statusCode; + } + if (null !== $this->body) { + $res['body'] = null !== $this->body ? $this->body->toMap() : null; + } + + return $res; + } + + /** + * @param array $map + * + * @return GetFusionAuthTokenResponse + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['headers'])) { + $model->headers = $map['headers']; + } + if (isset($map['statusCode'])) { + $model->statusCode = $map['statusCode']; + } + if (isset($map['body'])) { + $model->body = GetFusionAuthTokenResponseBody::fromMap($map['body']); + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetFusionAuthTokenResponseBody.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetFusionAuthTokenResponseBody.php new file mode 100644 index 0000000..5e64389 --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetFusionAuthTokenResponseBody.php @@ -0,0 +1,115 @@ + 'Code', + 'message' => 'Message', + 'model' => 'Model', + 'requestId' => 'RequestId', + 'success' => 'Success', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->code) { + $res['Code'] = $this->code; + } + if (null !== $this->message) { + $res['Message'] = $this->message; + } + if (null !== $this->model) { + $res['Model'] = $this->model; + } + if (null !== $this->requestId) { + $res['RequestId'] = $this->requestId; + } + if (null !== $this->success) { + $res['Success'] = $this->success; + } + + return $res; + } + + /** + * @param array $map + * + * @return GetFusionAuthTokenResponseBody + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['Code'])) { + $model->code = $map['Code']; + } + if (isset($map['Message'])) { + $model->message = $map['Message']; + } + if (isset($map['Model'])) { + $model->model = $map['Model']; + } + if (isset($map['RequestId'])) { + $model->requestId = $map['RequestId']; + } + if (isset($map['Success'])) { + $model->success = $map['Success']; + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetMobileRequest.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetMobileRequest.php new file mode 100644 index 0000000..5504b03 --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetMobileRequest.php @@ -0,0 +1,104 @@ + 'AccessToken', + 'outId' => 'OutId', + 'ownerId' => 'OwnerId', + 'resourceOwnerAccount' => 'ResourceOwnerAccount', + 'resourceOwnerId' => 'ResourceOwnerId', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->accessToken) { + $res['AccessToken'] = $this->accessToken; + } + if (null !== $this->outId) { + $res['OutId'] = $this->outId; + } + if (null !== $this->ownerId) { + $res['OwnerId'] = $this->ownerId; + } + if (null !== $this->resourceOwnerAccount) { + $res['ResourceOwnerAccount'] = $this->resourceOwnerAccount; + } + if (null !== $this->resourceOwnerId) { + $res['ResourceOwnerId'] = $this->resourceOwnerId; + } + + return $res; + } + + /** + * @param array $map + * + * @return GetMobileRequest + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['AccessToken'])) { + $model->accessToken = $map['AccessToken']; + } + if (isset($map['OutId'])) { + $model->outId = $map['OutId']; + } + if (isset($map['OwnerId'])) { + $model->ownerId = $map['OwnerId']; + } + if (isset($map['ResourceOwnerAccount'])) { + $model->resourceOwnerAccount = $map['ResourceOwnerAccount']; + } + if (isset($map['ResourceOwnerId'])) { + $model->resourceOwnerId = $map['ResourceOwnerId']; + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetMobileResponse.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetMobileResponse.php new file mode 100644 index 0000000..c30cc63 --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetMobileResponse.php @@ -0,0 +1,71 @@ + 'headers', + 'statusCode' => 'statusCode', + 'body' => 'body', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->headers) { + $res['headers'] = $this->headers; + } + if (null !== $this->statusCode) { + $res['statusCode'] = $this->statusCode; + } + if (null !== $this->body) { + $res['body'] = null !== $this->body ? $this->body->toMap() : null; + } + + return $res; + } + + /** + * @param array $map + * + * @return GetMobileResponse + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['headers'])) { + $model->headers = $map['headers']; + } + if (isset($map['statusCode'])) { + $model->statusCode = $map['statusCode']; + } + if (isset($map['body'])) { + $model->body = GetMobileResponseBody::fromMap($map['body']); + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetMobileResponseBody.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetMobileResponseBody.php new file mode 100644 index 0000000..20e2b0a --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetMobileResponseBody.php @@ -0,0 +1,101 @@ + 'Code', + 'getMobileResultDTO' => 'GetMobileResultDTO', + 'message' => 'Message', + 'requestId' => 'RequestId', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->code) { + $res['Code'] = $this->code; + } + if (null !== $this->getMobileResultDTO) { + $res['GetMobileResultDTO'] = null !== $this->getMobileResultDTO ? $this->getMobileResultDTO->toMap() : null; + } + if (null !== $this->message) { + $res['Message'] = $this->message; + } + if (null !== $this->requestId) { + $res['RequestId'] = $this->requestId; + } + + return $res; + } + + /** + * @param array $map + * + * @return GetMobileResponseBody + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['Code'])) { + $model->code = $map['Code']; + } + if (isset($map['GetMobileResultDTO'])) { + $model->getMobileResultDTO = getMobileResultDTO::fromMap($map['GetMobileResultDTO']); + } + if (isset($map['Message'])) { + $model->message = $map['Message']; + } + if (isset($map['RequestId'])) { + $model->requestId = $map['RequestId']; + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetMobileResponseBody/getMobileResultDTO.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetMobileResponseBody/getMobileResultDTO.php new file mode 100644 index 0000000..b7eaeea --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetMobileResponseBody/getMobileResultDTO.php @@ -0,0 +1,51 @@ + 'Mobile', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->mobile) { + $res['Mobile'] = $this->mobile; + } + + return $res; + } + + /** + * @param array $map + * + * @return getMobileResultDTO + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['Mobile'])) { + $model->mobile = $map['Mobile']; + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetPhoneWithTokenRequest.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetPhoneWithTokenRequest.php new file mode 100644 index 0000000..707c134 --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetPhoneWithTokenRequest.php @@ -0,0 +1,88 @@ + 'OwnerId', + 'resourceOwnerAccount' => 'ResourceOwnerAccount', + 'resourceOwnerId' => 'ResourceOwnerId', + 'spToken' => 'SpToken', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->ownerId) { + $res['OwnerId'] = $this->ownerId; + } + if (null !== $this->resourceOwnerAccount) { + $res['ResourceOwnerAccount'] = $this->resourceOwnerAccount; + } + if (null !== $this->resourceOwnerId) { + $res['ResourceOwnerId'] = $this->resourceOwnerId; + } + if (null !== $this->spToken) { + $res['SpToken'] = $this->spToken; + } + + return $res; + } + + /** + * @param array $map + * + * @return GetPhoneWithTokenRequest + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['OwnerId'])) { + $model->ownerId = $map['OwnerId']; + } + if (isset($map['ResourceOwnerAccount'])) { + $model->resourceOwnerAccount = $map['ResourceOwnerAccount']; + } + if (isset($map['ResourceOwnerId'])) { + $model->resourceOwnerId = $map['ResourceOwnerId']; + } + if (isset($map['SpToken'])) { + $model->spToken = $map['SpToken']; + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetPhoneWithTokenResponse.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetPhoneWithTokenResponse.php new file mode 100644 index 0000000..00a335d --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetPhoneWithTokenResponse.php @@ -0,0 +1,71 @@ + 'headers', + 'statusCode' => 'statusCode', + 'body' => 'body', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->headers) { + $res['headers'] = $this->headers; + } + if (null !== $this->statusCode) { + $res['statusCode'] = $this->statusCode; + } + if (null !== $this->body) { + $res['body'] = null !== $this->body ? $this->body->toMap() : null; + } + + return $res; + } + + /** + * @param array $map + * + * @return GetPhoneWithTokenResponse + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['headers'])) { + $model->headers = $map['headers']; + } + if (isset($map['statusCode'])) { + $model->statusCode = $map['statusCode']; + } + if (isset($map['body'])) { + $model->body = GetPhoneWithTokenResponseBody::fromMap($map['body']); + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetPhoneWithTokenResponseBody.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetPhoneWithTokenResponseBody.php new file mode 100644 index 0000000..5fe75eb --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetPhoneWithTokenResponseBody.php @@ -0,0 +1,101 @@ + 'Code', + 'data' => 'Data', + 'message' => 'Message', + 'requestId' => 'RequestId', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->code) { + $res['Code'] = $this->code; + } + if (null !== $this->data) { + $res['Data'] = null !== $this->data ? $this->data->toMap() : null; + } + if (null !== $this->message) { + $res['Message'] = $this->message; + } + if (null !== $this->requestId) { + $res['RequestId'] = $this->requestId; + } + + return $res; + } + + /** + * @param array $map + * + * @return GetPhoneWithTokenResponseBody + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['Code'])) { + $model->code = $map['Code']; + } + if (isset($map['Data'])) { + $model->data = data::fromMap($map['Data']); + } + if (isset($map['Message'])) { + $model->message = $map['Message']; + } + if (isset($map['RequestId'])) { + $model->requestId = $map['RequestId']; + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetPhoneWithTokenResponseBody/data.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetPhoneWithTokenResponseBody/data.php new file mode 100644 index 0000000..77c5f4e --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetPhoneWithTokenResponseBody/data.php @@ -0,0 +1,51 @@ + 'Mobile', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->mobile) { + $res['Mobile'] = $this->mobile; + } + + return $res; + } + + /** + * @param array $map + * + * @return data + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['Mobile'])) { + $model->mobile = $map['Mobile']; + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetSmsAuthTokensRequest.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetSmsAuthTokensRequest.php new file mode 100644 index 0000000..9315787 --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetSmsAuthTokensRequest.php @@ -0,0 +1,203 @@ + 'BundleId', + 'expire' => 'Expire', + 'osType' => 'OsType', + 'ownerId' => 'OwnerId', + 'packageName' => 'PackageName', + 'resourceOwnerAccount' => 'ResourceOwnerAccount', + 'resourceOwnerId' => 'ResourceOwnerId', + 'sceneCode' => 'SceneCode', + 'signName' => 'SignName', + 'smsCodeExpire' => 'SmsCodeExpire', + 'smsTemplateCode' => 'SmsTemplateCode', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->bundleId) { + $res['BundleId'] = $this->bundleId; + } + if (null !== $this->expire) { + $res['Expire'] = $this->expire; + } + if (null !== $this->osType) { + $res['OsType'] = $this->osType; + } + if (null !== $this->ownerId) { + $res['OwnerId'] = $this->ownerId; + } + if (null !== $this->packageName) { + $res['PackageName'] = $this->packageName; + } + if (null !== $this->resourceOwnerAccount) { + $res['ResourceOwnerAccount'] = $this->resourceOwnerAccount; + } + if (null !== $this->resourceOwnerId) { + $res['ResourceOwnerId'] = $this->resourceOwnerId; + } + if (null !== $this->sceneCode) { + $res['SceneCode'] = $this->sceneCode; + } + if (null !== $this->signName) { + $res['SignName'] = $this->signName; + } + if (null !== $this->smsCodeExpire) { + $res['SmsCodeExpire'] = $this->smsCodeExpire; + } + if (null !== $this->smsTemplateCode) { + $res['SmsTemplateCode'] = $this->smsTemplateCode; + } + + return $res; + } + + /** + * @param array $map + * + * @return GetSmsAuthTokensRequest + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['BundleId'])) { + $model->bundleId = $map['BundleId']; + } + if (isset($map['Expire'])) { + $model->expire = $map['Expire']; + } + if (isset($map['OsType'])) { + $model->osType = $map['OsType']; + } + if (isset($map['OwnerId'])) { + $model->ownerId = $map['OwnerId']; + } + if (isset($map['PackageName'])) { + $model->packageName = $map['PackageName']; + } + if (isset($map['ResourceOwnerAccount'])) { + $model->resourceOwnerAccount = $map['ResourceOwnerAccount']; + } + if (isset($map['ResourceOwnerId'])) { + $model->resourceOwnerId = $map['ResourceOwnerId']; + } + if (isset($map['SceneCode'])) { + $model->sceneCode = $map['SceneCode']; + } + if (isset($map['SignName'])) { + $model->signName = $map['SignName']; + } + if (isset($map['SmsCodeExpire'])) { + $model->smsCodeExpire = $map['SmsCodeExpire']; + } + if (isset($map['SmsTemplateCode'])) { + $model->smsTemplateCode = $map['SmsTemplateCode']; + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetSmsAuthTokensResponse.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetSmsAuthTokensResponse.php new file mode 100644 index 0000000..2001f88 --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetSmsAuthTokensResponse.php @@ -0,0 +1,71 @@ + 'headers', + 'statusCode' => 'statusCode', + 'body' => 'body', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->headers) { + $res['headers'] = $this->headers; + } + if (null !== $this->statusCode) { + $res['statusCode'] = $this->statusCode; + } + if (null !== $this->body) { + $res['body'] = null !== $this->body ? $this->body->toMap() : null; + } + + return $res; + } + + /** + * @param array $map + * + * @return GetSmsAuthTokensResponse + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['headers'])) { + $model->headers = $map['headers']; + } + if (isset($map['statusCode'])) { + $model->statusCode = $map['statusCode']; + } + if (isset($map['body'])) { + $model->body = GetSmsAuthTokensResponseBody::fromMap($map['body']); + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetSmsAuthTokensResponseBody.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetSmsAuthTokensResponseBody.php new file mode 100644 index 0000000..cf0583c --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetSmsAuthTokensResponseBody.php @@ -0,0 +1,101 @@ + 'Code', + 'data' => 'Data', + 'message' => 'Message', + 'requestId' => 'RequestId', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->code) { + $res['Code'] = $this->code; + } + if (null !== $this->data) { + $res['Data'] = null !== $this->data ? $this->data->toMap() : null; + } + if (null !== $this->message) { + $res['Message'] = $this->message; + } + if (null !== $this->requestId) { + $res['RequestId'] = $this->requestId; + } + + return $res; + } + + /** + * @param array $map + * + * @return GetSmsAuthTokensResponseBody + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['Code'])) { + $model->code = $map['Code']; + } + if (isset($map['Data'])) { + $model->data = data::fromMap($map['Data']); + } + if (isset($map['Message'])) { + $model->message = $map['Message']; + } + if (isset($map['RequestId'])) { + $model->requestId = $map['RequestId']; + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetSmsAuthTokensResponseBody/data.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetSmsAuthTokensResponseBody/data.php new file mode 100644 index 0000000..8d9b339 --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetSmsAuthTokensResponseBody/data.php @@ -0,0 +1,115 @@ + 'BizToken', + 'expireTime' => 'ExpireTime', + 'stsAccessKeyId' => 'StsAccessKeyId', + 'stsAccessKeySecret' => 'StsAccessKeySecret', + 'stsToken' => 'StsToken', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->bizToken) { + $res['BizToken'] = $this->bizToken; + } + if (null !== $this->expireTime) { + $res['ExpireTime'] = $this->expireTime; + } + if (null !== $this->stsAccessKeyId) { + $res['StsAccessKeyId'] = $this->stsAccessKeyId; + } + if (null !== $this->stsAccessKeySecret) { + $res['StsAccessKeySecret'] = $this->stsAccessKeySecret; + } + if (null !== $this->stsToken) { + $res['StsToken'] = $this->stsToken; + } + + return $res; + } + + /** + * @param array $map + * + * @return data + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['BizToken'])) { + $model->bizToken = $map['BizToken']; + } + if (isset($map['ExpireTime'])) { + $model->expireTime = $map['ExpireTime']; + } + if (isset($map['StsAccessKeyId'])) { + $model->stsAccessKeyId = $map['StsAccessKeyId']; + } + if (isset($map['StsAccessKeySecret'])) { + $model->stsAccessKeySecret = $map['StsAccessKeySecret']; + } + if (isset($map['StsToken'])) { + $model->stsToken = $map['StsToken']; + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/JyCreateVerifySchemeRequest.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/JyCreateVerifySchemeRequest.php new file mode 100644 index 0000000..77a2cb4 --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/JyCreateVerifySchemeRequest.php @@ -0,0 +1,191 @@ + 'AppName', + 'bundleId' => 'BundleId', + 'cmApiCode' => 'CmApiCode', + 'ctApiCode' => 'CtApiCode', + 'cuApiCode' => 'CuApiCode', + 'osType' => 'OsType', + 'ownerId' => 'OwnerId', + 'packName' => 'PackName', + 'packSign' => 'PackSign', + 'resourceOwnerAccount' => 'ResourceOwnerAccount', + 'resourceOwnerId' => 'ResourceOwnerId', + 'schemeName' => 'SchemeName', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->appName) { + $res['AppName'] = $this->appName; + } + if (null !== $this->bundleId) { + $res['BundleId'] = $this->bundleId; + } + if (null !== $this->cmApiCode) { + $res['CmApiCode'] = $this->cmApiCode; + } + if (null !== $this->ctApiCode) { + $res['CtApiCode'] = $this->ctApiCode; + } + if (null !== $this->cuApiCode) { + $res['CuApiCode'] = $this->cuApiCode; + } + if (null !== $this->osType) { + $res['OsType'] = $this->osType; + } + if (null !== $this->ownerId) { + $res['OwnerId'] = $this->ownerId; + } + if (null !== $this->packName) { + $res['PackName'] = $this->packName; + } + if (null !== $this->packSign) { + $res['PackSign'] = $this->packSign; + } + if (null !== $this->resourceOwnerAccount) { + $res['ResourceOwnerAccount'] = $this->resourceOwnerAccount; + } + if (null !== $this->resourceOwnerId) { + $res['ResourceOwnerId'] = $this->resourceOwnerId; + } + if (null !== $this->schemeName) { + $res['SchemeName'] = $this->schemeName; + } + + return $res; + } + + /** + * @param array $map + * + * @return JyCreateVerifySchemeRequest + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['AppName'])) { + $model->appName = $map['AppName']; + } + if (isset($map['BundleId'])) { + $model->bundleId = $map['BundleId']; + } + if (isset($map['CmApiCode'])) { + $model->cmApiCode = $map['CmApiCode']; + } + if (isset($map['CtApiCode'])) { + $model->ctApiCode = $map['CtApiCode']; + } + if (isset($map['CuApiCode'])) { + $model->cuApiCode = $map['CuApiCode']; + } + if (isset($map['OsType'])) { + $model->osType = $map['OsType']; + } + if (isset($map['OwnerId'])) { + $model->ownerId = $map['OwnerId']; + } + if (isset($map['PackName'])) { + $model->packName = $map['PackName']; + } + if (isset($map['PackSign'])) { + $model->packSign = $map['PackSign']; + } + if (isset($map['ResourceOwnerAccount'])) { + $model->resourceOwnerAccount = $map['ResourceOwnerAccount']; + } + if (isset($map['ResourceOwnerId'])) { + $model->resourceOwnerId = $map['ResourceOwnerId']; + } + if (isset($map['SchemeName'])) { + $model->schemeName = $map['SchemeName']; + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/JyCreateVerifySchemeResponse.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/JyCreateVerifySchemeResponse.php new file mode 100644 index 0000000..552897b --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/JyCreateVerifySchemeResponse.php @@ -0,0 +1,71 @@ + 'headers', + 'statusCode' => 'statusCode', + 'body' => 'body', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->headers) { + $res['headers'] = $this->headers; + } + if (null !== $this->statusCode) { + $res['statusCode'] = $this->statusCode; + } + if (null !== $this->body) { + $res['body'] = null !== $this->body ? $this->body->toMap() : null; + } + + return $res; + } + + /** + * @param array $map + * + * @return JyCreateVerifySchemeResponse + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['headers'])) { + $model->headers = $map['headers']; + } + if (isset($map['statusCode'])) { + $model->statusCode = $map['statusCode']; + } + if (isset($map['body'])) { + $model->body = JyCreateVerifySchemeResponseBody::fromMap($map['body']); + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/JyCreateVerifySchemeResponseBody.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/JyCreateVerifySchemeResponseBody.php new file mode 100644 index 0000000..543e9b0 --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/JyCreateVerifySchemeResponseBody.php @@ -0,0 +1,84 @@ + 'Code', + 'gateVerifySchemeData' => 'GateVerifySchemeData', + 'message' => 'Message', + 'requestId' => 'RequestId', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->code) { + $res['Code'] = $this->code; + } + if (null !== $this->gateVerifySchemeData) { + $res['GateVerifySchemeData'] = null !== $this->gateVerifySchemeData ? $this->gateVerifySchemeData->toMap() : null; + } + if (null !== $this->message) { + $res['Message'] = $this->message; + } + if (null !== $this->requestId) { + $res['RequestId'] = $this->requestId; + } + + return $res; + } + + /** + * @param array $map + * + * @return JyCreateVerifySchemeResponseBody + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['Code'])) { + $model->code = $map['Code']; + } + if (isset($map['GateVerifySchemeData'])) { + $model->gateVerifySchemeData = gateVerifySchemeData::fromMap($map['GateVerifySchemeData']); + } + if (isset($map['Message'])) { + $model->message = $map['Message']; + } + if (isset($map['RequestId'])) { + $model->requestId = $map['RequestId']; + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/JyCreateVerifySchemeResponseBody/gateVerifySchemeData.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/JyCreateVerifySchemeResponseBody/gateVerifySchemeData.php new file mode 100644 index 0000000..d1ce6d9 --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/JyCreateVerifySchemeResponseBody/gateVerifySchemeData.php @@ -0,0 +1,47 @@ + 'SchemeCode', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->schemeCode) { + $res['SchemeCode'] = $this->schemeCode; + } + + return $res; + } + + /** + * @param array $map + * + * @return gateVerifySchemeData + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['SchemeCode'])) { + $model->schemeCode = $map['SchemeCode']; + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/JyQueryAppInfoBySceneCodeRequest.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/JyQueryAppInfoBySceneCodeRequest.php new file mode 100644 index 0000000..99040eb --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/JyQueryAppInfoBySceneCodeRequest.php @@ -0,0 +1,85 @@ + 'OwnerId', + 'resourceOwnerAccount' => 'ResourceOwnerAccount', + 'resourceOwnerId' => 'ResourceOwnerId', + 'sceneCode' => 'SceneCode', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->ownerId) { + $res['OwnerId'] = $this->ownerId; + } + if (null !== $this->resourceOwnerAccount) { + $res['ResourceOwnerAccount'] = $this->resourceOwnerAccount; + } + if (null !== $this->resourceOwnerId) { + $res['ResourceOwnerId'] = $this->resourceOwnerId; + } + if (null !== $this->sceneCode) { + $res['SceneCode'] = $this->sceneCode; + } + + return $res; + } + + /** + * @param array $map + * + * @return JyQueryAppInfoBySceneCodeRequest + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['OwnerId'])) { + $model->ownerId = $map['OwnerId']; + } + if (isset($map['ResourceOwnerAccount'])) { + $model->resourceOwnerAccount = $map['ResourceOwnerAccount']; + } + if (isset($map['ResourceOwnerId'])) { + $model->resourceOwnerId = $map['ResourceOwnerId']; + } + if (isset($map['SceneCode'])) { + $model->sceneCode = $map['SceneCode']; + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/JyQueryAppInfoBySceneCodeResponse.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/JyQueryAppInfoBySceneCodeResponse.php new file mode 100644 index 0000000..a9ef016 --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/JyQueryAppInfoBySceneCodeResponse.php @@ -0,0 +1,71 @@ + 'headers', + 'statusCode' => 'statusCode', + 'body' => 'body', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->headers) { + $res['headers'] = $this->headers; + } + if (null !== $this->statusCode) { + $res['statusCode'] = $this->statusCode; + } + if (null !== $this->body) { + $res['body'] = null !== $this->body ? $this->body->toMap() : null; + } + + return $res; + } + + /** + * @param array $map + * + * @return JyQueryAppInfoBySceneCodeResponse + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['headers'])) { + $model->headers = $map['headers']; + } + if (isset($map['statusCode'])) { + $model->statusCode = $map['statusCode']; + } + if (isset($map['body'])) { + $model->body = JyQueryAppInfoBySceneCodeResponseBody::fromMap($map['body']); + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/JyQueryAppInfoBySceneCodeResponseBody.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/JyQueryAppInfoBySceneCodeResponseBody.php new file mode 100644 index 0000000..d1cd1be --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/JyQueryAppInfoBySceneCodeResponseBody.php @@ -0,0 +1,84 @@ + 'Code', + 'data' => 'Data', + 'message' => 'Message', + 'requestId' => 'RequestId', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->code) { + $res['Code'] = $this->code; + } + if (null !== $this->data) { + $res['Data'] = null !== $this->data ? $this->data->toMap() : null; + } + if (null !== $this->message) { + $res['Message'] = $this->message; + } + if (null !== $this->requestId) { + $res['RequestId'] = $this->requestId; + } + + return $res; + } + + /** + * @param array $map + * + * @return JyQueryAppInfoBySceneCodeResponseBody + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['Code'])) { + $model->code = $map['Code']; + } + if (isset($map['Data'])) { + $model->data = data::fromMap($map['Data']); + } + if (isset($map['Message'])) { + $model->message = $map['Message']; + } + if (isset($map['RequestId'])) { + $model->requestId = $map['RequestId']; + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/JyQueryAppInfoBySceneCodeResponseBody/data.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/JyQueryAppInfoBySceneCodeResponseBody/data.php new file mode 100644 index 0000000..92beda1 --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/JyQueryAppInfoBySceneCodeResponseBody/data.php @@ -0,0 +1,83 @@ + 'CmAppId', + 'cmAppKey' => 'CmAppKey', + 'ctAppId' => 'CtAppId', + 'ctAppKey' => 'CtAppKey', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->cmAppId) { + $res['CmAppId'] = $this->cmAppId; + } + if (null !== $this->cmAppKey) { + $res['CmAppKey'] = $this->cmAppKey; + } + if (null !== $this->ctAppId) { + $res['CtAppId'] = $this->ctAppId; + } + if (null !== $this->ctAppKey) { + $res['CtAppKey'] = $this->ctAppKey; + } + + return $res; + } + + /** + * @param array $map + * + * @return data + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['CmAppId'])) { + $model->cmAppId = $map['CmAppId']; + } + if (isset($map['CmAppKey'])) { + $model->cmAppKey = $map['CmAppKey']; + } + if (isset($map['CtAppId'])) { + $model->ctAppId = $map['CtAppId']; + } + if (isset($map['CtAppKey'])) { + $model->ctAppKey = $map['CtAppKey']; + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/QueryGateVerifyBillingPublicRequest.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/QueryGateVerifyBillingPublicRequest.php new file mode 100644 index 0000000..d1b76ac --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/QueryGateVerifyBillingPublicRequest.php @@ -0,0 +1,99 @@ + 'AuthenticationType', + 'month' => 'Month', + 'ownerId' => 'OwnerId', + 'resourceOwnerAccount' => 'ResourceOwnerAccount', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->authenticationType) { + $res['AuthenticationType'] = $this->authenticationType; + } + if (null !== $this->month) { + $res['Month'] = $this->month; + } + if (null !== $this->ownerId) { + $res['OwnerId'] = $this->ownerId; + } + if (null !== $this->resourceOwnerAccount) { + $res['ResourceOwnerAccount'] = $this->resourceOwnerAccount; + } + + return $res; + } + + /** + * @param array $map + * + * @return QueryGateVerifyBillingPublicRequest + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['AuthenticationType'])) { + $model->authenticationType = $map['AuthenticationType']; + } + if (isset($map['Month'])) { + $model->month = $map['Month']; + } + if (isset($map['OwnerId'])) { + $model->ownerId = $map['OwnerId']; + } + if (isset($map['ResourceOwnerAccount'])) { + $model->resourceOwnerAccount = $map['ResourceOwnerAccount']; + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/QueryGateVerifyBillingPublicResponse.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/QueryGateVerifyBillingPublicResponse.php new file mode 100644 index 0000000..59777f8 --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/QueryGateVerifyBillingPublicResponse.php @@ -0,0 +1,71 @@ + 'headers', + 'statusCode' => 'statusCode', + 'body' => 'body', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->headers) { + $res['headers'] = $this->headers; + } + if (null !== $this->statusCode) { + $res['statusCode'] = $this->statusCode; + } + if (null !== $this->body) { + $res['body'] = null !== $this->body ? $this->body->toMap() : null; + } + + return $res; + } + + /** + * @param array $map + * + * @return QueryGateVerifyBillingPublicResponse + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['headers'])) { + $model->headers = $map['headers']; + } + if (isset($map['statusCode'])) { + $model->statusCode = $map['statusCode']; + } + if (isset($map['body'])) { + $model->body = QueryGateVerifyBillingPublicResponseBody::fromMap($map['body']); + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/QueryGateVerifyBillingPublicResponseBody.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/QueryGateVerifyBillingPublicResponseBody.php new file mode 100644 index 0000000..37a039c --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/QueryGateVerifyBillingPublicResponseBody.php @@ -0,0 +1,101 @@ + 'Code', + 'data' => 'Data', + 'message' => 'Message', + 'requestId' => 'RequestId', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->code) { + $res['Code'] = $this->code; + } + if (null !== $this->data) { + $res['Data'] = null !== $this->data ? $this->data->toMap() : null; + } + if (null !== $this->message) { + $res['Message'] = $this->message; + } + if (null !== $this->requestId) { + $res['RequestId'] = $this->requestId; + } + + return $res; + } + + /** + * @param array $map + * + * @return QueryGateVerifyBillingPublicResponseBody + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['Code'])) { + $model->code = $map['Code']; + } + if (isset($map['Data'])) { + $model->data = data::fromMap($map['Data']); + } + if (isset($map['Message'])) { + $model->message = $map['Message']; + } + if (isset($map['RequestId'])) { + $model->requestId = $map['RequestId']; + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/QueryGateVerifyBillingPublicResponseBody/data.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/QueryGateVerifyBillingPublicResponseBody/data.php new file mode 100644 index 0000000..742a8c6 --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/QueryGateVerifyBillingPublicResponseBody/data.php @@ -0,0 +1,78 @@ + 'AmountSum', + 'sceneBillingList' => 'SceneBillingList', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->amountSum) { + $res['AmountSum'] = $this->amountSum; + } + if (null !== $this->sceneBillingList) { + $res['SceneBillingList'] = []; + if (null !== $this->sceneBillingList && \is_array($this->sceneBillingList)) { + $n = 0; + foreach ($this->sceneBillingList as $item) { + $res['SceneBillingList'][$n++] = null !== $item ? $item->toMap() : $item; + } + } + } + + return $res; + } + + /** + * @param array $map + * + * @return data + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['AmountSum'])) { + $model->amountSum = $map['AmountSum']; + } + if (isset($map['SceneBillingList'])) { + if (!empty($map['SceneBillingList'])) { + $model->sceneBillingList = []; + $n = 0; + foreach ($map['SceneBillingList'] as $item) { + $model->sceneBillingList[$n++] = null !== $item ? sceneBillingList::fromMap($item) : $item; + } + } + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/QueryGateVerifyBillingPublicResponseBody/data/sceneBillingList.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/QueryGateVerifyBillingPublicResponseBody/data/sceneBillingList.php new file mode 100644 index 0000000..09246f5 --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/QueryGateVerifyBillingPublicResponseBody/data/sceneBillingList.php @@ -0,0 +1,147 @@ + 'Add', + 'amount' => 'Amount', + 'appName' => 'AppName', + 'itemName' => 'ItemName', + 'sceneCode' => 'SceneCode', + 'sceneName' => 'SceneName', + 'singlePrice' => 'SinglePrice', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->add) { + $res['Add'] = $this->add; + } + if (null !== $this->amount) { + $res['Amount'] = $this->amount; + } + if (null !== $this->appName) { + $res['AppName'] = $this->appName; + } + if (null !== $this->itemName) { + $res['ItemName'] = $this->itemName; + } + if (null !== $this->sceneCode) { + $res['SceneCode'] = $this->sceneCode; + } + if (null !== $this->sceneName) { + $res['SceneName'] = $this->sceneName; + } + if (null !== $this->singlePrice) { + $res['SinglePrice'] = $this->singlePrice; + } + + return $res; + } + + /** + * @param array $map + * + * @return sceneBillingList + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['Add'])) { + $model->add = $map['Add']; + } + if (isset($map['Amount'])) { + $model->amount = $map['Amount']; + } + if (isset($map['AppName'])) { + $model->appName = $map['AppName']; + } + if (isset($map['ItemName'])) { + $model->itemName = $map['ItemName']; + } + if (isset($map['SceneCode'])) { + $model->sceneCode = $map['SceneCode']; + } + if (isset($map['SceneName'])) { + $model->sceneName = $map['SceneName']; + } + if (isset($map['SinglePrice'])) { + $model->singlePrice = $map['SinglePrice']; + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/QueryGateVerifyStatisticPublicRequest.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/QueryGateVerifyStatisticPublicRequest.php new file mode 100644 index 0000000..ef8c682 --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/QueryGateVerifyStatisticPublicRequest.php @@ -0,0 +1,150 @@ + 'AuthenticationType', + 'endDate' => 'EndDate', + 'osType' => 'OsType', + 'ownerId' => 'OwnerId', + 'resourceOwnerAccount' => 'ResourceOwnerAccount', + 'sceneCode' => 'SceneCode', + 'startDate' => 'StartDate', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->authenticationType) { + $res['AuthenticationType'] = $this->authenticationType; + } + if (null !== $this->endDate) { + $res['EndDate'] = $this->endDate; + } + if (null !== $this->osType) { + $res['OsType'] = $this->osType; + } + if (null !== $this->ownerId) { + $res['OwnerId'] = $this->ownerId; + } + if (null !== $this->resourceOwnerAccount) { + $res['ResourceOwnerAccount'] = $this->resourceOwnerAccount; + } + if (null !== $this->sceneCode) { + $res['SceneCode'] = $this->sceneCode; + } + if (null !== $this->startDate) { + $res['StartDate'] = $this->startDate; + } + + return $res; + } + + /** + * @param array $map + * + * @return QueryGateVerifyStatisticPublicRequest + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['AuthenticationType'])) { + $model->authenticationType = $map['AuthenticationType']; + } + if (isset($map['EndDate'])) { + $model->endDate = $map['EndDate']; + } + if (isset($map['OsType'])) { + $model->osType = $map['OsType']; + } + if (isset($map['OwnerId'])) { + $model->ownerId = $map['OwnerId']; + } + if (isset($map['ResourceOwnerAccount'])) { + $model->resourceOwnerAccount = $map['ResourceOwnerAccount']; + } + if (isset($map['SceneCode'])) { + $model->sceneCode = $map['SceneCode']; + } + if (isset($map['StartDate'])) { + $model->startDate = $map['StartDate']; + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/QueryGateVerifyStatisticPublicResponse.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/QueryGateVerifyStatisticPublicResponse.php new file mode 100644 index 0000000..cbc64c5 --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/QueryGateVerifyStatisticPublicResponse.php @@ -0,0 +1,71 @@ + 'headers', + 'statusCode' => 'statusCode', + 'body' => 'body', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->headers) { + $res['headers'] = $this->headers; + } + if (null !== $this->statusCode) { + $res['statusCode'] = $this->statusCode; + } + if (null !== $this->body) { + $res['body'] = null !== $this->body ? $this->body->toMap() : null; + } + + return $res; + } + + /** + * @param array $map + * + * @return QueryGateVerifyStatisticPublicResponse + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['headers'])) { + $model->headers = $map['headers']; + } + if (isset($map['statusCode'])) { + $model->statusCode = $map['statusCode']; + } + if (isset($map['body'])) { + $model->body = QueryGateVerifyStatisticPublicResponseBody::fromMap($map['body']); + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/QueryGateVerifyStatisticPublicResponseBody.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/QueryGateVerifyStatisticPublicResponseBody.php new file mode 100644 index 0000000..6c5d425 --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/QueryGateVerifyStatisticPublicResponseBody.php @@ -0,0 +1,101 @@ + 'Code', + 'data' => 'Data', + 'message' => 'Message', + 'requestId' => 'RequestId', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->code) { + $res['Code'] = $this->code; + } + if (null !== $this->data) { + $res['Data'] = null !== $this->data ? $this->data->toMap() : null; + } + if (null !== $this->message) { + $res['Message'] = $this->message; + } + if (null !== $this->requestId) { + $res['RequestId'] = $this->requestId; + } + + return $res; + } + + /** + * @param array $map + * + * @return QueryGateVerifyStatisticPublicResponseBody + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['Code'])) { + $model->code = $map['Code']; + } + if (isset($map['Data'])) { + $model->data = data::fromMap($map['Data']); + } + if (isset($map['Message'])) { + $model->message = $map['Message']; + } + if (isset($map['RequestId'])) { + $model->requestId = $map['RequestId']; + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/QueryGateVerifyStatisticPublicResponseBody/data.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/QueryGateVerifyStatisticPublicResponseBody/data.php new file mode 100644 index 0000000..e6975a9 --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/QueryGateVerifyStatisticPublicResponseBody/data.php @@ -0,0 +1,126 @@ + 'DayStatistic', + 'total' => 'Total', + 'totalFail' => 'TotalFail', + 'totalSuccess' => 'TotalSuccess', + 'totalUnknown' => 'TotalUnknown', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->dayStatistic) { + $res['DayStatistic'] = []; + if (null !== $this->dayStatistic && \is_array($this->dayStatistic)) { + $n = 0; + foreach ($this->dayStatistic as $item) { + $res['DayStatistic'][$n++] = null !== $item ? $item->toMap() : $item; + } + } + } + if (null !== $this->total) { + $res['Total'] = $this->total; + } + if (null !== $this->totalFail) { + $res['TotalFail'] = $this->totalFail; + } + if (null !== $this->totalSuccess) { + $res['TotalSuccess'] = $this->totalSuccess; + } + if (null !== $this->totalUnknown) { + $res['TotalUnknown'] = $this->totalUnknown; + } + + return $res; + } + + /** + * @param array $map + * + * @return data + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['DayStatistic'])) { + if (!empty($map['DayStatistic'])) { + $model->dayStatistic = []; + $n = 0; + foreach ($map['DayStatistic'] as $item) { + $model->dayStatistic[$n++] = null !== $item ? dayStatistic::fromMap($item) : $item; + } + } + } + if (isset($map['Total'])) { + $model->total = $map['Total']; + } + if (isset($map['TotalFail'])) { + $model->totalFail = $map['TotalFail']; + } + if (isset($map['TotalSuccess'])) { + $model->totalSuccess = $map['TotalSuccess']; + } + if (isset($map['TotalUnknown'])) { + $model->totalUnknown = $map['TotalUnknown']; + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/QueryGateVerifyStatisticPublicResponseBody/data/dayStatistic.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/QueryGateVerifyStatisticPublicResponseBody/data/dayStatistic.php new file mode 100644 index 0000000..a7f407b --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/QueryGateVerifyStatisticPublicResponseBody/data/dayStatistic.php @@ -0,0 +1,99 @@ + 'StatisticDateStr', + 'totalFail' => 'TotalFail', + 'totalSuccess' => 'TotalSuccess', + 'totalUnknown' => 'TotalUnknown', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->statisticDateStr) { + $res['StatisticDateStr'] = $this->statisticDateStr; + } + if (null !== $this->totalFail) { + $res['TotalFail'] = $this->totalFail; + } + if (null !== $this->totalSuccess) { + $res['TotalSuccess'] = $this->totalSuccess; + } + if (null !== $this->totalUnknown) { + $res['TotalUnknown'] = $this->totalUnknown; + } + + return $res; + } + + /** + * @param array $map + * + * @return dayStatistic + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['StatisticDateStr'])) { + $model->statisticDateStr = $map['StatisticDateStr']; + } + if (isset($map['TotalFail'])) { + $model->totalFail = $map['TotalFail']; + } + if (isset($map['TotalSuccess'])) { + $model->totalSuccess = $map['TotalSuccess']; + } + if (isset($map['TotalUnknown'])) { + $model->totalUnknown = $map['TotalUnknown']; + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/QuerySendDetailsRequest.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/QuerySendDetailsRequest.php new file mode 100644 index 0000000..ccc2049 --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/QuerySendDetailsRequest.php @@ -0,0 +1,155 @@ + 'BizId', + 'currentPage' => 'CurrentPage', + 'ownerId' => 'OwnerId', + 'pageSize' => 'PageSize', + 'phoneNumber' => 'PhoneNumber', + 'resourceOwnerAccount' => 'ResourceOwnerAccount', + 'resourceOwnerId' => 'ResourceOwnerId', + 'sendDate' => 'SendDate', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->bizId) { + $res['BizId'] = $this->bizId; + } + if (null !== $this->currentPage) { + $res['CurrentPage'] = $this->currentPage; + } + if (null !== $this->ownerId) { + $res['OwnerId'] = $this->ownerId; + } + if (null !== $this->pageSize) { + $res['PageSize'] = $this->pageSize; + } + if (null !== $this->phoneNumber) { + $res['PhoneNumber'] = $this->phoneNumber; + } + if (null !== $this->resourceOwnerAccount) { + $res['ResourceOwnerAccount'] = $this->resourceOwnerAccount; + } + if (null !== $this->resourceOwnerId) { + $res['ResourceOwnerId'] = $this->resourceOwnerId; + } + if (null !== $this->sendDate) { + $res['SendDate'] = $this->sendDate; + } + + return $res; + } + + /** + * @param array $map + * + * @return QuerySendDetailsRequest + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['BizId'])) { + $model->bizId = $map['BizId']; + } + if (isset($map['CurrentPage'])) { + $model->currentPage = $map['CurrentPage']; + } + if (isset($map['OwnerId'])) { + $model->ownerId = $map['OwnerId']; + } + if (isset($map['PageSize'])) { + $model->pageSize = $map['PageSize']; + } + if (isset($map['PhoneNumber'])) { + $model->phoneNumber = $map['PhoneNumber']; + } + if (isset($map['ResourceOwnerAccount'])) { + $model->resourceOwnerAccount = $map['ResourceOwnerAccount']; + } + if (isset($map['ResourceOwnerId'])) { + $model->resourceOwnerId = $map['ResourceOwnerId']; + } + if (isset($map['SendDate'])) { + $model->sendDate = $map['SendDate']; + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/QuerySendDetailsResponse.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/QuerySendDetailsResponse.php new file mode 100644 index 0000000..7fc1a8d --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/QuerySendDetailsResponse.php @@ -0,0 +1,71 @@ + 'headers', + 'statusCode' => 'statusCode', + 'body' => 'body', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->headers) { + $res['headers'] = $this->headers; + } + if (null !== $this->statusCode) { + $res['statusCode'] = $this->statusCode; + } + if (null !== $this->body) { + $res['body'] = null !== $this->body ? $this->body->toMap() : null; + } + + return $res; + } + + /** + * @param array $map + * + * @return QuerySendDetailsResponse + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['headers'])) { + $model->headers = $map['headers']; + } + if (isset($map['statusCode'])) { + $model->statusCode = $map['statusCode']; + } + if (isset($map['body'])) { + $model->body = QuerySendDetailsResponseBody::fromMap($map['body']); + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/QuerySendDetailsResponseBody.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/QuerySendDetailsResponseBody.php new file mode 100644 index 0000000..6a1445b --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/QuerySendDetailsResponseBody.php @@ -0,0 +1,146 @@ + 'AccessDeniedDetail', + 'code' => 'Code', + 'message' => 'Message', + 'model' => 'Model', + 'success' => 'Success', + 'totalCount' => 'TotalCount', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->accessDeniedDetail) { + $res['AccessDeniedDetail'] = $this->accessDeniedDetail; + } + if (null !== $this->code) { + $res['Code'] = $this->code; + } + if (null !== $this->message) { + $res['Message'] = $this->message; + } + if (null !== $this->model) { + $res['Model'] = []; + if (null !== $this->model && \is_array($this->model)) { + $n = 0; + foreach ($this->model as $item) { + $res['Model'][$n++] = null !== $item ? $item->toMap() : $item; + } + } + } + if (null !== $this->success) { + $res['Success'] = $this->success; + } + if (null !== $this->totalCount) { + $res['TotalCount'] = $this->totalCount; + } + + return $res; + } + + /** + * @param array $map + * + * @return QuerySendDetailsResponseBody + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['AccessDeniedDetail'])) { + $model->accessDeniedDetail = $map['AccessDeniedDetail']; + } + if (isset($map['Code'])) { + $model->code = $map['Code']; + } + if (isset($map['Message'])) { + $model->message = $map['Message']; + } + if (isset($map['Model'])) { + if (!empty($map['Model'])) { + $model->model = []; + $n = 0; + foreach ($map['Model'] as $item) { + $model->model[$n++] = null !== $item ? model_::fromMap($item) : $item; + } + } + } + if (isset($map['Success'])) { + $model->success = $map['Success']; + } + if (isset($map['TotalCount'])) { + $model->totalCount = $map['TotalCount']; + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/QuerySendDetailsResponseBody/model_.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/QuerySendDetailsResponseBody/model_.php new file mode 100644 index 0000000..c83148f --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/QuerySendDetailsResponseBody/model_.php @@ -0,0 +1,174 @@ + The text message templates must be created on the Go Globe page and approved. + * @example SMS_12231**** + * + * @var string + */ + public $templateCode; + protected $_name = [ + 'content' => 'Content', + 'errCode' => 'ErrCode', + 'outId' => 'OutId', + 'phoneNum' => 'PhoneNum', + 'receiveDate' => 'ReceiveDate', + 'sendDate' => 'SendDate', + 'sendStatus' => 'SendStatus', + 'templateCode' => 'TemplateCode', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->content) { + $res['Content'] = $this->content; + } + if (null !== $this->errCode) { + $res['ErrCode'] = $this->errCode; + } + if (null !== $this->outId) { + $res['OutId'] = $this->outId; + } + if (null !== $this->phoneNum) { + $res['PhoneNum'] = $this->phoneNum; + } + if (null !== $this->receiveDate) { + $res['ReceiveDate'] = $this->receiveDate; + } + if (null !== $this->sendDate) { + $res['SendDate'] = $this->sendDate; + } + if (null !== $this->sendStatus) { + $res['SendStatus'] = $this->sendStatus; + } + if (null !== $this->templateCode) { + $res['TemplateCode'] = $this->templateCode; + } + + return $res; + } + + /** + * @param array $map + * + * @return model_ + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['Content'])) { + $model->content = $map['Content']; + } + if (isset($map['ErrCode'])) { + $model->errCode = $map['ErrCode']; + } + if (isset($map['OutId'])) { + $model->outId = $map['OutId']; + } + if (isset($map['PhoneNum'])) { + $model->phoneNum = $map['PhoneNum']; + } + if (isset($map['ReceiveDate'])) { + $model->receiveDate = $map['ReceiveDate']; + } + if (isset($map['SendDate'])) { + $model->sendDate = $map['SendDate']; + } + if (isset($map['SendStatus'])) { + $model->sendStatus = $map['SendStatus']; + } + if (isset($map['TemplateCode'])) { + $model->templateCode = $map['TemplateCode']; + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/SendSmsVerifyCodeRequest.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/SendSmsVerifyCodeRequest.php new file mode 100644 index 0000000..601a65d --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/SendSmsVerifyCodeRequest.php @@ -0,0 +1,322 @@ + The extension code is automatically generated by the system when the signature is generated. You do not need to specify the extension code. You can skip this parameter based on your business requirements. If you want to use custom extension codes, contact your account manager. + * @example 1213123 + * + * @var string + */ + public $smsUpExtendCode; + + /** + * @description The code of the text message template. + * + * Log on to the [SMS console](https://dysms.console.aliyun.com/dysms.htm?spm=5176.12818093.categories-n-products.ddysms.3b2816d0xml2NA#/overview). In the left-side navigation pane, click **Go China** or **Go Globe**. You can view the text message template code in the **Template Code** column on the **Message Templates** tab. + * + * This parameter is required. + * @example azsq_***** + * + * @var string + */ + public $templateCode; + + /** + * @description The value of the variable in the text message template. The verification code is replaced with "##code##". + * + * > + * + * If line breaks are required in JSON-formatted data, they must meet the relevant requirements that are specified in the standard JSON protocol. + * + * For more information about template variables, see [SMS template specifications](https://help.aliyun.com/document_detail/108253.html). + * + * This parameter is required. + * @example {"code":"##code##"} + * + * @var string + */ + public $templateParam; + + /** + * @description The validity period of the verification code. Unit: seconds. Default value: 300. + * + * @example 300 + * + * @var int + */ + public $validTime; + protected $_name = [ + 'codeLength' => 'CodeLength', + 'codeType' => 'CodeType', + 'countryCode' => 'CountryCode', + 'duplicatePolicy' => 'DuplicatePolicy', + 'interval' => 'Interval', + 'outId' => 'OutId', + 'ownerId' => 'OwnerId', + 'phoneNumber' => 'PhoneNumber', + 'resourceOwnerAccount' => 'ResourceOwnerAccount', + 'resourceOwnerId' => 'ResourceOwnerId', + 'returnVerifyCode' => 'ReturnVerifyCode', + 'schemeName' => 'SchemeName', + 'signName' => 'SignName', + 'smsUpExtendCode' => 'SmsUpExtendCode', + 'templateCode' => 'TemplateCode', + 'templateParam' => 'TemplateParam', + 'validTime' => 'ValidTime', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->codeLength) { + $res['CodeLength'] = $this->codeLength; + } + if (null !== $this->codeType) { + $res['CodeType'] = $this->codeType; + } + if (null !== $this->countryCode) { + $res['CountryCode'] = $this->countryCode; + } + if (null !== $this->duplicatePolicy) { + $res['DuplicatePolicy'] = $this->duplicatePolicy; + } + if (null !== $this->interval) { + $res['Interval'] = $this->interval; + } + if (null !== $this->outId) { + $res['OutId'] = $this->outId; + } + if (null !== $this->ownerId) { + $res['OwnerId'] = $this->ownerId; + } + if (null !== $this->phoneNumber) { + $res['PhoneNumber'] = $this->phoneNumber; + } + if (null !== $this->resourceOwnerAccount) { + $res['ResourceOwnerAccount'] = $this->resourceOwnerAccount; + } + if (null !== $this->resourceOwnerId) { + $res['ResourceOwnerId'] = $this->resourceOwnerId; + } + if (null !== $this->returnVerifyCode) { + $res['ReturnVerifyCode'] = $this->returnVerifyCode; + } + if (null !== $this->schemeName) { + $res['SchemeName'] = $this->schemeName; + } + if (null !== $this->signName) { + $res['SignName'] = $this->signName; + } + if (null !== $this->smsUpExtendCode) { + $res['SmsUpExtendCode'] = $this->smsUpExtendCode; + } + if (null !== $this->templateCode) { + $res['TemplateCode'] = $this->templateCode; + } + if (null !== $this->templateParam) { + $res['TemplateParam'] = $this->templateParam; + } + if (null !== $this->validTime) { + $res['ValidTime'] = $this->validTime; + } + + return $res; + } + + /** + * @param array $map + * + * @return SendSmsVerifyCodeRequest + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['CodeLength'])) { + $model->codeLength = $map['CodeLength']; + } + if (isset($map['CodeType'])) { + $model->codeType = $map['CodeType']; + } + if (isset($map['CountryCode'])) { + $model->countryCode = $map['CountryCode']; + } + if (isset($map['DuplicatePolicy'])) { + $model->duplicatePolicy = $map['DuplicatePolicy']; + } + if (isset($map['Interval'])) { + $model->interval = $map['Interval']; + } + if (isset($map['OutId'])) { + $model->outId = $map['OutId']; + } + if (isset($map['OwnerId'])) { + $model->ownerId = $map['OwnerId']; + } + if (isset($map['PhoneNumber'])) { + $model->phoneNumber = $map['PhoneNumber']; + } + if (isset($map['ResourceOwnerAccount'])) { + $model->resourceOwnerAccount = $map['ResourceOwnerAccount']; + } + if (isset($map['ResourceOwnerId'])) { + $model->resourceOwnerId = $map['ResourceOwnerId']; + } + if (isset($map['ReturnVerifyCode'])) { + $model->returnVerifyCode = $map['ReturnVerifyCode']; + } + if (isset($map['SchemeName'])) { + $model->schemeName = $map['SchemeName']; + } + if (isset($map['SignName'])) { + $model->signName = $map['SignName']; + } + if (isset($map['SmsUpExtendCode'])) { + $model->smsUpExtendCode = $map['SmsUpExtendCode']; + } + if (isset($map['TemplateCode'])) { + $model->templateCode = $map['TemplateCode']; + } + if (isset($map['TemplateParam'])) { + $model->templateParam = $map['TemplateParam']; + } + if (isset($map['ValidTime'])) { + $model->validTime = $map['ValidTime']; + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/SendSmsVerifyCodeResponse.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/SendSmsVerifyCodeResponse.php new file mode 100644 index 0000000..101d426 --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/SendSmsVerifyCodeResponse.php @@ -0,0 +1,71 @@ + 'headers', + 'statusCode' => 'statusCode', + 'body' => 'body', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->headers) { + $res['headers'] = $this->headers; + } + if (null !== $this->statusCode) { + $res['statusCode'] = $this->statusCode; + } + if (null !== $this->body) { + $res['body'] = null !== $this->body ? $this->body->toMap() : null; + } + + return $res; + } + + /** + * @param array $map + * + * @return SendSmsVerifyCodeResponse + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['headers'])) { + $model->headers = $map['headers']; + } + if (isset($map['statusCode'])) { + $model->statusCode = $map['statusCode']; + } + if (isset($map['body'])) { + $model->body = SendSmsVerifyCodeResponseBody::fromMap($map['body']); + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/SendSmsVerifyCodeResponseBody.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/SendSmsVerifyCodeResponseBody.php new file mode 100644 index 0000000..c84b361 --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/SendSmsVerifyCodeResponseBody.php @@ -0,0 +1,117 @@ + 'AccessDeniedDetail', + 'code' => 'Code', + 'message' => 'Message', + 'model' => 'Model', + 'success' => 'Success', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->accessDeniedDetail) { + $res['AccessDeniedDetail'] = $this->accessDeniedDetail; + } + if (null !== $this->code) { + $res['Code'] = $this->code; + } + if (null !== $this->message) { + $res['Message'] = $this->message; + } + if (null !== $this->model) { + $res['Model'] = null !== $this->model ? $this->model->toMap() : null; + } + if (null !== $this->success) { + $res['Success'] = $this->success; + } + + return $res; + } + + /** + * @param array $map + * + * @return SendSmsVerifyCodeResponseBody + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['AccessDeniedDetail'])) { + $model->accessDeniedDetail = $map['AccessDeniedDetail']; + } + if (isset($map['Code'])) { + $model->code = $map['Code']; + } + if (isset($map['Message'])) { + $model->message = $map['Message']; + } + if (isset($map['Model'])) { + $model->model = model_::fromMap($map['Model']); + } + if (isset($map['Success'])) { + $model->success = $map['Success']; + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/SendSmsVerifyCodeResponseBody/model_.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/SendSmsVerifyCodeResponseBody/model_.php new file mode 100644 index 0000000..43dd126 --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/SendSmsVerifyCodeResponseBody/model_.php @@ -0,0 +1,99 @@ + 'BizId', + 'outId' => 'OutId', + 'requestId' => 'RequestId', + 'verifyCode' => 'VerifyCode', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->bizId) { + $res['BizId'] = $this->bizId; + } + if (null !== $this->outId) { + $res['OutId'] = $this->outId; + } + if (null !== $this->requestId) { + $res['RequestId'] = $this->requestId; + } + if (null !== $this->verifyCode) { + $res['VerifyCode'] = $this->verifyCode; + } + + return $res; + } + + /** + * @param array $map + * + * @return model_ + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['BizId'])) { + $model->bizId = $map['BizId']; + } + if (isset($map['OutId'])) { + $model->outId = $map['OutId']; + } + if (isset($map['RequestId'])) { + $model->requestId = $map['RequestId']; + } + if (isset($map['VerifyCode'])) { + $model->verifyCode = $map['VerifyCode']; + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyMobileRequest.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyMobileRequest.php new file mode 100644 index 0000000..3aef876 --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyMobileRequest.php @@ -0,0 +1,121 @@ + 'AccessCode', + 'outId' => 'OutId', + 'ownerId' => 'OwnerId', + 'phoneNumber' => 'PhoneNumber', + 'resourceOwnerAccount' => 'ResourceOwnerAccount', + 'resourceOwnerId' => 'ResourceOwnerId', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->accessCode) { + $res['AccessCode'] = $this->accessCode; + } + if (null !== $this->outId) { + $res['OutId'] = $this->outId; + } + if (null !== $this->ownerId) { + $res['OwnerId'] = $this->ownerId; + } + if (null !== $this->phoneNumber) { + $res['PhoneNumber'] = $this->phoneNumber; + } + if (null !== $this->resourceOwnerAccount) { + $res['ResourceOwnerAccount'] = $this->resourceOwnerAccount; + } + if (null !== $this->resourceOwnerId) { + $res['ResourceOwnerId'] = $this->resourceOwnerId; + } + + return $res; + } + + /** + * @param array $map + * + * @return VerifyMobileRequest + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['AccessCode'])) { + $model->accessCode = $map['AccessCode']; + } + if (isset($map['OutId'])) { + $model->outId = $map['OutId']; + } + if (isset($map['OwnerId'])) { + $model->ownerId = $map['OwnerId']; + } + if (isset($map['PhoneNumber'])) { + $model->phoneNumber = $map['PhoneNumber']; + } + if (isset($map['ResourceOwnerAccount'])) { + $model->resourceOwnerAccount = $map['ResourceOwnerAccount']; + } + if (isset($map['ResourceOwnerId'])) { + $model->resourceOwnerId = $map['ResourceOwnerId']; + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyMobileResponse.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyMobileResponse.php new file mode 100644 index 0000000..fd19f2e --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyMobileResponse.php @@ -0,0 +1,71 @@ + 'headers', + 'statusCode' => 'statusCode', + 'body' => 'body', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->headers) { + $res['headers'] = $this->headers; + } + if (null !== $this->statusCode) { + $res['statusCode'] = $this->statusCode; + } + if (null !== $this->body) { + $res['body'] = null !== $this->body ? $this->body->toMap() : null; + } + + return $res; + } + + /** + * @param array $map + * + * @return VerifyMobileResponse + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['headers'])) { + $model->headers = $map['headers']; + } + if (isset($map['statusCode'])) { + $model->statusCode = $map['statusCode']; + } + if (isset($map['body'])) { + $model->body = VerifyMobileResponseBody::fromMap($map['body']); + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyMobileResponseBody.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyMobileResponseBody.php new file mode 100644 index 0000000..57ee0bf --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyMobileResponseBody.php @@ -0,0 +1,101 @@ + 'Code', + 'gateVerifyResultDTO' => 'GateVerifyResultDTO', + 'message' => 'Message', + 'requestId' => 'RequestId', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->code) { + $res['Code'] = $this->code; + } + if (null !== $this->gateVerifyResultDTO) { + $res['GateVerifyResultDTO'] = null !== $this->gateVerifyResultDTO ? $this->gateVerifyResultDTO->toMap() : null; + } + if (null !== $this->message) { + $res['Message'] = $this->message; + } + if (null !== $this->requestId) { + $res['RequestId'] = $this->requestId; + } + + return $res; + } + + /** + * @param array $map + * + * @return VerifyMobileResponseBody + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['Code'])) { + $model->code = $map['Code']; + } + if (isset($map['GateVerifyResultDTO'])) { + $model->gateVerifyResultDTO = gateVerifyResultDTO::fromMap($map['GateVerifyResultDTO']); + } + if (isset($map['Message'])) { + $model->message = $map['Message']; + } + if (isset($map['RequestId'])) { + $model->requestId = $map['RequestId']; + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyMobileResponseBody/gateVerifyResultDTO.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyMobileResponseBody/gateVerifyResultDTO.php new file mode 100644 index 0000000..06b24ab --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyMobileResponseBody/gateVerifyResultDTO.php @@ -0,0 +1,71 @@ + 'VerifyId', + 'verifyResult' => 'VerifyResult', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->verifyId) { + $res['VerifyId'] = $this->verifyId; + } + if (null !== $this->verifyResult) { + $res['VerifyResult'] = $this->verifyResult; + } + + return $res; + } + + /** + * @param array $map + * + * @return gateVerifyResultDTO + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['VerifyId'])) { + $model->verifyId = $map['VerifyId']; + } + if (isset($map['VerifyResult'])) { + $model->verifyResult = $map['VerifyResult']; + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyPhoneWithTokenRequest.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyPhoneWithTokenRequest.php new file mode 100644 index 0000000..50f77d5 --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyPhoneWithTokenRequest.php @@ -0,0 +1,105 @@ + 'OwnerId', + 'phoneNumber' => 'PhoneNumber', + 'resourceOwnerAccount' => 'ResourceOwnerAccount', + 'resourceOwnerId' => 'ResourceOwnerId', + 'spToken' => 'SpToken', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->ownerId) { + $res['OwnerId'] = $this->ownerId; + } + if (null !== $this->phoneNumber) { + $res['PhoneNumber'] = $this->phoneNumber; + } + if (null !== $this->resourceOwnerAccount) { + $res['ResourceOwnerAccount'] = $this->resourceOwnerAccount; + } + if (null !== $this->resourceOwnerId) { + $res['ResourceOwnerId'] = $this->resourceOwnerId; + } + if (null !== $this->spToken) { + $res['SpToken'] = $this->spToken; + } + + return $res; + } + + /** + * @param array $map + * + * @return VerifyPhoneWithTokenRequest + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['OwnerId'])) { + $model->ownerId = $map['OwnerId']; + } + if (isset($map['PhoneNumber'])) { + $model->phoneNumber = $map['PhoneNumber']; + } + if (isset($map['ResourceOwnerAccount'])) { + $model->resourceOwnerAccount = $map['ResourceOwnerAccount']; + } + if (isset($map['ResourceOwnerId'])) { + $model->resourceOwnerId = $map['ResourceOwnerId']; + } + if (isset($map['SpToken'])) { + $model->spToken = $map['SpToken']; + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyPhoneWithTokenResponse.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyPhoneWithTokenResponse.php new file mode 100644 index 0000000..fe78395 --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyPhoneWithTokenResponse.php @@ -0,0 +1,71 @@ + 'headers', + 'statusCode' => 'statusCode', + 'body' => 'body', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->headers) { + $res['headers'] = $this->headers; + } + if (null !== $this->statusCode) { + $res['statusCode'] = $this->statusCode; + } + if (null !== $this->body) { + $res['body'] = null !== $this->body ? $this->body->toMap() : null; + } + + return $res; + } + + /** + * @param array $map + * + * @return VerifyPhoneWithTokenResponse + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['headers'])) { + $model->headers = $map['headers']; + } + if (isset($map['statusCode'])) { + $model->statusCode = $map['statusCode']; + } + if (isset($map['body'])) { + $model->body = VerifyPhoneWithTokenResponseBody::fromMap($map['body']); + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyPhoneWithTokenResponseBody.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyPhoneWithTokenResponseBody.php new file mode 100644 index 0000000..5c04ca1 --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyPhoneWithTokenResponseBody.php @@ -0,0 +1,101 @@ + 'Code', + 'gateVerify' => 'GateVerify', + 'message' => 'Message', + 'requestId' => 'RequestId', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->code) { + $res['Code'] = $this->code; + } + if (null !== $this->gateVerify) { + $res['GateVerify'] = null !== $this->gateVerify ? $this->gateVerify->toMap() : null; + } + if (null !== $this->message) { + $res['Message'] = $this->message; + } + if (null !== $this->requestId) { + $res['RequestId'] = $this->requestId; + } + + return $res; + } + + /** + * @param array $map + * + * @return VerifyPhoneWithTokenResponseBody + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['Code'])) { + $model->code = $map['Code']; + } + if (isset($map['GateVerify'])) { + $model->gateVerify = gateVerify::fromMap($map['GateVerify']); + } + if (isset($map['Message'])) { + $model->message = $map['Message']; + } + if (isset($map['RequestId'])) { + $model->requestId = $map['RequestId']; + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyPhoneWithTokenResponseBody/gateVerify.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyPhoneWithTokenResponseBody/gateVerify.php new file mode 100644 index 0000000..32ce8f9 --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyPhoneWithTokenResponseBody/gateVerify.php @@ -0,0 +1,71 @@ + 'VerifyId', + 'verifyResult' => 'VerifyResult', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->verifyId) { + $res['VerifyId'] = $this->verifyId; + } + if (null !== $this->verifyResult) { + $res['VerifyResult'] = $this->verifyResult; + } + + return $res; + } + + /** + * @param array $map + * + * @return gateVerify + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['VerifyId'])) { + $model->verifyId = $map['VerifyId']; + } + if (isset($map['VerifyResult'])) { + $model->verifyResult = $map['VerifyResult']; + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifySmsCodeRequest.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifySmsCodeRequest.php new file mode 100644 index 0000000..f5bbad4 --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifySmsCodeRequest.php @@ -0,0 +1,86 @@ + 'PhoneNumber', + 'smsCode' => 'SmsCode', + 'smsToken' => 'SmsToken', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->phoneNumber) { + $res['PhoneNumber'] = $this->phoneNumber; + } + if (null !== $this->smsCode) { + $res['SmsCode'] = $this->smsCode; + } + if (null !== $this->smsToken) { + $res['SmsToken'] = $this->smsToken; + } + + return $res; + } + + /** + * @param array $map + * + * @return VerifySmsCodeRequest + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['PhoneNumber'])) { + $model->phoneNumber = $map['PhoneNumber']; + } + if (isset($map['SmsCode'])) { + $model->smsCode = $map['SmsCode']; + } + if (isset($map['SmsToken'])) { + $model->smsToken = $map['SmsToken']; + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifySmsCodeResponse.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifySmsCodeResponse.php new file mode 100644 index 0000000..ebf6902 --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifySmsCodeResponse.php @@ -0,0 +1,71 @@ + 'headers', + 'statusCode' => 'statusCode', + 'body' => 'body', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->headers) { + $res['headers'] = $this->headers; + } + if (null !== $this->statusCode) { + $res['statusCode'] = $this->statusCode; + } + if (null !== $this->body) { + $res['body'] = null !== $this->body ? $this->body->toMap() : null; + } + + return $res; + } + + /** + * @param array $map + * + * @return VerifySmsCodeResponse + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['headers'])) { + $model->headers = $map['headers']; + } + if (isset($map['statusCode'])) { + $model->statusCode = $map['statusCode']; + } + if (isset($map['body'])) { + $model->body = VerifySmsCodeResponseBody::fromMap($map['body']); + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifySmsCodeResponseBody.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifySmsCodeResponseBody.php new file mode 100644 index 0000000..05e298e --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifySmsCodeResponseBody.php @@ -0,0 +1,105 @@ + 'Code', + 'data' => 'Data', + 'message' => 'Message', + 'requestId' => 'RequestId', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->code) { + $res['Code'] = $this->code; + } + if (null !== $this->data) { + $res['Data'] = $this->data; + } + if (null !== $this->message) { + $res['Message'] = $this->message; + } + if (null !== $this->requestId) { + $res['RequestId'] = $this->requestId; + } + + return $res; + } + + /** + * @param array $map + * + * @return VerifySmsCodeResponseBody + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['Code'])) { + $model->code = $map['Code']; + } + if (isset($map['Data'])) { + $model->data = $map['Data']; + } + if (isset($map['Message'])) { + $model->message = $map['Message']; + } + if (isset($map['RequestId'])) { + $model->requestId = $map['RequestId']; + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyWithFusionAuthTokenRequest.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyWithFusionAuthTokenRequest.php new file mode 100644 index 0000000..0c02a86 --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyWithFusionAuthTokenRequest.php @@ -0,0 +1,88 @@ + 'OwnerId', + 'resourceOwnerAccount' => 'ResourceOwnerAccount', + 'resourceOwnerId' => 'ResourceOwnerId', + 'verifyToken' => 'VerifyToken', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->ownerId) { + $res['OwnerId'] = $this->ownerId; + } + if (null !== $this->resourceOwnerAccount) { + $res['ResourceOwnerAccount'] = $this->resourceOwnerAccount; + } + if (null !== $this->resourceOwnerId) { + $res['ResourceOwnerId'] = $this->resourceOwnerId; + } + if (null !== $this->verifyToken) { + $res['VerifyToken'] = $this->verifyToken; + } + + return $res; + } + + /** + * @param array $map + * + * @return VerifyWithFusionAuthTokenRequest + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['OwnerId'])) { + $model->ownerId = $map['OwnerId']; + } + if (isset($map['ResourceOwnerAccount'])) { + $model->resourceOwnerAccount = $map['ResourceOwnerAccount']; + } + if (isset($map['ResourceOwnerId'])) { + $model->resourceOwnerId = $map['ResourceOwnerId']; + } + if (isset($map['VerifyToken'])) { + $model->verifyToken = $map['VerifyToken']; + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyWithFusionAuthTokenResponse.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyWithFusionAuthTokenResponse.php new file mode 100644 index 0000000..be835d2 --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyWithFusionAuthTokenResponse.php @@ -0,0 +1,71 @@ + 'headers', + 'statusCode' => 'statusCode', + 'body' => 'body', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->headers) { + $res['headers'] = $this->headers; + } + if (null !== $this->statusCode) { + $res['statusCode'] = $this->statusCode; + } + if (null !== $this->body) { + $res['body'] = null !== $this->body ? $this->body->toMap() : null; + } + + return $res; + } + + /** + * @param array $map + * + * @return VerifyWithFusionAuthTokenResponse + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['headers'])) { + $model->headers = $map['headers']; + } + if (isset($map['statusCode'])) { + $model->statusCode = $map['statusCode']; + } + if (isset($map['body'])) { + $model->body = VerifyWithFusionAuthTokenResponseBody::fromMap($map['body']); + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyWithFusionAuthTokenResponseBody.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyWithFusionAuthTokenResponseBody.php new file mode 100644 index 0000000..df8a5ed --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyWithFusionAuthTokenResponseBody.php @@ -0,0 +1,114 @@ + 'Code', + 'message' => 'Message', + 'model' => 'Model', + 'requestId' => 'RequestId', + 'success' => 'Success', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->code) { + $res['Code'] = $this->code; + } + if (null !== $this->message) { + $res['Message'] = $this->message; + } + if (null !== $this->model) { + $res['Model'] = null !== $this->model ? $this->model->toMap() : null; + } + if (null !== $this->requestId) { + $res['RequestId'] = $this->requestId; + } + if (null !== $this->success) { + $res['Success'] = $this->success; + } + + return $res; + } + + /** + * @param array $map + * + * @return VerifyWithFusionAuthTokenResponseBody + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['Code'])) { + $model->code = $map['Code']; + } + if (isset($map['Message'])) { + $model->message = $map['Message']; + } + if (isset($map['Model'])) { + $model->model = model_::fromMap($map['Model']); + } + if (isset($map['RequestId'])) { + $model->requestId = $map['RequestId']; + } + if (isset($map['Success'])) { + $model->success = $map['Success']; + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyWithFusionAuthTokenResponseBody/model_.php b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyWithFusionAuthTokenResponseBody/model_.php new file mode 100644 index 0000000..8553d19 --- /dev/null +++ b/vendor/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyWithFusionAuthTokenResponseBody/model_.php @@ -0,0 +1,83 @@ + 'PhoneNumber', + 'phoneScore' => 'PhoneScore', + 'verifyResult' => 'VerifyResult', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->phoneNumber) { + $res['PhoneNumber'] = $this->phoneNumber; + } + if (null !== $this->phoneScore) { + $res['PhoneScore'] = $this->phoneScore; + } + if (null !== $this->verifyResult) { + $res['VerifyResult'] = $this->verifyResult; + } + + return $res; + } + + /** + * @param array $map + * + * @return model_ + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['PhoneNumber'])) { + $model->phoneNumber = $map['PhoneNumber']; + } + if (isset($map['PhoneScore'])) { + $model->phoneScore = $map['PhoneScore']; + } + if (isset($map['VerifyResult'])) { + $model->verifyResult = $map['VerifyResult']; + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/endpoint-util/.gitignore b/vendor/vendor/alibabacloud/endpoint-util/.gitignore new file mode 100644 index 0000000..0ee6c28 --- /dev/null +++ b/vendor/vendor/alibabacloud/endpoint-util/.gitignore @@ -0,0 +1,13 @@ +composer.phar +/vendor/ + +# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control +# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file +composer.lock + +.idea +.DS_Store + +cache/ +*.cache +runtime/ diff --git a/vendor/vendor/alibabacloud/endpoint-util/.php_cs.dist b/vendor/vendor/alibabacloud/endpoint-util/.php_cs.dist new file mode 100644 index 0000000..8617ec2 --- /dev/null +++ b/vendor/vendor/alibabacloud/endpoint-util/.php_cs.dist @@ -0,0 +1,65 @@ +setRiskyAllowed(true) + ->setIndent(' ') + ->setRules([ + '@PSR2' => true, + '@PhpCsFixer' => true, + '@Symfony:risky' => true, + 'concat_space' => ['spacing' => 'one'], + 'array_syntax' => ['syntax' => 'short'], + 'array_indentation' => true, + 'combine_consecutive_unsets' => true, + 'method_separation' => true, + 'single_quote' => true, + 'declare_equal_normalize' => true, + 'function_typehint_space' => true, + 'hash_to_slash_comment' => true, + 'include' => true, + 'lowercase_cast' => true, + 'no_multiline_whitespace_before_semicolons' => true, + 'no_leading_import_slash' => true, + 'no_multiline_whitespace_around_double_arrow' => true, + 'no_spaces_around_offset' => true, + 'no_unneeded_control_parentheses' => true, + 'no_unused_imports' => true, + 'no_whitespace_before_comma_in_array' => true, + 'no_whitespace_in_blank_line' => true, + 'object_operator_without_whitespace' => true, + 'single_blank_line_before_namespace' => true, + 'single_class_element_per_statement' => true, + 'space_after_semicolon' => true, + 'standardize_not_equals' => true, + 'ternary_operator_spaces' => true, + 'trailing_comma_in_multiline_array' => true, + 'trim_array_spaces' => true, + 'unary_operator_spaces' => true, + 'whitespace_after_comma_in_array' => true, + 'no_extra_consecutive_blank_lines' => [ + 'curly_brace_block', + 'extra', + 'parenthesis_brace_block', + 'square_brace_block', + 'throw', + 'use', + ], + 'binary_operator_spaces' => [ + 'align_double_arrow' => true, + 'align_equals' => true, + ], + 'braces' => [ + 'allow_single_line_closure' => true, + ], + ]) + ->setFinder( + PhpCsFixer\Finder::create() + ->exclude('vendor') + ->exclude('tests') + ->in(__DIR__) + ); diff --git a/vendor/vendor/alibabacloud/endpoint-util/LICENSE b/vendor/vendor/alibabacloud/endpoint-util/LICENSE new file mode 100644 index 0000000..ec13fcc --- /dev/null +++ b/vendor/vendor/alibabacloud/endpoint-util/LICENSE @@ -0,0 +1,13 @@ +Copyright (c) 2009-present, Alibaba Cloud All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/vendor/vendor/alibabacloud/endpoint-util/README-CN.md b/vendor/vendor/alibabacloud/endpoint-util/README-CN.md new file mode 100644 index 0000000..80374a4 --- /dev/null +++ b/vendor/vendor/alibabacloud/endpoint-util/README-CN.md @@ -0,0 +1,31 @@ +English | [简体中文](README-CN.md) + +![](https://aliyunsdk-pages.alicdn.com/icons/AlibabaCloud.svg) + +## Alibaba Cloud Endpoint Library for PHP + +## Installation + +### Composer + +```bash +composer require alibabacloud/endpoint-util +``` + +## Issues + +[Opening an Issue](https://github.com/aliyun/endpoint-util/issues/new), Issues not conforming to the guidelines may be closed immediately. + +## Changelog + +Detailed changes for each release are documented in the [release notes](./ChangeLog.txt). + +## References + +* [Latest Release](https://github.com/aliyun/endpoint-util) + +## License + +[Apache-2.0](http://www.apache.org/licenses/LICENSE-2.0) + +Copyright (c) 2009-present, Alibaba Cloud All rights reserved. diff --git a/vendor/vendor/alibabacloud/endpoint-util/README.md b/vendor/vendor/alibabacloud/endpoint-util/README.md new file mode 100644 index 0000000..3cd5898 --- /dev/null +++ b/vendor/vendor/alibabacloud/endpoint-util/README.md @@ -0,0 +1,31 @@ +[English](README.md) | 简体中文 + +![](https://aliyunsdk-pages.alicdn.com/icons/AlibabaCloud.svg) + +## Alibaba Cloud Endpoint Library for PHP + +## 安装 + +### Composer + +```bash +composer require alibabacloud/endpoint-util +``` + +## 问题 + +[提交 Issue](https://github.com/aliyun/endpoint-util/issues/new),不符合指南的问题可能会立即关闭。 + +## 发行说明 + +每个版本的详细更改记录在[发行说明](./ChangeLog.txt)中。 + +## 相关 + +* [最新源码](https://github.com/aliyun/endpoint-util) + +## 许可证 + +[Apache-2.0](http://www.apache.org/licenses/LICENSE-2.0) + +Copyright (c) 2009-present, Alibaba Cloud All rights reserved. diff --git a/vendor/vendor/alibabacloud/endpoint-util/composer.json b/vendor/vendor/alibabacloud/endpoint-util/composer.json new file mode 100644 index 0000000..d22ce33 --- /dev/null +++ b/vendor/vendor/alibabacloud/endpoint-util/composer.json @@ -0,0 +1,42 @@ +{ + "name": "alibabacloud/endpoint-util", + "description": "Alibaba Cloud Endpoint Library for PHP", + "type": "library", + "license": "Apache-2.0", + "authors": [ + { + "name": "Alibaba Cloud SDK", + "email": "sdk-team@alibabacloud.com" + } + ], + "require": { + "php": ">5.5" + }, + "require-dev": { + "phpunit/phpunit": "^4.8.35|^5.4.3" + }, + "autoload": { + "psr-4": { + "AlibabaCloud\\Endpoint\\": "src" + } + }, + "autoload-dev": { + "psr-4": { + "AlibabaCloud\\Endpoint\\Tests\\": "tests" + } + }, + "scripts": { + "fixer": "php-cs-fixer fix ./", + "test": [ + "@clearCache", + "./vendor/bin/phpunit --colors=always" + ], + "clearCache": "rm -rf cache/*" + }, + "config": { + "sort-packages": true, + "preferred-install": "dist", + "optimize-autoloader": true + }, + "prefer-stable": true +} \ No newline at end of file diff --git a/vendor/vendor/alibabacloud/endpoint-util/phpunit.xml b/vendor/vendor/alibabacloud/endpoint-util/phpunit.xml new file mode 100644 index 0000000..8306a79 --- /dev/null +++ b/vendor/vendor/alibabacloud/endpoint-util/phpunit.xml @@ -0,0 +1,32 @@ + + + + + + tests + + + ./tests/Unit + + + + + + integration + + + + + + + + + + + + ./src + + + diff --git a/vendor/vendor/alibabacloud/endpoint-util/src/Endpoint.php b/vendor/vendor/alibabacloud/endpoint-util/src/Endpoint.php new file mode 100644 index 0000000..5afa676 --- /dev/null +++ b/vendor/vendor/alibabacloud/endpoint-util/src/Endpoint.php @@ -0,0 +1,61 @@ +..aliyuncs.com'; + const CENTRAL_RULES = '.aliyuncs.com'; + + /** + * @param string $product required + * @param string $regionId optional It will be required when endpoint type is 'regional' + * @param string $endpointType optional regional|central + * @param string $network optional + * @param string $suffix optional + * + * @throws \InvalidArgumentException + * + * @return string + */ + public static function getEndpointRules($product, $regionId, $endpointType = '', $network = '', $suffix = '') + { + if (empty($product)) { + throw new \InvalidArgumentException('Product name cannot be empty.'); + } + $endpoint = self::REGIONAL_RULES; + if (self::ENDPOINT_TYPE_REGIONAL === $endpointType) { + if (empty($regionId)) { + throw new \InvalidArgumentException('RegionId is empty, please set a valid RegionId'); + } + $endpoint = self::render($endpoint, 'region_id', strtolower($regionId)); + } elseif (self::ENDPOINT_TYPE_CENTRAL === $endpointType) { + $endpoint = self::CENTRAL_RULES; + } else { + throw new \InvalidArgumentException('Invalid EndpointType'); + } + if (!empty($network) && 'public' !== $network) { + $endpoint = self::render($endpoint, 'network', '-' . $network); + } else { + $endpoint = self::render($endpoint, 'network', ''); + } + if (!empty($suffix)) { + $endpoint = self::render($endpoint, 'suffix', '-' . $suffix); + } else { + $endpoint = self::render($endpoint, 'suffix', ''); + } + + return self::render($endpoint, 'product', strtolower($product)); + } + + private static function render($str, $tag, $replace) + { + return str_replace('<' . $tag . '>', $replace, $str); + } +} diff --git a/vendor/vendor/alibabacloud/endpoint-util/tests/EndpointTest.php b/vendor/vendor/alibabacloud/endpoint-util/tests/EndpointTest.php new file mode 100644 index 0000000..e21dcd4 --- /dev/null +++ b/vendor/vendor/alibabacloud/endpoint-util/tests/EndpointTest.php @@ -0,0 +1,58 @@ +expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('Product name cannot be empty.'); + Endpoint::getEndpointRules('', '', '', ''); + } + + public function testGetEndpointWhenInvalidEndpointType() + { + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('Invalid EndpointType'); + Endpoint::getEndpointRules('ecs', '', 'fake endpoint type', ''); + } + + public function testGetEndpointWhenInvalidRegionId() + { + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('RegionId is empty, please set a valid RegionId'); + Endpoint::getEndpointRules('ecs', '', Endpoint::ENDPOINT_TYPE_REGIONAL, ''); + } + + public function testGetEndpointCentral() + { + $endpoint = Endpoint::getEndpointRules('ecs', '', Endpoint::ENDPOINT_TYPE_CENTRAL); + $this->assertEquals('ecs.aliyuncs.com', $endpoint); + } + + public function testGetEndpointRegional() + { + $endpoint = Endpoint::getEndpointRules('ecs', 'cn-hangzhou', Endpoint::ENDPOINT_TYPE_REGIONAL); + $this->assertEquals('ecs.cn-hangzhou.aliyuncs.com', $endpoint); + } + + public function testGetEndpointRegionalWithNetwork() + { + $endpoint = Endpoint::getEndpointRules('ecs', 'cn-hangzhou', Endpoint::ENDPOINT_TYPE_REGIONAL, 'internal'); + $this->assertEquals('ecs-internal.cn-hangzhou.aliyuncs.com', $endpoint); + } + + public function testGetEndpointRegionalWithSuffix() + { + $endpoint = Endpoint::getEndpointRules('ecs', 'cn-hangzhou', Endpoint::ENDPOINT_TYPE_REGIONAL, 'internal', 'test'); + $this->assertEquals('ecs-test-internal.cn-hangzhou.aliyuncs.com', $endpoint); + } +} diff --git a/vendor/vendor/alibabacloud/endpoint-util/tests/bootstrap.php b/vendor/vendor/alibabacloud/endpoint-util/tests/bootstrap.php new file mode 100644 index 0000000..c62c4e8 --- /dev/null +++ b/vendor/vendor/alibabacloud/endpoint-util/tests/bootstrap.php @@ -0,0 +1,3 @@ +setRiskyAllowed(true) + ->setIndent(' ') + ->setRules([ + '@PSR2' => true, + '@PhpCsFixer' => true, + '@Symfony:risky' => true, + 'concat_space' => ['spacing' => 'one'], + 'array_syntax' => ['syntax' => 'short'], + 'array_indentation' => true, + 'combine_consecutive_unsets' => true, + 'method_separation' => true, + 'single_quote' => true, + 'declare_equal_normalize' => true, + 'function_typehint_space' => true, + 'hash_to_slash_comment' => true, + 'include' => true, + 'lowercase_cast' => true, + 'no_multiline_whitespace_before_semicolons' => true, + 'no_leading_import_slash' => true, + 'no_multiline_whitespace_around_double_arrow' => true, + 'no_spaces_around_offset' => true, + 'no_unneeded_control_parentheses' => true, + 'no_unused_imports' => true, + 'no_whitespace_before_comma_in_array' => true, + 'no_whitespace_in_blank_line' => true, + 'object_operator_without_whitespace' => true, + 'single_blank_line_before_namespace' => true, + 'single_class_element_per_statement' => true, + 'space_after_semicolon' => true, + 'standardize_not_equals' => true, + 'ternary_operator_spaces' => true, + 'trailing_comma_in_multiline_array' => true, + 'trim_array_spaces' => true, + 'unary_operator_spaces' => true, + 'whitespace_after_comma_in_array' => true, + 'no_extra_consecutive_blank_lines' => [ + 'curly_brace_block', + 'extra', + 'parenthesis_brace_block', + 'square_brace_block', + 'throw', + 'use', + ], + 'binary_operator_spaces' => [ + 'align_double_arrow' => true, + 'align_equals' => true, + ], + 'braces' => [ + 'allow_single_line_closure' => true, + ], + ]) + ->setFinder( + PhpCsFixer\Finder::create() + ->exclude('vendor') + ->exclude('tests') + ->in(__DIR__) + ); diff --git a/vendor/vendor/alibabacloud/gateway-spi/autoload.php b/vendor/vendor/alibabacloud/gateway-spi/autoload.php new file mode 100644 index 0000000..f48d6cb --- /dev/null +++ b/vendor/vendor/alibabacloud/gateway-spi/autoload.php @@ -0,0 +1,15 @@ +5.5", + "alibabacloud/credentials": "^1.1" + }, + "autoload": { + "psr-4": { + "Darabonba\\GatewaySpi\\": "src" + } + }, + "scripts": { + "fixer": "php-cs-fixer fix ./" + }, + "config": { + "sort-packages": true, + "preferred-install": "dist", + "optimize-autoloader": true + }, + "prefer-stable": true +} \ No newline at end of file diff --git a/vendor/vendor/alibabacloud/gateway-spi/src/Client.php b/vendor/vendor/alibabacloud/gateway-spi/src/Client.php new file mode 100644 index 0000000..7b7b131 --- /dev/null +++ b/vendor/vendor/alibabacloud/gateway-spi/src/Client.php @@ -0,0 +1,35 @@ +attributes, true); + Model::validateRequired('key', $this->key, true); + } + public function toMap() { + $res = []; + if (null !== $this->attributes) { + $res['attributes'] = $this->attributes; + } + if (null !== $this->key) { + $res['key'] = $this->key; + } + return $res; + } + /** + * @param array $map + * @return AttributeMap + */ + public static function fromMap($map = []) { + $model = new self(); + if(isset($map['attributes'])){ + $model->attributes = $map['attributes']; + } + if(isset($map['key'])){ + $model->key = $map['key']; + } + return $model; + } + /** + * @var mixed[] + */ + public $attributes; + + /** + * @var string[] + */ + public $key; + +} diff --git a/vendor/vendor/alibabacloud/gateway-spi/src/Models/InterceptorContext.php b/vendor/vendor/alibabacloud/gateway-spi/src/Models/InterceptorContext.php new file mode 100644 index 0000000..cc3a436 --- /dev/null +++ b/vendor/vendor/alibabacloud/gateway-spi/src/Models/InterceptorContext.php @@ -0,0 +1,63 @@ +request, true); + Model::validateRequired('configuration', $this->configuration, true); + Model::validateRequired('response', $this->response, true); + } + public function toMap() { + $res = []; + if (null !== $this->request) { + $res['request'] = null !== $this->request ? $this->request->toMap() : null; + } + if (null !== $this->configuration) { + $res['configuration'] = null !== $this->configuration ? $this->configuration->toMap() : null; + } + if (null !== $this->response) { + $res['response'] = null !== $this->response ? $this->response->toMap() : null; + } + return $res; + } + /** + * @param array $map + * @return InterceptorContext + */ + public static function fromMap($map = []) { + $model = new self(); + if(isset($map['request'])){ + $model->request = request::fromMap($map['request']); + } + if(isset($map['configuration'])){ + $model->configuration = configuration::fromMap($map['configuration']); + } + if(isset($map['response'])){ + $model->response = response::fromMap($map['response']); + } + return $model; + } + /** + * @var request + */ + public $request; + + /** + * @var configuration + */ + public $configuration; + + /** + * @var response + */ + public $response; + +} diff --git a/vendor/vendor/alibabacloud/gateway-spi/src/Models/InterceptorContext/configuration.php b/vendor/vendor/alibabacloud/gateway-spi/src/Models/InterceptorContext/configuration.php new file mode 100644 index 0000000..02e6f92 --- /dev/null +++ b/vendor/vendor/alibabacloud/gateway-spi/src/Models/InterceptorContext/configuration.php @@ -0,0 +1,83 @@ +regionId, true); + } + public function toMap() { + $res = []; + if (null !== $this->regionId) { + $res['regionId'] = $this->regionId; + } + if (null !== $this->endpoint) { + $res['endpoint'] = $this->endpoint; + } + if (null !== $this->endpointRule) { + $res['endpointRule'] = $this->endpointRule; + } + if (null !== $this->endpointMap) { + $res['endpointMap'] = $this->endpointMap; + } + if (null !== $this->endpointType) { + $res['endpointType'] = $this->endpointType; + } + if (null !== $this->network) { + $res['network'] = $this->network; + } + if (null !== $this->suffix) { + $res['suffix'] = $this->suffix; + } + return $res; + } + /** + * @param array $map + * @return configuration + */ + public static function fromMap($map = []) { + $model = new self(); + if(isset($map['regionId'])){ + $model->regionId = $map['regionId']; + } + if(isset($map['endpoint'])){ + $model->endpoint = $map['endpoint']; + } + if(isset($map['endpointRule'])){ + $model->endpointRule = $map['endpointRule']; + } + if(isset($map['endpointMap'])){ + $model->endpointMap = $map['endpointMap']; + } + if(isset($map['endpointType'])){ + $model->endpointType = $map['endpointType']; + } + if(isset($map['network'])){ + $model->network = $map['network']; + } + if(isset($map['suffix'])){ + $model->suffix = $map['suffix']; + } + return $model; + } + /** + * @var string + */ + public $regionId; + + public $endpoint; + + public $endpointRule; + + public $endpointMap; + + public $endpointType; + + public $network; + + public $suffix; + +} diff --git a/vendor/vendor/alibabacloud/gateway-spi/src/Models/InterceptorContext/request.php b/vendor/vendor/alibabacloud/gateway-spi/src/Models/InterceptorContext/request.php new file mode 100644 index 0000000..878ca95 --- /dev/null +++ b/vendor/vendor/alibabacloud/gateway-spi/src/Models/InterceptorContext/request.php @@ -0,0 +1,220 @@ +pathname, true); + Model::validateRequired('productId', $this->productId, true); + Model::validateRequired('action', $this->action, true); + Model::validateRequired('version', $this->version, true); + Model::validateRequired('protocol', $this->protocol, true); + Model::validateRequired('method', $this->method, true); + Model::validateRequired('authType', $this->authType, true); + Model::validateRequired('bodyType', $this->bodyType, true); + Model::validateRequired('reqBodyType', $this->reqBodyType, true); + Model::validateRequired('credential', $this->credential, true); + Model::validateRequired('userAgent', $this->userAgent, true); + } + public function toMap() { + $res = []; + if (null !== $this->headers) { + $res['headers'] = $this->headers; + } + if (null !== $this->query) { + $res['query'] = $this->query; + } + if (null !== $this->body) { + $res['body'] = $this->body; + } + if (null !== $this->stream) { + $res['stream'] = $this->stream; + } + if (null !== $this->hostMap) { + $res['hostMap'] = $this->hostMap; + } + if (null !== $this->pathname) { + $res['pathname'] = $this->pathname; + } + if (null !== $this->productId) { + $res['productId'] = $this->productId; + } + if (null !== $this->action) { + $res['action'] = $this->action; + } + if (null !== $this->version) { + $res['version'] = $this->version; + } + if (null !== $this->protocol) { + $res['protocol'] = $this->protocol; + } + if (null !== $this->method) { + $res['method'] = $this->method; + } + if (null !== $this->authType) { + $res['authType'] = $this->authType; + } + if (null !== $this->bodyType) { + $res['bodyType'] = $this->bodyType; + } + if (null !== $this->reqBodyType) { + $res['reqBodyType'] = $this->reqBodyType; + } + if (null !== $this->style) { + $res['style'] = $this->style; + } + if (null !== $this->credential) { + $res['credential'] = null !== $this->credential ? $this->credential->toMap() : null; + } + if (null !== $this->signatureVersion) { + $res['signatureVersion'] = $this->signatureVersion; + } + if (null !== $this->signatureAlgorithm) { + $res['signatureAlgorithm'] = $this->signatureAlgorithm; + } + if (null !== $this->userAgent) { + $res['userAgent'] = $this->userAgent; + } + return $res; + } + /** + * @param array $map + * @return request + */ + public static function fromMap($map = []) { + $model = new self(); + if(isset($map['headers'])){ + $model->headers = $map['headers']; + } + if(isset($map['query'])){ + $model->query = $map['query']; + } + if(isset($map['body'])){ + $model->body = $map['body']; + } + if(isset($map['stream'])){ + $model->stream = $map['stream']; + } + if(isset($map['hostMap'])){ + $model->hostMap = $map['hostMap']; + } + if(isset($map['pathname'])){ + $model->pathname = $map['pathname']; + } + if(isset($map['productId'])){ + $model->productId = $map['productId']; + } + if(isset($map['action'])){ + $model->action = $map['action']; + } + if(isset($map['version'])){ + $model->version = $map['version']; + } + if(isset($map['protocol'])){ + $model->protocol = $map['protocol']; + } + if(isset($map['method'])){ + $model->method = $map['method']; + } + if(isset($map['authType'])){ + $model->authType = $map['authType']; + } + if(isset($map['bodyType'])){ + $model->bodyType = $map['bodyType']; + } + if(isset($map['reqBodyType'])){ + $model->reqBodyType = $map['reqBodyType']; + } + if(isset($map['style'])){ + $model->style = $map['style']; + } + if(isset($map['credential'])){ + $model->credential = Credential::fromMap($map['credential']); + } + if(isset($map['signatureVersion'])){ + $model->signatureVersion = $map['signatureVersion']; + } + if(isset($map['signatureAlgorithm'])){ + $model->signatureAlgorithm = $map['signatureAlgorithm']; + } + if(isset($map['userAgent'])){ + $model->userAgent = $map['userAgent']; + } + return $model; + } + public $headers; + + public $query; + + public $body; + + public $stream; + + public $hostMap; + + /** + * @var string + */ + public $pathname; + + /** + * @var string + */ + public $productId; + + /** + * @var string + */ + public $action; + + /** + * @var string + */ + public $version; + + /** + * @var string + */ + public $protocol; + + /** + * @var string + */ + public $method; + + /** + * @var string + */ + public $authType; + + /** + * @var string + */ + public $bodyType; + + /** + * @var string + */ + public $reqBodyType; + + public $style; + + /** + * @var Credential + */ + public $credential; + + public $signatureVersion; + + public $signatureAlgorithm; + + /** + * @var string + */ + public $userAgent; + +} diff --git a/vendor/vendor/alibabacloud/gateway-spi/src/Models/InterceptorContext/response.php b/vendor/vendor/alibabacloud/gateway-spi/src/Models/InterceptorContext/response.php new file mode 100644 index 0000000..d899e4d --- /dev/null +++ b/vendor/vendor/alibabacloud/gateway-spi/src/Models/InterceptorContext/response.php @@ -0,0 +1,54 @@ +statusCode) { + $res['statusCode'] = $this->statusCode; + } + if (null !== $this->headers) { + $res['headers'] = $this->headers; + } + if (null !== $this->body) { + $res['body'] = $this->body; + } + if (null !== $this->deserializedBody) { + $res['deserializedBody'] = $this->deserializedBody; + } + return $res; + } + /** + * @param array $map + * @return response + */ + public static function fromMap($map = []) { + $model = new self(); + if(isset($map['statusCode'])){ + $model->statusCode = $map['statusCode']; + } + if(isset($map['headers'])){ + $model->headers = $map['headers']; + } + if(isset($map['body'])){ + $model->body = $map['body']; + } + if(isset($map['deserializedBody'])){ + $model->deserializedBody = $map['deserializedBody']; + } + return $model; + } + public $statusCode; + + public $headers; + + public $body; + + public $deserializedBody; + +} diff --git a/vendor/vendor/alibabacloud/openapi-util/.gitignore b/vendor/vendor/alibabacloud/openapi-util/.gitignore new file mode 100644 index 0000000..89c7aa5 --- /dev/null +++ b/vendor/vendor/alibabacloud/openapi-util/.gitignore @@ -0,0 +1,15 @@ +composer.phar +/vendor/ + +# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control +# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file +composer.lock + +.vscode/ +.idea +.DS_Store + +cache/ +*.cache +runtime/ +.php_cs.cache diff --git a/vendor/vendor/alibabacloud/openapi-util/.php_cs.dist b/vendor/vendor/alibabacloud/openapi-util/.php_cs.dist new file mode 100644 index 0000000..8617ec2 --- /dev/null +++ b/vendor/vendor/alibabacloud/openapi-util/.php_cs.dist @@ -0,0 +1,65 @@ +setRiskyAllowed(true) + ->setIndent(' ') + ->setRules([ + '@PSR2' => true, + '@PhpCsFixer' => true, + '@Symfony:risky' => true, + 'concat_space' => ['spacing' => 'one'], + 'array_syntax' => ['syntax' => 'short'], + 'array_indentation' => true, + 'combine_consecutive_unsets' => true, + 'method_separation' => true, + 'single_quote' => true, + 'declare_equal_normalize' => true, + 'function_typehint_space' => true, + 'hash_to_slash_comment' => true, + 'include' => true, + 'lowercase_cast' => true, + 'no_multiline_whitespace_before_semicolons' => true, + 'no_leading_import_slash' => true, + 'no_multiline_whitespace_around_double_arrow' => true, + 'no_spaces_around_offset' => true, + 'no_unneeded_control_parentheses' => true, + 'no_unused_imports' => true, + 'no_whitespace_before_comma_in_array' => true, + 'no_whitespace_in_blank_line' => true, + 'object_operator_without_whitespace' => true, + 'single_blank_line_before_namespace' => true, + 'single_class_element_per_statement' => true, + 'space_after_semicolon' => true, + 'standardize_not_equals' => true, + 'ternary_operator_spaces' => true, + 'trailing_comma_in_multiline_array' => true, + 'trim_array_spaces' => true, + 'unary_operator_spaces' => true, + 'whitespace_after_comma_in_array' => true, + 'no_extra_consecutive_blank_lines' => [ + 'curly_brace_block', + 'extra', + 'parenthesis_brace_block', + 'square_brace_block', + 'throw', + 'use', + ], + 'binary_operator_spaces' => [ + 'align_double_arrow' => true, + 'align_equals' => true, + ], + 'braces' => [ + 'allow_single_line_closure' => true, + ], + ]) + ->setFinder( + PhpCsFixer\Finder::create() + ->exclude('vendor') + ->exclude('tests') + ->in(__DIR__) + ); diff --git a/vendor/vendor/alibabacloud/openapi-util/README-CN.md b/vendor/vendor/alibabacloud/openapi-util/README-CN.md new file mode 100644 index 0000000..57b03a4 --- /dev/null +++ b/vendor/vendor/alibabacloud/openapi-util/README-CN.md @@ -0,0 +1,31 @@ +[English](README.md) | 简体中文 + +![](https://aliyunsdk-pages.alicdn.com/icons/AlibabaCloud.svg) + +## Alibaba Cloud OpenApi Util + +## 安装 + +### Composer + +```bash +composer require alibabacloud/openapi-util +``` + +## 问题 + +[提交 Issue](https://github.com/aliyun/openapiutil/issues/new),不符合指南的问题可能会立即关闭。 + +## 发行说明 + +每个版本的详细更改记录在[发行说明](./ChangeLog.txt)中。 + +## 相关 + +* [最新源码](https://github.com/aliyun/openapiutil) + +## 许可证 + +[Apache-2.0](http://www.apache.org/licenses/LICENSE-2.0) + +Copyright (c) 2009-present, Alibaba Cloud All rights reserved. diff --git a/vendor/vendor/alibabacloud/openapi-util/README.md b/vendor/vendor/alibabacloud/openapi-util/README.md new file mode 100644 index 0000000..2ad0472 --- /dev/null +++ b/vendor/vendor/alibabacloud/openapi-util/README.md @@ -0,0 +1,31 @@ +English | [简体中文](README-CN.md) + +![](https://aliyunsdk-pages.alicdn.com/icons/AlibabaCloud.svg) + +## Alibaba Cloud OpenApi Util + +## Installation + +### Composer + +```bash +composer require alibabacloud/openapi-util +``` + +## Issues + +[Opening an Issue](https://github.com/aliyun/openapiutil/issues/new), Issues not conforming to the guidelines may be closed immediately. + +## Changelog + +Detailed changes for each release are documented in the [release notes](./ChangeLog.txt). + +## References + +* [Latest Release](https://github.com/aliyun/openapiutil) + +## License + +[Apache-2.0](http://www.apache.org/licenses/LICENSE-2.0) + +Copyright (c) 2009-present, Alibaba Cloud All rights reserved. diff --git a/vendor/vendor/alibabacloud/openapi-util/autoload.php b/vendor/vendor/alibabacloud/openapi-util/autoload.php new file mode 100644 index 0000000..b787ba0 --- /dev/null +++ b/vendor/vendor/alibabacloud/openapi-util/autoload.php @@ -0,0 +1,17 @@ +5.5", + "alibabacloud/tea": "^3.1", + "alibabacloud/tea-utils": "^0.2", + "lizhichao/one-sm": "^1.5" + }, + "require-dev": { + "phpunit/phpunit": "*" + }, + "autoload": { + "psr-4": { + "AlibabaCloud\\OpenApiUtil\\": "src" + } + }, + "autoload-dev": { + "psr-4": { + "AlibabaCloud\\OpenApiUtil\\Tests\\": "tests" + } + }, + "scripts": { + "fixer": "php-cs-fixer fix ./", + "test": [ + "@clearCache", + "./vendor/bin/phpunit --colors=always" + ], + "clearCache": "rm -rf cache/*" + }, + "config": { + "sort-packages": true, + "preferred-install": "dist", + "optimize-autoloader": true + }, + "prefer-stable": true +} diff --git a/vendor/vendor/alibabacloud/openapi-util/phpunit.xml b/vendor/vendor/alibabacloud/openapi-util/phpunit.xml new file mode 100644 index 0000000..5042ba8 --- /dev/null +++ b/vendor/vendor/alibabacloud/openapi-util/phpunit.xml @@ -0,0 +1,31 @@ + + + + + + tests + + + ./tests + + + + + + integration + + + + + + + + + + + ./src + + + diff --git a/vendor/vendor/alibabacloud/openapi-util/src/OpenApiUtilClient.php b/vendor/vendor/alibabacloud/openapi-util/src/OpenApiUtilClient.php new file mode 100644 index 0000000..b891712 --- /dev/null +++ b/vendor/vendor/alibabacloud/openapi-util/src/OpenApiUtilClient.php @@ -0,0 +1,573 @@ +toMap(); + $map = self::exceptStream($map); + $newContent = $content::fromMap($map); + $class = new \ReflectionClass($newContent); + foreach ($class->getProperties(\ReflectionProperty::IS_PUBLIC) as $property) { + $name = $property->getName(); + if (!$property->isStatic()) { + $content->{$name} = $property->getValue($newContent); + } + } + } + + private static function exceptStream($map) + { + if ($map instanceof StreamInterface) { + return null; + } elseif (\is_array($map)) { + $data = []; + foreach ($map as $k => $v) { + if (null !== $v) { + $item = self::exceptStream($v); + if (null !== $item) { + $data[$k] = $item; + } + } else { + $data[$k] = $v; + } + } + return $data; + } + return $map; + } + + /** + * Get the string to be signed according to request. + * + * @param Request $request which contains signed messages + * + * @return string the signed string + */ + public static function getStringToSign($request) + { + $pathname = $request->pathname ?: ''; + $query = $request->query ?: []; + + $accept = isset($request->headers['accept']) ? $request->headers['accept'] : ''; + $contentMD5 = isset($request->headers['content-md5']) ? $request->headers['content-md5'] : ''; + $contentType = isset($request->headers['content-type']) ? $request->headers['content-type'] : ''; + $date = isset($request->headers['date']) ? $request->headers['date'] : ''; + + $result = $request->method . "\n" . + $accept . "\n" . + $contentMD5 . "\n" . + $contentType . "\n" . + $date . "\n"; + + $canonicalizedHeaders = self::getCanonicalizedHeaders($request->headers); + $canonicalizedResource = self::getCanonicalizedResource($pathname, $query); + + return $result . $canonicalizedHeaders . $canonicalizedResource; + } + + /** + * Get signature according to stringToSign, secret. + * + * @param string $stringToSign the signed string + * @param string $secret accesskey secret + * + * @return string the signature + */ + public static function getROASignature($stringToSign, $secret) + { + return base64_encode(hash_hmac('sha1', $stringToSign, $secret, true)); + } + + /** + * Parse filter into a form string. + * + * @param array $filter object + * + * @return string the string + */ + public static function toForm($filter) + { + $query = $filter; + if (null === $query) { + return ''; + } + if ($query instanceof Model) { + $query = $query->toMap(); + } + $tmp = []; + foreach ($query as $k => $v) { + if (0 !== strpos($k, '_')) { + $tmp[$k] = $v; + } + } + $res = self::flatten($tmp); + ksort($res); + + return http_build_query($res); + } + + /** + * Get timestamp. + * + * @return string the timestamp string + */ + public static function getTimestamp() + { + return gmdate('Y-m-d\\TH:i:s\\Z'); + } + + /** + * Parse filter into a object which's type is map[string]string. + * + * @param array $filter query param + * + * @return array the object + */ + public static function query($filter) + { + if (null === $filter) { + return []; + } + $dict = $filter; + if ($dict instanceof Model) { + $dict = $dict->toMap(); + } + $tmp = []; + foreach ($dict as $k => $v) { + if (0 !== strpos($k, '_')) { + $tmp[$k] = $v; + } + } + + return self::flatten($tmp); + } + + /** + * Get signature according to signedParams, method and secret. + * + * @param array $signedParams params which need to be signed + * @param string $method http method e.g. GET + * @param string $secret AccessKeySecret + * + * @return string the signature + */ + public static function getRPCSignature($signedParams, $method, $secret) + { + $secret .= '&'; + $strToSign = self::getRpcStrToSign($method, $signedParams); + + $signMethod = 'HMAC-SHA1'; + + return self::encode($signMethod, $strToSign, $secret); + } + + /** + * Parse object into a string with specified style. + * + * @style specified style e.g. repeatList + * + * @param mixed $object the object + * @param string $prefix the prefix string + * @param string $style + * + * @return string the string + */ + public static function arrayToStringWithSpecifiedStyle($object, $prefix, $style) + { + if (null === $object) { + return ''; + } + if ('repeatList' === $style) { + return self::toForm([$prefix => $object]); + } + if ('simple' == $style || 'spaceDelimited' == $style || 'pipeDelimited' == $style) { + $strs = self::flatten($object); + + switch ($style) { + case 'spaceDelimited': + return implode(' ', $strs); + + case 'pipeDelimited': + return implode('|', $strs); + + default: + return implode(',', $strs); + } + } elseif ('json' === $style) { + self::parse($object, $parsed); + return json_encode($parsed); + } + + return ''; + } + + /** + * Transform input as array. + * + * @param mixed $input + * + * @return array + */ + public static function parseToArray($input) + { + self::parse($input, $result); + + return $result; + } + + /** + * Transform input as map. + * + * @param mixed $input + * + * @return array + */ + public static function parseToMap($input) + { + self::parse($input, $result); + + return $result; + } + + public static function getEndpoint($endpoint, $useAccelerate, $endpointType = 'public') + { + if ('internal' == $endpointType) { + $tmp = explode('.', $endpoint); + $tmp[0] .= '-internal'; + $endpoint = implode('.', $tmp); + } + if ($useAccelerate && 'accelerate' == $endpointType) { + return 'oss-accelerate.aliyuncs.com'; + } + + return $endpoint; + } + + /** + * Encode raw with base16. + * + * @param int[] $raw encoding data + * + * @return string encoded string + */ + public static function hexEncode($raw) + { + if (is_array($raw)) { + $raw = Utils::toString($raw); + } + return bin2hex($raw); + } + + /** + * Hash the raw data with signatureAlgorithm. + * + * @param int[] $raw hashing data + * @param string $signatureAlgorithm the autograph method + * + * @return array hashed bytes + */ + public static function hash($raw, $signatureAlgorithm) + { + $str = Utils::toString($raw); + + switch ($signatureAlgorithm) { + case 'ACS3-HMAC-SHA256': + case 'ACS3-RSA-SHA256': + $res = hash('sha256', $str, true); + return Utils::toBytes($res); + case 'ACS3-HMAC-SM3': + $res = self::sm3($str); + return Utils::toBytes(hex2bin($res)); + } + + return []; + } + + /** + * Get the authorization. + * + * @param Request $request request params + * @param string $signatureAlgorithm the autograph method + * @param string $payload the hashed request + * @param string $accesskey the accessKey string + * @param string $accessKeySecret the accessKeySecret string + * + * @return string authorization string + * @throws \ErrorException + * + */ + public static function getAuthorization($request, $signatureAlgorithm, $payload, $accesskey, $accessKeySecret) + { + $canonicalURI = $request->pathname ? $request->pathname : '/'; + $query = $request->query ?: []; + $method = strtoupper($request->method); + $canonicalQueryString = self::getCanonicalQueryString($query); + $signHeaders = []; + foreach ($request->headers as $k => $v) { + $k = strtolower($k); + if (0 === strpos($k, 'x-acs-') || 'host' === $k || 'content-type' === $k) { + $signHeaders[$k] = $v; + } + } + ksort($signHeaders); + $headers = []; + foreach ($request->headers as $k => $v) { + $k = strtolower($k); + if (0 === strpos($k, 'x-acs-') || 'host' === $k || 'content-type' === $k) { + $headers[$k] = trim($v); + } + } + $canonicalHeaderString = ''; + ksort($headers); + foreach ($headers as $k => $v) { + $canonicalHeaderString .= $k . ':' . trim(self::filter($v)) . "\n"; + } + if (empty($canonicalHeaderString)) { + $canonicalHeaderString = "\n"; + } + + $canonicalRequest = $method . "\n" . $canonicalURI . "\n" . $canonicalQueryString . "\n" . + $canonicalHeaderString . "\n" . implode(';', array_keys($signHeaders)) . "\n" . $payload; + $strtosign = $signatureAlgorithm . "\n" . self::hexEncode(self::hash(Utils::toBytes($canonicalRequest), $signatureAlgorithm)); + $signature = self::sign($accessKeySecret, $strtosign, $signatureAlgorithm); + $signature = self::hexEncode($signature); + + return $signatureAlgorithm . + ' Credential=' . $accesskey . + ',SignedHeaders=' . implode(';', array_keys($signHeaders)) . + ',Signature=' . $signature; + } + + public static function sign($secret, $str, $algorithm) + { + $result = ''; + switch ($algorithm) { + case 'ACS3-HMAC-SHA256': + $result = hash_hmac('sha256', $str, $secret, true); + break; + case 'ACS3-HMAC-SM3': + $result = self::hmac_sm3($str, $secret, true); + break; + case 'ACS3-RSA-SHA256': + $privateKey = "-----BEGIN RSA PRIVATE KEY-----\n" . $secret . "\n-----END RSA PRIVATE KEY-----"; + @openssl_sign($str, $result, $privateKey, OPENSSL_ALGO_SHA256); + } + + return Utils::toBytes($result); + } + + /** + * Get encoded path. + * + * @param string $path the raw path + * + * @return string encoded path + */ + public static function getEncodePath($path) + { + $tmp = explode('/', $path); + foreach ($tmp as &$t) { + $t = rawurlencode($t); + } + + return implode('/', $tmp); + } + + /** + * Get encoded param. + * + * @param string $param the raw param + * + * @return string encoded param + */ + public static function getEncodeParam($param) + { + return rawurlencode($param); + } + + private static function getRpcStrToSign($method, $query) + { + ksort($query); + + $params = []; + foreach ($query as $k => $v) { + if (null !== $v) { + $k = rawurlencode($k); + $v = rawurlencode($v); + $params[] = $k . '=' . (string)$v; + } + } + $str = implode('&', $params); + + return $method . '&' . rawurlencode('/') . '&' . rawurlencode($str); + } + + private static function encode($signMethod, $strToSign, $secret) + { + switch ($signMethod) { + case 'HMAC-SHA256': + return base64_encode(hash_hmac('sha256', $strToSign, $secret, true)); + + default: + return base64_encode(hash_hmac('sha1', $strToSign, $secret, true)); + } + } + + /** + * @param array $items + * @param string $delimiter + * @param string $prepend + * + * @return array + */ + private static function flatten($items = [], $delimiter = '.', $prepend = '') + { + $flatten = []; + + foreach ($items as $key => $value) { + $pos = \is_int($key) ? $key + 1 : $key; + + if ($value instanceof Model) { + $value = $value->toMap(); + } elseif (\is_object($value)) { + $value = get_object_vars($value); + } + + if (\is_array($value) && !empty($value)) { + $flatten = array_merge( + $flatten, + self::flatten($value, $delimiter, $prepend . $pos . $delimiter) + ); + } else { + if (\is_bool($value)) { + $value = true === $value ? 'true' : 'false'; + } + $flatten[$prepend . $pos] = $value; + } + } + + return $flatten; + } + + private static function getCanonicalizedHeaders($headers, $prefix = 'x-acs-') + { + ksort($headers); + $str = ''; + foreach ($headers as $k => $v) { + if (0 === strpos(strtolower($k), $prefix)) { + $str .= $k . ':' . trim(self::filter($v)) . "\n"; + } + } + + return $str; + } + + private static function getCanonicalizedResource($pathname, $query) + { + if (0 === \count($query)) { + return $pathname; + } + ksort($query); + $tmp = []; + foreach ($query as $k => $v) { + if (!empty($v)) { + $tmp[] = $k . '=' . $v; + } else { + $tmp[] = $k; + } + } + + return $pathname . '?' . implode('&', $tmp); + } + + private static function parse($input, &$output) + { + if (null === $input || '' === $input) { + $output = []; + } + $recursive = function ($input) use (&$recursive) { + if ($input instanceof Model) { + $input = $input->toMap(); + } elseif (\is_object($input)) { + $input = get_object_vars($input); + } + if (!\is_array($input)) { + return $input; + } + $data = []; + foreach ($input as $k => $v) { + $data[$k] = $recursive($v); + } + + return $data; + }; + $output = $recursive($input); + if (!\is_array($output)) { + $output = [$output]; + } + } + + private static function filter($str) + { + return str_replace(["\t", "\n", "\r", "\f"], '', $str); + } + + private static function hmac_sm3($data, $key, $raw_output = false) + { + $pack = 'H' . \strlen(self::sm3('test')); + $blocksize = 64; + if (\strlen($key) > $blocksize) { + $key = pack($pack, self::sm3($key)); + } + $key = str_pad($key, $blocksize, \chr(0x00)); + $ipad = $key ^ str_repeat(\chr(0x36), $blocksize); + $opad = $key ^ str_repeat(\chr(0x5C), $blocksize); + $hmac = self::sm3($opad . pack($pack, self::sm3($ipad . $data))); + + return $raw_output ? pack($pack, $hmac) : $hmac; + } + + private static function sm3($message) + { + return (new Sm3())->sign($message); + } + + private static function getCanonicalQueryString($query) + { + ksort($query); + + $params = []; + foreach ($query as $k => $v) { + if (null === $v) { + continue; + } + $str = rawurlencode($k); + if ('' !== $v && null !== $v) { + $str .= '=' . rawurlencode($v); + } else { + $str .= '='; + } + $params[] = $str; + } + + return implode('&', $params); + } +} diff --git a/vendor/vendor/alibabacloud/openapi-util/tests/Models/SourceModel.php b/vendor/vendor/alibabacloud/openapi-util/tests/Models/SourceModel.php new file mode 100644 index 0000000..405cefb --- /dev/null +++ b/vendor/vendor/alibabacloud/openapi-util/tests/Models/SourceModel.php @@ -0,0 +1,126 @@ + 'Test', + 'empty' => 'empty', + 'bodyObject' => 'body', + 'listObject' => 'list', + ]; + public function validate() {} + public function toMap() { + $res = []; + if (null !== $this->test) { + $res['Test'] = $this->test; + } + if (null !== $this->empty) { + $res['empty'] = $this->empty; + } + if (null !== $this->bodyObject) { + $res['body'] = $this->bodyObject; + } + if (null !== $this->listObject) { + $res['list'] = $this->listObject; + } + if (null !== $this->urlListObject) { + $res['urlList'] = []; + if(null !== $this->urlListObject && is_array($this->urlListObject)){ + $n = 0; + foreach($this->urlListObject as $item){ + $res['urlList'][$n++] = null !== $item ? $item->toMap() : $item; + } + } + } + return $res; + } + /** + * @param array $map + * @return SourceModel + */ + public static function fromMap($map = []) { + $model = new self(); + if(isset($map['Test'])){ + $model->test = $map['Test']; + } + if(isset($map['empty'])){ + $model->empty = $map['empty']; + } + if(isset($map['body'])){ + $model->bodyObject = $map['body']; + } + if(isset($map['list'])){ + if(!empty($map['list'])){ + $model->listObject = $map['list']; + } + } + if(isset($map['urlList'])){ + if(!empty($map['urlList'])){ + $model->urlListObject = []; + $n = 0; + foreach($map['urlList'] as $item) { + $model->urlListObject[$n++] = null !== $item ? urlListObject::fromMap($item) : $item; + } + } + } + return $model; + } + /** + * @var string + */ + public $test; + + /** + * @var float + */ + public $empty; + + /** + * @var Stream + */ + public $bodyObject; + + /** + * @var Stream[] + */ + public $listObject; + + public $urlListObject; + +} + +class urlListObject extends Model { + protected $_name = [ + 'urlObject' => 'url', + ]; + public function validate() {} + public function toMap() { + $res = []; + if (null !== $this->urlObject) { + $res['url'] = $this->urlObject; + } + return $res; + } + /** + * @param array $map + * @return urlListObject + */ + public static function fromMap($map = []) { + $model = new self(); + if(isset($map['url'])){ + $model->urlObject = $map['url']; + } + return $model; + } + /** + * @var Stream + */ + public $urlObject; + +} + diff --git a/vendor/vendor/alibabacloud/openapi-util/tests/Models/TargetModel.php b/vendor/vendor/alibabacloud/openapi-util/tests/Models/TargetModel.php new file mode 100644 index 0000000..397aee4 --- /dev/null +++ b/vendor/vendor/alibabacloud/openapi-util/tests/Models/TargetModel.php @@ -0,0 +1,125 @@ + 'Test', + 'empty' => 'empty', + 'body' => 'body', + 'list' => 'list', + ]; + public function validate() {} + public function toMap() { + $res = []; + if (null !== $this->test) { + $res['Test'] = $this->test; + } + if (null !== $this->empty) { + $res['empty'] = $this->empty; + } + if (null !== $this->body) { + $res['body'] = $this->body; + } + if (null !== $this->list) { + $res['list'] = $this->list; + } + if (null !== $this->urlList) { + $res['urlList'] = []; + if(null !== $this->urlList && is_array($this->urlList)){ + $n = 0; + foreach($this->urlList as $item){ + $res['urlList'][$n++] = null !== $item ? $item->toMap() : $item; + } + } + } + return $res; + } + /** + * @param array $map + * @return TargetModel + */ + public static function fromMap($map = []) { + $model = new self(); + if(isset($map['Test'])){ + $model->test = $map['Test']; + } + if(isset($map['empty'])){ + $model->empty = $map['empty']; + } + if(isset($map['body'])){ + $model->body = $map['body']; + } + if(isset($map['list'])){ + if(!empty($map['list'])){ + $model->list = $map['list']; + } + } + if(isset($map['urlList'])){ + if(!empty($map['urlList'])){ + $model->urlList = []; + $n = 0; + foreach($map['urlList'] as $item) { + $model->urlList[$n++] = null !== $item ? urlList::fromMap($item) : $item; + } + } + } + return $model; + } + /** + * @var string + */ + public $test; + + /** + * @var float + */ + public $empty; + + /** + * @var Stream + */ + public $body; + + /** + * @var string[] + */ + public $list; + + public $urlList; + +} + +class urlList extends Model { + protected $_name = [ + 'url' => 'url', + ]; + public function validate() {} + public function toMap() { + $res = []; + if (null !== $this->url) { + $res['url'] = $this->url; + } + return $res; + } + /** + * @param array $map + * @return urlList + */ + public static function fromMap($map = []) { + $model = new self(); + if(isset($map['url'])){ + $model->url = $map['url']; + } + return $model; + } + /** + * @var string + */ + public $url; + +} \ No newline at end of file diff --git a/vendor/vendor/alibabacloud/openapi-util/tests/OpenApiUtilClientTest.php b/vendor/vendor/alibabacloud/openapi-util/tests/OpenApiUtilClientTest.php new file mode 100644 index 0000000..550b677 --- /dev/null +++ b/vendor/vendor/alibabacloud/openapi-util/tests/OpenApiUtilClientTest.php @@ -0,0 +1,501 @@ +a = 'foo'; + + $output = new MockModel(); + OpenApiUtilClient::convert($model, $output); + $this->assertEquals($model->a, $output->a); + + if (\function_exists('\GuzzleHttp\Psr7\stream_for')) { + // @deprecated stream_for will be removed in guzzlehttp/psr7:2.0 + $stream = \GuzzleHttp\Psr7\stream_for('test'); + } else { + $stream = \GuzzleHttp\Psr7\Utils::streamFor('test'); + } + $source = new SourceModel(); + $source->test = 'test'; + $source->bodyObject = $stream; + $source->listObject = [ + $stream + ]; + $urlListObject = new urlListObject(); + $urlListObject->urlObject = $stream; + $source->urlListObject = [ + $urlListObject + ]; + $target = new TargetModel(); + OpenApiUtilClient::convert($source, $target); + $this->assertEquals('test', $target->test); + $this->assertNull($target->empty); + $this->assertNull($target->body); + $this->assertTrue(empty($target->list)); + $this->assertNotNull($target->urlList[0]); + $this->assertNull($target->urlList[0]->url); + } + + public function testGetStringToSign() + { + $request = new Request(); + $request->method = 'GET'; + $request->pathname = '/'; + $request->headers['accept'] = 'application/json'; + + $this->assertEquals("GET\napplication/json\n\n\n\n/", OpenApiUtilClient::getStringToSign($request)); + + $request->headers = [ + 'accept' => 'application/json', + 'content-md5' => 'md5', + 'content-type' => 'application/json', + 'date' => 'date', + ]; + $this->assertEquals("GET\napplication/json\nmd5\napplication/json\ndate\n/", OpenApiUtilClient::getStringToSign($request)); + + $request->headers = [ + 'accept' => 'application/json', + 'content-md5' => 'md5', + 'content-type' => 'application/json', + 'date' => 'date', + 'x-acs-custom-key' => 'any value', + ]; + $this->assertEquals("GET\napplication/json\nmd5\napplication/json\ndate\nx-acs-custom-key:any value\n/", OpenApiUtilClient::getStringToSign($request)); + + $request->query = [ + 'key' => 'val ue with space', + ]; + $this->assertEquals("GET\napplication/json\nmd5\napplication/json\ndate\nx-acs-custom-key:any value\n/?key=val ue with space", OpenApiUtilClient::getStringToSign($request)); + } + + public function testGetROASignature() + { + $this->assertEquals('OmuTAr79tpI6CRoAdmzKRq5lHs0=', OpenApiUtilClient::getROASignature('stringtosign', 'secret')); + } + + public function testToForm() + { + $this->assertEquals('bool=true&client=test&strs.1=str1&strs.2=str2&strs.3=false&tag.key=value', OpenApiUtilClient::toForm([ + 'client' => 'test', + 'tag' => [ + 'key' => 'value', + ], + 'strs' => ['str1', 'str2', false], + 'bool' => true, + 'null' => null, + ])); + } + + public function testGetTimestamp() + { + $date = OpenApiUtilClient::getTimestamp(); + $this->assertEquals(20, \strlen($date)); + } + + public function testQuery() + { + $model = new MockModel(); + $model->a = 'foo'; + $model->c = 'boo'; + $model->r = true; + + $array = [ + 'a' => 'a', + 'b1' => [ + 'a' => 'a', + ], + 'b2' => [ + 'a' => 'a', + ], + 'c' => ['x', 'y', 'z'], + 'd' => [ + $model + ], + 'e' => true, + 'f' => null, + ]; + $this->assertEquals([ + 'a' => 'a', + 'b1.a' => 'a', + 'b2.a' => 'a', + 'c.1' => 'x', + 'c.2' => 'y', + 'c.3' => 'z', + 'd.1.A' => 'foo', + 'd.1.b' => '', + 'd.1.c' => 'boo', + 'd.1.c' => 'boo', + 'd.1.r' => 'true', + 'e' => 'true', + 'f' => null + ], OpenApiUtilClient::query($array)); + } + + public function testGetRPCSignature() + { + $request = new Request(); + $request->pathname = ''; + $request->query = [ + 'query' => 'test', + 'body' => 'test', + ]; + $this->assertEquals('XlUyV4sXjOuX5FnjUz9IF9tm5rU=', OpenApiUtilClient::getRPCSignature($request->query, $request->method, 'secret')); + } + + public function testArrayToStringWithSpecifiedStyle() + { + $data = ['ok', 'test', 2, 3]; + $this->assertEquals( + 'instance.1=ok&instance.2=test&instance.3=2&instance.4=3', + OpenApiUtilClient::arrayToStringWithSpecifiedStyle( + $data, + 'instance', + 'repeatList' + ) + ); + + $this->assertEquals( + '["ok","test",2,3]', + OpenApiUtilClient::arrayToStringWithSpecifiedStyle( + $data, + 'instance', + 'json' + ) + ); + + $test = new ParseModel([ + 'str' => 'A', + 'model' => new ParseModel(['str' => 'sub model']), + 'array' => [1, 2, 3], + ]); + $this->assertEquals( + '{"str":"A","model":{"str":"sub model","model":null,"array":null},"array":[1,2,3]}', + OpenApiUtilClient::arrayToStringWithSpecifiedStyle( + $test, + 'instance', + 'json' + ) + ); + // model item in array + $test = [ + new ParseModel([ + 'str' => 'A', + ]), + ]; + $this->assertEquals( + '[{"str":"A","model":null,"array":null}]', + OpenApiUtilClient::arrayToStringWithSpecifiedStyle( + $test, + 'instance', + 'json' + ) + ); + // model item in map + $test = [ + 'model' => new ParseModel([ + 'str' => 'A', + ]), + ]; + $this->assertEquals( + '{"model":{"str":"A","model":null,"array":null}}', + OpenApiUtilClient::arrayToStringWithSpecifiedStyle( + $test, + 'instance', + 'json' + ) + ); + + $this->assertEquals( + 'ok,test,2,3', + OpenApiUtilClient::arrayToStringWithSpecifiedStyle( + $data, + 'instance', + 'simple' + ) + ); + + $this->assertEquals( + 'ok test 2 3', + OpenApiUtilClient::arrayToStringWithSpecifiedStyle( + $data, + 'instance', + 'spaceDelimited' + ) + ); + + $this->assertEquals( + 'ok|test|2|3', + OpenApiUtilClient::arrayToStringWithSpecifiedStyle( + $data, + 'instance', + 'pipeDelimited' + ) + ); + + $this->assertEquals( + '', + OpenApiUtilClient::arrayToStringWithSpecifiedStyle( + $data, + 'instance', + 'piDelimited' + ) + ); + + $this->assertEquals( + '', + OpenApiUtilClient::arrayToStringWithSpecifiedStyle( + null, + 'instance', + 'pipeDelimited' + ) + ); + } + + public function testParseToArray() + { + $test = $this->parseData(); + $data = $test['data']; + $expected = $test['expected']; + foreach ($data as $index => $item) { + $this->assertEquals($expected[$index], OpenApiUtilClient::parseToArray($item)); + } + } + + public function testParseToMap() + { + $test = $this->parseData(); + $data = $test['data']; + $expected = $test['expected']; + foreach ($data as $index => $item) { + $this->assertEquals($expected[$index], OpenApiUtilClient::parseToMap($item)); + } + } + + public function testGetEndpoint() + { + $endpoint = 'ecs.cn-hangzhou.aliyun.cs.com'; + $useAccelerate = false; + $endpointType = 'public'; + + $this->assertEquals('ecs.cn-hangzhou.aliyun.cs.com', OpenApiUtilClient::getEndpoint($endpoint, $useAccelerate, $endpointType)); + + $endpointType = 'internal'; + $this->assertEquals('ecs-internal.cn-hangzhou.aliyun.cs.com', OpenApiUtilClient::getEndpoint($endpoint, $useAccelerate, $endpointType)); + + $useAccelerate = true; + $endpointType = 'accelerate'; + $this->assertEquals('oss-accelerate.aliyuncs.com', OpenApiUtilClient::getEndpoint($endpoint, $useAccelerate, $endpointType)); + } + + public function testHexEncode() + { + $data = OpenApiUtilClient::hash(Utils::toBytes('test'), 'ACS3-HMAC-SHA256'); + $this->assertEquals( + Utils::toBytes(hex2bin('9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08')), + $data + ); + + $data = OpenApiUtilClient::hash(Utils::toBytes('test'), 'ACS3-RSA-SHA256'); + $this->assertEquals( + Utils::toBytes(hex2bin('9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08')), + $data + ); + + $data = OpenApiUtilClient::hash(Utils::toBytes('test'), 'ACS3-HMAC-SM3'); + $this->assertEquals( + Utils::toBytes(hex2bin('55e12e91650d2fec56ec74e1d3e4ddbfce2ef3a65890c2a19ecf88a307e76a23')), + $data + ); + + $data = OpenApiUtilClient::hash(Utils::toBytes('test'), 'ACS3-HM-SHA256'); + $this->assertEquals('', Utils::toString($data)); + } + + public function testGetEncodePath() + { + $this->assertEquals( + '/path/%20test', + OpenApiUtilClient::getEncodePath('/path/ test') + ); + } + + public function testGetEncodeParam() + { + $this->assertEquals( + 'a%2Fb%2Fc%2F%20test', + OpenApiUtilClient::getEncodeParam('a/b/c/ test') + ); + } + + public function testGetAuthorization() + { + $request = new Request(); + $request->method = ''; + $request->pathname = ''; + $request->query = [ + 'test' => 'ok', + 'empty' => '', + ]; + $request->headers = [ + 'x-acs-test' => 'http', + 'x-acs-TEST' => 'https', + ]; + + $res = OpenApiUtilClient::getAuthorization($request, 'ACS3-HMAC-SHA256', '55e12e91650d2fec56ec74e1d3e4ddbfce2ef3a65890c2a19ecf88a307e76a23', 'acesskey', 'secret'); + + $this->assertEquals('ACS3-HMAC-SHA256 Credential=acesskey,SignedHeaders=x-acs-test,Signature=0a0f89a45f1ec3537a2d1a1046c71b95513a8f1f02526056968da19b99a5b914', $res); + + $request->query = null; + + $res = OpenApiUtilClient::getAuthorization($request, 'ACS3-HMAC-SHA256', '55e12e91650d2fec56ec74e1d3e4ddbfce2ef3a65890c2a19ecf88a307e76a23', 'acesskey', 'secret'); + + $this->assertEquals('ACS3-HMAC-SHA256 Credential=acesskey,SignedHeaders=x-acs-test,Signature=af6d32deb090ae85a21d7183055cf18dca17751da96979cdf964f8f0853e9dd2', $res); + } + + public function testSign() + { + $this->assertEquals( + 'b9ff646822f41ef647c1416fa2b8408923828abc0464af6706e18db3e8553da8', + OpenApiUtilClient::hexEncode(OpenApiUtilClient::sign('secret', 'source', 'ACS3-HMAC-SM3')) + ); + $this->assertEquals( + '1d93c62698a1c26427265668e79fac099aa26c1df873669599a2fb2f272e64c9', + OpenApiUtilClient::hexEncode(OpenApiUtilClient::sign('secret', 'source', 'ACS3-HMAC-SHA256')) + ); + } + + private function parseData() + { + return [ + 'data' => [ + 'NotArray', + new ParseModel([ + 'str' => 'A', + 'model' => new ParseModel(['str' => 'sub model']), + 'array' => [1, 2, 3], + ]), + [ // model item in array + new ParseModel([ + 'str' => 'A', + ]), + ], + [ // model item in map + 'model' => new ParseModel([ + 'str' => 'A', + ]), + ], + ], + 'expected' => [ + ['NotArray'], + [ + 'str' => 'A', + 'model' => [ + 'str' => 'sub model', + 'model' => null, + 'array' => null, + ], + 'array' => [1, 2, 3], + ], + [ + [ + 'str' => 'A', + 'model' => null, + 'array' => null, + ], + ], + [ + 'model' => [ + 'str' => 'A', + 'model' => null, + 'array' => null, + ], + ], + ], + 'expectedJsonStr' => [ + '["NotArray"]', + 'NotArray', + 'NotArray', + 'NotArray', + ], + ]; + } +} + +class MockModel extends Model +{ + public $a = 'A'; + + public $b = ''; + + public $c = ''; + + public $r; + + public function __construct() + { + $this->_name['a'] = 'A'; + $this->_required['c'] = true; + parent::__construct([]); + } + + public function toMap() + { + $res = []; + if (null !== $this->a) { + $res['A'] = $this->a; + } + if (null !== $this->b) { + $res['b'] = $this->b; + } + if (null !== $this->c) { + $res['c'] = $this->c; + } + if (null !== $this->r) { + $res['r'] = $this->r; + } + return $res; + } + + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['A'])) { + $model->a = $map['A']; + } + if (isset($map['b'])) { + $model->b = $map['b']; + } + if (isset($map['c'])) { + $model->c = $map['c']; + } + if (isset($map['r'])) { + $model->r = $map['r']; + } + return $model; + } +} + +class ParseModel extends Model +{ + public $str; + public $model; + public $array; +} diff --git a/vendor/vendor/alibabacloud/openapi-util/tests/bootstrap.php b/vendor/vendor/alibabacloud/openapi-util/tests/bootstrap.php new file mode 100644 index 0000000..c62c4e8 --- /dev/null +++ b/vendor/vendor/alibabacloud/openapi-util/tests/bootstrap.php @@ -0,0 +1,3 @@ +setRiskyAllowed(true) + ->setIndent(' ') + ->setRules([ + '@PSR2' => true, + '@PhpCsFixer' => true, + '@Symfony:risky' => true, + 'concat_space' => ['spacing' => 'one'], + 'array_syntax' => ['syntax' => 'short'], + 'array_indentation' => true, + 'combine_consecutive_unsets' => true, + 'method_separation' => true, + 'single_quote' => true, + 'declare_equal_normalize' => true, + 'function_typehint_space' => true, + 'hash_to_slash_comment' => true, + 'include' => true, + 'lowercase_cast' => true, + 'no_multiline_whitespace_before_semicolons' => true, + 'no_leading_import_slash' => true, + 'no_multiline_whitespace_around_double_arrow' => true, + 'no_spaces_around_offset' => true, + 'no_unneeded_control_parentheses' => true, + 'no_unused_imports' => true, + 'no_whitespace_before_comma_in_array' => true, + 'no_whitespace_in_blank_line' => true, + 'object_operator_without_whitespace' => true, + 'single_blank_line_before_namespace' => true, + 'single_class_element_per_statement' => true, + 'space_after_semicolon' => true, + 'standardize_not_equals' => true, + 'ternary_operator_spaces' => true, + 'trailing_comma_in_multiline_array' => true, + 'trim_array_spaces' => true, + 'unary_operator_spaces' => true, + 'whitespace_after_comma_in_array' => true, + 'no_extra_consecutive_blank_lines' => [ + 'curly_brace_block', + 'extra', + 'parenthesis_brace_block', + 'square_brace_block', + 'throw', + 'use', + ], + 'binary_operator_spaces' => [ + 'align_double_arrow' => true, + 'align_equals' => true, + ], + 'braces' => [ + 'allow_single_line_closure' => true, + ], + ]) + ->setFinder( + PhpCsFixer\Finder::create() + ->exclude('vendor') + ->exclude('tests') + ->in(__DIR__) + ); diff --git a/vendor/vendor/alibabacloud/tea-utils/README-CN.md b/vendor/vendor/alibabacloud/tea-utils/README-CN.md new file mode 100644 index 0000000..07553ca --- /dev/null +++ b/vendor/vendor/alibabacloud/tea-utils/README-CN.md @@ -0,0 +1,31 @@ +English | [简体中文](README-CN.md) + +![](https://aliyunsdk-pages.alicdn.com/icons/AlibabaCloud.svg) + +## Alibaba Cloud Tea Util for PHP + +## Installation + +### Composer + +```bash +composer require alibabacloud/tea-utils +``` + +## Issues + +[Opening an Issue](https://github.com/aliyun/tea-util/issues/new), Issues not conforming to the guidelines may be closed immediately. + +## Changelog + +Detailed changes for each release are documented in the [release notes](./ChangeLog.txt). + +## References + +* [Latest Release](https://github.com/aliyun/tea-util) + +## License + +[Apache-2.0](http://www.apache.org/licenses/LICENSE-2.0) + +Copyright (c) 2009-present, Alibaba Cloud All rights reserved. diff --git a/vendor/vendor/alibabacloud/tea-utils/README.md b/vendor/vendor/alibabacloud/tea-utils/README.md new file mode 100644 index 0000000..ef53f6e --- /dev/null +++ b/vendor/vendor/alibabacloud/tea-utils/README.md @@ -0,0 +1,31 @@ +[English](README.md) | 简体中文 + +![](https://aliyunsdk-pages.alicdn.com/icons/AlibabaCloud.svg) + +## Alibaba Cloud Tea Util for PHP + +## 安装 + +### Composer + +```bash +composer require alibabacloud/tea-utils +``` + +## 问题 + +[提交 Issue](https://github.com/aliyun/tea-util/issues/new),不符合指南的问题可能会立即关闭。 + +## 发行说明 + +每个版本的详细更改记录在[发行说明](./ChangeLog.txt)中。 + +## 相关 + +* [最新源码](https://github.com/aliyun/tea-util) + +## 许可证 + +[Apache-2.0](http://www.apache.org/licenses/LICENSE-2.0) + +Copyright (c) 2009-present, Alibaba Cloud All rights reserved. diff --git a/vendor/vendor/alibabacloud/tea-utils/composer.json b/vendor/vendor/alibabacloud/tea-utils/composer.json new file mode 100644 index 0000000..f1178c0 --- /dev/null +++ b/vendor/vendor/alibabacloud/tea-utils/composer.json @@ -0,0 +1,38 @@ +{ + "name": "alibabacloud/tea-utils", + "description": "Alibaba Cloud Tea Utils for PHP", + "type": "library", + "license": "Apache-2.0", + "authors": [ + { + "name": "Alibaba Cloud SDK", + "email": "sdk-team@alibabacloud.com" + } + ], + "support": { + "source": "https://github.com/aliyun/tea-util", + "issues": "https://github.com/aliyun/tea-util/issues" + }, + "require": { + "php": ">5.5", + "alibabacloud/tea": "^3.1" + }, + "autoload": { + "psr-4": { + "AlibabaCloud\\Tea\\Utils\\": "src" + } + }, + "autoload-dev": { + "psr-4": { + "AlibabaCloud\\Tea\\Utils\\Tests\\": "tests" + } + }, + "scripts": { + "fixer": "php-cs-fixer fix ./", + "test": [ + "@clearCache", + "./vendor/bin/phpunit --colors=always" + ], + "clearCache": "rm -rf cache/*" + } +} diff --git a/vendor/vendor/alibabacloud/tea-utils/phpunit.xml b/vendor/vendor/alibabacloud/tea-utils/phpunit.xml new file mode 100644 index 0000000..a44c1a2 --- /dev/null +++ b/vendor/vendor/alibabacloud/tea-utils/phpunit.xml @@ -0,0 +1,18 @@ + + + + + src + + + + + + + + + + tests + + + diff --git a/vendor/vendor/alibabacloud/tea-utils/src/Utils.php b/vendor/vendor/alibabacloud/tea-utils/src/Utils.php new file mode 100644 index 0000000..13ca84f --- /dev/null +++ b/vendor/vendor/alibabacloud/tea-utils/src/Utils.php @@ -0,0 +1,600 @@ +isSeekable()) { + $stream->rewind(); + } + + return $stream->getContents(); + } + + /** + * Read data from a readable stream, and parse it by JSON format. + * + * @param StreamInterface $stream the readable stream + * + * @return array the parsed result + */ + public static function readAsJSON($stream) + { + return self::parseJSON(self::readAsString($stream)); + } + + /** + * Generate a nonce string. + * + * @return string the nonce string + */ + public static function getNonce() + { + return md5(uniqid() . uniqid(md5(microtime(true)), true)); + } + + /** + * Get an UTC format string by current date, e.g. 'Thu, 06 Feb 2020 07:32:54 GMT'. + * + * @return string the UTC format string + */ + public static function getDateUTCString() + { + return gmdate('D, d M Y H:i:s T'); + } + + /** + * If not set the real, use default value. + * + * @param string $real + * @param string $default + * + * @return string + */ + public static function defaultString($real, $default = '') + { + return null === $real ? $default : $real; + } + + /** + * If not set the real, use default value. + * + * @param int $real + * @param int $default + * + * @return int the return number + */ + public static function defaultNumber($real, $default = 0) + { + if (null === $real) { + return $default; + } + + return (int) $real; + } + + /** + * Format a map to form string, like a=a%20b%20c. + * + * @param array|object $query + * + * @return string the form string + */ + public static function toFormString($query) + { + if (null === $query) { + return ''; + } + + if (\is_object($query)) { + $query = json_decode(self::toJSONString($query), true); + } + + return str_replace('+', '%20', http_build_query($query)); + } + + /** + * If not set the real, use default value. + * + * @param array|Model $object + * + * @return string the return string + */ + public static function toJSONString($object) + { + if (is_string($object)) { + return $object; + } + + if ($object instanceof Model) { + $object = $object->toMap(); + } + + return json_encode($object, JSON_UNESCAPED_UNICODE + JSON_UNESCAPED_SLASHES); + } + + /** + * Check the string is empty? + * + * @param string $val + * + * @return bool if string is null or zero length, return true + * + * @deprecated + */ + public static function _empty($val) + { + return empty($val); + } + + /** + * Check the string is empty? + * + * @param string $val + * + * @return bool if string is null or zero length, return true + * + * @deprecated + */ + public static function emptyWithSuffix($val) + { + return empty($val); + } + + /** + * Check the string is empty? + * + * @param string $val + * + * @return bool if string is null or zero length, return true + */ + public static function empty_($val) + { + return empty($val); + } + + /** + * Check one string equals another one? + * + * @param int $left + * @param int $right + * + * @return bool if equals, return true + */ + public static function equalString($left, $right) + { + return $left === $right; + } + + /** + * Check one number equals another one? + * + * @param int $left + * @param int $right + * + * @return bool if equals, return true + */ + public static function equalNumber($left, $right) + { + return $left === $right; + } + + /** + * Check one value is unset. + * + * @param mixed $value + * + * @return bool if unset, return true + */ + public static function isUnset(&$value = null) + { + return !isset($value) || null === $value; + } + + /** + * Stringify the value of map. + * + * @param array $map + * + * @return array the new stringified map + */ + public static function stringifyMapValue($map) + { + if (null === $map) { + return []; + } + foreach ($map as &$node) { + if (is_numeric($node)) { + $node = (string) $node; + } elseif (null === $node) { + $node = ''; + } elseif (\is_bool($node)) { + $node = true === $node ? 'true' : 'false'; + } elseif (\is_object($node)) { + $node = json_decode(json_encode($node), true); + } + } + + return $map; + } + + /** + * Anyify the value of map. + * + * @param array $m + * + * @return array the new anyfied map + */ + public static function anyifyMapValue($m) + { + return $m; + } + + /** + * Assert a value, if it is a boolean, return it, otherwise throws. + * + * @param mixed $value + * + * @return bool the boolean value + */ + public static function assertAsBoolean($value) + { + if (\is_bool($value)) { + return $value; + } + + throw new \InvalidArgumentException('It is not a boolean value.'); + } + + /** + * Assert a value, if it is a string, return it, otherwise throws. + * + * @param mixed $value + * + * @return string the string value + */ + public static function assertAsString($value) + { + if (\is_string($value)) { + return $value; + } + + throw new \InvalidArgumentException('It is not a string value.'); + } + + private static function is_bytes($value) + { + if (!\is_array($value)) { + return false; + } + $i = 0; + foreach ($value as $k => $ord) { + if ($k !== $i) { + return false; + } + if (!\is_int($ord)) { + return false; + } + if ($ord < 0 || $ord > 255) { + return false; + } + ++$i; + } + + return true; + } + + /** + * Assert a value, if it is a bytes, return it, otherwise throws. + * + * @param mixed $value + * + * @return bytes the bytes value + */ + public static function assertAsBytes($value) + { + if (self::is_bytes($value)) { + return $value; + } + + throw new \InvalidArgumentException('It is not a bytes value.'); + } + + /** + * Assert a value, if it is a number, return it, otherwise throws. + * + * @param mixed $value + * + * @return int the number value + */ + public static function assertAsNumber($value) + { + if (\is_numeric($value)) { + return $value; + } + + throw new \InvalidArgumentException('It is not a number value.'); + } + + /** + * Assert a value, if it is a integer, return it, otherwise throws + * @param mixed $value + * @return int the integer value + */ + public static function assertAsInteger($value){ + if (\is_int($value)) { + return $value; + } + + throw new \InvalidArgumentException('It is not a int value.'); + } + + /** + * Assert a value, if it is a map, return it, otherwise throws. + * + * @param $any + * + * @return array the map value + */ + public static function assertAsMap($any) + { + if (\is_array($any)) { + return $any; + } + + throw new \InvalidArgumentException('It is not a map value.'); + } + + public static function assertAsArray($any){ + if (\is_array($any)) { + return $any; + } + + throw new \InvalidArgumentException('It is not a array value.'); + } + + /** + * Get user agent, if it userAgent is not null, splice it with defaultUserAgent and return, otherwise return + * defaultUserAgent. + * + * @param string $userAgent + * + * @return string the string value + */ + public static function getUserAgent($userAgent = '') + { + if (empty(self::$defaultUserAgent)) { + self::$defaultUserAgent = sprintf('AlibabaCloud (%s; %s) PHP/%s Core/3.1 TeaDSL/1', PHP_OS, \PHP_SAPI, PHP_VERSION); + } + if (!empty($userAgent)) { + return self::$defaultUserAgent . ' ' . $userAgent; + } + + return self::$defaultUserAgent; + } + + /** + * If the code between 200 and 300, return true, or return false. + * + * @param int $code + * + * @return bool + */ + public static function is2xx($code) + { + return $code >= 200 && $code < 300; + } + + /** + * If the code between 300 and 400, return true, or return false. + * + * @param int $code + * + * @return bool + */ + public static function is3xx($code) + { + return $code >= 300 && $code < 400; + } + + /** + * If the code between 400 and 500, return true, or return false. + * + * @param int $code + * + * @return bool + */ + public static function is4xx($code) + { + return $code >= 400 && $code < 500; + } + + /** + * If the code between 500 and 600, return true, or return false. + * + * @param int $code + * + * @return bool + */ + public static function is5xx($code) + { + return $code >= 500 && $code < 600; + } + + /** + * Validate model. + * + * @param Model $model + */ + public static function validateModel($model) + { + if (null !== $model) { + $model->validate(); + } + } + + /** + * Model transforms to map[string]any. + * + * @param Model $model + * + * @return array + */ + public static function toMap($model) + { + if (null === $model) { + return []; + } + $map = $model->toMap(); + $names = $model->getName(); + $vars = get_object_vars($model); + foreach ($vars as $k => $v) { + if (false !== strpos($k, 'Shrink') && !isset($names[$k])) { + // A field that has the suffix `Shrink` and is not a Model class property. + $targetKey = ucfirst(substr($k, 0, \strlen($k) - 6)); + if (isset($map[$targetKey])) { + // $targetKey exists in $map. + $map[$targetKey] = $v; + } + } + } + + return $map; + } + + /** + * Suspends the current thread for the specified number of milliseconds. + * + * @param int $millisecond + */ + public static function sleep($millisecond) + { + usleep($millisecond * 1000); + } + + /** + * Transform input as array. + * + * @param mixed $input + * + * @return array + */ + public static function toArray($input) + { + if (\is_array($input)) { + foreach ($input as $k => &$v) { + $v = self::toArray($v); + } + } elseif ($input instanceof Model) { + $input = $input->toMap(); + foreach ($input as $k => &$v) { + $v = self::toArray($v); + } + } + + return $input; + } + + /** + * Assert a value, if it is a readable, return it, otherwise throws. + * + * @param mixed $value + * + * @return Stream the readable value + */ + public static function assertAsReadable($value) + { + if (\is_string($value)) { + return new Stream( + fopen('data://text/plain;base64,' . + base64_encode($value), 'r') + ); + } + if ($value instanceof Stream) { + return $value; + } + + throw new \InvalidArgumentException('It is not a stream value.'); + } +} diff --git a/vendor/vendor/alibabacloud/tea-utils/src/Utils/ExtendsParameters.php b/vendor/vendor/alibabacloud/tea-utils/src/Utils/ExtendsParameters.php new file mode 100644 index 0000000..670b2da --- /dev/null +++ b/vendor/vendor/alibabacloud/tea-utils/src/Utils/ExtendsParameters.php @@ -0,0 +1,38 @@ +headers) { + $res['headers'] = $this->headers; + } + if (null !== $this->queries) { + $res['queries'] = $this->queries; + } + return $res; + } + /** + * @param array $map + * @return ExtendsParameters + */ + public static function fromMap($map = []) { + $model = new self(); + if(isset($map['headers'])){ + $model->headers = $map['headers']; + } + if(isset($map['queries'])){ + $model->queries = $map['queries']; + } + return $model; + } + public $headers; + + public $queries; + +} diff --git a/vendor/vendor/alibabacloud/tea-utils/src/Utils/RuntimeOptions.php b/vendor/vendor/alibabacloud/tea-utils/src/Utils/RuntimeOptions.php new file mode 100644 index 0000000..5924228 --- /dev/null +++ b/vendor/vendor/alibabacloud/tea-utils/src/Utils/RuntimeOptions.php @@ -0,0 +1,273 @@ + 'autoretry', + 'ignoreSSL' => 'ignoreSSL', + 'key' => 'key', + 'cert' => 'cert', + 'ca' => 'ca', + 'maxAttempts' => 'max_attempts', + 'backoffPolicy' => 'backoff_policy', + 'backoffPeriod' => 'backoff_period', + 'readTimeout' => 'readTimeout', + 'connectTimeout' => 'connectTimeout', + 'httpProxy' => 'httpProxy', + 'httpsProxy' => 'httpsProxy', + 'noProxy' => 'noProxy', + 'maxIdleConns' => 'maxIdleConns', + 'localAddr' => 'localAddr', + 'socks5Proxy' => 'socks5Proxy', + 'socks5NetWork' => 'socks5NetWork', + 'keepAlive' => 'keepAlive', + ]; + public function validate() {} + public function toMap() { + $res = []; + if (null !== $this->autoretry) { + $res['autoretry'] = $this->autoretry; + } + if (null !== $this->ignoreSSL) { + $res['ignoreSSL'] = $this->ignoreSSL; + } + if (null !== $this->key) { + $res['key'] = $this->key; + } + if (null !== $this->cert) { + $res['cert'] = $this->cert; + } + if (null !== $this->ca) { + $res['ca'] = $this->ca; + } + if (null !== $this->maxAttempts) { + $res['max_attempts'] = $this->maxAttempts; + } + if (null !== $this->backoffPolicy) { + $res['backoff_policy'] = $this->backoffPolicy; + } + if (null !== $this->backoffPeriod) { + $res['backoff_period'] = $this->backoffPeriod; + } + if (null !== $this->readTimeout) { + $res['readTimeout'] = $this->readTimeout; + } + if (null !== $this->connectTimeout) { + $res['connectTimeout'] = $this->connectTimeout; + } + if (null !== $this->httpProxy) { + $res['httpProxy'] = $this->httpProxy; + } + if (null !== $this->httpsProxy) { + $res['httpsProxy'] = $this->httpsProxy; + } + if (null !== $this->noProxy) { + $res['noProxy'] = $this->noProxy; + } + if (null !== $this->maxIdleConns) { + $res['maxIdleConns'] = $this->maxIdleConns; + } + if (null !== $this->localAddr) { + $res['localAddr'] = $this->localAddr; + } + if (null !== $this->socks5Proxy) { + $res['socks5Proxy'] = $this->socks5Proxy; + } + if (null !== $this->socks5NetWork) { + $res['socks5NetWork'] = $this->socks5NetWork; + } + if (null !== $this->keepAlive) { + $res['keepAlive'] = $this->keepAlive; + } + if (null !== $this->extendsParameters) { + $res['extendsParameters'] = null !== $this->extendsParameters ? $this->extendsParameters->toMap() : null; + } + return $res; + } + /** + * @param array $map + * @return RuntimeOptions + */ + public static function fromMap($map = []) { + $model = new self(); + if(isset($map['autoretry'])){ + $model->autoretry = $map['autoretry']; + } + if(isset($map['ignoreSSL'])){ + $model->ignoreSSL = $map['ignoreSSL']; + } + if(isset($map['key'])){ + $model->key = $map['key']; + } + if(isset($map['cert'])){ + $model->cert = $map['cert']; + } + if(isset($map['ca'])){ + $model->ca = $map['ca']; + } + if(isset($map['max_attempts'])){ + $model->maxAttempts = $map['max_attempts']; + } + if(isset($map['backoff_policy'])){ + $model->backoffPolicy = $map['backoff_policy']; + } + if(isset($map['backoff_period'])){ + $model->backoffPeriod = $map['backoff_period']; + } + if(isset($map['readTimeout'])){ + $model->readTimeout = $map['readTimeout']; + } + if(isset($map['connectTimeout'])){ + $model->connectTimeout = $map['connectTimeout']; + } + if(isset($map['httpProxy'])){ + $model->httpProxy = $map['httpProxy']; + } + if(isset($map['httpsProxy'])){ + $model->httpsProxy = $map['httpsProxy']; + } + if(isset($map['noProxy'])){ + $model->noProxy = $map['noProxy']; + } + if(isset($map['maxIdleConns'])){ + $model->maxIdleConns = $map['maxIdleConns']; + } + if(isset($map['localAddr'])){ + $model->localAddr = $map['localAddr']; + } + if(isset($map['socks5Proxy'])){ + $model->socks5Proxy = $map['socks5Proxy']; + } + if(isset($map['socks5NetWork'])){ + $model->socks5NetWork = $map['socks5NetWork']; + } + if(isset($map['keepAlive'])){ + $model->keepAlive = $map['keepAlive']; + } + if(isset($map['extendsParameters'])){ + $model->extendsParameters = ExtendsParameters::fromMap($map['extendsParameters']); + } + return $model; + } + /** + * @description whether to try again + * @var bool + */ + public $autoretry; + + /** + * @description ignore SSL validation + * @var bool + */ + public $ignoreSSL; + + /** + * @description privite key for client certificate + * @var string + */ + public $key; + + /** + * @description client certificate + * @var string + */ + public $cert; + + /** + * @description server certificate + * @var string + */ + public $ca; + + /** + * @description maximum number of retries + * @var int + */ + public $maxAttempts; + + /** + * @description backoff policy + * @var string + */ + public $backoffPolicy; + + /** + * @description backoff period + * @var int + */ + public $backoffPeriod; + + /** + * @description read timeout + * @var int + */ + public $readTimeout; + + /** + * @description connect timeout + * @var int + */ + public $connectTimeout; + + /** + * @description http proxy url + * @var string + */ + public $httpProxy; + + /** + * @description https Proxy url + * @var string + */ + public $httpsProxy; + + /** + * @description agent blacklist + * @var string + */ + public $noProxy; + + /** + * @description maximum number of connections + * @var int + */ + public $maxIdleConns; + + /** + * @description local addr + * @var string + */ + public $localAddr; + + /** + * @description SOCKS5 proxy + * @var string + */ + public $socks5Proxy; + + /** + * @description SOCKS5 netWork + * @var string + */ + public $socks5NetWork; + + /** + * @description whether to enable keep-alive + * @var bool + */ + public $keepAlive; + + /** + * @description Extends Parameters + * @var ExtendsParameters + */ + public $extendsParameters; + +} diff --git a/vendor/vendor/alibabacloud/tea-utils/tests/UtilsTest.php b/vendor/vendor/alibabacloud/tea-utils/tests/UtilsTest.php new file mode 100644 index 0000000..70d54f4 --- /dev/null +++ b/vendor/vendor/alibabacloud/tea-utils/tests/UtilsTest.php @@ -0,0 +1,550 @@ +assertEquals([ + 115, 116, 114, 105, 110, 103, + ], Utils::toBytes('string')); + $this->assertEquals([ + 115, 116, 114, 105, 110, 103, + ], Utils::toBytes([ + 115, 116, 114, 105, 110, 103, + ])); + } + + public function testToString() + { + $this->assertEquals('string', Utils::toString([ + 115, 116, 114, 105, 110, 103, + ])); + $this->assertEquals('string', Utils::toString('string')); + } + + public function testParseJSON() + { + $this->assertEquals([ + 'a' => 'b', + ], Utils::parseJSON('{"a":"b"}')); + } + + public function testReadAsBytes() + { + $bytes = Utils::readAsBytes($this->getStream()); + $this->assertEquals(123, $bytes[0]); + } + + public function testReadAsString() + { + $string = Utils::readAsString($this->getStream()); + $this->assertEquals($string[0], '{'); + } + + public function testReadAsJSON() + { + $result = Utils::readAsJSON($this->getStream()); + $this->assertEquals('http://httpbin.org/get', $result['url']); + } + + public function testGetNonce() + { + $nonce1 = Utils::getNonce(); + $nonce2 = Utils::getNonce(); + + $this->assertNotEquals($nonce1, $nonce2); + } + + public function testGetDateUTCString() + { + $gmdate = Utils::getDateUTCString(); + $now = time(); + $this->assertTrue(abs($now - strtotime($gmdate)) <= 1); + } + + public function testDefaultString() + { + $this->assertEquals('', Utils::defaultString(null)); + $this->assertEquals('default', Utils::defaultString(null, 'default')); + $this->assertEquals('real', Utils::defaultString('real', 'default')); + } + + public function testDefaultNumber() + { + $this->assertEquals(0, Utils::defaultNumber(null)); + $this->assertEquals(0, Utils::defaultNumber(0, 3)); + $this->assertEquals(404, Utils::defaultNumber(null, 404)); + $this->assertEquals(200, Utils::defaultNumber(200, 404)); + } + + public function testToFormString() + { + $query = [ + 'foo' => 'bar', + 'empty' => '', + 'a' => null, + 'withWhiteSpace' => 'a b', + ]; + $this->assertEquals('foo=bar&empty=&withWhiteSpace=a%20b', Utils::toFormString($query)); + + $object = json_decode(json_encode($query)); + $this->assertEquals('foo=bar&empty=&withWhiteSpace=a%20b', Utils::toFormString($object)); + } + + public function testToJSONString() + { + $object = new \stdClass(); + $this->assertJson(Utils::toJSONString($object)); + $this->assertEquals('[]', Utils::toJSONString([])); + $this->assertEquals('["foo"]', Utils::toJSONString(['foo'])); + $this->assertEquals( + '{"str":"test","number":1,"bool":false,"null":null,"chinese":"中文","http":"https://aliyun.com:8080/zh/中文.html"}', + Utils::toJSONString([ + 'str' => 'test', + 'number' => 1, + 'bool' => FALSE, + 'null' => null, + 'chinese' => '中文', + 'http' => 'https://aliyun.com:8080/zh/中文.html', + ]) + ); + $this->assertEquals('1', Utils::toJSONString(1)); + $this->assertEquals('true', Utils::toJSONString(TRUE)); + $this->assertEquals('null', Utils::toJSONString(null)); + } + + public function testEmpty() + { + $this->assertTrue(Utils::_empty('')); + $this->assertFalse(Utils::_empty('not empty')); + } + + public function testEqualString() + { + $this->assertTrue(Utils::equalString('a', 'a')); + $this->assertFalse(Utils::equalString('a', 'b')); + } + + public function testEqualNumber() + { + $this->assertTrue(Utils::equalNumber(1, 1)); + $this->assertFalse(Utils::equalNumber(1, 2)); + } + + public function testIsUnset() + { + $this->assertTrue(Utils::isUnset($a)); + $b = 1; + $this->assertFalse(Utils::isUnset($b)); + } + + public function testStringifyMapValue() + { + $this->assertEquals([], Utils::stringifyMapValue(null)); + $this->assertEquals([ + 'foo' => 'bar', + 'null' => '', + 'true' => 'true', + 'false' => 'false', + 'number' => '1000', + ], Utils::stringifyMapValue([ + 'foo' => 'bar', + 'null' => null, + 'true' => true, + 'false' => false, + 'number' => 1000, + ])); + } + + public function testAnyifyMapValue() + { + $this->assertEquals([ + 'foo' => 'bar', + 'null' => null, + 'true' => true, + 'false' => false, + 'number' => 1000, + ], Utils::anyifyMapValue([ + 'foo' => 'bar', + 'null' => null, + 'true' => true, + 'false' => false, + 'number' => 1000, + ])); + } + + public function testAssertAsBoolean() + { + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('It is not a boolean value.'); + Utils::assertAsBoolean('true'); + + try { + $map = true; + $this->assertEquals($map, Utils::assertAsBoolean($map)); + } catch (\Exception $e) { + // should not be here + $this->assertTrue(false); + } + } + + public function testAssertAsString() + { + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('It is not a string value.'); + Utils::assertAsString(123); + + try { + $map = '123'; + $this->assertEquals($map, Utils::assertAsString($map)); + } catch (\Exception $e) { + // should not be here + $this->assertTrue(false); + } + } + + public function testAssertAsBytes() + { + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('It is not a bytes value.'); + // failed because $var is not array + Utils::assertAsBytes('test'); + // failed because $var is map not array + Utils::assertAsBytes(['foo' => 1]); + // failed because item value is not int + Utils::assertAsBytes(['1']); + // failed because item value is out off range + Utils::assertAsBytes([256]); + + try { + // success + $map = [1, 2, 3]; + $this->assertEquals($map, Utils::assertAsBytes($map)); + $this->assertEquals([ + 115, 116, 114, 105, 110, 103, + ], Utils::assertAsBytes(Utils::toBytes('string'))); + } catch (\Exception $e) { + // should not be here + $this->assertTrue(false); + } + } + + public function testAssertAsNumber() + { + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('It is not a number value.'); + Utils::assertAsNumber('is not number'); + + try { + $map = 123; + $this->assertEquals($map, Utils::assertAsNumber($map)); + } catch (\Exception $e) { + // should not be here + $this->assertTrue(false); + } + } + + public function testAssertAsInteger() + { + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('It is not a int value.'); + Utils::assertAsInteger('is not int'); + + try { + $map = 123; + $this->assertEquals($map, Utils::assertAsInteger($map)); + } catch (\Exception $e) { + // should not be here + $this->assertTrue(false); + } + } + + public function testAssertAsMap() + { + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('It is not a map value.'); + Utils::assertAsMap('is not array'); + + try { + $map = ['foo' => 'bar']; + $this->assertEquals($map, Utils::assertAsMap($map)); + } catch (\Exception $e) { + // should not be here + $this->assertTrue(false); + } + } + + public function testAssertAsArray() + { + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('It is not a array value.'); + Utils::assertAsArray('is not array'); + + try { + $map = ['foo']; + $this->assertEquals($map, Utils::assertAsArray($map)); + } catch (\Exception $e) { + // should not be here + $this->assertTrue(false); + } + } + + public function testGetUserAgent() + { + $this->assertTrue(false !== strpos(Utils::getUserAgent('CustomUserAgent'), 'CustomUserAgent')); + } + + public function testIs2xx() + { + $this->assertTrue(Utils::is2xx(200)); + $this->assertFalse(Utils::is2xx(300)); + } + + public function testIs3xx() + { + $this->assertTrue(Utils::is3xx(300)); + $this->assertFalse(Utils::is3xx(400)); + } + + public function testIs4xx() + { + $this->assertTrue(Utils::is4xx(400)); + $this->assertFalse(Utils::is4xx(500)); + } + + public function testIs5xx() + { + $this->assertTrue(Utils::is5xx(500)); + $this->assertFalse(Utils::is5xx(600)); + } + + public function testToMap() + { + $from = new RequestTest(); + $from->query = new RequestTestQuery([ + 'booleanParamInQuery' => true, + 'mapParamInQuery' => [1, 2, 3], + ]); + $this->assertTrue($from->query->booleanParamInQuery); + $this->assertEquals([1, 2, 3], $from->query->mapParamInQuery); + + $target = new RequestShrinkTest([]); + $this->convert($from, $target); + $this->assertEquals([ + 'BooleanParamInQuery' => true, + 'MapParamInQuery' => [1, 2, 3], + ], $target->query->toMap()); + + $target->query->mapParamInQueryShrink = json_encode($from->query->mapParamInQuery); + $this->assertEquals([ + 'BooleanParamInQuery' => true, + 'MapParamInQuery' => '[1,2,3]', + ], Utils::toMap($target->query)); + } + + public function testSleep() + { + $before = microtime(true) * 1000; + Utils::sleep(1000); + $after = microtime(true) * 1000; + $sub = $after - $before; + $this->assertTrue(990 <= $sub && $sub <= 1100); + } + + public function testToArray() + { + $model = new RequestTest(); + $model->query = 'foo'; + $this->assertEquals([ + ['query' => 'foo'], + ], Utils::toArray([$model])); + + $subModel = new RequestTest(); + $subModel->query = 'bar'; + $model->query = $subModel; + $this->assertEquals([ + ['query' => ['query' => 'bar']], + ], Utils::toArray([$model])); + } + + public function testAssertAsReadable() + { + $s0 = Utils::assertAsReadable('string content'); + $this->assertTrue($s0 instanceof Stream); + + $s1 = Utils::assertAsReadable($s0); + $this->assertEquals($s1, $s0); + + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('It is not a stream value.'); + Utils::assertAsReadable(0); + } + + public function testRuntimeOptions() + { + $opts = new RuntimeOptions([ + "autoretry" => false, + "ignoreSSL" => false, + "key" => "key", + "cert" => "cert", + "ca" => "ca", + "maxAttempts" => 3, + "backoffPolicy" => "backoffPolicy", + "backoffPeriod" => 10, + "readTimeout" => 3000, + "connectTimeout" => 3000, + "httpProxy" => "httpProxy", + "httpsProxy" => "httpsProxy", + "noProxy" => "noProxy", + "maxIdleConns" => 300, + "keepAlive" => true, + "extendsParameters" => new ExtendsParameters([ + "headers" => ['key' => 'value'], + "queries" => ['key' => 'value'], + ]), + ]); + $this->assertEquals(false, $opts->autoretry); + $this->assertEquals(false, $opts->ignoreSSL); + $this->assertEquals("key", $opts->key); + $this->assertEquals("cert", $opts->cert); + $this->assertEquals("ca", $opts->ca); + $this->assertEquals(3, $opts->maxAttempts); + $this->assertEquals("backoffPolicy", $opts->backoffPolicy); + $this->assertEquals(10, $opts->backoffPeriod); + $this->assertEquals(3000, $opts->readTimeout); + $this->assertEquals(3000, $opts->connectTimeout); + $this->assertEquals("httpProxy", $opts->httpProxy); + $this->assertEquals("httpsProxy", $opts->httpsProxy); + $this->assertEquals("noProxy", $opts->noProxy); + $this->assertEquals(300, $opts->maxIdleConns); + $this->assertEquals(true, $opts->keepAlive); + $this->assertEquals('value', $opts->extendsParameters->headers['key']); + $this->assertEquals('value', $opts->extendsParameters->queries['key']); + } + + private function convert($body, &$content) + { + $class = new \ReflectionClass($body); + foreach ($class->getProperties(\ReflectionProperty::IS_PUBLIC) as $property) { + $name = $property->getName(); + if (!$property->isStatic()) { + $value = $property->getValue($body); + if ($value instanceof StreamInterface) { + continue; + } + $content->{$name} = $value; + } + } + } +} + +/** + * @internal + * @coversNothing + */ +class RequestTest extends Model +{ + /** + * @var RequestTestQuery + */ + public $query; +} + +/** + * @internal + * @coversNothing + */ +class RequestShrinkTest extends Model +{ + /** + * @var RequestTestShrinkQuery + */ + public $query; +} + +class RequestTestQuery extends Model +{ + /** + * @description test + * + * @var bool + */ + public $booleanParamInQuery; + + /** + * @description test + * + * @var array + */ + public $mapParamInQuery; + protected $_name = [ + 'booleanParamInQuery' => 'BooleanParamInQuery', + 'mapParamInQuery' => 'MapParamInQuery', + ]; + + public function toMap() + { + $res = []; + if (null !== $this->booleanParamInQuery) { + $res['BooleanParamInQuery'] = $this->booleanParamInQuery; + } + if (null !== $this->mapParamInQuery) { + $res['MapParamInQuery'] = $this->mapParamInQuery; + } + + return $res; + } +} + +class RequestTestShrinkQuery extends Model +{ + /** + * @description test + * + * @var float + */ + public $booleanParamInQuery; + + /** + * @description test + * + * @var string + */ + public $mapParamInQueryShrink; + protected $_name = [ + 'booleanParamInQuery' => 'BooleanParamInQuery', + 'mapParamInQueryShrink' => 'MapParamInQuery', + ]; + + public function toMap() + { + $res = []; + if (null !== $this->booleanParamInQuery) { + $res['BooleanParamInQuery'] = $this->booleanParamInQuery; + } + if (null !== $this->mapParamInQueryShrink) { + $res['MapParamInQuery'] = $this->mapParamInQueryShrink; + } + + return $res; + } +} diff --git a/vendor/vendor/alibabacloud/tea-utils/tests/bootstrap.php b/vendor/vendor/alibabacloud/tea-utils/tests/bootstrap.php new file mode 100644 index 0000000..c62c4e8 --- /dev/null +++ b/vendor/vendor/alibabacloud/tea-utils/tests/bootstrap.php @@ -0,0 +1,3 @@ +setRiskyAllowed(true) + ->setIndent(' ') + ->setRules([ + '@PSR2' => true, + '@PhpCsFixer' => true, + '@Symfony:risky' => true, + 'concat_space' => ['spacing' => 'one'], + 'array_syntax' => ['syntax' => 'short'], + 'array_indentation' => true, + 'combine_consecutive_unsets' => true, + 'method_separation' => true, + 'single_quote' => true, + 'declare_equal_normalize' => true, + 'function_typehint_space' => true, + 'hash_to_slash_comment' => true, + 'include' => true, + 'lowercase_cast' => true, + 'no_multiline_whitespace_before_semicolons' => true, + 'no_leading_import_slash' => true, + 'no_multiline_whitespace_around_double_arrow' => true, + 'no_spaces_around_offset' => true, + 'no_unneeded_control_parentheses' => true, + 'no_unused_imports' => true, + 'no_whitespace_before_comma_in_array' => true, + 'no_whitespace_in_blank_line' => true, + 'object_operator_without_whitespace' => true, + 'single_blank_line_before_namespace' => true, + 'single_class_element_per_statement' => true, + 'space_after_semicolon' => true, + 'standardize_not_equals' => true, + 'ternary_operator_spaces' => true, + 'trailing_comma_in_multiline_array' => true, + 'trim_array_spaces' => true, + 'unary_operator_spaces' => true, + 'whitespace_after_comma_in_array' => true, + 'no_extra_consecutive_blank_lines' => [ + 'curly_brace_block', + 'extra', + 'parenthesis_brace_block', + 'square_brace_block', + 'throw', + 'use', + ], + 'binary_operator_spaces' => [ + 'align_double_arrow' => true, + 'align_equals' => true, + ], + 'braces' => [ + 'allow_single_line_closure' => true, + ], + ]) + ->setFinder( + PhpCsFixer\Finder::create() + ->exclude('vendor') + ->exclude('tests') + ->in(__DIR__) + ); diff --git a/vendor/vendor/alibabacloud/tea-xml/README-CN.md b/vendor/vendor/alibabacloud/tea-xml/README-CN.md new file mode 100644 index 0000000..0ac19d8 --- /dev/null +++ b/vendor/vendor/alibabacloud/tea-xml/README-CN.md @@ -0,0 +1,31 @@ +English | [简体中文](README-CN.md) + +![](https://aliyunsdk-pages.alicdn.com/icons/AlibabaCloud.svg) + +## Alibaba Cloud Tea XML Library for PHP + +## Installation + +### Composer + +```bash +composer require alibabacloud/tea-xml +``` + +## Issues + +[Opening an Issue](https://github.com/aliyun/tea-xml/issues/new), Issues not conforming to the guidelines may be closed immediately. + +## Changelog + +Detailed changes for each release are documented in the [release notes](./ChangeLog.txt). + +## References + +* [Latest Release](https://github.com/aliyun/tea-xml) + +## License + +[Apache-2.0](http://www.apache.org/licenses/LICENSE-2.0) + +Copyright (c) 2009-present, Alibaba Cloud All rights reserved. diff --git a/vendor/vendor/alibabacloud/tea-xml/README.md b/vendor/vendor/alibabacloud/tea-xml/README.md new file mode 100644 index 0000000..b0f3ea0 --- /dev/null +++ b/vendor/vendor/alibabacloud/tea-xml/README.md @@ -0,0 +1,31 @@ +[English](README.md) | 简体中文 + +![](https://aliyunsdk-pages.alicdn.com/icons/AlibabaCloud.svg) + +## Alibaba Cloud Tea XML Library for PHP + +## 安装 + +### Composer + +```bash +composer require alibabacloud/tea-xml +``` + +## 问题 + +[提交 Issue](https://github.com/aliyun/tea-xml/issues/new),不符合指南的问题可能会立即关闭。 + +## 发行说明 + +每个版本的详细更改记录在[发行说明](./ChangeLog.txt)中。 + +## 相关 + +* [最新源码](https://github.com/aliyun/tea-xml) + +## 许可证 + +[Apache-2.0](http://www.apache.org/licenses/LICENSE-2.0) + +Copyright (c) 2009-present, Alibaba Cloud All rights reserved. diff --git a/vendor/vendor/alibabacloud/tea-xml/composer.json b/vendor/vendor/alibabacloud/tea-xml/composer.json new file mode 100644 index 0000000..5322b04 --- /dev/null +++ b/vendor/vendor/alibabacloud/tea-xml/composer.json @@ -0,0 +1,44 @@ +{ + "name": "alibabacloud/tea-xml", + "description": "Alibaba Cloud Tea XML Library for PHP", + "type": "library", + "license": "Apache-2.0", + "authors": [ + { + "name": "Alibaba Cloud SDK", + "email": "sdk-team@alibabacloud.com" + } + ], + "require": { + "php": ">5.5" + }, + "require-dev": { + "phpunit/phpunit": "*", + "symfony/var-dumper": "*" + }, + "autoload": { + "psr-4": { + "AlibabaCloud\\Tea\\XML\\": "src" + } + }, + "autoload-dev": { + "psr-4": { + "AlibabaCloud\\Tea\\XML\\Tests\\": "tests" + } + }, + "scripts": { + "fixer": "php-cs-fixer fix ./", + "test": [ + "@clearCache", + "phpunit --colors=always" + ], + "clearCache": "rm -rf cache/*" + }, + "config": { + "sort-packages": true, + "preferred-install": "dist", + "optimize-autoloader": true + }, + "prefer-stable": true, + "minimum-stability": "dev" +} diff --git a/vendor/vendor/alibabacloud/tea-xml/phpunit.xml b/vendor/vendor/alibabacloud/tea-xml/phpunit.xml new file mode 100644 index 0000000..d43dde9 --- /dev/null +++ b/vendor/vendor/alibabacloud/tea-xml/phpunit.xml @@ -0,0 +1,32 @@ + + + + + + tests + + + ./tests + + + + + + integration + + + + + + + + + + + + ./src + + + diff --git a/vendor/vendor/alibabacloud/tea-xml/src/ArrayToXml.php b/vendor/vendor/alibabacloud/tea-xml/src/ArrayToXml.php new file mode 100644 index 0000000..d811c63 --- /dev/null +++ b/vendor/vendor/alibabacloud/tea-xml/src/ArrayToXml.php @@ -0,0 +1,151 @@ +version = $xmlVersion; + $this->encoding = $xmlEncoding; + } + + /** + * Build an XML Data Set. + * + * @param array $data Associative Array containing values to be parsed into an XML Data Set(s) + * @param string $startElement Root Opening Tag, default data + * + * @return string XML String containing values + * @return mixed Boolean false on failure, string XML result on success + */ + public function buildXML($data, $startElement = 'data') + { + if (!\is_array($data)) { + $err = 'Invalid variable type supplied, expected array not found on line ' . __LINE__ . ' in Class: ' . __CLASS__ . ' Method: ' . __METHOD__; + trigger_error($err); + + return false; //return false error occurred + } + $xml = new XmlWriter(); + $xml->openMemory(); + $xml->startDocument($this->version, $this->encoding); + $xml->startElement($startElement); + $data = $this->writeAttr($xml, $data); + $this->writeEl($xml, $data); + $xml->endElement(); //write end element + //returns the XML results + return $xml->outputMemory(true); + } + + /** + * Write keys in $data prefixed with @ as XML attributes, if $data is an array. + * When an @ prefixed key is found, a '%' key is expected to indicate the element itself, + * and '#' prefixed key indicates CDATA content. + * + * @param XMLWriter $xml object + * @param array $data with attributes filtered out + * + * @return array $data | $nonAttributes + */ + protected function writeAttr(XMLWriter $xml, $data) + { + if (\is_array($data)) { + $nonAttributes = []; + foreach ($data as $key => $val) { + //handle an attribute with elements + if ('@' == $key[0]) { + $xml->writeAttribute(substr($key, 1), $val); + } elseif ('%' == $key[0]) { + if (\is_array($val)) { + $nonAttributes = $val; + } else { + $xml->text($val); + } + } elseif ('#' == $key[0]) { + if (\is_array($val)) { + $nonAttributes = $val; + } else { + $xml->startElement(substr($key, 1)); + $xml->writeCData($val); + $xml->endElement(); + } + } elseif ('!' == $key[0]) { + if (\is_array($val)) { + $nonAttributes = $val; + } else { + $xml->writeCData($val); + } + } //ignore normal elements + else { + $nonAttributes[$key] = $val; + } + } + + return $nonAttributes; + } + + return $data; + } + + /** + * Write XML as per Associative Array. + * + * @param XMLWriter $xml object + * @param array $data Associative Data Array + */ + protected function writeEl(XMLWriter $xml, $data) + { + foreach ($data as $key => $value) { + if (\is_array($value) && !$this->isAssoc($value)) { //numeric array + foreach ($value as $itemValue) { + if (\is_array($itemValue)) { + $xml->startElement($key); + $itemValue = $this->writeAttr($xml, $itemValue); + $this->writeEl($xml, $itemValue); + $xml->endElement(); + } else { + $itemValue = $this->writeAttr($xml, $itemValue); + $xml->writeElement($key, "{$itemValue}"); + } + } + } elseif (\is_array($value)) { //associative array + $xml->startElement($key); + $value = $this->writeAttr($xml, $value); + $this->writeEl($xml, $value); + $xml->endElement(); + } else { //scalar + $value = $this->writeAttr($xml, $value); + $xml->writeElement($key, "{$value}"); + } + } + } + + /** + * Check if array is associative with string based keys + * FROM: http://stackoverflow.com/questions/173400/php-arrays-a-good-way-to-check-if-an-array-is-associative-or-sequential/4254008#4254008. + * + * @param array $array Array to check + * + * @return bool + */ + protected function isAssoc($array) + { + return (bool) \count(array_filter(array_keys($array), 'is_string')); + } +} diff --git a/vendor/vendor/alibabacloud/tea-xml/src/XML.php b/vendor/vendor/alibabacloud/tea-xml/src/XML.php new file mode 100644 index 0000000..3550e04 --- /dev/null +++ b/vendor/vendor/alibabacloud/tea-xml/src/XML.php @@ -0,0 +1,59 @@ + $v) { + if (isset($prop[$k])) { + $target[$k] = $v; + } + } + return $target; + } + } + + public static function toXML($array) + { + $arrayToXml = new ArrayToXml(); + if (\is_object($array)) { + $tmp = explode('\\', \get_class($array)); + $rootName = $tmp[\count($tmp) - 1]; + $data = json_decode(json_encode($array), true); + } else { + $tmp = $array; + reset($tmp); + $rootName = key($tmp); + $data = $array[$rootName]; + } + ksort($data); + + return $arrayToXml->buildXML($data, $rootName); + } + + private static function parse($xml) + { + if (\PHP_VERSION_ID < 80000) { + libxml_disable_entity_loader(true); + } + + return json_decode( + json_encode( + simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA) + ), + true + ); + } +} diff --git a/vendor/vendor/alibabacloud/tea-xml/tests/XMLTest.php b/vendor/vendor/alibabacloud/tea-xml/tests/XMLTest.php new file mode 100644 index 0000000..9bc5059 --- /dev/null +++ b/vendor/vendor/alibabacloud/tea-xml/tests/XMLTest.php @@ -0,0 +1,59 @@ +\n" . + "\n" . + " test\n" . + " 1\n" . + "\n"; + + public function testParseXml() + { + $res = XML::parseXml($this->xmlStr, new tests()); + $name = $res['name']; + $value = $res['value']; + $this->assertEquals('test', $name); + $this->assertEquals(1, $value); + + $res = XML::parseXml($this->xmlStr, null); + $name = $res['name']; + $value = $res['value']; + $this->assertEquals('test', $name); + $this->assertEquals(1, $value); + } + + public function testArrayToXML() + { + $data = [ + 'tests' => [ + 'name' => 'test', + 'value' => 1, + ], + ]; + $this->assertEquals("\ntest1", XML::toXML($data)); + } + + public function testObjectToXML() + { + $obj = new tests(); + $obj->name = 'test'; + $obj->value = 1; + $this->assertEquals("\ntest1", XML::toXML($obj)); + } +} + +class tests +{ + public $name = ''; + public $value = 0; +} diff --git a/vendor/vendor/alibabacloud/tea-xml/tests/bootstrap.php b/vendor/vendor/alibabacloud/tea-xml/tests/bootstrap.php new file mode 100644 index 0000000..c62c4e8 --- /dev/null +++ b/vendor/vendor/alibabacloud/tea-xml/tests/bootstrap.php @@ -0,0 +1,3 @@ +setRiskyAllowed(true) + ->setIndent(' ') + ->setRules([ + '@PSR2' => true, + '@PhpCsFixer' => true, + '@Symfony:risky' => true, + 'concat_space' => ['spacing' => 'one'], + 'array_syntax' => ['syntax' => 'short'], + 'array_indentation' => true, + 'combine_consecutive_unsets' => true, + 'method_separation' => true, + 'single_quote' => true, + 'declare_equal_normalize' => true, + 'function_typehint_space' => true, + 'hash_to_slash_comment' => true, + 'include' => true, + 'lowercase_cast' => true, + 'no_multiline_whitespace_before_semicolons' => true, + 'no_leading_import_slash' => true, + 'no_multiline_whitespace_around_double_arrow' => true, + 'no_spaces_around_offset' => true, + 'no_unneeded_control_parentheses' => true, + 'no_unused_imports' => true, + 'no_whitespace_before_comma_in_array' => true, + 'no_whitespace_in_blank_line' => true, + 'object_operator_without_whitespace' => true, + 'single_blank_line_before_namespace' => true, + 'single_class_element_per_statement' => true, + 'space_after_semicolon' => true, + 'standardize_not_equals' => true, + 'ternary_operator_spaces' => true, + 'trailing_comma_in_multiline_array' => true, + 'trim_array_spaces' => true, + 'unary_operator_spaces' => true, + 'whitespace_after_comma_in_array' => true, + 'no_extra_consecutive_blank_lines' => [ + 'curly_brace_block', + 'extra', + 'parenthesis_brace_block', + 'square_brace_block', + 'throw', + 'use', + ], + 'binary_operator_spaces' => [ + 'align_double_arrow' => true, + 'align_equals' => true, + ], + 'braces' => [ + 'allow_single_line_closure' => true, + ], + ]) + ->setFinder( + PhpCsFixer\Finder::create() + ->exclude('vendor') + ->exclude('tests') + ->in(__DIR__) + ); diff --git a/vendor/vendor/alibabacloud/tea/CHANGELOG.md b/vendor/vendor/alibabacloud/tea/CHANGELOG.md new file mode 100644 index 0000000..a3b6a53 --- /dev/null +++ b/vendor/vendor/alibabacloud/tea/CHANGELOG.md @@ -0,0 +1,148 @@ +# CHANGELOG + +## 3.1.22 - 2021-05-11 + +- Deprecate `stream_for` method. + +## 3.1.21 - 2021-03-15 + +- Supported set proxy&timeout on request. + +## 3.1.20 - 2020-12-02 + +- Fix the warning when the Tea::merge method received empty arguments. + +## 3.1.19 - 2020-10-09 + +- Fix the error when the code value is a string. + +## 3.1.18 - 2020-09-28 + +- Require Guzzle Version 7.0 + +## 3.1.17 - 2020-09-24 + +- TeaUnableRetryError support get error info. + +## 3.1.16 - 2020-08-31 + +- Fix the Maximum function nesting level error when repeated network requests. + +## 3.1.15 - 2020-07-28 + +- Improved validatePattern method. + +## 3.1.14 - 2020-07-03 + +- Supported set properties of TeaError with `ErrorInfo`. + +## 3.1.13 - 2020-06-09 + +- Reduce dependencies. + +## 3.1.12 - 2020-05-13 + +- Add validate method. +- Supported validate maximun&minimun of property. + +## 3.1.11 - 2020-05-07 + +- Fixed error when class is undefined. + +## 3.1.10 - 2020-05-07 + +- Fixed error when '$item' of array is null + +## 3.1.9 - 2020-04-13 + +- TeaUnableRetryError add $lastException param. + +## 3.1.8 - 2020-04-02 + +- Added some static methods of Model to validate fields of Model. + +## 3.1.7 - 2020-03-27 + +- Improve Tea::isRetryable method. + +## 3.1.6 - 2020-03-25 + +- Fixed bug when body is StreamInterface. + +## 3.1.5 - 2020-03-25 + +- Improve Model.toMap method. +- Improve Tea.merge method. +- Fixed tests. + +## 3.1.4 - 2020-03-20 + +- Added Tea::merge method. +- Change Tea::isRetryable method. + +## 3.1.3 - 2020-03-20 + +- Model: added toModel method. + +## 3.1.2 - 2020-03-19 + +- Model constructor supported array type parameter. + +## 3.1.1 - 2020-03-18 + +- Fixed bug : set method failed. +- Fixed bug : get empty contents form body. + +## 3.1.0 - 2020-03-13 + +- TeaUnableRetryError add 'lastRequest' property. +- Change Tea.send() method return. +- Fixed Tea. allowRetry() method. + +## 3.0.0 - 2020-02-14 +- Rename package name. + +## 2.0.3 - 2020-02-14 +- Improved Exception. + +## 2.0.2 - 2019-09-11 +- Supported `String`. + +## 2.0.1 - 2019-08-15 +- Supported `IteratorAggregate`. + +## 2.0.0 - 2019-08-14 +- Design `Request` as a standard `PsrRequest`. + +## 1.0.10 - 2019-08-12 +- Added `__toString` for `Response`. + +## 1.0.9 - 2019-08-01 +- Updated `Middleware`. + +## 1.0.8 - 2019-07-29 +- Supported `TransferStats`. + +## 1.0.7 - 2019-07-27 +- Improved request. + +## 1.0.6 - 2019-07-23 +- Trim key for parameter. + +## 1.0.5 - 2019-07-23 +- Supported default protocol. + +## 1.0.4 - 2019-07-22 +- Added `toArray()`. + +## 1.0.3 - 2019-05-02 +- Improved `Request`. + +## 1.0.2 - 2019-05-02 +- Added getHeader/getHeaders. + +## 1.0.1 - 2019-04-02 +- Improved design. + +## 1.0.0 - 2019-05-02 +- Initial release of the AlibabaCloud Tea Version 1.0.0 on Packagist See for more information. diff --git a/vendor/vendor/alibabacloud/tea/LICENSE.md b/vendor/vendor/alibabacloud/tea/LICENSE.md new file mode 100644 index 0000000..ec13fcc --- /dev/null +++ b/vendor/vendor/alibabacloud/tea/LICENSE.md @@ -0,0 +1,13 @@ +Copyright (c) 2009-present, Alibaba Cloud All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/vendor/vendor/alibabacloud/tea/README.md b/vendor/vendor/alibabacloud/tea/README.md new file mode 100644 index 0000000..a8cbe66 --- /dev/null +++ b/vendor/vendor/alibabacloud/tea/README.md @@ -0,0 +1,16 @@ + +## Installation +``` +composer require alibabacloud/tea --optimize-autoloader +``` +> Some users may not be able to install due to network problems, you can try to switch the Composer mirror. + + +## Changelog +Detailed changes for each release are documented in the [release notes](CHANGELOG.md). + + +## License +[Apache-2.0](LICENSE.md) + +Copyright (c) 2009-present, Alibaba Cloud All rights reserved. diff --git a/vendor/vendor/alibabacloud/tea/composer.json b/vendor/vendor/alibabacloud/tea/composer.json new file mode 100644 index 0000000..163689e --- /dev/null +++ b/vendor/vendor/alibabacloud/tea/composer.json @@ -0,0 +1,80 @@ +{ + "name": "alibabacloud/tea", + "homepage": "https://www.alibabacloud.com/", + "description": "Client of Tea for PHP", + "keywords": [ + "tea", + "client", + "alibabacloud", + "cloud" + ], + "type": "library", + "license": "Apache-2.0", + "support": { + "source": "https://github.com/aliyun/tea-php", + "issues": "https://github.com/aliyun/tea-php/issues" + }, + "authors": [ + { + "name": "Alibaba Cloud SDK", + "email": "sdk-team@alibabacloud.com", + "homepage": "http://www.alibabacloud.com" + } + ], + "require": { + "php": ">=5.5", + "ext-curl": "*", + "ext-json": "*", + "ext-libxml": "*", + "ext-mbstring": "*", + "ext-openssl": "*", + "ext-simplexml": "*", + "ext-xmlwriter": "*", + "guzzlehttp/guzzle": "^6.3|^7.0", + "adbario/php-dot-notation": "^2.4" + }, + "require-dev": { + "symfony/dotenv": "^3.4", + "phpunit/phpunit": "*", + "symfony/var-dumper": "^3.4" + }, + "suggest": { + "ext-sockets": "To use client-side monitoring" + }, + "autoload": { + "psr-4": { + "AlibabaCloud\\Tea\\": "src" + } + }, + "autoload-dev": { + "psr-4": { + "AlibabaCloud\\Tea\\Tests\\": "tests" + } + }, + "config": { + "sort-packages": true, + "preferred-install": "dist", + "optimize-autoloader": true + }, + "prefer-stable": true, + "minimum-stability": "dev", + "scripts": { + "cs": "phpcs --standard=PSR2 -n ./", + "cbf": "phpcbf --standard=PSR2 -n ./", + "fixer": "php-cs-fixer fix ./", + "test": [ + "@clearCache", + "phpunit --colors=always" + ], + "unit": [ + "@clearCache", + "phpunit --testsuite=Unit --colors=always" + ], + "feature": [ + "@clearCache", + "phpunit --testsuite=Feature --colors=always" + ], + "clearCache": "rm -rf cache/*", + "coverage": "open cache/coverage/index.html" + } +} diff --git a/vendor/vendor/alibabacloud/tea/src/Exception/TeaError.php b/vendor/vendor/alibabacloud/tea/src/Exception/TeaError.php new file mode 100644 index 0000000..f4ef0d9 --- /dev/null +++ b/vendor/vendor/alibabacloud/tea/src/Exception/TeaError.php @@ -0,0 +1,53 @@ +errorInfo = $errorInfo; + if (!empty($errorInfo)) { + $properties = ['name', 'message', 'code', 'data', 'description', 'accessDeniedDetail']; + foreach ($properties as $property) { + if (isset($errorInfo[$property])) { + $this->{$property} = $errorInfo[$property]; + if ($property === 'data' && isset($errorInfo['data']['statusCode'])) { + $this->statusCode = $errorInfo['data']['statusCode']; + } + } + } + } + } + + /** + * @return array + */ + public function getErrorInfo() + { + return $this->errorInfo; + } +} diff --git a/vendor/vendor/alibabacloud/tea/src/Exception/TeaRetryError.php b/vendor/vendor/alibabacloud/tea/src/Exception/TeaRetryError.php new file mode 100644 index 0000000..30aa7f8 --- /dev/null +++ b/vendor/vendor/alibabacloud/tea/src/Exception/TeaRetryError.php @@ -0,0 +1,21 @@ +getErrorInfo(); + } + parent::__construct($error_info, $lastException->getMessage(), $lastException->getCode(), $lastException); + $this->lastRequest = $lastRequest; + $this->lastException = $lastException; + } + + public function getLastRequest() + { + return $this->lastRequest; + } + + public function getLastException() + { + return $this->lastException; + } +} diff --git a/vendor/vendor/alibabacloud/tea/src/Helper.php b/vendor/vendor/alibabacloud/tea/src/Helper.php new file mode 100644 index 0000000..f1c0fd4 --- /dev/null +++ b/vendor/vendor/alibabacloud/tea/src/Helper.php @@ -0,0 +1,112 @@ + $ord) { + if ($k !== $i) { + return false; + } + if (!\is_int($ord)) { + return false; + } + if ($ord < 0 || $ord > 255) { + return false; + } + ++$i; + } + + return true; + } + + /** + * Convert a bytes to string(utf8). + * + * @param array $bytes + * + * @return string the return string + */ + public static function toString($bytes) + { + $str = ''; + foreach ($bytes as $ch) { + $str .= \chr($ch); + } + + return $str; + } + + /** + * @return array + */ + public static function merge(array $arrays) + { + $result = []; + foreach ($arrays as $array) { + foreach ($array as $key => $value) { + if (\is_int($key)) { + $result[] = $value; + + continue; + } + + if (isset($result[$key]) && \is_array($result[$key])) { + $result[$key] = self::merge( + [$result[$key], $value] + ); + + continue; + } + + $result[$key] = $value; + } + } + + return $result; + } +} diff --git a/vendor/vendor/alibabacloud/tea/src/Model.php b/vendor/vendor/alibabacloud/tea/src/Model.php new file mode 100644 index 0000000..538b55c --- /dev/null +++ b/vendor/vendor/alibabacloud/tea/src/Model.php @@ -0,0 +1,114 @@ + $v) { + $this->{$k} = $v; + } + } + } + + public function getName($name = null) + { + if (null === $name) { + return $this->_name; + } + + return isset($this->_name[$name]) ? $this->_name[$name] : $name; + } + + public function toMap() + { + $map = get_object_vars($this); + foreach ($map as $k => $m) { + if (0 === strpos($k, '_')) { + unset($map[$k]); + } + } + $res = []; + foreach ($map as $k => $v) { + $name = isset($this->_name[$k]) ? $this->_name[$k] : $k; + $res[$name] = $v; + } + + return $res; + } + + public function validate() + { + $vars = get_object_vars($this); + foreach ($vars as $k => $v) { + if (isset($this->_required[$k]) && $this->_required[$k] && empty($v)) { + throw new \InvalidArgumentException("{$k} is required."); + } + } + } + + public static function validateRequired($fieldName, $field, $val = null) + { + if (true === $val && null === $field) { + throw new \InvalidArgumentException($fieldName . ' is required'); + } + } + + public static function validateMaxLength($fieldName, $field, $val = null) + { + if (null !== $field && \strlen($field) > (int) $val) { + throw new \InvalidArgumentException($fieldName . ' is exceed max-length: ' . $val); + } + } + + public static function validateMinLength($fieldName, $field, $val = null) + { + if (null !== $field && \strlen($field) < (int) $val) { + throw new \InvalidArgumentException($fieldName . ' is less than min-length: ' . $val); + } + } + + public static function validatePattern($fieldName, $field, $regex = '') + { + if (null !== $field && '' !== $field && !preg_match("/^{$regex}$/", $field)) { + throw new \InvalidArgumentException($fieldName . ' is not match ' . $regex); + } + } + + public static function validateMaximum($fieldName, $field, $val) + { + if (null !== $field && $field > $val) { + throw new \InvalidArgumentException($fieldName . ' cannot be greater than ' . $val); + } + } + + public static function validateMinimum($fieldName, $field, $val) + { + if (null !== $field && $field < $val) { + throw new \InvalidArgumentException($fieldName . ' cannot be less than ' . $val); + } + } + + /** + * @param array $map + * @param Model $model + * + * @return mixed + */ + public static function toModel($map, $model) + { + $names = $model->getName(); + $names = array_flip($names); + foreach ($map as $key => $value) { + $name = isset($names[$key]) ? $names[$key] : $key; + $model->{$name} = $value; + } + + return $model; + } +} diff --git a/vendor/vendor/alibabacloud/tea/src/Parameter.php b/vendor/vendor/alibabacloud/tea/src/Parameter.php new file mode 100644 index 0000000..324a95d --- /dev/null +++ b/vendor/vendor/alibabacloud/tea/src/Parameter.php @@ -0,0 +1,50 @@ +toArray()); + } + + /** + * @return array + */ + public function getRealParameters() + { + $array = []; + $obj = new ReflectionObject($this); + $properties = $obj->getProperties(); + + foreach ($properties as $property) { + $docComment = $property->getDocComment(); + $key = trim(Helper::findFromString($docComment, '@real', "\n")); + $value = $property->getValue($this); + $array[$key] = $value; + } + + return $array; + } + + /** + * @return array + */ + public function toArray() + { + return $this->getRealParameters(); + } +} diff --git a/vendor/vendor/alibabacloud/tea/src/Request.php b/vendor/vendor/alibabacloud/tea/src/Request.php new file mode 100644 index 0000000..db49142 --- /dev/null +++ b/vendor/vendor/alibabacloud/tea/src/Request.php @@ -0,0 +1,123 @@ +method = $method; + } + + /** + * These fields are compatible if you define other fields. + * Mainly for compatibility situations where the code generator cannot generate set properties. + * + * @return PsrRequest + */ + public function getPsrRequest() + { + $this->assertQuery($this->query); + + $request = clone $this; + + $uri = $request->getUri(); + if ($this->query) { + $uri = $uri->withQuery(http_build_query($this->query)); + } + + if ($this->port) { + $uri = $uri->withPort($this->port); + } + + if ($this->protocol) { + $uri = $uri->withScheme($this->protocol); + } + + if ($this->pathname) { + $uri = $uri->withPath($this->pathname); + } + + if (isset($this->headers['host'])) { + $uri = $uri->withHost($this->headers['host']); + } + + $request = $request->withUri($uri); + $request = $request->withMethod($this->method); + + if ('' !== $this->body && null !== $this->body) { + if ($this->body instanceof StreamInterface) { + $request = $request->withBody($this->body); + } else { + $body = $this->body; + if (Helper::isBytes($this->body)) { + $body = Helper::toString($this->body); + } + if (\function_exists('\GuzzleHttp\Psr7\stream_for')) { + // @deprecated stream_for will be removed in guzzlehttp/psr7:2.0 + $request = $request->withBody(\GuzzleHttp\Psr7\stream_for($body)); + } else { + $request = $request->withBody(\GuzzleHttp\Psr7\Utils::streamFor($body)); + } + } + } + + if ($this->headers) { + foreach ($this->headers as $key => $value) { + $request = $request->withHeader($key, $value); + } + } + + return $request; + } + + /** + * @param array $query + */ + private function assertQuery($query) + { + if (!\is_array($query) && $query !== null) { + throw new InvalidArgumentException('Query must be array.'); + } + } +} diff --git a/vendor/vendor/alibabacloud/tea/src/Response.php b/vendor/vendor/alibabacloud/tea/src/Response.php new file mode 100644 index 0000000..cb446e7 --- /dev/null +++ b/vendor/vendor/alibabacloud/tea/src/Response.php @@ -0,0 +1,372 @@ +getStatusCode(), + $response->getHeaders(), + $response->getBody(), + $response->getProtocolVersion(), + $response->getReasonPhrase() + ); + $this->headers = $response->getHeaders(); + $this->body = $response->getBody(); + $this->statusCode = $response->getStatusCode(); + if ($this->body->isSeekable()) { + $this->body->seek(0); + } + + if (Helper::isJson((string) $this->getBody())) { + $this->dot = new Dot($this->toArray()); + } else { + $this->dot = new Dot(); + } + } + + /** + * @return string + */ + public function __toString() + { + return (string) $this->getBody(); + } + + /** + * @param string $name + * + * @return null|mixed + */ + public function __get($name) + { + $data = $this->dot->all(); + if (!isset($data[$name])) { + return null; + } + + return json_decode(json_encode($data))->{$name}; + } + + /** + * @param string $name + * @param mixed $value + */ + public function __set($name, $value) + { + $this->dot->set($name, $value); + } + + /** + * @param string $name + * + * @return bool + */ + public function __isset($name) + { + return $this->dot->has($name); + } + + /** + * @param $offset + */ + public function __unset($offset) + { + $this->dot->delete($offset); + } + + /** + * @return array + */ + public function toArray() + { + return \GuzzleHttp\json_decode((string) $this->getBody(), true); + } + + /** + * @param array|int|string $keys + * @param mixed $value + */ + public function add($keys, $value = null) + { + return $this->dot->add($keys, $value); + } + + /** + * @return array + */ + public function all() + { + return $this->dot->all(); + } + + /** + * @param null|array|int|string $keys + */ + public function clear($keys = null) + { + return $this->dot->clear($keys); + } + + /** + * @param array|int|string $keys + */ + public function delete($keys) + { + return $this->dot->delete($keys); + } + + /** + * @param string $delimiter + * @param null|array $items + * @param string $prepend + * + * @return array + */ + public function flatten($delimiter = '.', $items = null, $prepend = '') + { + return $this->dot->flatten($delimiter, $items, $prepend); + } + + /** + * @param null|int|string $key + * @param mixed $default + * + * @return mixed + */ + public function get($key = null, $default = null) + { + return $this->dot->get($key, $default); + } + + /** + * @param array|int|string $keys + * + * @return bool + */ + public function has($keys) + { + return $this->dot->has($keys); + } + + /** + * @param null|array|int|string $keys + * + * @return bool + */ + public function isEmpty($keys = null) + { + return $this->dot->isEmpty($keys); + } + + /** + * @param array|self|string $key + * @param array|self $value + */ + public function merge($key, $value = []) + { + return $this->dot->merge($key, $value); + } + + /** + * @param array|self|string $key + * @param array|self $value + */ + public function mergeRecursive($key, $value = []) + { + return $this->dot->mergeRecursive($key, $value); + } + + /** + * @param array|self|string $key + * @param array|self $value + */ + public function mergeRecursiveDistinct($key, $value = []) + { + return $this->dot->mergeRecursiveDistinct($key, $value); + } + + /** + * @param null|int|string $key + * @param mixed $default + * + * @return mixed + */ + public function pull($key = null, $default = null) + { + return $this->dot->pull($key, $default); + } + + /** + * @param null|int|string $key + * @param mixed $value + * + * @return mixed + */ + public function push($key = null, $value = null) + { + return $this->dot->push($key, $value); + } + + /** + * Replace all values or values within the given key + * with an array or Dot object. + * + * @param array|self|string $key + * @param array|self $value + */ + public function replace($key, $value = []) + { + return $this->dot->replace($key, $value); + } + + /** + * Set a given key / value pair or pairs. + * + * @param array|int|string $keys + * @param mixed $value + */ + public function set($keys, $value = null) + { + return $this->dot->set($keys, $value); + } + + /** + * Replace all items with a given array. + * + * @param mixed $items + */ + public function setArray($items) + { + return $this->dot->setArray($items); + } + + /** + * Replace all items with a given array as a reference. + */ + public function setReference(array &$items) + { + return $this->dot->setReference($items); + } + + /** + * Return the value of a given key or all the values as JSON. + * + * @param mixed $key + * @param int $options + * + * @return string + */ + public function toJson($key = null, $options = 0) + { + return $this->dot->toJson($key, $options); + } + + /** + * Retrieve an external iterator. + */ + #[\ReturnTypeWillChange] + public function getIterator() + { + return $this->dot->getIterator(); + } + + /** + * Whether a offset exists. + * + * @param $offset + * + * @return bool + */ + #[\ReturnTypeWillChange] + public function offsetExists($offset) + { + return $this->dot->offsetExists($offset); + } + + /** + * Offset to retrieve. + * + * @param $offset + * + * @return mixed + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->dot->offsetGet($offset); + } + + /** + * Offset to set. + * + * @param $offset + * @param $value + */ + #[\ReturnTypeWillChange] + public function offsetSet($offset, $value) + { + $this->dot->offsetSet($offset, $value); + } + + /** + * Offset to unset. + * + * @param $offset + */ + #[\ReturnTypeWillChange] + public function offsetUnset($offset) + { + $this->dot->offsetUnset($offset); + } + + /** + * Count elements of an object. + * + * @param null $key + * + * @return int + */ + #[\ReturnTypeWillChange] + public function count($key = null) + { + return $this->dot->count($key); + } +} diff --git a/vendor/vendor/alibabacloud/tea/src/Tea.php b/vendor/vendor/alibabacloud/tea/src/Tea.php new file mode 100644 index 0000000..a138ad9 --- /dev/null +++ b/vendor/vendor/alibabacloud/tea/src/Tea.php @@ -0,0 +1,287 @@ +getPsrRequest(); + } + + $config = self::resolveConfig($config); + + $res = self::client()->send( + $request, + $config + ); + + return new Response($res); + } + + /** + * @return PromiseInterface + */ + public static function sendAsync(RequestInterface $request, array $config = []) + { + if (method_exists($request, 'getPsrRequest')) { + $request = $request->getPsrRequest(); + } + + $config = self::resolveConfig($config); + + return self::client()->sendAsync( + $request, + $config + ); + } + + /** + * @return Client + */ + public static function client(array $config = []) + { + if (isset(self::$config['handler'])) { + $stack = self::$config['handler']; + } else { + $stack = HandlerStack::create(); + $stack->push(Middleware::mapResponse(static function (ResponseInterface $response) { + return new Response($response); + })); + } + + self::$config['handler'] = $stack; + + if (!isset(self::$config['on_stats'])) { + self::$config['on_stats'] = function (TransferStats $stats) { + Response::$info = $stats->getHandlerStats(); + }; + } + + $new_config = Helper::merge([self::$config, $config]); + + return new Client($new_config); + } + + /** + * @param string $method + * @param string|UriInterface $uri + * @param array $options + * + * @throws GuzzleException + * + * @return ResponseInterface + */ + public static function request($method, $uri, $options = []) + { + return self::client()->request($method, $uri, $options); + } + + /** + * @param string $method + * @param string $uri + * @param array $options + * + * @throws GuzzleException + * + * @return string + */ + public static function string($method, $uri, $options = []) + { + return (string) self::client()->request($method, $uri, $options) + ->getBody(); + } + + /** + * @param string $method + * @param string|UriInterface $uri + * @param array $options + * + * @return PromiseInterface + */ + public static function requestAsync($method, $uri, $options = []) + { + return self::client()->requestAsync($method, $uri, $options); + } + + /** + * @param string|UriInterface $uri + * @param array $options + * + * @throws GuzzleException + * + * @return null|mixed + */ + public static function getHeaders($uri, $options = []) + { + return self::request('HEAD', $uri, $options)->getHeaders(); + } + + /** + * @param string|UriInterface $uri + * @param string $key + * @param null|mixed $default + * + * @throws GuzzleException + * + * @return null|mixed + */ + public static function getHeader($uri, $key, $default = null) + { + $headers = self::getHeaders($uri); + + return isset($headers[$key][0]) ? $headers[$key][0] : $default; + } + + /** + * @param int $retryTimes + * @param float $now + * + * @return bool + */ + public static function allowRetry(array $runtime, $retryTimes, $now) + { + unset($now); + if (!isset($retryTimes) || null === $retryTimes || !\is_numeric($retryTimes)) { + return false; + } + if ($retryTimes > 0 && (empty($runtime) || !isset($runtime['retryable']) || !$runtime['retryable'] || !isset($runtime['maxAttempts']))) { + return false; + } + $maxAttempts = $runtime['maxAttempts']; + $retry = empty($maxAttempts) ? 0 : (int) $maxAttempts; + + return $retry >= $retryTimes; + } + + /** + * @param int $retryTimes + * + * @return int + */ + public static function getBackoffTime(array $runtime, $retryTimes) + { + $backOffTime = 0; + $policy = isset($runtime['policy']) ? $runtime['policy'] : ''; + + if (empty($policy) || 'no' == $policy) { + return $backOffTime; + } + + $period = isset($runtime['period']) ? $runtime['period'] : ''; + if (null !== $period && '' !== $period) { + $backOffTime = (int) $period; + if ($backOffTime <= 0) { + return $retryTimes; + } + } + + return $backOffTime; + } + + public static function sleep($time) + { + sleep($time); + } + + public static function isRetryable($retry, $retryTimes = 0) + { + if ($retry instanceof TeaError) { + return true; + } + if (\is_array($retry)) { + $max = isset($retry['maxAttempts']) ? (int) ($retry['maxAttempts']) : 3; + + return $retryTimes <= $max; + } + + return false; + } + + /** + * @param mixed|Model[] ...$item + * + * @return mixed + */ + public static function merge(...$item) + { + $tmp = []; + $n = 0; + foreach ($item as $i) { + if (\is_object($i)) { + if ($i instanceof Model) { + $i = $i->toMap(); + } else { + $i = json_decode(json_encode($i), true); + } + } + if (null === $i) { + continue; + } + if (\is_array($i)) { + $tmp[$n++] = $i; + } + } + + if (\count($tmp)) { + return \call_user_func_array('array_merge', $tmp); + } + + return []; + } + + private static function resolveConfig(array $config = []) + { + $options = new Dot(['http_errors' => false]); + if (isset($config['httpProxy']) && !empty($config['httpProxy'])) { + $options->set('proxy.http', $config['httpProxy']); + } + if (isset($config['httpsProxy']) && !empty($config['httpsProxy'])) { + $options->set('proxy.https', $config['httpsProxy']); + } + if (isset($config['noProxy']) && !empty($config['noProxy'])) { + $options->set('proxy.no', $config['noProxy']); + } + if (isset($config['ignoreSSL']) && !empty($config['ignoreSSL'])) { + $options->set('verify',!((bool)$config['ignoreSSL'])); + } + // readTimeout&connectTimeout unit is millisecond + $read_timeout = isset($config['readTimeout']) && !empty($config['readTimeout']) ? (int) $config['readTimeout'] : 0; + $con_timeout = isset($config['connectTimeout']) && !empty($config['connectTimeout']) ? (int) $config['connectTimeout'] : 0; + // timeout unit is second + $options->set('timeout', ($read_timeout + $con_timeout) / 1000); + + return $options->all(); + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/.coveralls.yml b/vendor/vendor/aliyuncs/oss-sdk-php/.coveralls.yml new file mode 100644 index 0000000..850cc59 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/.coveralls.yml @@ -0,0 +1,2 @@ +coverage_clover: coverage.xml +json_path: coverage.json diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/.gitignore b/vendor/vendor/aliyuncs/oss-sdk-php/.gitignore new file mode 100644 index 0000000..7cdb514 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/.gitignore @@ -0,0 +1,8 @@ +vendor +composer.lock +doc +output +.idea +.buildpath +.project +.settings diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/.travis.yml b/vendor/vendor/aliyuncs/oss-sdk-php/.travis.yml new file mode 100644 index 0000000..0b40ba2 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/.travis.yml @@ -0,0 +1,21 @@ +language: php +php: + - 7.1 + - 7.0 + - 5.6 + - 5.5 + - 5.4 +install: + - composer self-update + - composer install --no-interaction +script: + - php vendor/bin/phpunit +after_success: + - php vendor/bin/coveralls -v +env: + global: + - secure: SzmQ854lQmhV6ZkAG7lQNTY3CkazrXnDSb6VMwPU/sdaLGxPO159AW3fJS5d0sO/XN1P8x5WNkoA4i9soDlLBRibEEISNUM/2EMnpszsRymZ9o97PrS2IgORXTUL/OF+rpATzyNVB2p+2l9hBLiGf17exMSA5iOeY7W6E+VKPGi8TFykgbGUnLKU0h1hV3rzmtfGjOXcSpvYU/hxeZD/J/+6m5Gic9b/pNS+AbfTj7Y7Ru9tNsnyUP29V/vtEYtpQir3ZxQiSiUv9idybgGnJBOMYydJofb/mpFYHhYLSWqtMKGNLpeawmqs4z8S1Tvx5U5uzW5+h/mpzhvBaFlWGpm8t89BQxun5LVX5NiYCrV7TqaLitGp1cSpMjMDnrnSTNzk1exVz+rWZZcWS7yB9ULYA681GA8StXWk167qB7Y30iK1dFK3+2mDN2cEY+qLs8+bupDowQ4eOM+eqfhxX8F8+ouKcKomETsjiIwL+CUsIe6wjvnYFWb1YlRhbsI75bblHApflohnt6gVSJ78ZPqID+u2oUMjmIWXLTnRR2Y2tgEW8uqHeIoQ8BBntLdQDmv0BO4FpnGQIwrUUwQYeNzEM0DOr3hWZhyDR6Xvl+9H0l52xjANaSqpuTZfC3zmeFTG7kIjydvxNePRrony6XAawL9BvI7aKWuVF6YVjPM= + - secure: nEhsU8aUQqsAJeuger+boh51oTpeo4YNG7vUWbKxdwVDIrcLb+l7r7RvTlxU7mt8IZTWwicgri18mh+Wi04BwX4ulBA1SCs8jPbL51KEo5izoDGGtLSd2fuPHdslYSrwagrvq90EPnDT/7fHWn/TAoT+rueZzjNyCu5IGSgL3GnXaUThsJ82NMePL2YRdP4Q1qmtZPRFBOkOQ6F0heuV8fw8sLyTO3txaCQum9YneGxrWxOl/E8zB0qtlnPwLE8ogaHZMQh2/jThmTbI5UqwRTxV4f0qoD5eJYH+j0fslsSAjsg/HPnSuVcnccK3zSU+s2sV4dPCcISzECJvZEObwipfxOGhdqt5gMcxHhn8qVsbT97iIh106pG/BJCDgQd2EeVW8WfCi6cCuCKIMipvVkMypkmjQHWU1XaqPzILl7g5diW9Ctp2C4Akq5dYdrdu8IrnVK1ShtkQVaWU+S/Bht8VU5gYP7olPW/GdTz7sceU1NOIC4NPXqmWKbfavR98U5dkHMLMvzABYL1Q87h+KhPD1c14NUyw3YENUW7REiF/X5lERRm5H0kJ/1JqAa+AgeHQEGmPVuZV2s/na4b0S1479QRVmSM/6ZzXQpU+Y8jCRfETpUFA4S331369kirHgCqDlxyIntuEKrzivD02/O+5C3eJ0WHRz6QsN2/R4qg= + - secure: ZTvzNXEZP4efl+a/3VGMmdabfUQp83v5/lecMns039Ro7UuZYPdtbPtpPnpjaTI6Htd22A4Rva5BU/3JCQJAyQvpbKNn5sGou2SmfQu3o0SyhggSB7gWjYAf707aW1j4bHYfP8IjDS5NjuVk3AqXeNSUuLRUXRmwSOB0lSYiRhiTJY+pUdBl382Hx4NbhIU/gmOzRoJCs7coTip8IURXYEHPi5dnDWluajxI+TgNXFccSgEleeQDJajYgXmpLb2EhSj8piipOnVgaCEE5bh5fbp32024Qq38SGHKcbfnwj2IInpZpZESJknRKoqAlFjdOJhork82dBcvAr5JxCBZKx5IuwXcTjxkQ6tRtBeqhPLPFuX3MQ8WrtU+wniPM0RCH/VoFkUKO7JGQDwmoi2AKago4PsuDs4P6Y6CeuOVpcso731GwwMNhIJcyrJJivXprQNEGsEw+9wLjU1qNYs6IIA3S/gPzFrNbdX5Wf8vxt0vLpgYvBNtPnLMejMtknuyfVzf5iKuVVoGPDTEz+ajs06+jfoPfm/4sLTaLghuVH7Adm74OpF769JQNnQYKwJuu4bNlcbLJChulCEMBOx7myqo/9O6RCTuqzHaGmVWNot4RGqRFHgJGl/JJf0WpAVitbhbRH3kGoyKb6jFM74CJbPsE7OORlJLDC3cdD3C8Pk= + - secure: Qr5NR4CVzBKCQgRgMH0x772TPJ1+brx3UCvtRNu8fi4j3p8bz+HDMjBaBDSFmEB09nunLI55/8mj88/5GXmnpFs8+CPTkcW+QZOcxg3cxpI4SNmxoB12/ZawlFHAqSUaRRE7RUWVkY3KL8tIGjEZcFyUBQ1DVNX3OMpiKs3NLtHa7oUIknyBxdSokm4kpLhSXYe7WmO0vhuZbMZE0S1EISToiBS6AdhGUEbTLJ/vNsIDY07fu6+Vh3HxVbyUFPqUZGlkZpQ+2xMJ3kiqPBMrXtRF/IhhPjORDil6Ns9SQ8/AAlaCddvYvRaT4Pjv2/aX+t3l28qI1qmryPtWXpce5UXecWGYqdRpSJc6Y/pEt4m4FeeGoEFWnSPGIs7FRmeiis8q2rojGZ18i4vI/k4iHmqEBnTlMp3SWnRb9L1adJ8ZAWln8aC88gkQXm67w7+1CxLycerbYj9H1ugqHENuHcxv4uHUcZgEENX3EWatu8i9+K2IUuU/2zcmpu7qtsziYcoyW8DOOmYpJfXGMLtmF9+pqp/Tp6i0tltFSEfmY3N8o7xvv3enLvFHsjL+3ElFdd1blUPSrvZJHgA9M3lJ+QF1RJZCpJqgPlQ0XOZK1Bf4P46zpEj01wKaK4JQrkLPRXhbBOuIJn5O6WlFJyPX4+SaBfwTzb4AvM4aUg2TgTg= + - secure: Inw5ftA8fxvhMHRZwoZzATxn4WICJsCq7ZX4y2gI+b/8u0JQIsbLgY9WTYV+XdSxOoNwuVa1oUxEWI0aDORtXKC3XaIXXKrwndag0zxS77JEYwWvQsjM7BhEbF7MF7MYk8rRXpn6mbfGAT/NfqEOx91RCY8UKeMzD0oPkpkBnJ9Ekuod6JBBq+7j3v4mYUItA8pxvw7b4Pdd4z2xzjgOwNhJYMOCpts50DWZI+WXj0HvTYaMXe5mJJtORK5lsr0a9cbsBqAzE6l+3zGI8XkgHn130ux5XH3DE7hZBeti3ZNaO3d2Vv+496/1EObG0rSFk+z3dmNKqjMz4nh3bYIkdLMegwmgCWs2mvQhkwYhzmnPRHVSERrgZjSWnuKn2PKnBar6tui9KaLNgpo2j3jWpwMLJ3bGAfE5JtMppxAxNqj/q+YB2UZo7Mn7EDjkTDjgxCuazTJwWqH7xxCOykWPABBI17P3JaOXQJEK39LavpfSMm3kdmU0ocpUs7FniLuFm6xL71VxY1wHG10yskczEcFHZ3iyIyGM+xum4vbt5y6Yg+zfdExYQsbrxHDDZ3HbHY3tEU0WhM55vrC42NIXRWqXqJ8OAxpl4nivfx96eoBAThiUU9xXtZmh7WRFVYsstoGtxZwfk5+bi+oeVO9kih4xabwbgHgL9BTc1TR1C4U= diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/CHANGELOG.md b/vendor/vendor/aliyuncs/oss-sdk-php/CHANGELOG.md new file mode 100644 index 0000000..9cb0156 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/CHANGELOG.md @@ -0,0 +1,159 @@ +# ChangeLog - Aliyun OSS SDK for PHP + +## v2.7.2 / 2024-10-28 +* Added: presign supports response-* parameters +* Added: forcePathStyle option. + +## v2.7.1 / 2024-02-28 +* Fixed: fix deprecated + +## v2.7.0 / 2024-02-02 +* Added: support signature version 4. +* Added: support checkObjectEndcoding option. +* Added: support strictObjectName option. +* Added: support filePathCompatible option. +* Added: support path style. +* Added: support environment variables credentials provider. +* Update: add filed for some api. +* Fixed: fix some bugs. + +## v2.6.0 / 2022-08-03 +* Added: support credentials provider. +* Fixed: compatible with swoole curl handler. +* Added: support more bucket stat info. + +## v2.5.0 / 2022-05-13 +* Added: support bucket transfer acceleration. +* Added: support bucket cname token. +* Added: support listobjectsV2. + +## v2.4.3 / 2021-08-25 +* Fixed: integer overflow in PHP5.x. + +## v2.4.2 / 2021-06-04 +* Compatible with PHP8. +* Fixed: compatible with PHP5.4. +* Fixed: the signature is incorrect in some scenarios +* Update: change $requestUrl from a member variable to a local variable. + +## v2.4.1 / 2020-09-29 +* Fixed: the getBucketPolicy bug. + + +## v2.4.0 / 2020-08-31 + +* Added: disable Expect: 100-continue +* Added: support getBucketInfo +* Added: support getBucketStat +* Added: support bucket policy +* Added: support bucket encryption +* Added: support bucket tagging +* Added: support bucket worm +* Added: support versioning +* Added: support request payment +* Added: support object tagging +* Added: support code archive +* Added: support process object +* Added: support traffic limit paramter +* Added: support upload object from file handle +* Added: support getSimplifiedObjectMeta +* Fixed: the object name can not be '0' stirng. +* Update: endpoint validity check +* Update: add new pre-signed url api + + +## v2.3.1 / 2019-01-15 + +* translate chinese comments into english +* Added: endpoint validity check + +## v2.3.0 / 2018-01-05 + +* Fixed: putObject support creating empty files +* Fixed: createBucket support IA/Archive +* Added: support restoreObject +* Added: support the Symlink feature +* Added: support getBucketLocation +* Added: support getBucketMeta +* Added: support proxy server Proxy + +## v2.2.4 / 2017-04-25 + +* Fixed getObject to local file bug + +## v2.2.3 / 2017-04-14 + +* Fixed md5 check + +## v2.2.2 / 2017-01-18 + +* Resolve to run the connection number and memory bug on php7 + +## v2.2.1 / 2016-12-01 + +* No HTTP curl is allowed to automatically populate accept-encoding + +## v2.2.0 / 2016-11-22 + +* Fixed PutObject/CompleteMultipartUpload return values(#26) + +## v2.1.0 / 2016-11-12 + +* Added[RTMP](https://help.aliyun.com/document_detail/44297.html)interface +* Add support[image service](https://help.aliyun.com/document_detail/44686.html) + +## v2.0.7 / 2016-06-17 + +* Support append object + +## v2.0.6 + +* Trim access key id/secret and endpoint +* Refine tests and setup travis CI + +## v2.0.5 + +* Added Add/Delete/Get BucketCname interface + +## v2.0.4 + +* Added Put/Get Object Acl interface + +## v2.0.3 + +* Fixing the constants in Util is defined in a PHP version that is less than 5.6. + +## v2.0.2 + +* The problem of content-type cannot be specified when restoring multipart uploads + +## v2.0.1 + +* Increase the ListObjects/ListMultipartUploads special characters +* Provides the interface to get the details of the OssException + + +## 2015.11.25 + +* **Large version upgrade, no longer compatible with previous interface, new version has made great improvements to ease of use, suggesting that users migrate to a new version.** + +## Modify the content + +* PHP 5.2 is no longer supported + +### Add the cotent + +* Introduce namespace +* Interface naming and modification, using hump naming +* The interface is modified, and the common parameters are extracted from the Options parameter. +* The interface returns the result modification, processing the return result, and the user can directly get the data structure easily processed  +* OssClient's constructor changes +* The Endpoint address that support CNAME and IP formats +* Rearrange the sample file organization structure and use function to organize the function points +* Add an interface that sets the connection timeout and requests timeout +* Remove the outdated interface associated with the Object Group +* The message in the OssException is changed to English + +### Repair problem + +* The object name is not complete diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/LICENSE.md b/vendor/vendor/aliyuncs/oss-sdk-php/LICENSE.md new file mode 100644 index 0000000..3183de8 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/LICENSE.md @@ -0,0 +1,21 @@ +#The MIT License (MIT) + +Copyright (c) ali-sdk and other contributors. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/README-CN.md b/vendor/vendor/aliyuncs/oss-sdk-php/README-CN.md new file mode 100644 index 0000000..89c1e5a --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/README-CN.md @@ -0,0 +1,149 @@ +# Aliyun OSS SDK for PHP + +[![Latest Stable Version](https://poser.pugx.org/aliyuncs/oss-sdk-php/v/stable)](https://packagist.org/packages/aliyuncs/oss-sdk-php) +[![Build Status](https://travis-ci.org/aliyun/aliyun-oss-php-sdk.svg?branch=master)](https://travis-ci.org/aliyun/aliyun-oss-php-sdk) +[![Coverage Status](https://coveralls.io/repos/github/aliyun/aliyun-oss-php-sdk/badge.svg?branch=master)](https://coveralls.io/github/aliyun/aliyun-oss-php-sdk?branch=master) + +## [README of English](https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/README.md) + +## 概述 + +阿里云对象存储(Object Storage Service,简称OSS),是阿里云对外提供的海量、安全、低成本、高可靠的云存储服务。用户可以通过调用API,在任何应用、任何时间、任何地点上传和下载数据,也可以通过用户Web控制台对数据进行简单的管理。OSS适合存放任意文件类型,适合各种网站、开发企业及开发者使用。 + + +## 运行环境 +- PHP 5.3+ +- cURL extension + +提示: + +- Ubuntu下可以使用apt-get包管理器安装php的cURL扩展 `sudo apt-get install php5-curl` + +## 安装方法 + +1. 如果您通过composer管理您的项目依赖,可以在你的项目根目录运行: + + $ composer require aliyuncs/oss-sdk-php + + 或者在你的`composer.json`中声明对Aliyun OSS SDK for PHP的依赖: + + "require": { + "aliyuncs/oss-sdk-php": "~2.0" + } + + 然后通过`composer install`安装依赖。composer安装完成后,在您的PHP代码中引入依赖即可: + + require_once __DIR__ . '/vendor/autoload.php'; + +2. 您也可以直接下载已经打包好的[phar文件][releases-page],然后在你 + 的代码中引入这个文件即可: + + require_once '/path/to/oss-sdk-php.phar'; + +3. 下载SDK源码,在您的代码中引入SDK目录下的`autoload.php`文件: + + require_once '/path/to/oss-sdk/autoload.php'; + +## 快速使用 + +### 常用类 + +| 类名 | 解释 | +|:------------------|:------------------------------------| +|OSS\OssClient | OSS客户端类,用户通过OssClient的实例调用接口 | +|OSS\Core\OssException | OSS异常类,用户在使用的过程中,只需要注意这个异常| + +### OssClient初始化 + +SDK的OSS操作通过OssClient类完成的,下面代码创建一个OssClient对象: + +```php +"; ; +$accessKeySecret = "<您从OSS获得的AccessKeySecret>"; +$endpoint = "<您选定的OSS数据中心访问域名,例如oss-cn-hangzhou.aliyuncs.com>"; +try { + $ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint); +} catch (OssException $e) { + print $e->getMessage(); +} +``` + +### 文件操作 + +文件(又称对象,Object)是OSS中最基本的数据单元,您可以把它简单地理解为文件,用下面代码可以实现一个Object的上传: + +```php +"; +$object = "<您使用的Object名字,注意命名规范>"; +$content = "Hello, OSS!"; // 上传的文件内容 +try { + $ossClient->putObject($bucket, $object, $content); +} catch (OssException $e) { + print $e->getMessage(); +} +``` + +### 存储空间操作 + +存储空间(又称Bucket)是一个用户用来管理所存储Object的存储空间,对于用户来说是一个管理Object的单元,所有的Object都必须隶属于某个Bucket。您可以按照下面的代码新建一个Bucket: + +```php +"; +try { + $ossClient->createBucket($bucket); +} catch (OssException $e) { + print $e->getMessage(); +} +``` + +### 返回结果处理 + +OssClient提供的接口返回返回数据分为两种: + +* Put,Delete类接口,接口返回null,如果没有OssException,即可认为操作成功 +* Get,List类接口,接口返回对应的数据,如果没有OssException,即可认为操作成功,举个例子: + +```php +listBuckets(); +$bucketList = $bucketListInfo->getBucketList(); +foreach($bucketList as $bucket) { + print($bucket->getLocation() . "\t" . $bucket->getName() . "\t" . $bucket->getCreateDate() . "\n"); +} +``` +上面代码中的$bucketListInfo的数据类型是 `OSS\Model\BucketListInfo` + + +### 运行Sample程序 + +1. 修改 `samples/Config.php`, 补充配置信息 +2. 执行 `cd samples/ && php RunAll.php` + +### 运行单元测试 + +1. 执行`composer install`下载依赖的库 +2. 设置环境变量 + + export OSS_ACCESS_KEY_ID=access-key-id + export OSS_ACCESS_KEY_SECRET=access-key-secret + export OSS_ENDPOINT=endpoint + export OSS_BUCKET=bucket-name + +3. 执行 `php vendor/bin/phpunit` + +## License + +- MIT + +## 联系我们 + +- [阿里云OSS官方网站](http://oss.aliyun.com) +- [阿里云OSS官方论坛](http://bbs.aliyun.com) +- [阿里云OSS官方文档中心](http://www.aliyun.com/product/oss#Docs) +- 阿里云官方技术支持:[提交工单](https://workorder.console.aliyun.com/#/ticket/createIndex) + +[releases-page]: https://github.com/aliyun/aliyun-oss-php-sdk/releases +[phar-composer]: https://github.com/clue/phar-composer diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/README.md b/vendor/vendor/aliyuncs/oss-sdk-php/README.md new file mode 100644 index 0000000..b77a356 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/README.md @@ -0,0 +1,150 @@ +# Alibaba Cloud OSS SDK for PHP + +[![Latest Stable Version](https://poser.pugx.org/aliyuncs/oss-sdk-php/v/stable)](https://packagist.org/packages/aliyuncs/oss-sdk-php) +[![Build Status](https://travis-ci.org/aliyun/aliyun-oss-php-sdk.svg?branch=master)](https://travis-ci.org/aliyun/aliyun-oss-php-sdk) +[![Coverage Status](https://coveralls.io/repos/github/aliyun/aliyun-oss-php-sdk/badge.svg?branch=master)](https://coveralls.io/github/aliyun/aliyun-oss-php-sdk?branch=master) + +## [README of Chinese](https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/README-CN.md) + +## Overview + +Alibaba Cloud Object Storage Service (OSS) is a cloud storage service provided by Alibaba Cloud, featuring a massive capacity, security, a low cost, and high reliability. You can upload and download data on any application anytime and anywhere by calling APIs, and perform simple management of data through the web console. The OSS can store any type of files and therefore applies to various websites, development enterprises and developers. + + +## Run environment +- PHP 5.3+. +- cURL extension. + +Tips: + +- In Ubuntu, you can use the ***apt-get*** package manager to install the *PHP cURL extension*: `sudo apt-get install php5-curl`. + +## Install OSS PHP SDK + +- If you use the ***composer*** to manage project dependencies, run the following command in your project's root directory: + + composer require aliyuncs/oss-sdk-php + + You can also declare the dependency on Alibaba Cloud OSS SDK for PHP in the `composer.json` file. + + "require": { + "aliyuncs/oss-sdk-php": "~2.0" + } + + Then run `composer install` to install the dependency. After the Composer Dependency Manager is installed, import the dependency in your PHP code: + + require_once __DIR__ . '/vendor/autoload.php'; + +- You can also directly download the packaged [PHAR File][releases-page], and + introduce the file to your code: + + require_once '/path/to/oss-sdk-php.phar'; + +- Download the SDK source code, and introduce the `autoload.php` file under the SDK directory to your code: + + require_once '/path/to/oss-sdk/autoload.php'; + +## Quick use + +### Common classes + +| Class | Explanation | +|:------------------|:------------------------------------| +|OSS\OssClient | OSS client class. An OssClient instance can be used to call the interface. | +|OSS\Core\OssException |OSS Exception class . You only need to pay attention to this exception when you use the OssClient. | + +### Initialize an OssClient + +The SDK's operations for the OSS are performed through the OssClient class. The code below creates an OssClient object: + +```php +"; +$accessKeySecret = ""; +$endpoint = ""; +try { + $ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint); +} catch (OssException $e) { + print $e->getMessage(); +} +``` + +### Operations on objects + +Objects are the most basic data units on the OSS. You can simply consider objects as files. The following code uploads an object: + +```php +"; +$object = ""; +$content = "Hello, OSS!"; // Content of the uploaded file +try { + $ossClient->putObject($bucket, $object, $content); +} catch (OssException $e) { + print $e->getMessage(); +} +``` + +### Operations on buckets + +Buckets are the space that you use to manage the stored objects. It is an object management unit for users. Each object must belong to a bucket. You can create a bucket with the following code: + +```php +"; +try { + $ossClient->createBucket($bucket); +} catch (OssException $e) { + print $e->getMessage(); +} +``` + +### Handle returned results + +The OssClient provides the following two types of returned data from interfaces: + +- Put and Delete interfaces: The *PUT* and *DELETE* operations are deemed successful if *null* is returned by the interfaces without *OSSException*. +- Get and List interfaces: The *GET* and *LIST* operations are deemed successful if the desired data is returned by the interfaces without *OSSException*. For example, + + ```php + listBuckets(); + $bucketList = $bucketListInfo->getBucketList(); + foreach($bucketList as $bucket) { + print($bucket->getLocation() . "\t" . $bucket->getName() . "\t" . $bucket->getCreateDate() . "\n"); + } + ``` +In the above code, $bucketListInfo falls into the 'OSS\Model\BucketListInfo' data type. + + +### Run a sample project + +- Modify `samples/Config.php` to complete the configuration information. +- Run `cd samples/ && php RunAll.php`. + +### Run a unit test + +- Run `composer install` to download the dependent libraries. +- Set the environment variable. + + export OSS_ACCESS_KEY_ID=access-key-id + export OSS_ACCESS_KEY_SECRET=access-key-secret + export OSS_ENDPOINT=endpoint + export OSS_BUCKET=bucket-name + +- Run `php vendor/bin/phpunit` + +## License + +- MIT + +## Contact us + +- [Alibaba Cloud OSS official website](http://oss.aliyun.com). +- [Alibaba Cloud OSS official forum](http://bbs.aliyun.com). +- [Alibaba Cloud OSS official documentation center](http://www.aliyun.com/product/oss#Docs). +- Alibaba Cloud official technical support: [Submit a ticket](https://workorder.console.aliyun.com/#/ticket/createIndex). + +[releases-page]: https://github.com/aliyun/aliyun-oss-php-sdk/releases +[phar-composer]: https://github.com/clue/phar-composer + diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/autoload.php b/vendor/vendor/aliyuncs/oss-sdk-php/autoload.php new file mode 100644 index 0000000..ec13201 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/autoload.php @@ -0,0 +1,11 @@ +=5.3" + }, + "require-dev" : { + "phpunit/phpunit": "*", + "php-coveralls/php-coveralls": "*" + }, + "minimum-stability": "stable", + "autoload": { + "psr-4": {"OSS\\": "src/OSS"} + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/example.jpg b/vendor/vendor/aliyuncs/oss-sdk-php/example.jpg new file mode 100644 index 0000000000000000000000000000000000000000..ffd46a2f81b1fe020ed0673f27711124110eed3f GIT binary patch literal 21839 zcmbT6Wl$W^*X9Qg1PL+;GDsLCSb{S+f#B{iNN|VXG6aGL1|NKa1lJkdB@o=*CAdrQ zKnU6V-*;=bYCrAn>FWN_eY@-aTJAmPdHV0d-*vzy*ad2>OadGkRiShBDJi#X;A|fCLl0AP8B%`2sLH!c+f|8z!f`XQnmYxyJ%*^~8 z#K!rGiQ^>`Gt+-Ag7NQE{3rON`1qtuloXUq|IhKa6F~X|<0(c076u~#lN1As6yt9X zfc{@UaWMWX0RJ;EFtM<4aPgkt6FmLbp#B*E69Wqi6B`TXAH%=a0soEzut{;qUh=%f zCD$~^V|1h74NlB`0+z1s0%}eEWa6`M55XsR{(_Q|5hwgY@C-oxMXiN@yy-G8F_=BP)H}{R(Iip z`LuolE!-ywo-^@pFrWVi?Z3$W@4!O-zsUX<*#G8Q0uW+h{CjvI+$K+I)$tsJ~rz^hZo@j`1KWf=EcjNIVSyfn`vb4CeiA(Y>&N9&;J z4(PSS|H*@N&76CkaOw~p=YdQW9y~LQVv#k7lfq-k?bH__v+$orI^@*`@gU#x(|H(* zm@T?0CQcQ-qa4+W?JDPB5uLeMc&((B>s#aS_7xb#{xD0dilJmcIfFaf&S7n~swUWc zqP%P%>|#zyWq;nv<=CFyuT*y9Cq@uB%L9q8Z{?Vo8!dbU>{eUUnYqgvMe+u5JFo&7 z^D-v7OU%5=@jsHl_Qd8Wu3F4j<~jF)qm~6i7-el}ns#f{jp)P&d6at#@%py9NL+mm zq#uSOxj}A5!|w!2sVlMuf$Ytu*XA#AkvDf@ zdO|8_qbDrjc4bfxGJ3#ix`z`_MkeHGs-DViaVW9`tMp8(AfnbzpVexhBtsqs8}1eO zA*NF#n!pRN7kVS3<`6qAQ0DVAG#HLz&pg+|wOc+>H)~cL!(%M3wW+g?;XcqsauVYh zvuFZ7yAG7tG~m_0k9xb+F1|_F=2hm!2`ZMDe5P=s!b9f8YwK)X7GW z&Afe11w=eFSqVq?`7upyF(uQLfZ)4}8V|QP4|V0PBOOyVz?sUES>vc!sRg6Sg_&V* zg(E{!ux|K@xC1Q{s0hBAxQ3SXCgvb_qb#*ZFWs&6B&V(LtTHBMKXxxC*v)NSj&nFP zC4p|0ey(COSQa(Vey5BaQI(-R^gT7Gm^5Rb7X zo8TMQv5b9Yba&h=`8#=~A0k{^1K{U1FPH#L+k1sfEwtP3qPUo)aTVC*f#b&xsLjFZ zv6c?@iZ6X0CZJTS*D6+)ak9FIQG=_p=$%zOwrFxeS4X)u?TKmR09LO!*UfZNOae#V zcV+me?2dY!+WX41pf>4Ic6HOtxayCp7$i0CHQp1|uthJ84u@c9JC`4oRT6SR$dap+Rv<2coZ zqd8ZQ7(t@*g(H=Pp%RN2%m&7##^0VV>IhpJ=RmM~2TS#F(4$fYJW7jQAj^9C3VO60 zCX5;|onYx0q&nH6rXuC1MFJ8fx2a^3R_IRJ+?Qq}I306royX;Y)D=+ms^(ia{HQHR zUMWtQ!C$wVa!{DZO6oxExve-yo`~<`iLmEJc1n4los7H$C$TV)X0hf5om(Ltm!fB+ zAwuBV86LCuO#(N@`N_Xr{ zndh!uB#iZiB#z9K@DWu0!F)@>0R@lPm-wGC=ce@=@fc2xxSOofKYU*}1@QEJqF$b; zqvcZw3qSy4)~yl;QNLdEe6OS{hToK!=gQib3&lRaC0Cm`sjz$sa%eLP;wG|7XEgsT zYkta3U(Zfhjdi5@+d*9$wxW@7MmOZyr~_@)(EM*`%u zr(l`j9}Z_@&g2X;Lr=o@ymBI-HU(3|PO5ciUd;G31~WI41pelVy(gnkrHz4%&HK;a z|2T}%L~Y^o_NdLgZ`%@kCXq6r?CkX6Br(=@U6h081_0kYor*D)^I#SUdcR}_-&cGgy@XTF>H>2vu~%_Md3_m zxAg-QuGn>^AsXV){LI+jWbjBus8X|fTq(Q>ML{aW8NEw;(5=-E%MJ0@aVi!t9b(+I z$+<~nMJfI%?1%OVQ$%Rtu^{szik!0KXGCH>u^yk2z!~|Ex||~P!nIuIM>^Zz zn64`>eG&&tOxNkImBQg#{NYC)qvCI9XdNlX$D!G5YP>|maN5y*0X$>Eb112r)i&td zINBsVl3^}9qDY0>N>(VRqgzyk;R=uZ|xdFg{H1TycR)DelOus@r{5SX`&7jyC|-kWY(H8t)e*w z$%(V<2W`PY4%=^;%tsw$F>#KNprsdFW2T#<6F)_!8N*XL91dP{rNlcF-58$8H~RA$ z6R>Z{^ZUWoft(FtoFfsS^#P*$HB?7=VX zVvss{>fDJu*daXiLHBXqb&X<#Kck7#~Te_iH;O=3(*kl z9?OKzIqUF=X5D2m-goklJ=TSLy&knP!EJ(M_=h~!=$#`yjIy%FdS1moHXia&IS1~? ztJVX+!_u> zC32|MTnAHq&qNmWeWeFo@T{A$dQY{^ksWGsJf0)w@pCEw(*`j^7T~!17eHeOUG{|^idqz6Y*(uM1;kgjyIH)X{5=Wb z(Ab#;*+(4+3fTMc_XT;QB^}}dwLYf?uto4?%i2-8^|28efZz^!oA6MjP!A4nNOc^Gt0T<$j0p<^GbzD86kSH?_$G zd58HN)vZEZXa2;gQk`gOYde=r;v$r+@5sU^!}Or*SDh_YPxFgxMX>`i0r zDZbyd0__$gn zW2f`RU3jhn)x_-yxUznkFUT+fEOohUiT=p#(jb$kH~qQjk{Urppo3_kt1xhH;?M=c zbw3v)GW-gJ+{`w;2U15KTlwBx1Jz_@GW8|A#`TK(QMi&k6@jIYV=|<`L&7YL5oxB5 zhJ$7m2;T78(sO{Z7~$x~0#|?fhGAOnthAg=Ekg_*rchkOp;O0P!^(w>N)Odz*=}J^{kF9|iYibVhCFjwFnm|dih;|qf6>PN zVQCOX)ov0)|Ez1T_L*?SvJpzE%xG9}*=xTQpna@B^>C?Q|FnnGr&>CooGrB6FY3*Z zKm4lPur*8Pi^7>FN8}Q7>@Y4}3_g84Y=1o~|41mkBZhn7v3@(@y@^!U?3YKZUdOka z2TI|IQRau-juKuo`7;b1(h&20heq0|Mq%LYy?o^3qQuCtwQZy zJ48j?k#{y*m+sn<5Z6IGj~@IQKln_kr>V1I(z|TI0#g1IR(zT>GRwxo!S7+pJNY>4 zyc;AoyJG~3mw^Ui&f)9?*C)m=as4v$kB83sTervLy3n9S=Y>%3)}9lU8geST1_d!g z^zcdqx{Qzl6#3Pw)QO(PHaCI~0qDPg@1h&gqq2e-y3%qLzOQ>QuKN`G>pzZ*A2*Wo zPgUD`q)HUEexUue^t(@Ud0C9Z*%5!uLOW~9l8W^k_ST_eoFn+am@-B>xuQX=Y`NIwXEp&UPJL)Cv z&74n~P`X=Tq!_|ChuFYXmC0)7&^vvy61O28LM*Fz6K3IIkT~WMGd1YG>@EWDoou#8 zdbBzD_DYM@sPP!S@xIG_P0zH)Fk8m;GRq4cQ-F{cFFS@Qopu>-Hsm#GWO|iqJ>y;N z^?h&XoHbRHIDAO0knF76byJe`ZuuF8dNVrDKnCI>T$(zolz?M@-G_KrrkDxd4=-G& zA1V^Tc#054Px5aQtKk?JQLs%5XpcCJWYK`cJ3{NM;0O~Cnj0dp(4OhoNzrWu3XXI5 zR7c~(x(I?FymNnBBp%wIi3LCIOC>Sa7%bo!SpH?v5W%~pqsF3;VHYC=JwRW{Ic-QP z6)Y+DwY_#M0&X!`vpbEFw*?TX1Fzbnij|8yPCp-L8y!?^6Kb+a_mn4oY4-SmM6mr3 z_{xvw){FGaFuVz4sWPtdhO>{rMe{q+U%H_@bIdf0vmP^SrB{-lZ}riY?BS6Y%KG^S zEvgMkfC!u}EbROF`ru)Ky^;>;Rv2SeYLa8Y+Xil`Z*B4d(G~GRqKcy~KL(at=4jUx zBzsRxk7{BQHKCa%znCN4-9={&=sbmEs%Zzr0(Gm)jY=gf;;!j3zXnW@NP2pqC6sIP zZr-_d^B?8Zeq1<;(MS5`Y+@Zy$M%LbXx}9^%rdIN^Q*zwIi`8-%c=^mx#QB^9{u&f zTW8@7fiK%%F!E7+KI5|rJ?jFN1x?F~|IF$2I9$psSxA2g;KrscaGME`|8-sYmA~~x zOR!-A8jlLNmqQ>y0sUoT|2kTqg!4JVEpGuS{UqUaDxf#Pf{-1e&Y_RJx* zg*my_M5XGhajFG?J_`NCR$%)F-2-rwgu?zAE$K?+`;Uoo3N`>&c{B;+rox0zLA2&1 zyA^oswgO#Ys!~uJOzh6LEWrj@!Sr@wcugQH{dDD~vOhyNa-z7%oMjAK+GC4ebr>lq zyu`%-LzoCL_92ySQ+4IhZuJe$v`51GCuGR8=5lM7)XD8^JP(7wH+As_Q+vTuto96B z-?kmKjj$^oWHdCBuQ@`3j z^xN1B^9+`Iqnh+bXD3@hFQ_^D_~5Z9sc~R2wH2Lj?pJ`vs3lc(dfp8Az=3vQRlk7C zJHQ0s?K||4ENg>`J9}NiD{PCpOk8YusUZ6#XMbztJ4i)eLLY3i5zR=Zr#hQqv)NL5 zmoW6f8&6x8wVAk$8hO|!#fzr|e=3+3%n?E)OX#)F+QXeOZ0E7I{M|cpB(v+2K5hpigT{|5usJxJEPlJ^>u%~4?AuamAOu2Hh7j$9 zZELug`0ZsoSo&w&9(AL<1aYu7p&QmIqkgs@Q=deK%fT5todfJ&RvBAdm$E?WX} z`x5wLj=6-T-1^QV-M}nZi67|I6_9f~b*JI?9+0rKS*b4k8-do$^9Z^^jHajt!A%i2 zx~Z zQFjmK@^vajONw^Fz+ud7;lj~CQCyRY->2mn0fg!?WwJ+xn8?-j=$XO6 zUw{Mi=8{AheWCvJyYcxd~s!=1(}j7sGve zw`9w2#TcJs-R9GD?aS|&s5#Q4Kp>*L`0E-4K_W0+h>O&~1N+H#FoT5x$OrAd@FgQ7 z>FbsNxi{IHl^ibG*|#2tZaIBz9Q|~REv+*w@J+l(xn8%V_@58u%U&E|H4Se#K(IaF zW`}^0v(m3Ye4MUs+H~;p1AMnfQ7*e;r$_Kgp8lq--lV=`2{t8|7Cr#fJuwCM`VmPh zY|qjX3LWYv>7TrtA0eaQGA^v(8|QcJ%^K^Hg#j}Mt;v>_0fsM#yXTtDiTUTgWT#?1 zIVba3Bs2Ua=wFCyxEYhP!OBv0xCU&S>bo(S{0sQ#&Y{+AOe%_Nevt#+M|q`xc=>Fw zezu=sp0S*3t-n+oLusX2K1G;j=oUyAS>RzpAJ-FsT+U>h{#EU6|J~JGNN#c4YG61e8@TmPul@D>Zi8 zQPB|I@({?e!@K$+EVz>z z6vqP6`)n=c&L0cj+vs1boLlKwbt=GIUzf%k9`o_XSg5Owmo7~ljNq`&nfH|?@z$Q$ zr72oFRZQn@w|&N1Bz5w+XF0h&!6}v-Xs(8vHe6p+YJDO$X|3asJBBfzHW6{jRf{Qk zfBp3JR#z|oRw@5DkB?W8=BpSVraumB6aOmHKkN5_p8eZD-IUfXe#o{m!245I=aVh) z4on1kOfA-9=5)>}7h*sG_S|xu=m809&VbLrlu|kCn6$nCj{K&2MeTo8xT#@{)!rrA z@7NhDDPrf?#nqKuT%PjbFQBi*U-j*CW;10M(AK>kalQkB=lgd2W8pE@zYpC}>hu9z8t>+Ba2(wwbHP^_%+wC>Dx1)ybH$o=qukeJn%)Yx??diW#_BC` z3ppFup7z$sy14h&{s`{en`?KGC-_o3)h4=8cq~CvAIG+7Cs?BO)h*|H>#BC^4Z zaOVBU>B@l+AZwn5Bg>hY7pCUUmLA{L1P=vyfU)Al+5Ihnbr{-|boHb5F{ho?oCe$f zKBdJyl)yTrCe{ay+K`;*$u~F%RV0IquPNzw1aR z-4ii=AwS!fpAtaCj^BGNbPbp8!6EL>D>-Aap9Qou(CR8WI821FdCiSacxZH~c<-@Gsjou6FEOR1NpEOG=5Im%-Fv0|xX&I|Q;|2pg5G5AZbv3U zH%bR{(iE~0t1qZl8{<*d?~QvZ2`5EWFfMxR6d{nkpO5uLZ-{_uM|$zaozptzLph~g zzw*0mO&Xr_9=;GHuKB<#=Uzi1NBgI|Y`Ws>v@;iKD`lZGn!1+GhyWMnF;z5kY7Vz3 zxLiU|2=P=zdT%ixFRUYz56aZ7?Ah&AM_uT6Ge>j#+vTJn1C?BerPd!WOanJ*v>(8< z98uY_E3Uri5l&;a9LaP=rSj_c0|R~kq~MGGLPNvO6GcwA)Trlgxi}ie^k{nlxdWuo z5mZhJ|6gHNWo_XI^`e1g)X4&S;@ptVJ!%G^Y*|6z;w!F+b12cyKtAO_dFGurwVZYa zo`;T&A8;JHn237})AQgK+WS`jY#@T#TcvUS_IzN*cZuJ5xw$w1Kh92(J4aLI4~x@@^$z~M(v{0CmdDhGyU z+YZCIUU+cIMe}-~S4`E_T8!|Qg=35PxszmM)9BZpW4W$>y@!D0r+(1!%;vU8V?bDxp=Q3ZM1XcV6psdAc+9#C? z$L6L^RLp%s`*4gxevAWHN7R9R(D$_}q$I3`u=f#lm$WU)FYhA9o}k-s_0GxXt(%kz zKOfN1rBa2}z5yRjgDV6tqBAjmAwxa*u(GfvM!B9F4ebyRkD`t}&v(N=8 ziHQ*w(_jUBdNGGejTQz6kMBFQ#r1|OS>UR9X9*M0Wf#-+_{jw*spvv8=<#whd8 zSPEU>*<6jw)qcp&{G6%!otaR~)mWRlai(;DW&20>%)1I}0lEn0K4khzIXswb7h^}p zjnhF*K^}ak_b^HOjk`?M=J*aU|B>m~>`Qc;Nx1H}j(XDJ058ViOe%xF0BB{+Z#hMl z;J%Bdy9n6*{akoV#JqdUW!%*rxM`NfVA6naFEmu+aPWQgzPWgzV!7g>^U;=FW(nKX(=VNzpuU2cU-g7Tnj@ej4 zr;o`$_*%IO8#?cGxa`!$%N|W-QbAhA3S_)^(0ZZj=X|V^+xhGX3>B z5od!C3l0Y@XY#_K7w73&)fxtE2wQO+yA_;tzD8KwcV_3#*W4V{$}6oeviREhAs9frbw!)3-XTweD(hQxRo{Lb4%a=?E3UH}qVoenx5JyI zg;8cnvrh*G4B|7wX?fIpN(b@a(^YXo-b^I0T0dvXr56X+s6uTcgO82+YzCh*uMT>> zpaNwzJZAW`9P}!(jR~b7Z&W(dvkskg>MfK{-jhYLE~l41d!b1>NJ-%W%IzCen87Ok z_?xFGhelnu`w1p=6*Hk<$8+BtJ3GvYwHZc(x`x)Hoj zt^{uQUwu!0!N?13tyOjLan}dWPZb&d01;<(jav2ckzf2|A5wZdCf|e`F^YH-rA%xP z`gX0;Do7Gq@x{jlG`-UCBRSZx0s5}2%Xf+ANH0|yypH%JGGI^ZZqm0gp_B0A*^}4m zRX}3di)b&`N$UnSmqiMLktxtXcO?{7GZbj2fS2t*^?CVwY>DU|Rf#p&Wo_vtrT1{s zy>7{|x!Dse))LHGCjnf&?wXjt0RMWIw+!alMiMDwi#6|XKBBQKmp}XknC2x}W{prL zLP@ZiSZM-3Ba1mj<%s>nKaE3&w5lsKiE4XsckfbQJEil8D2;V@-?B81Xzgqx`*o5% zJuYhDuX>uh60WYWoX2|e6X3Dq(CsVn&*_RBNh&4`ggcT1ht3t7*r!wy*J3xCK!`E* zq}+YNV)qx4S_A-Pgfm7gEa0J8^?{R@6yXL}l~il~*X_BY^XS^=DC1@rA@tqUlbB#! zrMRX_!H#Bs#K?#@+LZ{_^GqqB%^j1sz_#A+bs^2$PXetj8}Y1}^YK~ILwwvNOKb(P z-;;U`4Ygiob)V-MnUv5kRiDxs)I96Rpi3MUVc*{eX4c%jXk@*u>hK0MELAf{P$+5eL`52zKcgp@XXww z77E`1&CscAmZTdP-3>8&rjzIMNJDpZ%03*e`MR?PLxm;~A-vg#rrLts;9qBR-z#Hc1^Pt<+$Wfh0)R%4WVl>y@D6q;oTV50$LY4%t_l_ z0I#c}qaoG4UiWK;a2d5uVpWabFYoti^CR-U-9t$#jnax#k4J#xv| zqyIA%0goY44UTxvlkj0l!T1KnR*yxf8qozVq?VnMy&PCiJ!GF%?0em7C>Spqa=wKz zpL?Xo)S5VJMJQ_pHNM=*4yjON;7O6|I(aX*&XI4yB^5)rtrx#E7-sf|1G6_DAtsCw zREqqt8ZLKWd`g`#S#Mva*z`3pyY8~2DUIFl!1zy0%~M2w${Ey$ub=Xgw8rj6QPcpW zmZUhdjrAsz+=zQMAU7m@x2avi&pK7qcQUJh0f47;9Z%$I;)FsN#bhXqkvL3~r2MwO zbV?|c&^1q;7-;BBjAKhIk6@M|H=14sgM^e&TnU=Z5Za>yVPT8B7E(+ad>4r$wtsWT zS4oDI9@}YnF(psg3FTF}!+Ux^#R{flPiA-D9R{=TF$mLy3xN=q2K##K2uTU816#q{ zi&D3vmTGr?g^%+9K?>I&86~P+F@M%c+(m!u5Z>)o9cZYFyu=xk2yiQ&h4Of%rJkeQ8~pw_J4x?aMG_DKGcZRff>AiuTAuF};LfJL$*} z8csfEQhuKJUMFET=mTsg*7w0^lg6nm}oCSwh5p&T8bdsuoZp~V9v2?iq840cxn z&#%$=zhe$fFN7G{&Dl#$MR=}{^pX3X1KX}1bNQdu$fUxq&5^w=w!fie%{+8G*`FVf zt7@9i^oyb^A+qU{9$Y3lse?H*s)E{yc{cOawJ^mfmr@VL!=bYtxkQebV{9)mpZ*88 zv89YgTg$ZB2j`oo^YBa0t%r3!00MsoJY=xXWd(63nL&xs=x{lu$Ct z)!HV_HF$CGdxyWkPBd8RSl~*O+JVg_|G9g%tdL*2_AIec`o~!9*S6NwU$3;Q)f`5D zlFNOrNz^t}cVRVn5BNs)z|laeBv{1;qWF?WrQv-)ePV?($t0E?k!j8Q&U?M=8mK*b zNvj_;khoWd3E3cG9wq*j zD>#YP`m3)gAaadv5W$QfPp_<%86ri>b za92HVajExw;x%SD=zjLMjqE@9{s39`sG+*ymL1xRR#e)1XW?;6N?F@<;ZGb=YmL#Q zi?!f``n{}|K;}CR&{G{v2>yLl5nY`lnt*wQHC?aOW-_F%9S?2gAzW6Vb!879fj5IZ zroND7*-YX?1ru_`qfq{y&WB*8AlRP3XR?Ykd7=SvHxrzY^j}uIZVzC}imj^qEV(TH zs=Ph#%Lid`NAy%NBR6d`T3I2Sb{3vOx7Y4WKBv(2NhC47g1s~ z@&q)Sb+?&l{h=mp;E+#4xv1zoF&;J(6Wm#LTNAnE;;Q3<_S04qNi8@9lTx^qK>C4$ zU6&583zF)qN1a!GFqIV2Fsz>&pA;0B@FmSQ7czT&m0dWgc*ZFMeBS(tE~i+LqsjQ; zYYq(l{fr$$ygc$(=%(F=*GWnt)*SSsERyX9hMPyf*@;jiMJJ_7_jYfTDS!6kW$KHC zb#d^!TVh@3*1!DVGRcM$*(s1?al$lGaknR_bjN??F1(}JV6Vtj`79&Oh?cz#8Ld!G zoz%)N@clCnA7=hk`MYN;gS?sH`{E7(G1kmxu{+FUzgG%d8Aao{FI34)z641f#1L%9 z&fG4Q`U%Mss{Saao=&}VV*puVTh9Lz8$_-ShL*rfZklkoNEV5*fAh_2v2UAOq49gr zdBq#wtyqf7+pa_Z&8m+)Wg@^BOG{iWzWF%CzW~V;Pq@~ju4vq@6X<3u(fC*LlE|yp z7j+|%)jKH%6S^BMf~O>xC1$A*ovZIB1E5KPbsr|ekNFVs!=IOm&|NQWr}n30?tY^l zrUDa0v#l%r^dop098iu<%GgyRCn>$d*;HA=Fi$b~Sgo2pYw4HI{M3kvb2cqegNNqo zq+WByl407vfYf4lx{#L2NN>gBm0@Aj~!z$-{0cT2azcfhNoCj&|n7K7mCpuzfFQ zcczR4K~1UMYRfjSHdhE%lFqWWV?gTB?Rn~`Jn%tg)G}oJA_&J*ySu44K*nU$w|>55 zxRkzSD@ivl|4*KD$~upY#B7+!%)lhK&RN{mk^kp#xiu^=feP0{-WJyMMNOi<9glE4 z$#BcH<-wPiY2n0f@k)komIsrAyY^+@EM*?3EUYLK670k6S6;gZMWPKUXoFHD)vj{P z6;4S;e2BBJ;58gtw?`(*2(wO$GyOd))edjiWNXns z1A_~Up;0aw*~Smu0{cr|v$4sJ6i*`a3w@bWbA2rNLEOq%YMb#JD z-B@iq6ZqYq{vm?#^YE`D>NAMHINka?>ps~DrbuhtpXA09t`wMT(`kfYs^qB5jV#UW z^lg}iImjvPkEfuBC^~r5FB|ly8Y;XnsD`o@uLZiJXOdI72FksW5x9EB{`#C{2D9(3 zCds-pSTRW_#+8wp=JjG1-AsY>k7XqzYOHtxFQWDtiPRI@(iayHLeQ}U1R zp6?{AK@5bh(Rt(o(ls+l{9zD`8D`3UO9ev{voJ zM280WO`p0Xbl}C#&(I&N0)_nLUN#k&?iB`ypBcS6iY2u`4#~>&U>2q4P#l@`H zo64I{Z-y8=UpN1=st(5wbjf=RkqZBeSB@)m;9r1V(7-wVQ!j$I`|grz^`=u8OdE|> z-jZ9!O37c*o=O!~$3An7L;|HrR9l(1s7hi-ou^mFarzI>q%C zKOp>6lIH~8tq&QPytsfQKeDoBv9~l1?IAbTI_vrb*vrWx663!)oVEFpK8^>Kj!9T} zOtlT&Uv4Y7%OjU_XpQ~}jix;o9kyc@Cnp4mCBrXya&u1Wgn{)qdyAwCa&W`ITdLi< zylJyUQ{69?TL9|bB!w2mFuV1>(X_y(8+0V<18Z*I&cbjO0BMvlV6w{VP}mlYzox)& zh1*cSDhToZFwAIP10y{#VB9txkQ1wdfUeQ|{zF^(hgKc=d}}Saf97B?((j-FvI6*pW|GXRTB|+@E*2@k_MRiwU3SXK0QIJk?+Hty%WF+$MZ>Obpv}07 zS?GLK*MZ?pHbq9!NZH(^v6G{hH0`c&CUCDv4gVzcKrQ>_#qZAbTRGCOU$8k|OE%6$ z3;b;WWN!soU1F+QWV+PP6dTc~SWNUl*v$}_e~pr)ShoLAxojXcWjyKxR!$?j7?4v2 zh*lnu0ce+gw9C^lCC?qN#2cDmqa&7#+yE?0B?@SuZ z<~khVK`7G4Gd$|lJb|Re5ULI z$K_XEq1P53j}>$P@>tE46h9jyy_JS81ZOlN4X!jh|L~Y57C4Tbo5v5&dppMJ9D4Vf z7$4fuw@NBqj*}bnC)EXbpU)S1-HJ3txo+dWQn=Y{JJN3>TUFBdskl9_`^GP0W)g(1 zB=zoxZV5QzlYJ0&2XsNur|0frw~l zII5=v3@tS%Up&~&ePqMUqD0~guhwDAOXNUD8Zz>}SOO?rW!=roO^qvl0CC#Xr6;{^ zQ(XyaUWsL%n|#!Mk>aXDXm(X8I905$ZAiQePRRfIP+n2>E%qK)gG5-kQa)jQSF~N+ z74H*l5rpQ*m^#xbGyg15E56=P)zoZ*VIIECbkjNdu8v>jZd$(szSX-F;|hNAIQ0v! z$Op99f_g)#A!^CeR{0$odMMI9-Ri=kK(*pM$YaQOuH6ygc)qxbViAQF-99dTYpqQtTGpR0#B-u6bj;x_C$;Fxy?K zFcXG-EikrXeB7)WmGI*0I`uB6*9I_MIW?i06{q6>2!dtuii$OoN$E37yW{P>7mbYB z6B70kW)`Rsp|7v@X2V?{5AjGuE=^oD4PLrHxtm#sq@N17wFGR_c~xdHDv6C$tp&OV zl$W*6psp4k776ip$*?uO-p1`VISl{MQ~<9;_qB{5RpUHceNSd`veHub)|$(OnP>Qe zKQVYmrN8u+^!+Ef&(yTkeoJ8f9aaOTmlSwjckf*=QJ;x&w02~O0_#G|vkiX#)@u=! zMfr!$uUXx=_Ty&l6okBOy{HIKd^`L~%mdm`tQJd0qa4NT&Fbm~A85(Mhw^n%$Z;uL z|E%3DLQRA-*~s3BcxZQv7_qFYtLMHilqWnd=k%91u4XN{Dr<~TbkR-2P^ZKy*=%Wk zU18*HQy=M=214+Kk9v7~Pvv3i1Fp;HD5k?|ijK`ZvHkUPp$7>f!3VRBp+E^8&&gsR zZ~Y0b=#ue?P^bh0TwGESq4yn^#$yJ)HpL$~bGF1SUTsX@J1VzvWKwjKW$4?dc-U9RH}B+?HO}JwsekEfTYs4O&h|-9&Z>7Vq-mp*OrVj z=`*kcdu-%r8{)p9^qbThhqsqb?ej3jyzxruGxiQl+rUFpiI*3Mq?I?j3Jhf6S_*pZ zahOYDNqd{aE$c|sm{KE@f0Sh%aa$91XndFcC7+d)yIujH~4+!Z{gqn&0`=b5OcQcq)F*o)cYSg>h9(ODbdoU}??*Jr4} zw?qwVtAnuS1M#FxU38O z64uZ!`90KSB+-AQYntTKu&FlIFSmrwDLV)^P$w^U(F0ivB`@}CNG6JTAd?h3l3n6h zF}N0Ab4}^4-k5X=rGU{p$iv-xF^wAiM&_M?y156@Y{48#D4nXBG|>p}S2WuogH>qP7`K|# zhiGs^3-{V`UG&q)9fMoiu9={2x-hc9^kPFt3G4K4%N)vt<-2kVAli+7FpWpu<-kfn znYga=8_t6Eh*P~r|9F9v2q+z3Ip#94HJ23-;P67I&Uh{7C&tiWPm7F+eQo>N{@m(I z!pQM@-6dH<5;06Hk7>M0V^yz>PxWt0d-+KX*ZN-AKZ&V{kZfflY3jk`R>z~e_E2q$ z^H*?jvVGxR3kg%mz=@bUncoFZhYR;JNW4NWIWDGWfLl_R4z`_w`p3LP6(4CAHIFg& z9l%;js>g!|7OBnl#RvC#IR)xgHX+Xwty^R8?2NIyZA&Prz{Mj0JleG46`XZPY%YP; z*@iYL5jq&LpXsH!MG^MeW3A1p%KoxGhAcVT>GJ8FoK|BH$rcxphjgleB8Rwn5w$GA zsY2TiZ8;n#20^9}JhPasW(Xyu7=L^<&?T;&eqhxD~>8il?fgV{u|xBydta_5RoDHGs;{M{?*FrP!y}DR1k! zrz~AL)kwriKHmF0l*i1uj0h&K`dQPWz+|aggxm#N^Wf{7Vgu8aafa`Ged~C!R%T^A z;bNfsJ-Vj*Ss9ukbi-djL~~}j@rjC!HK76N$@FE(#*EcO4+2eV0Lne}4E_@HVnHTRAol+?NL&YU4_p z%X~B2zpvI=4}Cl!I6oSf%+eBxZ9n;4)8u~A#BEBG`l|TSqkZEI)PyvBM@y@4d@ zpF=>zJN6;iGkM0Ua@=W!{b&i9pC2{s(*}Gv6UI{&lYg$|(?*_h%v=rMN!Eg!eKDER zB(#DD7ZF1A1M^Sm!{4+qZ;89lYm&;Ey)JO{X@W2zlm@ideJ|@jmX}Pf;@3 z6ZDPfBok2iVKkr2Lk^IamTS_(V9iPZU!W8o-1-Z6+b=Lzt-0goU*mv!?Z*_?H&Z^;njA79{L*iG7Ds9-@ADe2 zE9G_h{cL@9dg1X|$Gn?}NS)hdRc_}tEQn;PsBv2B>625Jr}F%nh(JxUtx~#z#Qr;w z)~(N>hkLnk+~~)=%L1zkLk0xy_*lM3(XTl}jD*s`wN*S9HUVV>;@@x0i8WT-kGzWA z;!AEh1KuJdDk_5Jz3T@DVQq))i<%<`GIg31A01sPVBpdt+wlo1H%4i> z^CANFdkz%oVnK@M4ReE?!Zp>>UX=F z*1%||zfI<;-H7KSUM{Q^E?CF{yHoMod36UA+j~k=MdeA90J92AVQ(Ntew{)_}u5H3Jl{%DX1!jGI0= zD)#Q~vp2SsEmMw@eu6LJNOzu#aVGWt6;%Q2Z9l;e9s(U$0?D3A(;V07)$b^#6ssqT z7q_(Ccw+ZINg&sIg~lxrI0~9upIG{svlX@hX@PjcJ8m)l07;PjCaY@E{Pn_5$C;Zf zPu>q-tJ~}SFgH*Sy?)$kI-ta}q0Qz1%${CP0Z9oXN4-lXGe3I+ccTTb!3P{~YM0y( z{x@k^nq1a(nS@ra?kEAGnTU>S**v2j_-I>Rs~Sj1s;aKG9ryJ$&)b=;a!keL~#i?GA`U=<5eCYp205%lK z>t%JYw~h%5EVJ_%QWPm-LCHMuKfE{{*!mukY&QL{T%<9JmJtFIx{?lkN|E2_0i>;~ zYRd2NCC2+RDdzirsU5ps88*lQ$`j>_aX7&B&IWs8v1gF!sRsA+CZ7@G9T;GLU(&T~ zY|%6e+xyEj^HIWD#FOE;DDK_3A1*t5&FNUz7IKjHcTTY-!7|4)jN}k^Y#e8)>A)cK zU9ewf`XEu4L#EaA_MgQ5B9K6@ExpvxtSEV6(h!F~mmbxNYjC%g_oSd_lWdl`=L~?k z#~nygzwj!3*0^PpU!F9LE-y6*XJT6*VWeVyfZ*f3X2EvWEbjw5c~^2t0t5hX$V%g% zlrSUcO%j7^P4xUM#@(IHFJVH{apbwRbEs`LVDrQXFsW1Xa9j8sNy_A2Vny6cNu{^cd}1miJbP zXL3BD9D?7g93;v}%C{gE+FKsPjP|S*k)*X)pxx&xkk2nM$fNmo{c1?AF72ae?x2xT z{{VL&fj18<Ebb zKe$&k^sQ3cPSosYgig}Ls{Iox?Ig^BqlG)h_2%`R-&#C~eER z&wsu^;P43GcN9tz<{V~=cIkC#eQOik3pmEbj7)ZhY<$OVNiX^2p19(t(Y1dtMSCyw#zu<7>t zpO>dd*HD!TyCVp095(QFjxs*)r^-9j&YEq;T9=|%L*$M*r*Q9T?`ma^IDlqC&yWKi z25=dO!Nv}7YFD{`55WWosXfiU8fb!+QlJgUM|^HPl78pDDQ+~l?CpQIrkWJIm6lko zOo1a;BxRhF{q4MUJ5R4TtEFmI@m^je^IhIrwg`?==`w;8h6=>h%L_Zxyvgq#$HJyJQMxkIqfc=soPvi(WFzeGh%o_BWXe~z?_Yx zR02BieHOBHJrd^j?%5q)CyLHF7~E%x21{}dMh*sZ*w&7T2$CIM`qmTuqOpi11##v! zLmn~15IF#zy}1;opq1OcpV!_yJ6M8UU80e1QPy9d&XLuD7|M`1=nmpB)P5X6{i7Yx zmfn9QC23hhi1ELl;~o8*IRtaXE~9A(lz)ltZnCwl@FS+tcritK0Q4<5$J2lFSOb1wApOslh3!b z`IzMQ=Z|b-gVU`)N7Unr7>&Kl6brfI00OQ6+y)0A{G<#Xhd%u@abC(VulWO$Nctkz z#45`?jT1w8r@0b9IcHsn%oo%U!*5KGJt`jy`0mzQyK5OW1UiGW#QWq@uEjw{;Nh4m z#-t2nvk}nOh3eiV)ipcF?-`OinZMQrbMt-GRv9~Z0CR!PO-ZD9gu`bt$7+ofk$s+M zsB&r|WWs(8+8j}u4secE$GjYiI@E)h#prQZBV=qml(q;iRQgH#Ma{}XXFQE>2?2=6XOL|lC>cF+I`$aN zQHt3oXr`2-Gb1SSaCZ>fu)VX$=i0aBxsu+}TgzBXX7&^b<$w#Yky}2a2X|0Cs<~G( zh$duMxskl*gxQGLsf?#58TIITWDoweGVDm#fK4=ttOne4Zk;^l5vbKJ{aI#8UY z_OxHA$Fa4%yn^QO?r%&vFC#ut5kNQt@E{7wy}O>vQn;5f!vyjdEjjs^k`8&~eMcQ@ zcU)w$yq;TVBZ+p0NmTE7bI#B9MnC{|1L;_IIznrbdGRvAe**_(!Pv`@o!R8z4xRI# zQC$?F7P+MKJhvy!V|jI!zk6tWt1G5?4#&3nS{BZ5$;$N$k}!WWp1a~*`}khlK+vt5 zXV`5;!?u1`nT|*++=a;pw(ol3bZt5Q*>44n+)(*b8D+U;K1c&BS%+Pu?H}+gb*(=g z_=4A8md}_7^D`^W_*hXQwke3f5 z6lWlU#Yy9F!2_wu6=W=Sa$AVzb+$y?H=1@Bb}8JXbjjYI&z@_RySS3ZcxFVJTTF=* z;~^v7eU5SS4EOyGyc&R;eZ0ZG%1;`<}=Yfvi=OU*;MhPyacCm4_=os4> zV2E2x9y8|<0t{t|UWX?xRON(!B8QnXNjVcIiQa%ZbB4R3$d|`vvAal3T$T4keD>KoNsv6$Az> zaCklXk=p&Fw-yMlwh+xG<&kALAT}_h0uDlR#~EUJflt-7mzL61x4yVr`^k>zCYx^8 zJTL%Yb{vkqJMpS=T7D%YjtXJqZIUtjnMVHruc!5>qqvn@3V2+Q4?sKOv}`_W7(wS~ za6N@!v$vSsp0(0_+~= zapUr?IavA3xi}zk_}62n+r>SL2_shmKzSYZ))gadLB(92%Tu(py_;lj98VFBHD~#} zwmD&tqmjuUUc7TN>XDlf1;SfGuf$O-Wt1uCTXgH0TQ3tlRD|T)q$xIUr*I3=z|wJJWSdMCzJ+*5W<#tK_yZ zgU2K5{Lf*gqSLM= z4JEgj#uM`tW08^Hp8oYNlhNN}JDQ2-TWy7x%n?WCW20vSlkJ03>UXhSfMQ^W%L;>l zQ1SY4T>XXA^22b?D>FQMSd+;d@t?qcRjC?*XA6KgF#w-jVzZoV!dEn>)XcWc9m2CU z#3nE~VBq7Z`uFS8(zdNE%Uj$}_Bmj>K6A{ls3+%8Luaz}KZXre(<4;1OT|zw6_FNB z>Zd#pO3Sm=FJ-;FN4Sxf?J=$i?Y*)-hbJSwV;J*Yb}lbNQWu_i?j&g>m6Tv2F3AF5 z{{R;!1m}a0Gx$~AH|*DX6t}jsT}H`u=4R=CdRqZ|Stm*#L7 z91)NYPfCL3(g`Jdi-B-&*4crEIRu|%MHwYW0B1YBNhI|qwRD9G;QM*742vYL81h2^ zaC!Qg&S;~wv(#=NMUH8&UO62{EWT@SeX5~eP)^-H%vM%1JUgNr9a19>tsA8Ahn^{- zD!?8?9^bEX>re3(mXHM913=DM_!McnCyQc2)?S3U;G?_F{l zGIkvO-aAr+RogApa*d19-=K_4sEoyr%tq6X?wofV{MhJo$2A;EOl@$57%S{$CnI(T zBl-RnhifZ&_UrQEMazw&=05(lw{B0`CWro6qp4Nw4Q%vwB1lmWn>*XX8F`TX$1DLj z>~Vwn(i_7C%#cU25{bQ;kTA|hIR60kdsKQOu(Z6n&+nE#9Q7QnR?`^jw@@wV^OcFn zZu|qCK$=N!Ww&=`h{D-Ic>B4cFil)7?%dY`NMo03$>xu| zjJ!58k`HswBifwzW<^B|MB7yDJy$r-AAui-;YjY$leLK4yN^9j9MyZU5_Z}E{n+R| z+Od-NtV~_a2ykE~*M4)g!*k|yoDb)ZVd+-vuOpIKAs$?9G++`lxHvs|&OJECZ+hgW zxRxunjU;7M$xshW^{%eY)*GabS(9|1XA*A7A28^6?^)EQxo&M4N;@*jYS%W_7Z%=Z ztd{{wKsesRorDg#2PZy*2C^1wrn;3ayvPuS5^Zc8-)Qa9kRn9ka`Sc4l;RA zX}9eRHjqckvng%Z&UxwA{Nk!hZxi0TGUs;2Ad`YfJmaToOaB0#;yBxt^W8E2$Weh> z#wl4LOJs`gd3W|tA}#3%#^S%kJ;>)C)f&jC8aU-;I0O!$9{sv={&Q5=bs+e+&~&@_xj~=n6%&6h{6QVaVsUJ^SLR%WDL1 zT(U%}UKK1y8Ts-3D{^HY+7|KST?Ksa~4tohydF^6P0JD73lfl}#r*D#|h zO#4ECgUILWQz}YP)NQw^dsDmf?-0mif&jil6en@R6TI{U + + + + + + ./src + + + + + + + + ./tests + ./tests/OSS/Tests/BucketCnameTest.php + + + diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/samples/Bucket.php b/vendor/vendor/aliyuncs/oss-sdk-php/samples/Bucket.php new file mode 100644 index 0000000..a54b74e --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/samples/Bucket.php @@ -0,0 +1,254 @@ +createBucket($bucket, OssClient::OSS_ACL_TYPE_PUBLIC_READ_WRITE); +Common::println("bucket $bucket created"); + +// Check whether a bucket exists +$doesExist = $ossClient->doesBucketExist($bucket); +Common::println("bucket $bucket exist? " . ($doesExist ? "yes" : "no")); + +// Get the region of bucket +$regions = $ossClient->getBucketLocation($bucket); +Common::println("bucket $bucket region: " .print_r($regions,true)); + +// Get the meta of a bucket +$metas = $ossClient->getBucketMeta($bucket); +Common::println("bucket $bucket meta: " .print_r($metas,true)); + +// Get the info of bucket +$info = $ossClient->getBucketInfo($bucket); +Common::println("bucket name:".$info->getName()."\n"); +Common::println("bucket location:". $info->getLocation()."\n"); +Common::println("bucket creation time:".$info->getCreateDate()."\n"); +Common::println("bucket storage class:".$info->getStorageClass()."\n"); +Common::println("bucket extranet endpoint:".$info->getExtranetEndpoint()."\n"); +Common::println("bucket intranet endpoint:".$info->getIntranetEndpoint()."\n"); + + +// Get the bucket list +$bucketListInfo = $ossClient->listBuckets(); + +// Set bucket ACL +$ossClient->putBucketAcl($bucket, OssClient::OSS_ACL_TYPE_PUBLIC_READ_WRITE); +Common::println("bucket $bucket acl put"); +// Get bucket ACL +$acl = $ossClient->getBucketAcl($bucket); +Common::println("bucket $bucket acl get: " . $acl); + + +//******************************* For complete usage, see the following functions **************************************************** + +createBucket($ossClient, $bucket); +doesBucketExist($ossClient, $bucket); +getBucketLocation($ossClient, $bucket); +getBucketMeta($ossClient,$bucket); +getBucketInfo($ossClient, $bucket); +deleteBucket($ossClient, $bucket); +putBucketAcl($ossClient, $bucket); +getBucketAcl($ossClient, $bucket); +listBuckets($ossClient); + +/** + * Create a new bucket + * acl indicates the access permission of a bucket, including: private, public-read-only/private-read-write, and public read-write. + * Private indicates that only the bucket owner or authorized users can access the data.. + * The three permissions are separately defined by (OssClient::OSS_ACL_TYPE_PRIVATE,OssClient::OSS_ACL_TYPE_PUBLIC_READ, OssClient::OSS_ACL_TYPE_PUBLIC_READ_WRITE) + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket Name of the bucket to create + * @return null + */ +function createBucket($ossClient, $bucket) +{ + try { + $ossClient->createBucket($bucket, OssClient::OSS_ACL_TYPE_PUBLIC_READ_WRITE); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); +} + +/** + * Check whether a bucket exists. + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + */ +function doesBucketExist($ossClient, $bucket) +{ + try { + $res = $ossClient->doesBucketExist($bucket); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + if ($res === true) { + print(__FUNCTION__ . ": OK" . "\n"); + } else { + print(__FUNCTION__ . ": FAILED" . "\n"); + } +} + +/** + * Get the info of bucket + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + */ +function getBucketInfo($ossClient, $bucket) +{ + try { + $info = $ossClient->getBucketInfo($bucket); + printf("bucket name:%s\n", $info->getName()); + printf("bucket location:%s\n", $info->getLocation()); + printf("bucket creation time:%s\n", $info->getCreateDate()); + printf("bucket storage class:%s\n", $info->getStorageClass()); + printf("bucket extranet endpoint:%s\n", $info->getExtranetEndpoint()); + printf("bucket intranet endpoint:%s\n", $info->getIntranetEndpoint()); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); +} + + +/** + * Get the meta of a bucket + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + */ +function getBucketLocation($ossClient, $bucket) +{ + try { + $regions = $ossClient->getBucketLocation($bucket); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + + print("bucket $bucket region: " .print_r($regions,true)); + +} + + +/** + * Get the bucket's meta + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + */ +function getBucketMeta($ossClient, $bucket) +{ + try { + $metas = $ossClient->getBucketMeta($bucket); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); + print("bucket $bucket meta: " .print_r($metas,true)); +} + +/** + * Delete a bucket. If the bucket is not empty, the deletion fails. + * A bucket which is not empty indicates that it does not contain any objects or parts that are not completely uploaded during multipart upload + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket Name of the bucket to delete + * @return null + */ +function deleteBucket($ossClient, $bucket) +{ + try { + $ossClient->deleteBucket($bucket); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); +} + +/** + * Set bucket ACL + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function putBucketAcl($ossClient, $bucket) +{ + $acl = OssClient::OSS_ACL_TYPE_PRIVATE; + try { + $ossClient->putBucketAcl($bucket, $acl); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); +} + + +/** + * Get bucket ACL + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function getBucketAcl($ossClient, $bucket) +{ + try { + $res = $ossClient->getBucketAcl($bucket); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); + print('acl: ' . $res); +} + + +/** + * List all buckets + * + * @param OssClient $ossClient OssClient instance + * @return null + */ +function listBuckets($ossClient) +{ + $bucketList = null; + try { + $bucketListInfo = $ossClient->listBuckets(); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); + $bucketList = $bucketListInfo->getBucketList(); + foreach ($bucketList as $bucket) { + print($bucket->getLocation() . "\t" . $bucket->getName() . "\t" . $bucket->getCreatedate() . "\n"); + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/samples/BucketCname.php b/vendor/vendor/aliyuncs/oss-sdk-php/samples/BucketCname.php new file mode 100644 index 0000000..c39eb40 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/samples/BucketCname.php @@ -0,0 +1,91 @@ +'; +$ossClient->addBucketCname($bucket, $myDomain); + +// View cname records +$cnameConfig = $ossClient->getBucketCname($bucket); +Common::println("bucket $bucket cname:" . $cnameConfig->serializeToXml()); + +// Delete bucket cname +$myDomain = ''; +$ossClient->deleteBucketCname($bucket,$myDomain); +Common::println("bucket $bucket cname deleted"); + +//******************************* For complete usage, see the following functions **************************************************** + +addBucketCname($ossClient, $bucket); +getBucketCname($ossClient, $bucket); +deleteBucketCname($ossClient, $bucket); + +/** + * Set bucket cname + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function addBucketCname($ossClient, $bucket) +{ + // Set up a custom domain name. + $myDomain = ''; + try { + $ossClient->addBucketCname($bucket, $myDomain); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); +} + +/** + * Get bucket cname + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function getBucketCname($ossClient, $bucket) +{ + try { + $cnameConfig = $ossClient->getBucketCname($bucket); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); + print($cnameConfig->serializeToXml() . "\n"); +} + +/** + * Delete bucket cname + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function deleteBucketCname($ossClient, $bucket) +{ + $myDomain = ''; + try { + $ossClient->deleteBucketCname($bucket, $myDomain); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/samples/BucketCors.php b/vendor/vendor/aliyuncs/oss-sdk-php/samples/BucketCors.php new file mode 100644 index 0000000..f5f8f21 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/samples/BucketCors.php @@ -0,0 +1,171 @@ +addAllowedHeader("x-oss-header"); +$rule->addAllowedOrigin("http://www.b.com"); +$rule->addAllowedMethod("POST"); +$rule->setMaxAgeSeconds(10); +$corsConfig->addRule($rule); +$ossClient->putBucketCors($bucket, $corsConfig); +Common::println("bucket $bucket corsConfig created:" . $corsConfig->serializeToXml()); + +// Get cors configuration +$corsConfig = $ossClient->getBucketCors($bucket); + +if ($corsConfig->getResponseVary()){ + printf("Response Vary : true" .PHP_EOL); +}else{ + printf("Response Vary : false" .PHP_EOL); +} + +foreach ($corsConfig->getRules() as $key => $rule){ + if($rule->getAllowedHeaders()){ + foreach($rule->getAllowedHeaders() as $header){ + printf("Allowed Headers :" .$header .PHP_EOL); + } + } + if ($rule->getAllowedMethods()){ + foreach($rule->getAllowedMethods() as $method){ + printf("Allowed Methods :" .$method . PHP_EOL); + } + + } + if($rule->getAllowedOrigins()){ + foreach($rule->getAllowedOrigins() as $origin){ + printf("Allowed Origins :" .$origin , PHP_EOL); + } + + } + if($rule->getExposeHeaders()){ + foreach($rule->getExposeHeaders() as $exposeHeader){ + printf("Expose Headers :" .$exposeHeader . PHP_EOL); + } + } + printf("Max Age Seconds :" .$rule->getMaxAgeSeconds() .PHP_EOL); + +} + +// Delete cors configuration +$ossClient->deleteBucketCors($bucket); +Common::println("bucket $bucket corsConfig deleted"); + +//******************************* For complete usage, see the following functions ***************************************************** + +putBucketCors($ossClient, $bucket); +getBucketCors($ossClient, $bucket); +deleteBucketCors($ossClient, $bucket); +getBucketCors($ossClient, $bucket); + +/** + * Set bucket cores + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function putBucketCors($ossClient, $bucket) +{ + $corsConfig = new CorsConfig(); + $rule = new CorsRule(); + $rule->addAllowedHeader("x-oss-header"); + $rule->addAllowedOrigin("http://www.b.com"); + $rule->addAllowedMethod("POST"); + $rule->setMaxAgeSeconds(10); + $corsConfig->addRule($rule); + + try { + $ossClient->putBucketCors($bucket, $corsConfig); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); +} + +/** + * Get and print the cors configuration of a bucket + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function getBucketCors($ossClient, $bucket) +{ + $corsConfig = null; + try { + $corsConfig = $ossClient->getBucketCors($bucket); + + if ($corsConfig->getResponseVary()){ + printf("Response Vary : true" .PHP_EOL); + }else{ + printf("Response Vary : false" .PHP_EOL); + } + foreach ($corsConfig->getRules() as $key => $rule){ + if($rule->getAllowedHeaders()){ + foreach($rule->getAllowedHeaders() as $header){ + printf("Allowed Headers :" .$header .PHP_EOL); + } + } + if ($rule->getAllowedMethods()){ + foreach($rule->getAllowedMethods() as $method){ + printf("Allowed Methods :" .$method . PHP_EOL); + } + + } + if($rule->getAllowedOrigins()){ + foreach($rule->getAllowedOrigins() as $origin){ + printf("Allowed Origins :" .$origin , PHP_EOL); + } + + } + if($rule->getExposeHeaders()){ + foreach($rule->getExposeHeaders() as $exposeHeader){ + printf("Expose Headers :" .$exposeHeader . PHP_EOL); + } + } + printf("Max Age Seconds :" .$rule->getMaxAgeSeconds() .PHP_EOL); + + } + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); +} + +/** + * Delete all cors configuraiton of a bucket + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function deleteBucketCors($ossClient, $bucket) +{ + try { + $ossClient->deleteBucketCors($bucket); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); +} + diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/samples/BucketEncryption.php b/vendor/vendor/aliyuncs/oss-sdk-php/samples/BucketEncryption.php new file mode 100644 index 0000000..0e61d5b --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/samples/BucketEncryption.php @@ -0,0 +1,98 @@ +putBucketEncryption($bucket, $config); +Common::println("bucket $bucket encryoption created"); + +$config = $ossClient->getBucketEncryption($bucket); +Common::println("bucket $bucket encryoption:".$config->serializeToXml()); + +$config = $ossClient->deleteBucketEncryption($bucket); +Common::println("bucket $bucket encryoption has deleted"); + +//******************************* For complete usage, see the following functions **************************************************** +putBucketEncryption($ossClient, $bucket); +getBucketEncryption($ossClient, $bucket); +deleteBucketEncryption($ossClient, $bucket); + +/** + * Configure Bucket encryption + * @param OssClient $ossClient OssClient instance + * @param string $bucket Name of the bucket to create + * @return null + */ + +function putBucketEncryption($ossClient,$bucket){ + try { + // Set Bucket's default server-side encryption method to OSS fully managed encryption (SSE-OSS). + $config = new ServerSideEncryptionConfig("AES256"); + // Set Bucket's default server-side encryption method to KMS, and do not specify a CMK ID. + //$config = new ServerSideEncryptionConfig("KMS"); + // Set Bucket's default server-side encryption method to KMS, and specify the CMK ID. + //$config = new ServerSideEncryptionConfig("KMS", "your kms id"); + $ossClient->putBucketEncryption($bucket, $config); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); +} + +/** + * Get Bucket encryption + * @param OssClient $ossClient OssClient instance + * @param string $bucket Name of the bucket to create + * @return null + */ + +function getBucketEncryption($ossClient,$bucket){ + try { + $config = $ossClient->getBucketEncryption($bucket); + print($config->getSSEAlgorithm()); + print($config->getKMSMasterKeyID()); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); +} + + +/** + * Delete Bucket encryption + * @param OssClient $ossClient OssClient instance + * @param string $bucket Name of the bucket to create + * @return null + */ + +function deleteBucketEncryption($ossClient,$bucket){ + try { + $ossClient->deleteBucketEncryption($bucket); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); +} + diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/samples/BucketLifecycle.php b/vendor/vendor/aliyuncs/oss-sdk-php/samples/BucketLifecycle.php new file mode 100644 index 0000000..04d2edd --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/samples/BucketLifecycle.php @@ -0,0 +1,109 @@ +addRule($lifecycleRule); +$ossClient->putBucketLifecycle($bucket, $lifecycleConfig); +Common::println("bucket $bucket lifecycleConfig created:" . $lifecycleConfig->serializeToXml()); + +// Get lifecycle configuration +$lifecycleConfig = $ossClient->getBucketLifecycle($bucket); +Common::println("bucket $bucket lifecycleConfig fetched:" . $lifecycleConfig->serializeToXml()); + +// Delete bucket lifecycle configuration +$ossClient->deleteBucketLifecycle($bucket); +Common::println("bucket $bucket lifecycleConfig deleted"); + + +//***************************** For complete usage, see the following functions *********************************************** + +putBucketLifecycle($ossClient, $bucket); +getBucketLifecycle($ossClient, $bucket); +deleteBucketLifecycle($ossClient, $bucket); +getBucketLifecycle($ossClient, $bucket); + +/** + * Set bucket lifecycle configuration + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function putBucketLifecycle($ossClient, $bucket) +{ + $lifecycleConfig = new LifecycleConfig(); + $actions = array(); + $actions[] = new LifecycleAction(OssClient::OSS_LIFECYCLE_EXPIRATION, OssClient::OSS_LIFECYCLE_TIMING_DAYS, 3); + $lifecycleRule = new LifecycleRule("delete obsoleted files", "obsoleted/", "Enabled", $actions); + $lifecycleConfig->addRule($lifecycleRule); + $actions = array(); + $actions[] = new LifecycleAction(OssClient::OSS_LIFECYCLE_EXPIRATION, OssClient::OSS_LIFECYCLE_TIMING_DATE, '2022-10-12T00:00:00.000Z'); + $lifecycleRule = new LifecycleRule("delete temporary files", "temporary/", "Enabled", $actions); + $lifecycleConfig->addRule($lifecycleRule); + try { + $ossClient->putBucketLifecycle($bucket, $lifecycleConfig); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); +} + +/** + * Get bucket lifecycle configuration + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function getBucketLifecycle($ossClient, $bucket) +{ + $lifecycleConfig = null; + try { + $lifecycleConfig = $ossClient->getBucketLifecycle($bucket); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); + print($lifecycleConfig->serializeToXml() . "\n"); +} + +/** + * Delete bucket lifecycle configuration + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function deleteBucketLifecycle($ossClient, $bucket) +{ + try { + $ossClient->deleteBucketLifecycle($bucket); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); +} + + diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/samples/BucketLogging.php b/vendor/vendor/aliyuncs/oss-sdk-php/samples/BucketLogging.php new file mode 100644 index 0000000..eef71f2 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/samples/BucketLogging.php @@ -0,0 +1,95 @@ +putBucketLogging($bucket, $bucket, "access.log", array()); +Common::println("bucket $bucket lifecycleConfig created"); + +// Get bucket access logging rules +$loggingConfig = $ossClient->getBucketLogging($bucket, array()); +Common::println("bucket $bucket lifecycleConfig fetched:" . $loggingConfig->serializeToXml()); + +// Delete bucket access logging rules +$loggingConfig = $ossClient->getBucketLogging($bucket, array()); +Common::println("bucket $bucket lifecycleConfig deleted"); + +//******************************* For complete usage, see the following functions **************************************************** + +putBucketLogging($ossClient, $bucket); +getBucketLogging($ossClient, $bucket); +deleteBucketLogging($ossClient, $bucket); +getBucketLogging($ossClient, $bucket); + +/** + * Set bucket logging configuration + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function putBucketLogging($ossClient, $bucket) +{ + $option = array(); + // Access logs are stored in the same bucket. + $targetBucket = $bucket; + $targetPrefix = "access.log"; + + try { + $ossClient->putBucketLogging($bucket, $targetBucket, $targetPrefix, $option); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); +} + +/** + * Get bucket logging configuration + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function getBucketLogging($ossClient, $bucket) +{ + $loggingConfig = null; + $options = array(); + try { + $loggingConfig = $ossClient->getBucketLogging($bucket, $options); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); + print($loggingConfig->serializeToXml() . "\n"); +} + +/** + * Delete bucket logging configuration + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function deleteBucketLogging($ossClient, $bucket) +{ + try { + $ossClient->deleteBucketLogging($bucket); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/samples/BucketPayment.php b/vendor/vendor/aliyuncs/oss-sdk-php/samples/BucketPayment.php new file mode 100644 index 0000000..ad04555 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/samples/BucketPayment.php @@ -0,0 +1,116 @@ +putBucketRequestPayment($bucket, "Requester"); + +//Get requester payment mode configuration +$payer = $ossClient->getBucketRequestPayment($bucket); +Common::println("bucket $bucket Payer:".$payer.PHP_EOL); + +//Third-party paid access to Object +$options = array( + OssClient::OSS_HEADERS => array( + OssClient::OSS_REQUEST_PAYER => 'requester', + )); + +$content = "hello"; +$object = "object"; + +//PutObject interface to specify the payer +$ossClient->putObject($bucket, $object, $content, $options); + +// GetObject interface to specify the payer +$ossClient->getObject($bucket, $object, $options); + +// DeleteObject interface to specify the payer +$ossClient->deleteObject($bucket, $object, $options); + +//******************************* For complete usage, see the following functions **************************************************** + +putBucketRequestPayment($ossClient,$bucket); +getBucketRequestPayment($ossClient,$bucket); +setObjectPayment($ossClient,$bucket); + +/** + * Set requester payment mode + * @param OssClient $ossClient OssClient instance + * @param string $bucket Name of the bucket to create + * @return null + */ +function putBucketRequestPayment($ossClient, $bucket) +{ + try { + $ossClient->putBucketRequestPayment($bucket, "Requester"); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + + print(__FUNCTION__ . ": OK" . "\n"); +} + + +/** + * Get payment mode of bucket + * @param OssClient $ossClient OssClient instance + * @param string $bucket Name of the bucket to create + * @return null + */ +function getBucketRequestPayment($ossClient, $bucket) +{ + try { + $payer = $ossClient->getBucketRequestPayment($bucket); + print("bucket $bucket Payer:".$payer.PHP_EOL); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + + print(__FUNCTION__ . ": OK" . "\n"); +} + +/** + * Set payment mode of object + * @param OssClient $ossClient OssClient instance + * @param string $bucket Name of the bucket to create + * @return null + */ +function setObjectPayment($ossClient,$bucket){ + // Specify the payment model for the requester. + $options = array( + OssClient::OSS_HEADERS => array( + OssClient::OSS_REQUEST_PAYER => 'requester', + )); + + try { + + $content = "hello"; + $object = "object"; + //PutObject interface to specify the payer + $ossClient->putObject($bucket, $object, $content, $options); + // GetObject interface to specify the payer + $ossClient->getObject($bucket, $object, $options); + // DeleteObject interface to specify the payer + $ossClient->deleteObject($bucket, $object, $options); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + + print(__FUNCTION__ . ": OK" . "\n"); +} + + diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/samples/BucketPolicy.php b/vendor/vendor/aliyuncs/oss-sdk-php/samples/BucketPolicy.php new file mode 100644 index 0000000..333efac --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/samples/BucketPolicy.php @@ -0,0 +1,123 @@ +putBucketPolicy($bucket, $policy); + +// Get bucket pllicy +$policy = $ossClient->getBucketPolicy($bucket); +Common::println("bucket $bucket policy: " . $policy); + + +// Delete bucket pllicy +$policy = $ossClient->deleteBucketPolicy($bucket); + +//******************************* For complete usage, see the following functions **************************************************** + +putBucketPolicy($ossClient, $bucket); +getBucketPolicy($ossClient, $bucket); +deleteBucketPolicy($ossClient, $bucket); + +/** + * Set Bucket Policy + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket Name of the bucket to create + * @return null + */ +function putBucketPolicy($ossClient, $bucket) +{ + $policy = <<< BBBB +{ + "Version":"1", + "Statement":[ + { + "Action":[ + "oss:PutObject", + "oss:GetObject" + ], + "Effect":"Allow", + "Resource":["acs:oss:*:*:*/user1/*"] + } + ] +} +BBBB; + + try { + $ossClient->putBucketPolicy($bucket, $policy); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + + print(__FUNCTION__ . ": OK" . "\n"); +} + + +/** + * Get Bucket Policy + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket Name of the bucket to create + * @return null + */ +function getBucketPolicy($ossClient, $bucket) +{ + try { + $policy = $ossClient->getBucketPolicy($bucket); + print($policy); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + + print(__FUNCTION__ . ": OK" . "\n"); +} + + +/** + * Delete Bucket Policy + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket Name of the bucket to create + * @return null + */ +function deleteBucketPolicy($ossClient, $bucket) +{ + try { + $ossClient->deleteBucketPolicy($bucket); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + + print(__FUNCTION__ . ": OK" . "\n"); +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/samples/BucketReferer.php b/vendor/vendor/aliyuncs/oss-sdk-php/samples/BucketReferer.php new file mode 100644 index 0000000..628f784 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/samples/BucketReferer.php @@ -0,0 +1,101 @@ +setAllowEmptyReferer(true); +$refererConfig->addReferer("www.aliiyun.com"); +$refererConfig->addReferer("www.aliiyuncs.com"); +$ossClient->putBucketReferer($bucket, $refererConfig); +Common::println("bucket $bucket refererConfig created:" . $refererConfig->serializeToXml()); +// Get referer whitelist +$refererConfig = $ossClient->getBucketReferer($bucket); +Common::println("bucket $bucket refererConfig fetched:" . $refererConfig->serializeToXml()); + +// Delete referrer whitelist +$refererConfig = new RefererConfig(); +$ossClient->putBucketReferer($bucket, $refererConfig); +Common::println("bucket $bucket refererConfig deleted"); + + +//******************************* For complete usage, see the following functions **************************************************** + +putBucketReferer($ossClient, $bucket); +getBucketReferer($ossClient, $bucket); +deleteBucketReferer($ossClient, $bucket); +getBucketReferer($ossClient, $bucket); + +/** + * Set bucket referer configuration + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function putBucketReferer($ossClient, $bucket) +{ + $refererConfig = new RefererConfig(); + $refererConfig->setAllowEmptyReferer(true); + $refererConfig->addReferer("www.aliiyun.com"); + $refererConfig->addReferer("www.aliiyuncs.com"); + try { + $ossClient->putBucketReferer($bucket, $refererConfig); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); +} + +/** + * Get bucket referer configuration + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function getBucketReferer($ossClient, $bucket) +{ + $refererConfig = null; + try { + $refererConfig = $ossClient->getBucketReferer($bucket); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); + print($refererConfig->serializeToXml() . "\n"); +} + +/** + * Delete bucket referer configuration + * Referer whitelist cannot be directly deleted. So use a empty one to overwrite it. + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function deleteBucketReferer($ossClient, $bucket) +{ + $refererConfig = new RefererConfig(); + try { + $ossClient->putBucketReferer($bucket, $refererConfig); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/samples/BucketStat.php b/vendor/vendor/aliyuncs/oss-sdk-php/samples/BucketStat.php new file mode 100644 index 0000000..43c03e6 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/samples/BucketStat.php @@ -0,0 +1,65 @@ +getBucketStat($bucket); +Common::println("Bucket ".$bucket." current storage is:".$stat->getStorage().PHP_EOL); +Common::println("Bucket ".$bucket." object count is:".$stat->getObjectCount().PHP_EOL); +Common::println("Bucket ".$bucket." multipart upload count is:".$stat->getMultipartUploadCount().PHP_EOL); +Common::println("Bucket ".$bucket." live channel count is:".$stat->getLiveChannelCount().PHP_EOL); +Common::println("Bucket ".$bucket." last modified time is:".$stat->getLastModifiedTime().PHP_EOL); +Common::println("Bucket ".$bucket." standard storage is:".$stat->getStandardStorage().PHP_EOL); +Common::println("Bucket ".$bucket." standard object count is:".$stat->getStandardObjectCount().PHP_EOL); +Common::println("Bucket ".$bucket." infrequent access storage is:".$stat->getInfrequentAccessStorage().PHP_EOL); +Common::println("Bucket ".$bucket." infrequent access real storage is:".$stat->getInfrequentAccessRealStorage().PHP_EOL); +Common::println("Bucket ".$bucket." infrequent access object count is:".$stat->getInfrequentAccessObjectCount().PHP_EOL); +Common::println("Bucket ".$bucket." archive storage is:".$stat->getArchiveStorage().PHP_EOL); +Common::println("Bucket ".$bucket." archive real storage is:".$stat->getArchiveRealStorage().PHP_EOL); +Common::println("Bucket ".$bucket." archive object count is:".$stat->getArchiveObjectCount().PHP_EOL); +Common::println("Bucket ".$bucket." cold archive storage is:".$stat->getColdArchiveStorage().PHP_EOL); +Common::println("Bucket ".$bucket." cold archive real storage is:".$stat->getColdArchiveRealStorage().PHP_EOL); +Common::println("Bucket ".$bucket." cold archive object count is:".$stat->getColdArchiveObjectCount().PHP_EOL); + +//******************************* For complete usage, see the following functions **************************************************** +getBucketStat($ossClient,$bucket); +/** + * get bucket stat + * @param OssClient $ossClient OssClient instance + * @param string $bucket Name of the bucket to create + * @return null + */ +function getBucketStat($ossClient, $bucket) +{ + try { + $stat = $ossClient->getBucketStat($bucket); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + printf("Bucket ".$bucket." current storage is:".$stat->getStorage().PHP_EOL); + printf("Bucket ".$bucket." object count is:".$stat->getObjectCount().PHP_EOL); + printf("Bucket ".$bucket." multipart upload count is:".$stat->getMultipartUploadCount().PHP_EOL); + printf("Bucket ".$bucket." live channel count is:".$stat->getLiveChannelCount().PHP_EOL); + printf("Bucket ".$bucket." last modified time is:".$stat->getLastModifiedTime().PHP_EOL); + printf("Bucket ".$bucket." standard storage is:".$stat->getStandardStorage().PHP_EOL); + printf("Bucket ".$bucket." standard object count is:".$stat->getStandardObjectCount().PHP_EOL); + printf("Bucket ".$bucket." infrequent access storage is:".$stat->getInfrequentAccessStorage().PHP_EOL); + printf("Bucket ".$bucket." infrequent access real storage is:".$stat->getInfrequentAccessRealStorage().PHP_EOL); + printf("Bucket ".$bucket." infrequent access object count is:".$stat->getInfrequentAccessObjectCount().PHP_EOL); + printf("Bucket ".$bucket." archive storage is:".$stat->getArchiveStorage().PHP_EOL); + printf("Bucket ".$bucket." archive real storage is:".$stat->getArchiveRealStorage().PHP_EOL); + printf("Bucket ".$bucket." archive object count is:".$stat->getArchiveObjectCount().PHP_EOL); + printf("Bucket ".$bucket." cold archive storage is:".$stat->getColdArchiveStorage().PHP_EOL); + printf("Bucket ".$bucket." cold archive real storage is:".$stat->getColdArchiveRealStorage().PHP_EOL); + printf("Bucket ".$bucket." cold archive object count is:".$stat->getColdArchiveObjectCount().PHP_EOL); + print(__FUNCTION__ . ": OK" . "\n"); +} \ No newline at end of file diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/samples/BucketTags.php b/vendor/vendor/aliyuncs/oss-sdk-php/samples/BucketTags.php new file mode 100644 index 0000000..e361eaa --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/samples/BucketTags.php @@ -0,0 +1,112 @@ +addTag(new Tag("key1", "value1")); +$config->addTag(new Tag("key2", "value2")); +$ossClient->putBucketTags($bucket, $config); + +// Get bucket tags +$config = $ossClient->getBucketTags($bucket); +Common::println("bucket $bucket tags: ".$config->serializeToXml()); + +// Delete bucket tags + +// Delete the specified tag of the bucket. +$tags = array(); +$tags[] = new Tag("key1", "value1"); +$tags[] = new Tag("key2", "value2"); +$ossClient->deleteBucketTags($bucket, $tags); + +// Delete all tags in the bucket. +$ossClient->deleteBucketTags($bucket); + +//******************************* For complete usage, see the following functions **************************************************** + +putBucketTags($ossClient, $bucket); +getBucketTags($ossClient, $bucket); +deleteBucketTags($ossClient, $bucket); + + +/** + * Create bucket tag + * @param OssClient $ossClient OssClient instance + * @param string $bucket Name of the bucket to create + * @return null + */ +function putBucketTags($ossClient, $bucket) +{ + try { + // 设置Bucket标签。 + $config = new TaggingConfig(); + $config->addTag(new Tag("key1", "value1")); + $config->addTag(new Tag("key2", "value2")); + $ossClient->putBucketTags($bucket, $config); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + + print(__FUNCTION__ . ": OK" . "\n"); +} + + +/** + * get bucket tag + * @param OssClient $ossClient OssClient instance + * @param string $bucket Name of the bucket to create + * @return null + */ +function getBucketTags($ossClient, $bucket) +{ + try { + $config = $ossClient->getBucketTags($bucket); + print_r($config->getTags()); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + + print(__FUNCTION__ . ": OK" . "\n"); +} + +/** + * delete bucket tag + * @param OssClient $ossClient OssClient instance + * @param string $bucket Name of the bucket to create + * @return null + */ +function deleteBucketTags($ossClient, $bucket) +{ + try { + // Delete the specified tag of the bucket. + $tags = array(); + $tags[] = new Tag("key1", "value1"); + $tags[] = new Tag("key2", "value2"); + $ossClient->deleteBucketTags($bucket, $tags); + + // Delete all tags in the bucket. + //$ossClient->deleteBucketTags($bucket); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + + print(__FUNCTION__ . ": OK" . "\n"); +} + diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/samples/BucketTransferAcceleration.php b/vendor/vendor/aliyuncs/oss-sdk-php/samples/BucketTransferAcceleration.php new file mode 100644 index 0000000..ee112db --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/samples/BucketTransferAcceleration.php @@ -0,0 +1,61 @@ +sfer acceleration +$enabled = true; // set true to enable transfer acceleration; set false to disalbe transfer acceleration +$ossClient->putBucketTransferAcceleration($bucket, $enabled); +printf('putBucketTransferAcceleration SUCCESS' . "\n"); + + +// get transfer acceleration +$result = $ossClient->getBucketTransferAcceleration($bucket); +printf('getBucketTransferAcceleration Status:%s'."\n",$result); + + +//******************************* For complete usage, see the following functions **************************************************** +putBucketTransferAcceleration($ossClient,$bucket); +getBucketTransferAcceleration($bucket); + +/** + * @param $ossClient OssClient + * @param $bucket bucket_name string + * @param $enabled string + */ +function putBucketTransferAcceleration($ossClient, $bucket, $enabled) +{ + try{ + $enabled = true; // set true to enable transfer acceleration; set false to disalbe transfer acceleration + $ossClient->putBucketTransferAcceleration($bucket,$enabled); + printf('putBucketTransferAcceleration SUCCESS' . "\n"); + } catch(OssException $e) { + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); +} + +/** + * @param $ossClient OssClient + * @param $bucket bucket_name string + */ +function getBucketTransferAcceleration($ossClient, $bucket) +{ + try{ + $result = $ossClient->getBucketTransferAcceleration($bucket); + printf('getBucketTransferAcceleration Status:%s'."\n",$result); + } catch(OssException $e) { + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/samples/BucketVersion.php b/vendor/vendor/aliyuncs/oss-sdk-php/samples/BucketVersion.php new file mode 100644 index 0000000..a1b4ed6 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/samples/BucketVersion.php @@ -0,0 +1,235 @@ +putBucketVersioning($bucket, "Enabled"); +Common::println("bucket $bucket version Enabled"); +// show all object list +$option = array( + OssClient::OSS_KEY_MARKER => null, + OssClient::OSS_VERSION_ID_MARKER => null +); +$bool = true; +while ($bool) { + $result = $ossClient->listObjectVersions($bucket, $option); + ## View the version information of the listed object. + foreach ($result->getObjectVersionList() as $key => $info) { + Common::println("key name: " . $info->getKey()); + Common::println("versionid: " . $info->getVersionId()); + Common::println("Is latest: " . $info->getIsLatest()); + } + + ## View the version information that lists the deletion flags. + foreach ($result->getDeleteMarkerList() as $key => $info) { + Common::println("del_maker key name: " . $info->getKey()); + Common::println("del_maker versionid: " . $info->getVersionId()); + Common::println("del_maker Is latest: " . $info->getIsLatest()); + } + + if ($result->getIsTruncated() === 'true') { + $option = array( + OssClient::OSS_KEY_MARKER => $result->getNextKeyMarker(), + OssClient::OSS_VERSION_ID_MARKER => $result->getNextVersionIdMarker() + ); + } else { + $bool = false; + } +} + +// show the prefix object + +$option = array( + OssClient::OSS_KEY_MARKER => null, + OssClient::OSS_VERSION_ID_MARKER => null, + OssClient::OSS_PREFIX => "test" +); +$bool = true; +while ($bool) { + $result = $ossClient->listObjectVersions($bucket, $option); + ## View the version information of the listed object. + foreach ($result->getObjectVersionList() as $key => $info) { + Common::println("key name: " . $info->getKey()); + Common::println("versionid: " . $info->getVersionId()); + Common::println("Is latest: " . $info->getIsLatest()); + } + + ## View the version information that lists the deletion flags. + foreach ($result->getDeleteMarkerList() as $key => $info) { + Common::println("del_maker key name: " . $info->getKey()); + Common::println("del_maker versionid: " . $info->getVersionId()); + Common::println("del_maker Is latest: " . $info->getIsLatest()); + } + + if ($result->getIsTruncated() === 'true') { + $option[OssClient::OSS_KEY_MARKER] = $result->getNextKeyMarker(); + $option[OssClient::OSS_VERSION_ID_MARKER] = $result->getNextVersionIdMarker(); + } else { + $bool = false; + } +} + +// list the number of objects + +$option = array( + OssClient::OSS_KEY_MARKER => null, + OssClient::OSS_VERSION_ID_MARKER => null, + OssClient::OSS_MAX_KEYS => 200 +); + +$result = $ossClient->listObjectVersions($bucket, $option); +## View the version information of the listed object. +foreach ($result->getObjectVersionList() as $key => $info) { + Common::println("key name: " . $info->getKey()); + Common::println("versionid: " . $info->getVersionId()); + Common::println("Is latest: " . $info->getIsLatest()); +} + +## View the version information that lists the deletion flags. +foreach ($result->getDeleteMarkerList() as $key => $info) { + Common::println("del_maker key name: " . $info->getKey()); + Common::println("del_maker versionid: " . $info->getVersionId()); + Common::println("del_maker Is latest: " . $info->getIsLatest()); +} + + +// show root folder list +$option = array( + OssClient::OSS_KEY_MARKER => null, + OssClient::OSS_VERSION_ID_MARKER => null, + OssClient::OSS_DELIMITER => "/", +); +$bool = true; +while ($bool) { + $result = $ossClient->listObjectVersions($bucket, $option); + ## View the version information of the listed object. + foreach ($result->getObjectVersionList() as $key => $info) { + Common::println("key name: " . $info->getKey()); + Common::println("versionid: " . $info->getVersionId()); + Common::println("Is latest: " . $info->getIsLatest()); + } + + ## View the version information that lists the deletion flags. + foreach ($result->getDeleteMarkerList() as $key => $info) { + Common::println("del_maker key name: " . $info->getKey()); + Common::println("del_maker versionid: " . $info->getVersionId()); + Common::println("del_maker Is latest: " . $info->getIsLatest()); + } + + if ($result->getIsTruncated() === 'true') { + $option[OssClient::OSS_KEY_MARKER] = $result->getNextKeyMarker(); + $option[OssClient::OSS_VERSION_ID_MARKER] = $result->getNextVersionIdMarker(); + } else { + $bool = false; + } +} + +// Show subfolder objects list +$option = array( + OssClient::OSS_KEY_MARKER => null, + OssClient::OSS_VERSION_ID_MARKER => null, + OssClient::OSS_DELIMITER => "/", + OssClient::OSS_PREFIX => "test/", +); +$bool = true; +while ($bool) { + $result = $ossClient->listObjectVersions($bucket, $option); + ## View the version information of the listed object. + foreach ($result->getObjectVersionList() as $key => $info) { + Common::println("key name: " . $info->getKey()); + Common::println("versionid: " . $info->getVersionId()); + Common::println("Is latest: " . $info->getIsLatest()); + } + + ## View the version information that lists the deletion flags. + foreach ($result->getDeleteMarkerList() as $key => $info) { + Common::println("del_maker key name: " . $info->getKey()); + Common::println("del_maker versionid: " . $info->getVersionId()); + Common::println("del_maker Is latest: " . $info->getIsLatest()); + } + + if ($result->getIsTruncated() === 'true') { + $option[OssClient::OSS_KEY_MARKER] = $result->getNextKeyMarker(); + $option[OssClient::OSS_VERSION_ID_MARKER] = $result->getNextVersionIdMarker(); + } else { + $bool = false; + } +} + + +//******************************* For complete usage, see the following functions **************************************************** + +listObjectVersions($ossClient, $bucket); +putBucketVersioning($ossClient, $bucket); +/** + * @param OssClient $ossClient OssClient instance + * @param string $bucket Name of the bucket to create + * @return null + */ +function listObjectVersions($ossClient, $bucket) +{ + try { + $option = array( + OssClient::OSS_KEY_MARKER => null, + OssClient::OSS_VERSION_ID_MARKER => null, + ); + $bool = true; + while ($bool) { + $result = $ossClient->listObjectVersions($bucket, $option); + ## View the version information of the listed object. + foreach ($result->getObjectVersionList() as $key => $info) { + Common::println("key name: " . $info->getKey()); + Common::println("versionid: " . $info->getVersionId()); + Common::println("Is latest: " . $info->getIsLatest()); + } + + ## View the version information that lists the deletion flags. + foreach ($result->getDeleteMarkerList() as $key => $info) { + Common::println("del_maker key name: " . $info->getKey()); + Common::println("del_maker versionid: " . $info->getVersionId()); + Common::println("del_maker Is latest: " . $info->getIsLatest()); + } + + if ($result->getIsTruncated() === 'true') { + $option[OssClient::OSS_KEY_MARKER] = $result->getNextKeyMarker(); + $option[OssClient::OSS_VERSION_ID_MARKER] = $result->getNextVersionIdMarker(); + } else { + $bool = false; + } + } + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); +} + +/** + * Enabled or Suspended bucket version + * @param OssClient $ossClient OssClient instance + * @param string $bucket Name of the bucket to create + * @return null + */ +function putBucketVersioning($ossClient, $bucket) +{ + try { + //Set the storage space version control to enable version control (Enabled) or suspend version control (Suspended). + $ossClient->putBucketVersioning($bucket, "Enabled"); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); +} \ No newline at end of file diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/samples/BucketWebsite.php b/vendor/vendor/aliyuncs/oss-sdk-php/samples/BucketWebsite.php new file mode 100644 index 0000000..6c387e6 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/samples/BucketWebsite.php @@ -0,0 +1,92 @@ +putBucketWebsite($bucket, $websiteConfig); +Common::println("bucket $bucket websiteConfig created:" . $websiteConfig->serializeToXml()); + +// Get bucket static website configuration +$websiteConfig = $ossClient->getBucketWebsite($bucket); +Common::println("bucket $bucket websiteConfig fetched:" . $websiteConfig->serializeToXml()); + +// Delete bucket static website configuration +$ossClient->deleteBucketWebsite($bucket); +Common::println("bucket $bucket websiteConfig deleted"); + +//******************************* For complete usage, see the following functions **************************************************** + +putBucketWebsite($ossClient, $bucket); +getBucketWebsite($ossClient, $bucket); +deleteBucketWebsite($ossClient, $bucket); +getBucketWebsite($ossClient, $bucket); + +/** + * Sets bucket static website configuration + * + * @param $ossClient OssClient + * @param $bucket string bucket name + * @return null + */ +function putBucketWebsite($ossClient, $bucket) +{ + $websiteConfig = new WebsiteConfig("index.html", "error.html"); + try { + $ossClient->putBucketWebsite($bucket, $websiteConfig); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); +} + +/** + * Get bucket static website configuration + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function getBucketWebsite($ossClient, $bucket) +{ + $websiteConfig = null; + try { + $websiteConfig = $ossClient->getBucketWebsite($bucket); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); + print($websiteConfig->serializeToXml() . "\n"); +} + +/** + * Delete bucket static website configuration + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function deleteBucketWebsite($ossClient, $bucket) +{ + try { + $ossClient->deleteBucketWebsite($bucket); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/samples/BucketWorm.php b/vendor/vendor/aliyuncs/oss-sdk-php/samples/BucketWorm.php new file mode 100644 index 0000000..c4b0fb9 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/samples/BucketWorm.php @@ -0,0 +1,145 @@ +initiateBucketWorm($bucket, 30); +Common::println("bucket $bucket wormId: " . $wormId.PHP_EOL); + +// Cancel an unlocked compliance retention policy +$ossClient->abortBucketWorm($bucket); + +//Lock compliant retention policy +$wormId = $ossClient->initiateBucketWorm($bucket, 30); +$ossClient->completeBucketWorm($bucket, $wormId); + +// Get compliant retention policy +$config = $ossClient->getBucketWorm($bucket); +Common::println("WormId:".$config->getWormId().PHP_EOL); +Common::println("State:". $config->getState().PHP_EOL); +Common::println("Day:". $config->getDay().PHP_EOL); + +// Extend the retention days of objects +$wormId = ""; +// Extend the retention days of objects in the locked compliance retention policy to 120 days. +$ossClient->extendBucketWorm($bucket, $wormId, 120); + +//******************************* For complete usage, see the following functions **************************************************** + +initiateBucketWorm($ossClient, $bucket); +abortBucketWorm($ossClient, $bucket); +completeBucketWorm($ossClient, $bucket); +getBucketWorm($ossClient, $bucket); +extendBucketWorm($ossClient, $bucket); + +/** + * Set Bucket Worm Ploicy + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket Name of the bucket to create + * @return null + */ +function initiateBucketWorm($ossClient, $bucket) +{ + try { + $wormId = $ossClient->initiateBucketWorm($bucket,30); + print("bucket $bucket wormId: " . $wormId.PHP_EOL); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + + print(__FUNCTION__ . ": OK" . "\n"); +} + + +/** + * Cancel an unlocked compliance retention policy + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket Name of the bucket to create + * @return null + */ +function abortBucketWorm($ossClient, $bucket) +{ + try { + $ossClient->abortBucketWorm($bucket); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + + print(__FUNCTION__ . ": OK" . "\n"); +} + + +/** + * Complete Bucket Worm + * @param $ossClient $ossClient OssClient instance + * @param $bucket $bucket Name of the bucket to create + */ +function completeBucketWorm($ossClient, $bucket) +{ + try { + $wormId = $ossClient->initiateBucketWorm($bucket, 30); + $ossClient->completeBucketWorm($bucket, $wormId); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + + print(__FUNCTION__ . ": OK" . "\n"); +} + +/** + * Get Bucket Worm + * @param $ossClient $ossClient OssClient instance + * @param $bucket $bucket Name of the bucket to create + */ +function getBucketWorm($ossClient, $bucket) +{ + try { + $config = $ossClient->getBucketWorm($bucket); + + printf("WormId:%s\n", $config->getWormId()); + printf("State:%s\n", $config->getState()); + printf("Day:%d\n", $config->getDay()); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + + print(__FUNCTION__ . ": OK" . "\n"); +} + +/** + * Extend the retention days of objects + * @param $ossClient $ossClient OssClient instance + * @param $bucket $bucket Name of the bucket to create + */ +function extendBucketWorm($ossClient, $bucket) +{ + $wormId = ""; + try { + $ossClient->ExtendBucketWorm($bucket, $wormId, 120); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + + print(__FUNCTION__ . ": OK" . "\n"); +} \ No newline at end of file diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/samples/Callback.php b/vendor/vendor/aliyuncs/oss-sdk-php/samples/Callback.php new file mode 100644 index 0000000..4b7bc41 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/samples/Callback.php @@ -0,0 +1,83 @@ + $url, + OssClient::OSS_CALLBACK_VAR => $var + ); +$result = $ossClient->putObject($bucket, "b.file", "random content", $options); +Common::println($result['body']); +Common::println($result['info']['http_code']); + +/** + * completeMultipartUpload Upload content to an OSS file using callback. + * callbackurl specifies the server url for the request callback + * The callbackbodytype can be application/json or application/x-www-form-urlencoded,the optional parameters,the default for the application/x - WWW - form - urlencoded + * Users can choose not to set OSS_BACK_VAR. + */ +$object = "multipart-callback-test.txt"; +$copiedObject = "multipart-callback-test.txt.copied"; +$ossClient->putObject($bucket, $copiedObject, file_get_contents(__FILE__)); + +/** + * step 1. Initialize a block upload event, that is, a multipart upload process to get an upload id + */ +$upload_id = $ossClient->initiateMultipartUpload($bucket, $object); + +/** + * step 2. uploadPartCopy + */ +$copyId = 1; +$eTag = $ossClient->uploadPartCopy($bucket, $copiedObject, $bucket, $object, $copyId, $upload_id); +$upload_parts[] = array( + 'PartNumber' => $copyId, + 'ETag' => $eTag, + ); +$listPartsInfo = $ossClient->listParts($bucket, $object, $upload_id); + +/** + * step 3. + */ +$json = + '{ + "callbackUrl":"callback.oss-demo.com:23450", + "callbackHost":"oss-cn-hangzhou.aliyuncs.com", + "callbackBody":"{\"mimeType\":${mimeType},\"size\":${size},\"x:var1\":${x:var1},\"x:var2\":${x:var2}}", + "callbackBodyType":"application/json" + }'; +$var = + '{ + "x:var1":"value1", + "x:var2":"值2" + }'; +$options = array(OssClient::OSS_CALLBACK => $json, + OssClient::OSS_CALLBACK_VAR => $var); + +$result = $ossClient->completeMultipartUpload($bucket, $object, $upload_id, $upload_parts, $options); +Common::println($result['body']); +Common::println($result['info']['http_code']); diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/samples/Common.php b/vendor/vendor/aliyuncs/oss-sdk-php/samples/Common.php new file mode 100644 index 0000000..49bd493 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/samples/Common.php @@ -0,0 +1,84 @@ +getMessage() . "\n"); + return null; + } + return $ossClient; + } + + public static function getBucketName() + { + return self::bucket; + } + + /** + * A tool function which creates a bucket and exists the process if there are exceptions + */ + public static function createBucket() + { + $ossClient = self::getOssClient(); + if (is_null($ossClient)) exit(1); + $bucket = self::getBucketName(); + $acl = OssClient::OSS_ACL_TYPE_PUBLIC_READ; + try { + $ossClient->createBucket($bucket, $acl); + } catch (OssException $e) { + + $message = $e->getMessage(); + if (\OSS\Core\OssUtil::startsWith($message, 'http status: 403')) { + echo "Please Check your AccessKeyId and AccessKeySecret" . "\n"; + exit(0); + } elseif (strpos($message, "BucketAlreadyExists") !== false) { + echo "Bucket already exists. Please check whether the bucket belongs to you, or it was visited with correct endpoint. " . "\n"; + exit(0); + } + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); + } + + public static function println($message) + { + if (!empty($message)) { + echo strval($message) . "\n"; + } + } +} + +# Common::createBucket(); diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/samples/Config.php b/vendor/vendor/aliyuncs/oss-sdk-php/samples/Config.php new file mode 100644 index 0000000..fc3a167 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/samples/Config.php @@ -0,0 +1,15 @@ +warpper = $credential; + } + public function getCredentials(){ + $ak = $this->warpper->getAccessKeyId(); + $sk = $this->warpper->getAccessKeySecret(); + $token = $this->warpper->getSecurityToken(); + return new StaticCredentialsProvider($ak, $sk, $token); + } +} + +$bucket = Common::getBucketName(); + +//AccessKey Credentials demo +$credential = new Credential(array( + 'type' => 'access_key', + 'access_key_id' => '', + 'access_key_secret' => '', +)); +$providerWarpper = new AlibabaCloudCredentialsWrapper($credential); +$config = array( + 'provider' => $providerWarpper, + 'endpoint'=> '' +); +try { + $ossClient = new OssClient($config); + $ossClient->putObject($bucket,'c.file','hi oss,this is credentials test of access key'); + $result = $ossClient->getObject($bucket,'c.file'); + var_dump($result); +} catch (OssException $e) { + printf($e->getMessage() . "\n"); + return; +} + + +// EcsRamRole Credentials demo +$ecsRamRole = new Credential(array( + 'type' => 'ecs_ram_role', + 'role_name' => 'EcsRamRoleOssTest', +)); +$providerWarpper = new AlibabaCloudCredentialsWrapper($ecsRamRole); +$bucket = 'oss-bucket-cd-yp-test'; +$config = array( + 'provider' => $providerWarpper, + 'endpoint'=> '' +); +try { + $ossClient = new OssClient($config); + $ossClient->putObject($bucket,'c.file','hi oss,this is credentials test of EcsRamRole'); + $result = $ossClient->getObject($bucket,'c.file'); + var_dump($result); +} catch (OssException $e) { + printf($e->getMessage() . "\n"); + return; +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/samples/CredentialsProvider.php b/vendor/vendor/aliyuncs/oss-sdk-php/samples/CredentialsProvider.php new file mode 100644 index 0000000..8a96b44 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/samples/CredentialsProvider.php @@ -0,0 +1,63 @@ +'; +$secret = ''; +$provider = new StaticCredentialsProvider($id,$secret); +$config = array( + 'provider' => $provider, + 'endpoint'=>'' +); +try { + $ossClient = new OssClient($config); + $ossClient->putObject($bucket,'c.file','hi oss,this is credentials test of access key provider'); + $result = $ossClient->getObject($bucket,'c.file'); + var_dump($result); +} catch (OssException $e) { + printf($e->getMessage() . "\n"); + return; +} + +// Sts provider demo +$id = ''; +$secret = ''; +$token = ''; +$provider = new StaticCredentialsProvider($id,$secret,$token); +$config = array( + 'provider' => $provider, + 'endpoint'=> "" +); + +try { + $ossClient = new OssClient($config); + $ossClient->putObject($bucket,'c.file','hi oss,this is credentials test of sts provider'); + $result = $ossClient->getObject($bucket,'c.file'); + var_dump($result); +} catch (OssException $e) { + printf($e->getMessage() . "\n"); + return; +} + +// read from env +$envProvider = new EnvironmentVariableCredentialsProvider(); +$config = array( + 'provider' => $envProvider, + 'endpoint'=> "" +); + +try { + $ossClient = new OssClient($config); + $ossClient->putObject($bucket,'c.file','hi oss,this is credentials test of sts provider'); + $result = $ossClient->getObject($bucket,'c.file'); + var_dump($result); +} catch (OssException $e) { + printf($e->getMessage() . "\n"); + return; +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/samples/Image.php b/vendor/vendor/aliyuncs/oss-sdk-php/samples/Image.php new file mode 100644 index 0000000..8531733 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/samples/Image.php @@ -0,0 +1,87 @@ +uploadFile($bucketName, $object, "example.jpg"); + +// Image resize +$options = array( + OssClient::OSS_FILE_DOWNLOAD => $download_file, + OssClient::OSS_PROCESS => "image/resize,m_fixed,h_100,w_100", ); +$ossClient->getObject($bucketName, $object, $options); +printImage("imageResize",$download_file); + +// Image crop +$options = array( + OssClient::OSS_FILE_DOWNLOAD => $download_file, + OssClient::OSS_PROCESS => "image/crop,w_100,h_100,x_100,y_100,r_1", ); +$ossClient->getObject($bucketName, $object, $options); +printImage("iamgeCrop", $download_file); + +// Image rotate +$options = array( + OssClient::OSS_FILE_DOWNLOAD => $download_file, + OssClient::OSS_PROCESS => "image/rotate,90", ); +$ossClient->getObject($bucketName, $object, $options); +printImage("imageRotate", $download_file); + +// Image sharpen +$options = array( + OssClient::OSS_FILE_DOWNLOAD => $download_file, + OssClient::OSS_PROCESS => "image/sharpen,100", ); +$ossClient->getObject($bucketName, $object, $options); +printImage("imageSharpen", $download_file); + +// Add watermark into a image +$options = array( + OssClient::OSS_FILE_DOWNLOAD => $download_file, + OssClient::OSS_PROCESS => "image/watermark,text_SGVsbG8g5Zu-54mH5pyN5YqhIQ", ); +$ossClient->getObject($bucketName, $object, $options); +printImage("imageWatermark", $download_file); + +// Image format convertion +$options = array( + OssClient::OSS_FILE_DOWNLOAD => $download_file, + OssClient::OSS_PROCESS => "image/format,png", ); +$ossClient->getObject($bucketName, $object, $options); +printImage("imageFormat", $download_file); + +// Get image information +$options = array( + OssClient::OSS_FILE_DOWNLOAD => $download_file, + OssClient::OSS_PROCESS => "image/info", ); +$ossClient->getObject($bucketName, $object, $options); +printImage("imageInfo", $download_file); + + +/** + * Generate a signed url which could be used in browser to access the object. The expiration time is 1 hour. + */ + $timeout = 3600; +$options = array( + OssClient::OSS_PROCESS => "image/resize,m_lfit,h_100,w_100", + ); +$signedUrl = $ossClient->signUrl($bucketName, $object, $timeout, "GET", $options); +Common::println("rtmp url: \n" . $signedUrl); + +// Finally delete the $object uploaded. +$ossClient->deleteObject($bucketName, $object); + +function printImage($func, $imageFile) +{ + $array = getimagesize($imageFile); + Common::println("$func, image width: " . $array[0]); + Common::println("$func, image height: " . $array[1]); + Common::println("$func, image type: " . ($array[2] === 2 ? 'jpg' : 'png')); + Common::println("$func, image size: " . ceil(sprintf('%u',filesize($imageFile)))); +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/samples/LiveChannel.php b/vendor/vendor/aliyuncs/oss-sdk-php/samples/LiveChannel.php new file mode 100644 index 0000000..67bb541 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/samples/LiveChannel.php @@ -0,0 +1,131 @@ + 'live channel test', + 'type' => 'HLS', + 'fragDuration' => 10, + 'fragCount' => 5, + 'playListName' => 'hello.m3u8' + )); +$info = $ossClient->putBucketLiveChannel($bucket, 'test_rtmp_live', $config); +Common::println("bucket $bucket liveChannel created:\n" . +"live channel name: ". $info->getName() . "\n" . +"live channel description: ". $info->getDescription() . "\n" . +"publishurls: ". $info->getPublishUrls()[0] . "\n" . +"playurls: ". $info->getPlayUrls()[0] . "\n"); + +/** + * You can use listBucketLiveChannels to list and manage all existing live channels. + * Prefix can be used to filter listed live channels by prefix. + * Max_keys indicates the maximum numbers of live channels that can be listed in an iterator at one time. Its value is 1000 in maximum and 100 by default. + */ +$list = $ossClient->listBucketLiveChannels($bucket); +Common::println("bucket $bucket listLiveChannel:\n" . +"list live channel prefix: ". $list->getPrefix() . "\n" . +"list live channel marker: ". $list->getMarker() . "\n" . +"list live channel maxkey: ". $list->getMaxKeys() . "\n" . +"list live channel IsTruncated: ". $list->getIsTruncated() . "\n" . +"list live channel getNextMarker: ". $list->getNextMarker() . "\n"); + +foreach($list->getChannelList() as $list) +{ + Common::println("bucket $bucket listLiveChannel:\n" . + "list live channel IsTruncated: ". $list->getName() . "\n" . + "list live channel Description: ". $list->getDescription() . "\n" . + "list live channel Status: ". $list->getStatus() . "\n" . + "list live channel getNextMarker: ". $list->getLastModified() . "\n"); +} +/** + * Obtain the play_url (url used for rtmp stream pushing. + * If the the bucket is not globally readable and writable, + * the url must be signed as shown in the following.) and pulish_url (the url included in the m3u8 file generated in stream pushing) used to push streams. + */ +$play_url = $ossClient->signRtmpUrl($bucket, "test_rtmp_live", 3600, array('params' => array('playlistName' => 'playlist.m3u8'))); +Common::println("bucket $bucket rtmp url: \n" . $play_url); +$play_url = $ossClient->signRtmpUrl($bucket, "test_rtmp_live", 3600); +Common::println("bucket $bucket rtmp url: \n" . $play_url); + +/** + * If you want to disable a created live channel (disable the pushing streaming or do not allow stream pushing to an IP address), call putLiveChannelStatus to change the channel status to "Disabled". + * If you want to enable a disabled live channel, call PutLiveChannelStatus to chanage the channel status to "Enabled". + */ +$resp = $ossClient->putLiveChannelStatus($bucket, "test_rtmp_live", "enabled"); + +/** + * You can callLiveChannelInfo to get the information about a live channel. + */ +$info = $ossClient->getLiveChannelInfo($bucket, 'test_rtmp_live'); +Common::println("bucket $bucket LiveChannelInfo:\n" . +"live channel info description: ". $info->getDescription() . "\n" . +"live channel info status: ". $info->getStatus() . "\n" . +"live channel info type: ". $info->getType() . "\n" . +"live channel info fragDuration: ". $info->getFragDuration() . "\n" . +"live channel info fragCount: ". $info->getFragCount() . "\n" . +"live channel info playListName: ". $info->getPlayListName() . "\n"); + +/** + * Gets the historical pushing streaming records by calling getLiveChannelHistory. Now the max records to return is 10. + */ +$history = $ossClient->getLiveChannelHistory($bucket, "test_rtmp_live"); +if (count($history->getLiveRecordList()) != 0) +{ + foreach($history->getLiveRecordList() as $recordList) + { + Common::println("bucket $bucket liveChannelHistory:\n" . + "live channel history startTime: ". $recordList->getStartTime() . "\n" . + "live channel history endTime: ". $recordList->getEndTime() . "\n" . + "live channel history remoteAddr: ". $recordList->getRemoteAddr() . "\n"); + } +} + +/** + * Get the live channel's status by calling getLiveChannelStatus. + * If the live channel is receiving the pushing stream, all attributes in stat_result are valid. + * If the live channel is idle or disabled, then the status is idle or Disabled and other attributes have no meaning. + */ +$status = $ossClient->getLiveChannelStatus($bucket, "test_rtmp_live"); +Common::println("bucket $bucket listLiveChannel:\n" . +"live channel status status: ". $status->getStatus() . "\n" . +"live channel status ConnectedTime: ". $status->getConnectedTime() . "\n" . +"live channel status VideoWidth: ". $status->getVideoWidth() . "\n" . +"live channel status VideoHeight: ". $status->getVideoHeight() . "\n" . +"live channel status VideoFrameRate: ". $status->getVideoFrameRate() . "\n" . +"live channel status VideoBandwidth: ". $status->getVideoBandwidth() . "\n" . +"live channel status VideoCodec: ". $status->getVideoCodec() . "\n" . +"live channel status AudioBandwidth: ". $status->getAudioBandwidth() . "\n" . +"live channel status AudioSampleRate: ". $status->getAudioSampleRate() . "\n" . +"live channel status AdioCodec: ". $status->getAudioCodec() . "\n"); + +/** + * If you want to generate a play url from the ts files generated from pushing streaming, call postVodPlayList. + * Specify the start time to 60 seconds before the current time and the end time to the current time, which means that a video of 60 seconds is generated. + * The playlist file is specified to “vod_playlist.m3u8”, which means that a palylist file named vod_playlist.m3u8 is created after the interface is called. + */ +$current_time = time(); +$ossClient->postVodPlaylist($bucket, + "test_rtmp_live", "vod_playlist.m3u8", + array('StartTime' => $current_time - 60, + 'EndTime' => $current_time) +); + +/** + * Call delete_live_channel to delete a live channel if it will no longer be in used. + */ +$ossClient->deleteBucketLiveChannel($bucket, "test_rtmp_live"); diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/samples/MultipartUpload.php b/vendor/vendor/aliyuncs/oss-sdk-php/samples/MultipartUpload.php new file mode 100644 index 0000000..dd4b7fd --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/samples/MultipartUpload.php @@ -0,0 +1,182 @@ +multiuploadFile($bucket, "file.php", __FILE__, array()); +Common::println("local file " . __FILE__ . " is uploaded to the bucket $bucket, file.php"); + + +// Upload local directory's data into target dir +$ossClient->uploadDir($bucket, "targetdir", __DIR__); +Common::println("local dir " . __DIR__ . " is uploaded to the bucket $bucket, targetdir/"); + + +// List the incomplete multipart uploads +$listMultipartUploadInfo = $ossClient->listMultipartUploads($bucket, array()); + + +//******************************* For complete usage, see the following functions **************************************************** + +multiuploadFile($ossClient, $bucket); +putObjectByRawApis($ossClient, $bucket); +uploadDir($ossClient, $bucket); +listMultipartUploads($ossClient, $bucket); + +/** + * Upload files using multipart upload + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function multiuploadFile($ossClient, $bucket) +{ + $object = "test/multipart-test.txt"; + $file = __FILE__; + $options = array(); + + try { + $ossClient->multiuploadFile($bucket, $object, $file, $options); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); +} + +/** + * Use basic multipart upload for file upload. + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @throws OssException + */ +function putObjectByRawApis($ossClient, $bucket) +{ + $object = "test/multipart-test.txt"; + /** + * step 1. Initialize a block upload event, that is, a multipart upload process to get an upload id + */ + try { + $uploadId = $ossClient->initiateMultipartUpload($bucket, $object); + } catch (OssException $e) { + printf(__FUNCTION__ . ": initiateMultipartUpload FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": initiateMultipartUpload OK" . "\n"); + /* + * step 2. Upload parts + */ + $partSize = 10 * 1024 * 1024; + $uploadFile = __FILE__; + $uploadFileSize = sprintf('%u',filesize($uploadFile)); + $pieces = $ossClient->generateMultiuploadParts($uploadFileSize, $partSize); + $responseUploadPart = array(); + $uploadPosition = 0; + $isCheckMd5 = true; + foreach ($pieces as $i => $piece) { + $fromPos = $uploadPosition + (integer)$piece[$ossClient::OSS_SEEK_TO]; + $toPos = (integer)$piece[$ossClient::OSS_LENGTH] + $fromPos - 1; + $upOptions = array( + $ossClient::OSS_FILE_UPLOAD => $uploadFile, + $ossClient::OSS_PART_NUM => ($i + 1), + $ossClient::OSS_SEEK_TO => $fromPos, + $ossClient::OSS_LENGTH => $toPos - $fromPos + 1, + $ossClient::OSS_CHECK_MD5 => $isCheckMd5, + ); + if ($isCheckMd5) { + $contentMd5 = OssUtil::getMd5SumForFile($uploadFile, $fromPos, $toPos); + $upOptions[$ossClient::OSS_CONTENT_MD5] = $contentMd5; + } + //2. Upload each part to OSS + try { + $responseUploadPart[] = $ossClient->uploadPart($bucket, $object, $uploadId, $upOptions); + } catch (OssException $e) { + printf(__FUNCTION__ . ": initiateMultipartUpload, uploadPart - part#{$i} FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + printf(__FUNCTION__ . ": initiateMultipartUpload, uploadPart - part#{$i} OK\n"); + } + $uploadParts = array(); + foreach ($responseUploadPart as $i => $eTag) { + $uploadParts[] = array( + 'PartNumber' => ($i + 1), + 'ETag' => $eTag, + ); + } + /** + * step 3. Complete the upload + */ + try { + $ossClient->completeMultipartUpload($bucket, $object, $uploadId, $uploadParts); + } catch (OssException $e) { + printf(__FUNCTION__ . ": completeMultipartUpload FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + printf(__FUNCTION__ . ": completeMultipartUpload OK\n"); +} + +/** + * Upload by directories + * + * @param OssClient $ossClient OssClient + * @param string $bucket bucket name + * + */ +function uploadDir($ossClient, $bucket) +{ + $localDirectory = "."; + $prefix = "samples/codes"; + try { + $ossClient->uploadDir($bucket, $prefix, $localDirectory); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + printf(__FUNCTION__ . ": completeMultipartUpload OK\n"); +} + +/** + * Get ongoing multipart uploads + * + * @param $ossClient OssClient + * @param $bucket string + */ +function listMultipartUploads($ossClient, $bucket) +{ + $options = array( + 'max-uploads' => 100, + 'key-marker' => '', + 'prefix' => '', + 'upload-id-marker' => '' + ); + try { + $listMultipartUploadInfo = $ossClient->listMultipartUploads($bucket, $options); + } catch (OssException $e) { + printf(__FUNCTION__ . ": listMultipartUploads FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + printf(__FUNCTION__ . ": listMultipartUploads OK\n"); + $listUploadInfo = $listMultipartUploadInfo->getUploads(); + var_dump($listUploadInfo); +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/samples/Object.php b/vendor/vendor/aliyuncs/oss-sdk-php/samples/Object.php new file mode 100644 index 0000000..5d83efa --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/samples/Object.php @@ -0,0 +1,765 @@ +putObject($bucket, "b.file", "hi, oss"); +Common::println("b.file is created"); +Common::println($result['x-oss-request-id']); +Common::println($result['etag']); +Common::println($result['content-md5']); +Common::println($result['body']); + +// Uploads a local file to an OSS file +$result = $ossClient->uploadFile($bucket, "c.file", __FILE__); +Common::println("c.file is created"); +Common::println("b.file is created"); +Common::println($result['x-oss-request-id']); +Common::println($result['etag']); +Common::println($result['content-md5']); +Common::println($result['body']); + +// Download an oss object as an in-memory variable +$content = $ossClient->getObject($bucket, "b.file"); +Common::println("b.file is fetched, the content is: " . $content); + +// Add a symlink to an object +$content = $ossClient->putSymlink($bucket, "test-symlink", "b.file"); +Common::println("test-symlink is created"); +Common::println($result['x-oss-request-id']); +Common::println($result['etag']); + +// Get a symlink +$content = $ossClient->getSymlink($bucket, "test-symlink"); +Common::println("test-symlink refer to : " . $content[OssClient::OSS_SYMLINK_TARGET]); + +// Download an object to a local file. +$options = array( + OssClient::OSS_FILE_DOWNLOAD => "./c.file.localcopy", +); +$ossClient->getObject($bucket, "c.file", $options); +Common::println("b.file is fetched to the local file: c.file.localcopy"); +Common::println("b.file is created"); + + +// Restore Object +$day = 3; +$tier = 'Expedited'; +$config = new RestoreConfig($day,$tier); +$options = array( + OssClient::OSS_RESTORE_CONFIG => $config +); +$ossClient->restoreObject($bucket, 'b.file',$options); + + +// Copy an object +$result = $ossClient->copyObject($bucket, "c.file", $bucket, "c.file.copy"); +Common::println("lastModifiedTime: " . $result[0]); +Common::println("ETag: " . $result[1]); + +// Check whether an object exists +$doesExist = $ossClient->doesObjectExist($bucket, "c.file.copy"); +Common::println("file c.file.copy exist? " . ($doesExist ? "yes" : "no")); + +// Delete an object +$result = $ossClient->deleteObject($bucket, "c.file.copy"); +Common::println("c.file.copy is deleted"); +Common::println("b.file is created"); +Common::println($result['x-oss-request-id']); + +// Check whether an object exists +$doesExist = $ossClient->doesObjectExist($bucket, "c.file.copy"); +Common::println("file c.file.copy exist? " . ($doesExist ? "yes" : "no")); + +// Delete multiple objects in batch +$result = $ossClient->deleteObjects($bucket, array("b.file", "c.file")); +foreach($result as $object) + Common::println($object); + +sleep(2); +unlink("c.file.localcopy"); + +// Normal upload and download speed limit +$object= "b.file"; +$content = "hello world"; + +// The speed limit is 100 KB/s, which is 819200 bit/s. +$options = array( + OssClient::OSS_HEADERS => array( + OssClient::OSS_TRAFFIC_LIMIT => 819200, + )); +// Speed limit upload. +$ossClient->putObject($bucket, $object, $content, $options); + +// Speed limit download. +$ossClient->getObject($bucket, $object, $options); + +// Signed URL upload and download speed limit + +// Create a URL for uploading with a limited rate, and the validity period is 60s. +$timeout = 60; +$signedUrl = $ossClient->signUrl($bucket, $object, $timeout, "PUT", $options); +Common::println("b.file speed limit upload url:".$signedUrl.PHP_EOL); + +// Create a URL for speed-limited downloads, with a validity period of 120s. +$timeout = 120; +$signedUrl = $ossClient->signUrl($bucket, $object, $timeout, "GET", $options); +Common::println("b.file speed limit download url:".$signedUrl.PHP_EOL); + +//******************************* For complete usage, see the following functions **************************************************** + +listObjects($ossClient, $bucket); +listObjectsV2($ossClient, $bucket); +listAllObjects($ossClient, $bucket); +createObjectDir($ossClient, $bucket); +putObject($ossClient, $bucket); +uploadFile($ossClient, $bucket); +getObject($ossClient, $bucket); +getObjectToLocalFile($ossClient, $bucket); +copyObject($ossClient, $bucket); +modifyMetaForObject($ossClient, $bucket); +getObjectMeta($ossClient, $bucket); +deleteObject($ossClient, $bucket); +deleteObjects($ossClient, $bucket); +doesObjectExist($ossClient, $bucket); +getSymlink($ossClient, $bucket); +putSymlink($ossClient, $bucket); +putObjectSpeed($ossClient, $bucket); +getObjectSpeed($ossClient, $bucket); +signUrlSpeedUpload($ossClient, $bucket); +signUrlSpeedDownload($ossClient, $bucket); +restoreObject($ossClient,$bucket); +/** + * Create a 'virtual' folder + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function createObjectDir($ossClient, $bucket) +{ + try { + $ossClient->createObjectDir($bucket, "dir"); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); +} + +/** + * Upload in-memory data to oss + * + * Simple upload---upload specified in-memory data to an OSS object + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function putObject($ossClient, $bucket) +{ + $object = "oss-php-sdk-test/upload-test-object-name.txt"; + $content = file_get_contents(__FILE__); + $options = array(); + try { + $ossClient->putObject($bucket, $object, $content, $options); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); +} + + +/** + * Uploads a local file to OSS + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function uploadFile($ossClient, $bucket) +{ + $object = "oss-php-sdk-test/upload-test-object-name.txt"; + $filePath = __FILE__; + $options = array(); + + try { + $ossClient->uploadFile($bucket, $object, $filePath, $options); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); +} + +/** + * Lists all files and folders in the bucket. + * Note if there's more items than the max-keys specified, the caller needs to use the nextMarker returned as the value for the next call's maker paramter. + * Loop through all the items returned from ListObjects. + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function listObjects($ossClient, $bucket) +{ + $prefix = 'oss-php-sdk-test/'; + $delimiter = '/'; + $nextMarker = ''; + $maxkeys = 1000; + $options = array( + 'delimiter' => $delimiter, + 'prefix' => $prefix, + 'max-keys' => $maxkeys, + 'marker' => $nextMarker, + ); + try { + $listObjectInfo = $ossClient->listObjects($bucket, $options); + printf("Bucket Name: %s". "\n",$listObjectInfo->getBucketName()); + printf("Prefix: %s". "\n",$listObjectInfo->getPrefix()); + printf("Marker: %s". "\n",$listObjectInfo->getMarker()); + printf("Next Marker: %s". "\n",$listObjectInfo->getNextMarker()); + printf("Max Keys: %s". "\n",$listObjectInfo->getMaxKeys()); + printf("Delimiter: %s". "\n",$listObjectInfo->getDelimiter()); + printf("Is Truncated: %s". "\n",$listObjectInfo->getIsTruncated()); + $objectList = $listObjectInfo->getObjectList(); // object list + $prefixList = $listObjectInfo->getPrefixList(); // directory list + if (!empty($objectList)) { + print("objectList:\n"); + foreach ($objectList as $objectInfo) { + printf("Object Name: %s". "\n",$objectInfo->getKey()); + printf("Object Size: %s". "\n",$objectInfo->getSize()); + printf("Object Type: %s". "\n",$objectInfo->getType()); + printf("Object ETag: %s". "\n",$objectInfo->getETag()); + printf("Object Last Modified: %s". "\n",$objectInfo->getLastModified()); + printf("Object Storage Class: %s". "\n",$objectInfo->getStorageClass()); + + if ($objectInfo->getRestoreInfo()){ + printf("Restore Info: %s". "\n",$objectInfo->getRestoreInfo() ); + } + + if($objectInfo->getOwner()){ + printf("Owner Id:".$objectInfo->getOwner()->getId() . "\n"); + printf("Owner Name:".$objectInfo->getOwner()->getDisplayName() . "\n"); + } + } + } + if (!empty($prefixList)) { + print("prefixList: \n"); + foreach ($prefixList as $prefixInfo) { + printf("Common Prefix:%s\n",$prefixInfo->getPrefix()); + } + } + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); +} + +/** + * Lists all files and folders in the bucket. + * Note if there's more items than the max-keys specified, the caller needs to use the nextMarker returned as the value for the next call's maker paramter. + * Loop through all the items returned from ListObjects. + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function listObjectsV2($ossClient, $bucket) +{ + $prefix = 'oss-php-sdk-test/'; + $delimiter = '/'; + $maxkeys = 1000; + $options = array( + 'delimiter' => $delimiter, + 'prefix' => $prefix, + 'max-keys' => $maxkeys, + 'start-after' =>'test-object', + 'fetch-owner' =>'true', + ); + try { + $listObjectInfo = $ossClient->listObjectsV2($bucket, $options); + printf("Bucket Name: %s". "\n",$listObjectInfo->getBucketName()); + printf("Prefix: %s". "\n",$listObjectInfo->getPrefix()); + printf("Next Continuation Token: %s". "\n",$listObjectInfo->getNextContinuationToken()); + printf("Continuation Token: %s". "\n",$listObjectInfo->getContinuationToken()); + printf("Max Keys: %s". "\n",$listObjectInfo->getMaxKeys()); + printf("Key Count: %s". "\n",$listObjectInfo->getKeyCount()); + printf("Delimiter: %s". "\n",$listObjectInfo->getDelimiter()); + printf("Is Truncated: %s". "\n",$listObjectInfo->getIsTruncated()); + printf("Start After: %s". "\n",$listObjectInfo->getStartAfter()); + $objectList = $listObjectInfo->getObjectList(); // object list + $prefixList = $listObjectInfo->getPrefixList(); // directory list + if (!empty($objectList)) { + print("objectList:\n"); + foreach ($objectList as $objectInfo) { + printf("Object Name: %s". "\n",$objectInfo->getKey()); + printf("Object Size: %s". "\n",$objectInfo->getSize()); + printf("Object Type: %s". "\n",$objectInfo->getType()); + printf("Object ETag: %s". "\n",$objectInfo->getETag()); + printf("Object Last Modified: %s". "\n",$objectInfo->getLastModified()); + printf("Object Storage Class: %s". "\n",$objectInfo->getStorageClass()); + + if ($objectInfo->getRestoreInfo()){ + printf("Restore Info: %s". "\n",$objectInfo->getRestoreInfo() ); + } + + if($objectInfo->getOwner()){ + printf("Owner Id:".$objectInfo->getOwner()->getId() . "\n"); + printf("Owner Name:".$objectInfo->getOwner()->getDisplayName() . "\n"); + } + } + } + if (!empty($prefixList)) { + print("prefixList: \n"); + foreach ($prefixList as $prefixInfo) { + printf("Common Prefix:%s\n",$prefixInfo->getPrefix()); + } + } + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); +} + +/** + * Lists all folders and files under the bucket. Use nextMarker repeatedly to get all objects. + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function listAllObjects($ossClient, $bucket) +{ + // Create dir/obj 'folder' and put some files into it. + for ($i = 0; $i < 100; $i += 1) { + $ossClient->putObject($bucket, "dir/obj" . strval($i), "hi"); + $ossClient->createObjectDir($bucket, "dir/obj" . strval($i)); + } + + $prefix = 'dir/'; + $delimiter = '/'; + $nextMarker = ''; + $maxkeys = 30; + + while (true) { + $options = array( + 'delimiter' => $delimiter, + 'prefix' => $prefix, + 'max-keys' => $maxkeys, + 'marker' => $nextMarker, + ); + var_dump($options); + try { + $listObjectInfo = $ossClient->listObjects($bucket, $options); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + // Get the nextMarker, and it would be used as the next call's marker parameter to resume from the last call + $nextMarker = $listObjectInfo->getNextMarker(); + $listObject = $listObjectInfo->getObjectList(); + $listPrefix = $listObjectInfo->getPrefixList(); + var_dump(count($listObject)); + var_dump(count($listPrefix)); + if ($nextMarker === '') { + break; + } + } +} + +/** + * Get the content of an object. + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function getObject($ossClient, $bucket) +{ + $object = "oss-php-sdk-test/upload-test-object-name.txt"; + $options = array(); + try { + $content = $ossClient->getObject($bucket, $object, $options); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); + if (file_get_contents(__FILE__) === $content) { + print(__FUNCTION__ . ": FileContent checked OK" . "\n"); + } else { + print(__FUNCTION__ . ": FileContent checked FAILED" . "\n"); + } +} + +/** + * Put symlink + * + * @param OssClient $ossClient The Instance of OssClient + * @param string $bucket bucket name + * @return null + */ +function putSymlink($ossClient, $bucket) +{ + $symlink = "test-samples-symlink"; + $object = "test-samples-object"; + try { + $ossClient->putObject($bucket, $object, 'test-content'); + $ossClient->putSymlink($bucket, $symlink, $object); + $content = $ossClient->getObject($bucket, $symlink); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); + if ($content == 'test-content') { + print(__FUNCTION__ . ": putSymlink checked OK" . "\n"); + } else { + print(__FUNCTION__ . ": putSymlink checked FAILED" . "\n"); + } +} + +/** + * Get symlink + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function getSymlink($ossClient, $bucket) +{ + $symlink = "test-samples-symlink"; + $object = "test-samples-object"; + try { + $ossClient->putObject($bucket, $object, 'test-content'); + $ossClient->putSymlink($bucket, $symlink, $object); + $content = $ossClient->getSymlink($bucket, $symlink); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); + if ($content[OssClient::OSS_SYMLINK_TARGET]) { + print(__FUNCTION__ . ": getSymlink checked OK" . "\n"); + } else { + print(__FUNCTION__ . ": getSymlink checked FAILED" . "\n"); + } +} + +/** + * Get_object_to_local_file + * + * Get object + * Download object to a specified file. + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function getObjectToLocalFile($ossClient, $bucket) +{ + $object = "oss-php-sdk-test/upload-test-object-name.txt"; + $localfile = "upload-test-object-name.txt"; + $options = array( + OssClient::OSS_FILE_DOWNLOAD => $localfile, + ); + + try { + $ossClient->getObject($bucket, $object, $options); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK, please check localfile: 'upload-test-object-name.txt'" . "\n"); + if (file_get_contents($localfile) === file_get_contents(__FILE__)) { + print(__FUNCTION__ . ": FileContent checked OK" . "\n"); + } else { + print(__FUNCTION__ . ": FileContent checked FAILED" . "\n"); + } + if (file_exists($localfile)) { + unlink($localfile); + } +} + +/** + * Copy object + * When the source object is same as the target one, copy operation will just update the metadata. + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function copyObject($ossClient, $bucket) +{ + $fromBucket = $bucket; + $fromObject = "oss-php-sdk-test/upload-test-object-name.txt"; + $toBucket = $bucket; + $toObject = $fromObject . '.copy'; + $options = array(); + + try { + $ossClient->copyObject($fromBucket, $fromObject, $toBucket, $toObject, $options); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); +} + +/** + * Update Object Meta + * it leverages the feature of copyObject: when the source object is just the target object, the metadata could be updated via copy + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function modifyMetaForObject($ossClient, $bucket) +{ + $fromBucket = $bucket; + $fromObject = "oss-php-sdk-test/upload-test-object-name.txt"; + $toBucket = $bucket; + $toObject = $fromObject; + $copyOptions = array( + OssClient::OSS_HEADERS => array( + 'Cache-Control' => 'max-age=60', + 'Content-Disposition' => 'attachment; filename="xxxxxx"', + ), + ); + try { + $ossClient->copyObject($fromBucket, $fromObject, $toBucket, $toObject, $copyOptions); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); +} + +/** + * Get object meta, that is, getObjectMeta + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function getObjectMeta($ossClient, $bucket) +{ + $object = "oss-php-sdk-test/upload-test-object-name.txt"; + try { + $objectMeta = $ossClient->getObjectMeta($bucket, $object); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); + if (isset($objectMeta[strtolower('Content-Disposition')]) && + 'attachment; filename="xxxxxx"' === $objectMeta[strtolower('Content-Disposition')] + ) { + print(__FUNCTION__ . ": ObjectMeta checked OK" . "\n"); + } else { + print(__FUNCTION__ . ": ObjectMeta checked FAILED" . "\n"); + } +} + +/** + * Delete an object + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function deleteObject($ossClient, $bucket) +{ + $object = "oss-php-sdk-test/upload-test-object-name.txt"; + try { + $ossClient->deleteObject($bucket, $object); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); +} + + +/** + * Delete multiple objects in batch + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function deleteObjects($ossClient, $bucket) +{ + $objects = array(); + $objects[] = "oss-php-sdk-test/upload-test-object-name.txt"; + $objects[] = "oss-php-sdk-test/upload-test-object-name.txt.copy"; + try { + $ossClient->deleteObjects($bucket, $objects); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); +} + +/** + * Check whether an object exists + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function doesObjectExist($ossClient, $bucket) +{ + $object = "oss-php-sdk-test/upload-test-object-name.txt"; + try { + $exist = $ossClient->doesObjectExist($bucket, $object); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); + var_dump($exist); +} + +/** + * Speed limit upload. + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function putObjectSpeed($ossClient, $bucket) +{ + $object = "upload-test-object-name.txt"; + $content = file_get_contents(__FILE__); + $options = array( + OssClient::OSS_HEADERS => array( + OssClient::OSS_TRAFFIC_LIMIT => 819200, + )); + try { + $ossClient->putObject($bucket, $object, $content, $options); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); +} + +/** + * Speed limit download. + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function getObjectSpeed($ossClient, $bucket) +{ + $object = "upload-test-object-name.txt"; + $options = array( + OssClient::OSS_HEADERS => array( + OssClient::OSS_TRAFFIC_LIMIT => 819200, + )); + try { + $ossClient->getObject($bucket, $object, $options); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); +} + +/** + * Speed limit download. + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function signUrlSpeedUpload($ossClient, $bucket) +{ + $object = "upload-test-object-name.txt"; + $timeout = 120; + $options = array( + OssClient::OSS_TRAFFIC_LIMIT => 819200, + ); + $timeout = 60; + $signedUrl = $ossClient->signUrl($bucket, $object, $timeout, "PUT", $options); + print($signedUrl); +} + + +/** + * Speed limit download. + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function signUrlSpeedDownload($ossClient, $bucket) +{ + $object = "upload-test-object-name.txt"; + $timeout = 120; + $options = array( + OssClient::OSS_TRAFFIC_LIMIT => 819200, + ); + $signedUrl = $ossClient->signUrl($bucket, $object, $timeout, "GET", $options); + print($signedUrl); + print(__FUNCTION__ . ": OK" . "\n"); +} + +/** + * Restore object + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function restoreObject($ossClient, $bucket) +{ + $object = "oss-php-sdk-test/upload-test-object-name.txt"; + $day = 3; + $tier = 'Expedited'; + $config = new RestoreConfig($day,$tier); + $options = array( + OssClient::OSS_RESTORE_CONFIG => $config + ); + try { + $ossClient->restoreObject($bucket, $object,$options); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/samples/ObjectTagging.php b/vendor/vendor/aliyuncs/oss-sdk-php/samples/ObjectTagging.php new file mode 100644 index 0000000..adc283b --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/samples/ObjectTagging.php @@ -0,0 +1,366 @@ + array( + 'x-oss-tagging' => 'key1=value1&key2=value2&key3=value3', + ) +); +$result = $ossClient->putObject($bucket, $object, __FILE__,$options); +Common::println("b.file is created"); +Common::println("tag is:".$result['oss-requestheaders']['x-oss-tagging']); + +// Add object tags when uploading parts + +$object = "b.file"; +$file = __FILE__; +$options = array( + OssClient::OSS_CHECK_MD5 => true, + OssClient::OSS_PART_SIZE => 1, + OssClient::OSS_HEADERS => array( + 'x-oss-tagging' => 'key1=value1&key2=value2&key3=value3', + ), +); +$result = $ossClient->multiuploadFile($bucket, $object, $file, $options); +Common::println("b.file is created"); +Common::println("tag is:".$result['oss-requestheaders']['x-oss-tagging']); + +// get tags from object + +$object = "a.txt"; +$result = $ossClient->getObjectTagging($bucket,$object); +printf($object.'tags is: '.$result->serializeToXml().PHP_EOL); + + +// Add or change object tags to uploaded objects +$config = new TaggingConfig(); +$config->addTag(new Tag("key1", "value1")); +$config->addTag(new Tag("key2", "value2")); + +$ossClient->putObjectTagging($bucket, $object, $config); +// Add object tags when uploading +$object = "a.txt"; +$filePath = "D:\\localpath\\b.txt"; +$filePath1 = "D:\\localpath\\c.txt"; +$options = array( + OssClient::OSS_HEADERS => array( + 'x-oss-tagging' => 'key1=value1&key2=value2', + ) +); +$position = $ossClient->appendObject($bucket, $object,'content one',0,$options); +printf('Content one append object Success'.PHP_EOL); +$position = $ossClient->appendObject($bucket, $object, 'content two',$position,$options); +printf('Content two append object Success'.PHP_EOL); + +// delete tags +$object = "g.file"; +$ossClient->deleteObjectTagging($bucket, $object); +printf($object.' tags has deleted'.PHP_EOL); + +// Copy a small file +$fromBucket = $bucket; +$fromObject = "a.file"; +$toBucket = $bucket; +$toObject = $fromObject . '.copy'; +$options = array( + OssClient::OSS_HEADERS => array( + 'x-oss-tagging-directive' => 'Replace', + 'x-oss-tagging'=>'key1=value1&key2=value2&key3=value3', + )); +$ossClient->copyObject($fromBucket, $fromObject, $toBucket, $toObject, $options); +$config = $ossClient->getObjectTagging($bucket, $toObject); +Common::println('object tags is:'.$config->serializeToXml()); + +// Copy a large file +$fromBucket = $bucket; +$fromObject = "a.file"; +$toBucket = $bucket; +$toObject = $fromObject . '.copy'; +$options = array( + OssClient::OSS_HEADERS => array( + 'x-oss-tagging'=>'key1=value1&key2=value2&key3=value3', + )); + +$part_size = 256*1024*1024; +$objectMeta = $ossClient->getObjectMeta($fromBucket, $fromObject); +$length = $objectMeta['content-length']; +$upload_id = $ossClient->initiateMultipartUpload($toBucket, $toObject,$options); +$pieces = $ossClient->generateMultiuploadParts($length, $part_size); +$response_upload_part = array(); +$copyId = 1; +$upload_position = 0; +foreach ($pieces as $i => $piece) { + $from_pos = $upload_position + (integer)$piece['seekTo']; + $to_pos = (integer)$piece['length'] + $from_pos - 1; + $up_options = array( + 'start' => $from_pos, + 'end' => $to_pos, + ); + $response_upload_part[] = $ossClient->uploadPartCopy( $fromBucket, $fromObject, $toBucket, $toObject, $copyId, $upload_id, $up_options); + printf("initiateMultipartUpload, uploadPartCopy - part#{$copyId} OK\n"); + $copyId = $copyId + 1; +} +$upload_parts = array(); +foreach ($response_upload_part as $i => $etag) { + $upload_parts[] = array( + 'PartNumber' => ($i + 1), + 'ETag' => $etag, + ); +} +$result = $ossClient->completeMultipartUpload($toBucket, $toObject, $upload_id, $upload_parts); +$config = $ossClient->getObjectTagging($bucket, $toObject); +Common::println($toObject.' tags is:'.$config->serializeToXml()); + + + +//******************************* For complete usage, see the following functions **************************************************** + +putObject($ossClient,$bucket); +multiuploadFile($ossClient,$bucket); +appendObject($ossClient,$bucket); +putObjectTagging($ossClient,$bucket); +getObjectTagging($ossClient,$bucket); +deleteObjectTagging($ossClient,$bucket); +copyObjectSmall($ossClient,$bucket); +copyObjectLarge($ossClient,$bucket); +/** + * Upload Object add tag + * @param $ossClient OssClient + * @param $bucket bucket_name + */ +function putObject($ossClient,$bucket){ + $object = "b.file"; + $options = array( + OssClient::OSS_HEADERS => array( + 'x-oss-tagging' => 'key1=value1&key2=value2&key3=value3', + )); + try { + // 通过简单上传的方式上传Object。 + $result = $ossClient->putObject($bucket, $object, __FILE__,$options); + Common::println("b.file is created".PHP_EOL); + Common::println("tag is:".$result['oss-requestheaders']['x-oss-tagging'].PHP_EOL); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + + print(__FUNCTION__ . ": OK" . "\n"); +} + +/** + * Add object tags when uploading parts + * @param $ossClient OssClient + * @param $bucket bucket_name + */ +function multiuploadFile($ossClient,$bucket){ + $object = "b.file"; + $file = __FILE__; + $options = array( + OssClient::OSS_CHECK_MD5 => true, + OssClient::OSS_PART_SIZE => 1, + OssClient::OSS_HEADERS => array( + 'x-oss-tagging' => 'key1=value1&key2=value2&key3=value3', + ), + ); + + try { + $result = $ossClient->multiuploadFile($bucket, $object, $file, $options); + Common::println("b.file is created".PHP_EOL); + Common::println("tag is:".$result['oss-requestheaders']['x-oss-tagging'].PHP_EOL); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + + print(__FUNCTION__ . ": OK" . "\n"); +} + +/** + * Add object tags when uploading + * @param $ossClient OssClient + * @param $bucket bucket_name string + */ +function appendObject($ossClient,$bucket){ + $object = "g.file"; + $content_array = array('Hello OSS', 'Hi OSS'); + $options = array( + OssClient::OSS_HEADERS => array( + 'x-oss-tagging' => 'key1=value1&key2=value2', + )); + + try { + $position = $ossClient->appendObject($bucket, $object, $content_array[0], 0, $options); + printf($content_array[0].' append object Success'.PHP_EOL); + $position = $ossClient->appendObject($bucket, $object, $content_array[1], $position); + printf($content_array[1].' append object Success'.PHP_EOL); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + + print(__FUNCTION__ . ": OK" . "\n"); +} + +/** + * @param $ossClient OssClient + * @param $bucket bucket_name string + * @throws OssException + */ +function putObjectTagging($ossClient,$bucket){ + $object = "g.file"; + $config = new TaggingConfig(); + $config->addTag(new Tag("key1", "value1")); + $config->addTag(new Tag("key2", "value2")); + + try { + $ossClient->putObjectTagging($bucket, $object, $config); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + + print(__FUNCTION__ . ": OK" . "\n"); +} + + +/** + * get object tags + * @param $ossClient OssClient + * @param $bucket bucket_name string + */ +function getObjectTagging($ossClient,$bucket){ + $object = "g.file"; + try { + $config = $ossClient->getObjectTagging($bucket, $object); + printf($object." tags is:".$config->serializeToXml().PHP_EOL); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + + print(__FUNCTION__ . ": OK" . "\n"); +} + + +/** + * get object tags + * @param $ossClient OssClient + * @param $bucket bucket_name string + */ +function deleteObjectTagging($ossClient,$bucket){ + $object = "g.file"; + try { + $ossClient->deleteObjectTagging($bucket, $object); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + + print(__FUNCTION__ . ": OK" . "\n"); +} + +/** + * Copy small files + * @param $ossClient OssClient + * @param $bucket bucket_name string + */ +function copyObjectSmall($ossClient,$bucket){ + $fromBucket = $bucket; + $fromObject = "a.file"; + $toBucket = $bucket; + $toObject = $fromObject . '.copy'; + $options = array( + OssClient::OSS_HEADERS => array( + 'x-oss-tagging-directive' => 'Replace', + 'x-oss-tagging'=>'key1=value1&key2=value2&key3=value3', + )); + + try { + $ossClient->copyObject($fromBucket, $fromObject, $toBucket, $toObject, $options); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + + $config = $ossClient->getObjectTagging($bucket, $toObject); + Common::println('object tags is:'.$config->serializeToXml()); + print(__FUNCTION__ . ": OK" . "\n"); +} + +/** + * Copy a large file + * @param $ossClient OssClient + * @param $bucket bucket_name string + */ +function copyObjectLarge($ossClient,$bucket){ + $fromBucket = $bucket; + $fromObject = "a.file"; + $toBucket = $bucket; + $toObject = $fromObject . '.copy'; + $options = array( + OssClient::OSS_HEADERS => array( + 'x-oss-tagging'=>'key1=value1&key2=value2&key3=value3', + )); + + $part_size = 256*1024*1024; + try{ + $objectMeta = $ossClient->getObjectMeta($fromBucket, $fromObject); + $length = $objectMeta['content-length']; + $upload_id = $ossClient->initiateMultipartUpload($toBucket, $toObject,$options); + $pieces = $ossClient->generateMultiuploadParts($length, $part_size); + $response_upload_part = array(); + $copyId = 1; + $upload_position = 0; + foreach ($pieces as $i => $piece) { + $from_pos = $upload_position + (integer)$piece['seekTo']; + $to_pos = (integer)$piece['length'] + $from_pos - 1; + $up_options = array( + 'start' => $from_pos, + 'end' => $to_pos, + ); + $response_upload_part[] = $ossClient->uploadPartCopy( $fromBucket, $fromObject, $toBucket, $toObject, $copyId, $upload_id, $up_options); + printf("initiateMultipartUpload, uploadPartCopy - part#{$copyId} OK\n"); + $copyId = $copyId + 1; + } + $upload_parts = array(); + foreach ($response_upload_part as $i => $etag) { + $upload_parts[] = array( + 'PartNumber' => ($i + 1), + 'ETag' => $etag, + ); + } + $result = $ossClient->completeMultipartUpload($toBucket, $toObject, $upload_id, $upload_parts); + printf('copy success'. "\n"); + } catch(OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + + + } + $config = $ossClient->getObjectTagging($bucket, $toObject); + Common::println($toObject.' tags is:'.$config->serializeToXml()); + print(__FUNCTION__ . ": OK" . "\n"); +} + diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/samples/RunAll.php b/vendor/vendor/aliyuncs/oss-sdk-php/samples/RunAll.php new file mode 100644 index 0000000..0cd7ec1 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/samples/RunAll.php @@ -0,0 +1,13 @@ +uploadFile($bucket, "a.file", __FILE__); + +// Generate a signed url for getting an object. The URL can be used in browser directly to download the file. +$signedUrl = $ossClient->signUrl($bucket, "a.file", 3600); +Common::println($signedUrl); + +// Generate the signed url for putting an object. User can use put method with this url to upload a file to "a.file". +$signedUrl = $ossClient->signUrl($bucket, "a.file", "3600", "PUT"); +Common::println($signedUrl); + +// Generate the signed url for putting an object from local file. The url can be used directly to upload the file to "a.file". +$signedUrl = $ossClient->signUrl($bucket, "a.file", 3600, "PUT", array('Content-Type' => 'txt')); +Common::println($signedUrl); + +//******************************* For complete usage, see the following functions **************************************************** + +getSignedUrlForPuttingObject($ossClient, $bucket); +getSignedUrlForPuttingObjectFromFile($ossClient, $bucket); +getSignedUrlForGettingObject($ossClient, $bucket); + +/** + * Generate the signed url for getObject() to control read accesses under private privilege + * + * @param $ossClient OssClient OssClient instance + * @param $bucket string bucket name + * @return null + */ +function getSignedUrlForGettingObject($ossClient, $bucket) +{ + $object = "test/test-signature-test-upload-and-download.txt"; + $timeout = 3600; + try { + $signedUrl = $ossClient->signUrl($bucket, $object, $timeout); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": signedUrl: " . $signedUrl . "\n"); + /** + * Use similar code to access the object by url, or use browser to access the object. + */ + $request = new RequestCore($signedUrl); + $request->set_method('GET'); + $request->add_header('Content-Type', ''); + $request->send_request(); + $res = new ResponseCore($request->get_response_header(), $request->get_response_body(), $request->get_response_code()); + if ($res->isOK()) { + print(__FUNCTION__ . ": OK" . "\n"); + } else { + print(__FUNCTION__ . ": FAILED" . "\n"); + }; +} + +/** + * Generate the signed url for PutObject to control write accesses under private privilege. + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + * @throws OssException + */ +function getSignedUrlForPuttingObject($ossClient, $bucket) +{ + $object = "test/test-signature-test-upload-and-download.txt"; + $timeout = 3600; + $options = NULL; + try { + $signedUrl = $ossClient->signUrl($bucket, $object, $timeout, "PUT"); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": signedUrl: " . $signedUrl . "\n"); + $content = file_get_contents(__FILE__); + + $request = new RequestCore($signedUrl); + $request->set_method('PUT'); + $request->add_header('Content-Type', ''); + $request->add_header('Content-Length', strlen($content)); + $request->set_body($content); + $request->send_request(); + $res = new ResponseCore($request->get_response_header(), + $request->get_response_body(), $request->get_response_code()); + if ($res->isOK()) { + print(__FUNCTION__ . ": OK" . "\n"); + } else { + print(__FUNCTION__ . ": FAILED" . "\n"); + }; +} + +/** + * Generate the signed url for PutObject's signed url. User could use the signed url to upload file directly. + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @throws OssException + */ +function getSignedUrlForPuttingObjectFromFile($ossClient, $bucket) +{ + $file = __FILE__; + $object = "test/test-signature-test-upload-and-download.txt"; + $timeout = 3600; + $options = array('Content-Type' => 'txt'); + try { + $signedUrl = $ossClient->signUrl($bucket, $object, $timeout, "PUT", $options); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": signedUrl: " . $signedUrl . "\n"); + + $request = new RequestCore($signedUrl); + $request->set_method('PUT'); + $request->add_header('Content-Type', 'txt'); + $request->set_read_file($file); + $request->set_read_stream_size(sprintf('%u',filesize($file))); + $request->send_request(); + $res = new ResponseCore($request->get_response_header(), + $request->get_response_body(), $request->get_response_code()); + if ($res->isOK()) { + print(__FUNCTION__ . ": OK" . "\n"); + } else { + print(__FUNCTION__ . ": FAILED" . "\n"); + }; +} \ No newline at end of file diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Core/MimeTypes.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Core/MimeTypes.php new file mode 100644 index 0000000..17685c3 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Core/MimeTypes.php @@ -0,0 +1,263 @@ + 1) { + $ext = strtolower(end($parts)); + if (isset(self::$mime_types[$ext])) { + return self::$mime_types[$ext]; + } + } + + return null; + } + + private static $mime_types = array( + 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', + 'xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template', + 'potx' => 'application/vnd.openxmlformats-officedocument.presentationml.template', + 'ppsx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow', + 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation', + 'sldx' => 'application/vnd.openxmlformats-officedocument.presentationml.slide', + 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', + 'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template', + 'xlam' => 'application/vnd.ms-excel.addin.macroEnabled.12', + 'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroEnabled.12', + 'apk' => 'application/vnd.android.package-archive', + 'hqx' => 'application/mac-binhex40', + 'cpt' => 'application/mac-compactpro', + 'doc' => 'application/msword', + 'ogg' => 'audio/ogg', + 'pdf' => 'application/pdf', + 'rtf' => 'text/rtf', + 'mif' => 'application/vnd.mif', + 'xls' => 'application/vnd.ms-excel', + 'ppt' => 'application/vnd.ms-powerpoint', + 'odc' => 'application/vnd.oasis.opendocument.chart', + 'odb' => 'application/vnd.oasis.opendocument.database', + 'odf' => 'application/vnd.oasis.opendocument.formula', + 'odg' => 'application/vnd.oasis.opendocument.graphics', + 'otg' => 'application/vnd.oasis.opendocument.graphics-template', + 'odi' => 'application/vnd.oasis.opendocument.image', + 'odp' => 'application/vnd.oasis.opendocument.presentation', + 'otp' => 'application/vnd.oasis.opendocument.presentation-template', + 'ods' => 'application/vnd.oasis.opendocument.spreadsheet', + 'ots' => 'application/vnd.oasis.opendocument.spreadsheet-template', + 'odt' => 'application/vnd.oasis.opendocument.text', + 'odm' => 'application/vnd.oasis.opendocument.text-master', + 'ott' => 'application/vnd.oasis.opendocument.text-template', + 'oth' => 'application/vnd.oasis.opendocument.text-web', + 'sxw' => 'application/vnd.sun.xml.writer', + 'stw' => 'application/vnd.sun.xml.writer.template', + 'sxc' => 'application/vnd.sun.xml.calc', + 'stc' => 'application/vnd.sun.xml.calc.template', + 'sxd' => 'application/vnd.sun.xml.draw', + 'std' => 'application/vnd.sun.xml.draw.template', + 'sxi' => 'application/vnd.sun.xml.impress', + 'sti' => 'application/vnd.sun.xml.impress.template', + 'sxg' => 'application/vnd.sun.xml.writer.global', + 'sxm' => 'application/vnd.sun.xml.math', + 'sis' => 'application/vnd.symbian.install', + 'wbxml' => 'application/vnd.wap.wbxml', + 'wmlc' => 'application/vnd.wap.wmlc', + 'wmlsc' => 'application/vnd.wap.wmlscriptc', + 'bcpio' => 'application/x-bcpio', + 'torrent' => 'application/x-bittorrent', + 'bz2' => 'application/x-bzip2', + 'vcd' => 'application/x-cdlink', + 'pgn' => 'application/x-chess-pgn', + 'cpio' => 'application/x-cpio', + 'csh' => 'application/x-csh', + 'dvi' => 'application/x-dvi', + 'spl' => 'application/x-futuresplash', + 'gtar' => 'application/x-gtar', + 'hdf' => 'application/x-hdf', + 'jar' => 'application/java-archive', + 'jnlp' => 'application/x-java-jnlp-file', + 'js' => 'application/javascript', + 'json' => 'application/json', + 'ksp' => 'application/x-kspread', + 'chrt' => 'application/x-kchart', + 'kil' => 'application/x-killustrator', + 'latex' => 'application/x-latex', + 'rpm' => 'application/x-rpm', + 'sh' => 'application/x-sh', + 'shar' => 'application/x-shar', + 'swf' => 'application/x-shockwave-flash', + 'sit' => 'application/x-stuffit', + 'sv4cpio' => 'application/x-sv4cpio', + 'sv4crc' => 'application/x-sv4crc', + 'tar' => 'application/x-tar', + 'tcl' => 'application/x-tcl', + 'tex' => 'application/x-tex', + 'man' => 'application/x-troff-man', + 'me' => 'application/x-troff-me', + 'ms' => 'application/x-troff-ms', + 'ustar' => 'application/x-ustar', + 'src' => 'application/x-wais-source', + 'zip' => 'application/zip', + 'm3u' => 'audio/x-mpegurl', + 'ra' => 'audio/x-pn-realaudio', + 'wav' => 'audio/x-wav', + 'wma' => 'audio/x-ms-wma', + 'wax' => 'audio/x-ms-wax', + 'pdb' => 'chemical/x-pdb', + 'xyz' => 'chemical/x-xyz', + 'bmp' => 'image/bmp', + 'gif' => 'image/gif', + 'ief' => 'image/ief', + 'png' => 'image/png', + 'wbmp' => 'image/vnd.wap.wbmp', + 'ras' => 'image/x-cmu-raster', + 'pnm' => 'image/x-portable-anymap', + 'pbm' => 'image/x-portable-bitmap', + 'pgm' => 'image/x-portable-graymap', + 'ppm' => 'image/x-portable-pixmap', + 'rgb' => 'image/x-rgb', + 'xbm' => 'image/x-xbitmap', + 'xpm' => 'image/x-xpixmap', + 'xwd' => 'image/x-xwindowdump', + 'css' => 'text/css', + 'rtx' => 'text/richtext', + 'tsv' => 'text/tab-separated-values', + 'jad' => 'text/vnd.sun.j2me.app-descriptor', + 'wml' => 'text/vnd.wap.wml', + 'wmls' => 'text/vnd.wap.wmlscript', + 'etx' => 'text/x-setext', + 'mxu' => 'video/vnd.mpegurl', + 'flv' => 'video/x-flv', + 'wm' => 'video/x-ms-wm', + 'wmv' => 'video/x-ms-wmv', + 'wmx' => 'video/x-ms-wmx', + 'wvx' => 'video/x-ms-wvx', + 'avi' => 'video/x-msvideo', + 'movie' => 'video/x-sgi-movie', + 'ice' => 'x-conference/x-cooltalk', + '3gp' => 'video/3gpp', + 'ai' => 'application/postscript', + 'aif' => 'audio/x-aiff', + 'aifc' => 'audio/x-aiff', + 'aiff' => 'audio/x-aiff', + 'asc' => 'text/plain', + 'atom' => 'application/atom+xml', + 'au' => 'audio/basic', + 'bin' => 'application/octet-stream', + 'cdf' => 'application/x-netcdf', + 'cgm' => 'image/cgm', + 'class' => 'application/octet-stream', + 'dcr' => 'application/x-director', + 'dif' => 'video/x-dv', + 'dir' => 'application/x-director', + 'djv' => 'image/vnd.djvu', + 'djvu' => 'image/vnd.djvu', + 'dll' => 'application/octet-stream', + 'dmg' => 'application/octet-stream', + 'dms' => 'application/octet-stream', + 'dtd' => 'application/xml-dtd', + 'dv' => 'video/x-dv', + 'dxr' => 'application/x-director', + 'eps' => 'application/postscript', + 'exe' => 'application/octet-stream', + 'ez' => 'application/andrew-inset', + 'gram' => 'application/srgs', + 'grxml' => 'application/srgs+xml', + 'gz' => 'application/x-gzip', + 'htm' => 'text/html', + 'html' => 'text/html', + 'ico' => 'image/x-icon', + 'ics' => 'text/calendar', + 'ifb' => 'text/calendar', + 'iges' => 'model/iges', + 'igs' => 'model/iges', + 'jp2' => 'image/jp2', + 'jpe' => 'image/jpeg', + 'jpeg' => 'image/jpeg', + 'jpg' => 'image/jpeg', + 'kar' => 'audio/midi', + 'lha' => 'application/octet-stream', + 'lzh' => 'application/octet-stream', + 'm4a' => 'audio/mp4a-latm', + 'm4p' => 'audio/mp4a-latm', + 'm4u' => 'video/vnd.mpegurl', + 'm4v' => 'video/x-m4v', + 'mac' => 'image/x-macpaint', + 'mathml' => 'application/mathml+xml', + 'mesh' => 'model/mesh', + 'mid' => 'audio/midi', + 'midi' => 'audio/midi', + 'mov' => 'video/quicktime', + 'mp2' => 'audio/mpeg', + 'mp3' => 'audio/mpeg', + 'mp4' => 'video/mp4', + 'mpe' => 'video/mpeg', + 'mpeg' => 'video/mpeg', + 'mpg' => 'video/mpeg', + 'mpga' => 'audio/mpeg', + 'msh' => 'model/mesh', + 'nc' => 'application/x-netcdf', + 'oda' => 'application/oda', + 'ogv' => 'video/ogv', + 'pct' => 'image/pict', + 'pic' => 'image/pict', + 'pict' => 'image/pict', + 'pnt' => 'image/x-macpaint', + 'pntg' => 'image/x-macpaint', + 'ps' => 'application/postscript', + 'qt' => 'video/quicktime', + 'qti' => 'image/x-quicktime', + 'qtif' => 'image/x-quicktime', + 'ram' => 'audio/x-pn-realaudio', + 'rdf' => 'application/rdf+xml', + 'rm' => 'application/vnd.rn-realmedia', + 'roff' => 'application/x-troff', + 'sgm' => 'text/sgml', + 'sgml' => 'text/sgml', + 'silo' => 'model/mesh', + 'skd' => 'application/x-koan', + 'skm' => 'application/x-koan', + 'skp' => 'application/x-koan', + 'skt' => 'application/x-koan', + 'smi' => 'application/smil', + 'smil' => 'application/smil', + 'snd' => 'audio/basic', + 'so' => 'application/octet-stream', + 'svg' => 'image/svg+xml', + 't' => 'application/x-troff', + 'texi' => 'application/x-texinfo', + 'texinfo' => 'application/x-texinfo', + 'tif' => 'image/tiff', + 'tiff' => 'image/tiff', + 'tr' => 'application/x-troff', + 'txt' => 'text/plain', + 'vrml' => 'model/vrml', + 'vxml' => 'application/voicexml+xml', + 'webm' => 'video/webm', + 'webp' => 'image/webp', + 'wrl' => 'model/vrml', + 'xht' => 'application/xhtml+xml', + 'xhtml' => 'application/xhtml+xml', + 'xml' => 'application/xml', + 'xsl' => 'application/xml', + 'xslt' => 'application/xslt+xml', + 'xul' => 'application/vnd.mozilla.xul+xml', + ); +} \ No newline at end of file diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Core/OssException.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Core/OssException.php new file mode 100644 index 0000000..2320c9e --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Core/OssException.php @@ -0,0 +1,54 @@ +details = $details; + } else { + $message = $details; + parent::__construct($message); + } + } + + public function getHTTPStatus() + { + return isset($this->details['status']) ? $this->details['status'] : ''; + } + + public function getRequestId() + { + return isset($this->details['request-id']) ? $this->details['request-id'] : ''; + } + + public function getErrorCode() + { + return isset($this->details['code']) ? $this->details['code'] : ''; + } + + public function getErrorMessage() + { + return isset($this->details['message']) ? $this->details['message'] : ''; + } + + public function getDetails() + { + return isset($this->details['body']) ? $this->details['body'] : ''; + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Core/OssUtil.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Core/OssUtil.php new file mode 100644 index 0000000..e70609a --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Core/OssUtil.php @@ -0,0 +1,543 @@ + $value) { + if (is_string($key) && !is_array($value)) { + if (strlen($value) > 0) { + $temp[] = rawurlencode($key) . '=' . rawurlencode($value); + } else { + $temp[] = rawurlencode($key); + } + } + } + return implode('&', $temp); + } + + /** + * Html encoding '<', '>', '&', '\', '"' in subject parameter. + * + * @param string $subject + * @return string + */ + public static function sReplace($subject) + { + $search = array('<', '>', '&', '\'', '"'); + $replace = array('<', '>', '&', ''', '"'); + return str_replace($search, $replace, $subject); + } + + /** + * Check whether the string includes any chinese character + * + * @param $str + * @return int + */ + public static function chkChinese($str) + { + return preg_match('/[\x80-\xff]./', $str); + } + + /** + * Checks if the string is encoded by GB2312. + * + * @param string $str + * @return boolean false UTF-8 encoding TRUE GB2312 encoding + */ + public static function isGb2312($str) + { + for ($i = 0; $i < strlen($str); $i++) { + $v = ord($str[$i]); + if ($v > 127) { + if (($v >= 228) && ($v <= 233)) { + if (($i + 2) >= (strlen($str) - 1)) return true; // not enough characters + $v1 = ord($str[$i + 1]); + $v2 = ord($str[$i + 2]); + if (($v1 >= 128) && ($v1 <= 191) && ($v2 >= 128) && ($v2 <= 191)) + return false; + else + return true; + } + } + } + return false; + } + + /** + * Checks if the string is encoded by GBK + * + * @param string $str + * @param boolean $gbk + * @return boolean + */ + public static function checkChar($str, $gbk = true) + { + for ($i = 0; $i < strlen($str); $i++) { + $v = ord($str[$i]); + if ($v > 127) { + if (($v >= 228) && ($v <= 233)) { + if (($i + 2) >= (strlen($str) - 1)) return $gbk ? true : FALSE; // not enough characters + $v1 = ord($str[$i + 1]); + $v2 = ord($str[$i + 2]); + if ($gbk) { + return (($v1 >= 128) && ($v1 <= 191) && ($v2 >= 128) && ($v2 <= 191)) ? FALSE : TRUE;//GBK + } else { + return (($v1 >= 128) && ($v1 <= 191) && ($v2 >= 128) && ($v2 <= 191)) ? TRUE : FALSE; + } + } + } + } + return $gbk ? TRUE : FALSE; + } + + /** + * Checks if the bucket name is valid + * bucket naming rules + * 1. Can only include lowercase letters, numbers, or dashes + * 2. Must start and end with lowercase letters or numbers + * 3. Must be within a length from 3 to 63 bytes. + * + * @param string $bucket Bucket name + * @return boolean + */ + public static function validateBucket($bucket) + { + $pattern = '/^[a-z0-9][a-z0-9-]{2,62}$/'; + if (!preg_match($pattern, $bucket)) { + return false; + } + return true; + } + + /** + * Checks if object name is valid + * object naming rules: + * 1. Must be within a length from 1 to 1023 bytes + * 2. Cannot start with '/' or '\\'. + * 3. Must be encoded in UTF-8. + * + * @param string $object Object名称 + * @return boolean + */ + public static function validateObject($object) + { + $pattern = '/^.{1,1023}$/'; + if (!preg_match($pattern, $object) || + self::startsWith($object, '/') || self::startsWith($object, '\\') + ) { + return false; + } + return true; + } + + + /** + * Checks if $str starts with $findMe + * + * @param string $str + * @param string $findMe + * @return bool + */ + public static function startsWith($str, $findMe) + { + if (strpos($str, $findMe) === 0) { + return true; + } else { + return false; + } + } + + + /** + * Generate the xml message of createBucketXmlBody. + * + * @param string $storageClass + * @return string + */ + public static function createBucketXmlBody($storageClass) + { + $xml = new \SimpleXMLElement(''); + $xml->addChild('StorageClass', $storageClass); + return $xml->asXML(); + } + + /** + * validate $options + * + * @param array $options + * @throws OssException + */ + public static function validateOptions($options) + { + //$options + if ($options != NULL && !is_array($options)) { + throw new OssException ($options . ':' . 'option must be array'); + } + } + + /** + * check whether the Content is valid. + * + * @param $content string + * @throws OssException + */ + public static function validateContent($content) + { + if (empty($content)) { + throw new OssException("http body content is invalid"); + } + } + + /** + * Check if BUCKET/OBJECT/OBJECT GROUP is empty. + * + * @param string $name + * @param string $errMsg + * @throws OssException + * @return void + */ + public static function throwOssExceptionWithMessageIfEmpty($name, $errMsg) + { + if (empty($name)) { + if (is_string($name) && $name == '0') + return; + throw new OssException($errMsg); + } + } + + /** + * This is a method for test only. DO NOT USE. + * + * @param $filename + * @param $size + */ + public static function generateFile($filename, $size) + { + if (file_exists($filename) && $size == sprintf('%u',filesize($filename))) { + echo $filename . " already exists, no need to create again. "; + return; + } + $part_size = 1 * 1024 * 1024; + $fp = fopen($filename, "w"); + $characters = << 0) { + if ($size < $part_size) { + $write_size = $size; + } else { + $write_size = $part_size; + } + $size -= $write_size; + $a = $characters[rand(0, $charactersLength - 1)]; + $content = str_repeat($a, $write_size); + $flag = fwrite($fp, $content); + if (!$flag) { + echo "write to " . $filename . " failed.
    "; + break; + } + } + } else { + echo "open " . $filename . " failed.
    "; + } + fclose($fp); + } + + /** + * Get MD5 of the file. + * + * @param $filename + * @param $from_pos + * @param $to_pos + * @return string + */ + public static function getMd5SumForFile($filename, $from_pos, $to_pos) + { + $content_md5 = ""; + if (($to_pos - $from_pos) > self::OSS_MAX_PART_SIZE) { + return $content_md5; + } + $filesize = sprintf('%u',filesize($filename)); + if ($from_pos >= $filesize || $to_pos >= $filesize || $from_pos < 0 || $to_pos < 0) { + return $content_md5; + } + + $total_length = $to_pos - $from_pos + 1; + $buffer = 8192; + $left_length = $total_length; + if (!file_exists($filename)) { + return $content_md5; + } + + if (false === $fh = fopen($filename, 'rb')) { + return $content_md5; + } + + fseek($fh, $from_pos); + $data = ''; + while (!feof($fh)) { + if ($left_length >= $buffer) { + $read_length = $buffer; + } else { + $read_length = $left_length; + } + if ($read_length <= 0) { + break; + } else { + $data .= fread($fh, $read_length); + $left_length = $left_length - $read_length; + } + } + fclose($fh); + $content_md5 = base64_encode(md5($data, true)); + return $content_md5; + } + + /** + * Check if the OS is Windows. The default encoding in Windows is GBK. + * + * @return bool + */ + public static function isWin() + { + return strtoupper(substr(PHP_OS, 0, 3)) == "WIN"; + } + + /** + * Encodes the file path from GBK to UTF-8. + * The default encoding in Windows is GBK. + * And if the file path is in Chinese, the file would not be found without the transcoding to UTF-8. + * + * @param $file_path + * @return string + */ + public static function encodePath($file_path) + { + if (self::chkChinese($file_path) && self::isWin()) { + $file_path = iconv('utf-8', 'gbk', $file_path); + } + return $file_path; + } + + /** + * Check if the endpoint is in the IPv4 format, such as xxx.xxx.xxx.xxx:port or xxx.xxx.xxx.xxx. + * + * @param string $endpoint The endpoint to check. + * @return boolean + */ + public static function isIPFormat($endpoint) + { + $ip_array = explode(":", $endpoint); + $hostname = $ip_array[0]; + $ret = filter_var($hostname, FILTER_VALIDATE_IP); + if (!$ret) { + return false; + } else { + return true; + } + } + + /** + * Get the host:port from endpoint. + * + * @param string $endpoint the endpoint. + * @return string + * @throws OssException + */ + public static function getHostPortFromEndpoint($endpoint) + { + $str = $endpoint; + $pos = strpos($str, "://"); + if ($pos !== false) { + $str = substr($str, $pos+3); + } + + $pos = strpos($str, '#'); + if ($pos !== false) { + $str = substr($str, 0, $pos); + } + + $pos = strpos($str, '?'); + if ($pos !== false) { + $str = substr($str, 0, $pos); + } + + $pos = strpos($str, '/'); + if ($pos !== false) { + $str = substr($str, 0, $pos); + } + + $pos = strpos($str, '@'); + if ($pos !== false) { + $str = substr($str, $pos+1); + } + + if (!preg_match('/^[\w.-]+(:[0-9]+)?$/', $str)) { + throw new OssException("endpoint is invalid:" . $endpoint); + } + + return $str; + } + + /** + * Generate the xml message of DeleteMultiObjects. + * + * @param string[] $objects + * @param bool $quiet + * @return string + */ + public static function createDeleteObjectsXmlBody($objects, $quiet) + { + $xml = new \SimpleXMLElement(''); + $xml->addChild('Quiet', $quiet); + foreach ($objects as $object) { + $sub_object = $xml->addChild('Object'); + $object = OssUtil::sReplace($object); + $sub_object->addChild('Key', $object); + } + return $xml->asXML(); + } + + /** + * Generate the xml message of DeleteMultiObjects. + * + * @param DeleteObjectInfo[] $objects + * @param bool $quiet + * @return string + */ + public static function createDeleteObjectVersionsXmlBody($objects, $quiet) + { + $xml = new \SimpleXMLElement(''); + $xml->addChild('Quiet', $quiet); + foreach ($objects as $object) { + $sub_object = $xml->addChild('Object'); + $key = OssUtil::sReplace($object->getKey()); + $sub_object->addChild('Key', $key); + $versionId = $object->getVersionId(); + if (!empty($versionId)) { + $sub_object->addChild('VersionId', $object->getVersionId()); + } + } + return $xml->asXML(); + } + + /** + * Generate the xml message of CompleteMultipartUpload. + * + * @param array[] $listParts + * @return string + */ + public static function createCompleteMultipartUploadXmlBody($listParts) + { + $xml = new \SimpleXMLElement(''); + foreach ($listParts as $node) { + $part = $xml->addChild('Part'); + $part->addChild('PartNumber', $node['PartNumber']); + $part->addChild('ETag', $node['ETag']); + } + return $xml->asXML(); + } + + /** + * Read the directory, return a associative array in which the MD5 is the named key and the is the value. + * + * @param string $dir + * @param string $exclude + * @param bool $recursive + * @return string[] + */ + public static function readDir($dir, $exclude = ".|..|.svn|.git", $recursive = false) + { + $file_list_array = array(); + $base_path = $dir; + $exclude_array = explode("|", $exclude); + $exclude_array = array_unique(array_merge($exclude_array, array('.', '..'))); + + if ($recursive) { + foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($dir)) as $new_file) { + if ($new_file->isDir()) continue; + $object = str_replace($base_path, '', $new_file); + if (!in_array(strtolower($object), $exclude_array)) { + $object = ltrim($object, '/'); + if (is_file($new_file)) { + $key = md5($new_file . $object, false); + $file_list_array[$key] = array('path' => $new_file, 'file' => $object,); + } + } + } + } else if ($handle = opendir($dir)) { + while (false !== ($file = readdir($handle))) { + if (!in_array(strtolower($file), $exclude_array)) { + $new_file = $dir . '/' . $file; + $object = $file; + $object = ltrim($object, '/'); + if (is_file($new_file)) { + $key = md5($new_file . $object, false); + $file_list_array[$key] = array('path' => $new_file, 'file' => $object,); + } + } + } + closedir($handle); + } + return $file_list_array; + } + + /** + * Decode key based on the encoding type + * + * @param string $key + * @param string $encoding + * @return string + */ + public static function decodeKey($key, $encoding) + { + if ($encoding == "") { + return $key; + } + + if ($encoding == "url") { + return rawurldecode($key); + } else { + throw new OssException("Unrecognized encoding type: " . $encoding); + } + } + + public static function unparseUrl($parsed_url) { + $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : ''; + $host = isset($parsed_url['host']) ? $parsed_url['host'] : ''; + $port = isset($parsed_url['port']) ? ':' . $parsed_url['port'] : ''; + $path = isset($parsed_url['path']) ? $parsed_url['path'] : ''; + $query = isset($parsed_url['query']) ? '?' . $parsed_url['query'] : ''; + return "$scheme$host$port$path$query"; + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Credentials/Credentials.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Credentials/Credentials.php new file mode 100644 index 0000000..2a8ffb5 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Credentials/Credentials.php @@ -0,0 +1,63 @@ +key = trim($key); + $this->secret = trim($secret); + $this->token = $token; + } + + + /** + * @return string + */ + public function getAccessKeyId() + { + return $this->key; + } + + /** + * @return string + */ + public function getAccessKeySecret() + { + return $this->secret; + } + + /** + * @return string|null + */ + public function getSecurityToken() + { + return $this->token; + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Credentials/CredentialsProvider.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Credentials/CredentialsProvider.php new file mode 100644 index 0000000..b2fde83 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Credentials/CredentialsProvider.php @@ -0,0 +1,11 @@ +credentials = new Credentials($key, $secret, $token); + } + + /** + * @return Credentials + */ + public function getCredentials() + { + return $this->credentials; + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Http/LICENSE b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Http/LICENSE new file mode 100644 index 0000000..49b38bd --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Http/LICENSE @@ -0,0 +1,25 @@ +Copyright (c) 2006-2010 Ryan Parman, Foleeo Inc., and contributors. All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are +permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this list of + conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, this list + of conditions and the following disclaimer in the documentation and/or other materials + provided with the distribution. + + * Neither the name of Ryan Parman, Foleeo Inc. nor the names of its contributors may be used to + endorse or promote products derived from this software without specific prior written + permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS +OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS +AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Http/RequestCore.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Http/RequestCore.php new file mode 100644 index 0000000..58bb215 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Http/RequestCore.php @@ -0,0 +1,898 @@ +). + */ + public $request_class = 'OSS\Http\RequestCore'; + + /** + * The default class to use for HTTP Responses (defaults to ). + */ + public $response_class = 'OSS\Http\ResponseCore'; + + /** + * Default useragent string to use. + */ + public $useragent = 'RequestCore/1.4.3'; + + /** + * File to read from while streaming up. + */ + public $read_file = null; + + /** + * The resource to read from while streaming up. + */ + public $read_stream = null; + + /** + * The size of the stream to read from. + */ + public $read_stream_size = null; + + /** + * The length already read from the stream. + */ + public $read_stream_read = 0; + + /** + * File to write to while streaming down. + */ + public $write_file = null; + + /** + * The resource to write to while streaming down. + */ + public $write_stream = null; + + /** + * Stores the intended starting seek position. + */ + public $seek_position = null; + + /** + * The location of the cacert.pem file to use. + */ + public $cacert_location = false; + + /** + * The state of SSL certificate verification. + */ + public $ssl_verification = true; + + /** + * The user-defined callback function to call when a stream is read from. + */ + public $registered_streaming_read_callback = null; + + /** + * The user-defined callback function to call when a stream is written to. + */ + public $registered_streaming_write_callback = null; + + /** + * The request timeout time, which is 5,184,000 seconds,that is, 60 days by default + * + * @var int + */ + public $timeout = 5184000; + + /** + * The connection timeout time, which is 10 seconds by default + * + * @var int + */ + public $connect_timeout = 10; + + /*%******************************************************************************************%*/ + // CONSTANTS + + /** + * GET HTTP Method + */ + const HTTP_GET = 'GET'; + + /** + * POST HTTP Method + */ + const HTTP_POST = 'POST'; + + /** + * PUT HTTP Method + */ + const HTTP_PUT = 'PUT'; + + /** + * DELETE HTTP Method + */ + const HTTP_DELETE = 'DELETE'; + + /** + * HEAD HTTP Method + */ + const HTTP_HEAD = 'HEAD'; + + + /*%******************************************************************************************%*/ + // CONSTRUCTOR/DESTRUCTOR + + /** + * Construct a new instance of this class. + * + * @param string $url (Optional) The URL to request or service endpoint to query. + * @param string $proxy (Optional) The faux-url to use for proxy settings. Takes the following format: `proxy://user:pass@hostname:port` + * @param array $helpers (Optional) An associative array of classnames to use for request, and response functionality. Gets passed in automatically by the calling class. + * @return $this A reference to the current instance. + */ + public function __construct($url = null, $proxy = null, $helpers = null) + { + // Set some default values. + $this->request_url = $url; + $this->method = self::HTTP_GET; + $this->request_headers = array(); + $this->request_body = ''; + + // Set a new Request class if one was set. + if (isset($helpers['request']) && !empty($helpers['request'])) { + $this->request_class = $helpers['request']; + } + + // Set a new Request class if one was set. + if (isset($helpers['response']) && !empty($helpers['response'])) { + $this->response_class = $helpers['response']; + } + + if ($proxy) { + $this->set_proxy($proxy); + } + + return $this; + } + + /** + * Destruct the instance. Closes opened file handles. + * + * @return $this A reference to the current instance. + */ + public function __destruct() + { + if (isset($this->read_file) && isset($this->read_stream)) { + fclose($this->read_stream); + } + + if (isset($this->write_file) && isset($this->write_stream)) { + fclose($this->write_stream); + } + + return $this; + } + + + /*%******************************************************************************************%*/ + // REQUEST METHODS + + /** + * Set the credentials to use for authentication. + * + * @param string $user (Required) The username to authenticate with. + * @param string $pass (Required) The password to authenticate with. + * @return $this A reference to the current instance. + */ + public function set_credentials($user, $pass) + { + $this->username = $user; + $this->password = $pass; + return $this; + } + + /** + * Add a custom HTTP header to the cURL request. + * + * @param string $key (Required) The custom HTTP header to set. + * @param mixed $value (Required) The value to assign to the custom HTTP header. + * @return $this A reference to the current instance. + */ + public function add_header($key, $value) + { + $this->request_headers[$key] = $value; + return $this; + } + + /** + * Remove an HTTP header from the cURL request. + * + * @param string $key (Required) The custom HTTP header to set. + * @return $this A reference to the current instance. + */ + public function remove_header($key) + { + if (isset($this->request_headers[$key])) { + unset($this->request_headers[$key]); + } + return $this; + } + + /** + * Set the method type for the request. + * + * @param string $method (Required) One of the following constants: , , , , . + * @return $this A reference to the current instance. + */ + public function set_method($method) + { + $this->method = strtoupper($method); + return $this; + } + + /** + * Set a custom useragent string for the class. + * + * @param string $ua (Required) The useragent string to use. + * @return $this A reference to the current instance. + */ + public function set_useragent($ua) + { + $this->useragent = $ua; + return $this; + } + + /** + * Set the body to send in the request. + * + * @param string $body (Required) The textual content to send along in the body of the request. + * @return $this A reference to the current instance. + */ + public function set_body($body) + { + $this->request_body = $body; + return $this; + } + + /** + * Set the URL to make the request to. + * + * @param string $url (Required) The URL to make the request to. + * @return $this A reference to the current instance. + */ + public function set_request_url($url) + { + $this->request_url = $url; + return $this; + } + + /** + * Set additional CURLOPT settings. These will merge with the default settings, and override if + * there is a duplicate. + * + * @param array $curlopts (Optional) A set of key-value pairs that set `CURLOPT` options. These will merge with the existing CURLOPTs, and ones passed here will override the defaults. Keys should be the `CURLOPT_*` constants, not strings. + * @return $this A reference to the current instance. + */ + public function set_curlopts($curlopts) + { + $this->curlopts = $curlopts; + return $this; + } + + /** + * Set the length in bytes to read from the stream while streaming up. + * + * @param integer $size (Required) The length in bytes to read from the stream. + * @return $this A reference to the current instance. + */ + public function set_read_stream_size($size) + { + $this->read_stream_size = $size; + + return $this; + } + + /** + * Set the resource to read from while streaming up. Reads the stream from its current position until + * EOF or `$size` bytes have been read. If `$size` is not given it will be determined by and + * . + * + * @param resource $resource (Required) The readable resource to read from. + * @param integer $size (Optional) The size of the stream to read. + * @return $this A reference to the current instance. + */ + public function set_read_stream($resource, $size = null) + { + if (!isset($size) || $size < 0) { + $stats = fstat($resource); + + if ($stats && $stats['size'] >= 0) { + $position = ftell($resource); + + if ($position !== false && $position >= 0) { + $size = $stats['size'] - $position; + } + } + } + + $this->read_stream = $resource; + + return $this->set_read_stream_size($size); + } + + /** + * Set the file to read from while streaming up. + * + * @param string $location (Required) The readable location to read from. + * @return $this A reference to the current instance. + */ + public function set_read_file($location) + { + $this->read_file = $location; + $read_file_handle = fopen($location, 'r'); + + return $this->set_read_stream($read_file_handle); + } + + /** + * Set the resource to write to while streaming down. + * + * @param resource $resource (Required) The writeable resource to write to. + * @return $this A reference to the current instance. + */ + public function set_write_stream($resource) + { + $this->write_stream = $resource; + + return $this; + } + + /** + * Set the file to write to while streaming down. + * + * @param string $location (Required) The writeable location to write to. + * @return $this A reference to the current instance. + */ + public function set_write_file($location) + { + $this->write_file = $location; + } + + /** + * Set the proxy to use for making requests. + * + * @param string $proxy (Required) The faux-url to use for proxy settings. Takes the following format: `proxy://user:pass@hostname:port` + * @return $this A reference to the current instance. + */ + public function set_proxy($proxy) + { + $proxy = parse_url($proxy); + $proxy['user'] = isset($proxy['user']) ? $proxy['user'] : null; + $proxy['pass'] = isset($proxy['pass']) ? $proxy['pass'] : null; + $proxy['port'] = isset($proxy['port']) ? $proxy['port'] : null; + $this->proxy = $proxy; + return $this; + } + + /** + * Set the intended starting seek position. + * + * @param integer $position (Required) The byte-position of the stream to begin reading from. + * @return $this A reference to the current instance. + */ + public function set_seek_position($position) + { + $this->seek_position = isset($position) ? (integer)$position : null; + + return $this; + } + + /** + * A callback function that is invoked by cURL for streaming up. + * + * @param resource $curl_handle (Required) The cURL handle for the request. + * @param resource $header_content (Required) The header callback result. + * @return headers from a stream. + */ + public function streaming_header_callback($curl_handle, $header_content) + { + $code = curl_getinfo($curl_handle, CURLINFO_HTTP_CODE); + + if (isset($this->write_file) && intval($code) / 100 == 2 && !isset($this->write_file_handle)) + { + $this->write_file_handle = fopen($this->write_file, 'w'); + $this->set_write_stream($this->write_file_handle); + } + + $this->response_raw_headers .= $header_content; + return strlen($header_content); + } + + + /** + * Register a callback function to execute whenever a data stream is read from using + * . + * + * The user-defined callback function should accept three arguments: + * + *
      + *
    • $curl_handle - resource - Required - The cURL handle resource that represents the in-progress transfer.
    • + *
    • $file_handle - resource - Required - The file handle resource that represents the file on the local file system.
    • + *
    • $length - integer - Required - The length in kilobytes of the data chunk that was transferred.
    • + *
    + * + * @param string|array|function $callback (Required) The callback function is called by , so you can pass the following values:
      + *
    • The name of a global function to execute, passed as a string.
    • + *
    • A method to execute, passed as array('ClassName', 'MethodName').
    • + *
    • An anonymous function (PHP 5.3+).
    + * @return $this A reference to the current instance. + */ + public function register_streaming_read_callback($callback) + { + $this->registered_streaming_read_callback = $callback; + + return $this; + } + + /** + * Register a callback function to execute whenever a data stream is written to using + * . + * + * The user-defined callback function should accept two arguments: + * + *
      + *
    • $curl_handle - resource - Required - The cURL handle resource that represents the in-progress transfer.
    • + *
    • $length - integer - Required - The length in kilobytes of the data chunk that was transferred.
    • + *
    + * + * @param string|array|function $callback (Required) The callback function is called by , so you can pass the following values:
      + *
    • The name of a global function to execute, passed as a string.
    • + *
    • A method to execute, passed as array('ClassName', 'MethodName').
    • + *
    • An anonymous function (PHP 5.3+).
    + * @return $this A reference to the current instance. + */ + public function register_streaming_write_callback($callback) + { + $this->registered_streaming_write_callback = $callback; + + return $this; + } + + + /*%******************************************************************************************%*/ + // PREPARE, SEND, AND PROCESS REQUEST + + /** + * A callback function that is invoked by cURL for streaming up. + * + * @param resource $curl_handle (Required) The cURL handle for the request. + * @param resource $file_handle (Required) The open file handle resource. + * @param integer $length (Required) The maximum number of bytes to read. + * @return binary Binary data from a stream. + */ + public function streaming_read_callback($curl_handle, $file_handle, $length) + { + // Once we've sent as much as we're supposed to send... + if ($this->read_stream_read >= $this->read_stream_size) { + // Send EOF + return ''; + } + + // If we're at the beginning of an upload and need to seek... + if ($this->read_stream_read == 0 && isset($this->seek_position) && $this->seek_position !== ftell($this->read_stream)) { + if (fseek($this->read_stream, $this->seek_position) !== 0) { + throw new RequestCore_Exception('The stream does not support seeking and is either not at the requested position or the position is unknown.'); + } + } + + $read = fread($this->read_stream, min($this->read_stream_size - $this->read_stream_read, $length)); // Remaining upload data or cURL's requested chunk size + $this->read_stream_read += strlen($read); + + $out = $read === false ? '' : $read; + + // Execute callback function + if ($this->registered_streaming_read_callback) { + call_user_func($this->registered_streaming_read_callback, $curl_handle, $file_handle, $out); + } + + return $out; + } + + /** + * A callback function that is invoked by cURL for streaming down. + * + * @param resource $curl_handle (Required) The cURL handle for the request. + * @param binary $data (Required) The data to write. + * @return integer The number of bytes written. + */ + public function streaming_write_callback($curl_handle, $data) + { + $code = curl_getinfo($curl_handle, CURLINFO_HTTP_CODE); + + if (intval($code) / 100 != 2) + { + $this->response_error_body .= $data; + return strlen($data); + } + + $length = strlen($data); + $written_total = 0; + $written_last = 0; + + while ($written_total < $length) { + $written_last = fwrite($this->write_stream, substr($data, $written_total)); + + if ($written_last === false) { + return $written_total; + } + + $written_total += $written_last; + } + + // Execute callback function + if ($this->registered_streaming_write_callback) { + call_user_func($this->registered_streaming_write_callback, $curl_handle, $written_total); + } + + return $written_total; + } + + /** + * Prepare and adds the details of the cURL request. This can be passed along to a + * function. + * + * @return resource The handle for the cURL object. + * + */ + public function prep_request() + { + $curl_handle = curl_init(); + + // Set default options. + curl_setopt($curl_handle, CURLOPT_URL, $this->request_url); + curl_setopt($curl_handle, CURLOPT_FILETIME, true); + curl_setopt($curl_handle, CURLOPT_FRESH_CONNECT, false); +// curl_setopt($curl_handle, CURLOPT_CLOSEPOLICY, CURLCLOSEPOLICY_LEAST_RECENTLY_USED); + curl_setopt($curl_handle, CURLOPT_MAXREDIRS, 5); + curl_setopt($curl_handle, CURLOPT_HEADER, true); + curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, true); + curl_setopt($curl_handle, CURLOPT_TIMEOUT, $this->timeout); + curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, $this->connect_timeout); + curl_setopt($curl_handle, CURLOPT_NOSIGNAL, true); + curl_setopt($curl_handle, CURLOPT_REFERER, $this->request_url); + curl_setopt($curl_handle, CURLOPT_USERAGENT, $this->useragent); + curl_setopt($curl_handle, CURLOPT_HEADERFUNCTION, array($this, 'streaming_header_callback')); + curl_setopt($curl_handle, CURLOPT_READFUNCTION, array($this, 'streaming_read_callback')); + + // Verification of the SSL cert + if ($this->ssl_verification) { + curl_setopt($curl_handle, CURLOPT_SSL_VERIFYPEER, true); + curl_setopt($curl_handle, CURLOPT_SSL_VERIFYHOST, 2); + } else { + curl_setopt($curl_handle, CURLOPT_SSL_VERIFYPEER, false); + curl_setopt($curl_handle, CURLOPT_SSL_VERIFYHOST, false); + } + + // chmod the file as 0755 + if ($this->cacert_location === true) { + curl_setopt($curl_handle, CURLOPT_CAINFO, dirname(__FILE__) . '/cacert.pem'); + } elseif (is_string($this->cacert_location)) { + curl_setopt($curl_handle, CURLOPT_CAINFO, $this->cacert_location); + } + + // Debug mode + if ($this->debug_mode) { + curl_setopt($curl_handle, CURLOPT_VERBOSE, true); + } + + // Handle open_basedir & safe mode + if (!ini_get('safe_mode') && !ini_get('open_basedir')) { + curl_setopt($curl_handle, CURLOPT_FOLLOWLOCATION, true); + } + + // Enable a proxy connection if requested. + if ($this->proxy) { + $host = $this->proxy['host']; + $host .= ($this->proxy['port']) ? ':' . $this->proxy['port'] : ''; + curl_setopt($curl_handle, CURLOPT_PROXY, $host); + + if (isset($this->proxy['user']) && isset($this->proxy['pass'])) { + curl_setopt($curl_handle, CURLOPT_PROXYUSERPWD, $this->proxy['user'] . ':' . $this->proxy['pass']); + } + } + + // Set credentials for HTTP Basic/Digest Authentication. + if ($this->username && $this->password) { + curl_setopt($curl_handle, CURLOPT_HTTPAUTH, CURLAUTH_ANY); + curl_setopt($curl_handle, CURLOPT_USERPWD, $this->username . ':' . $this->password); + } + + // Handle the encoding if we can. + if (extension_loaded('zlib')) { + curl_setopt($curl_handle, CURLOPT_ENCODING, ''); + } + + // Process custom headers + if (isset($this->request_headers) && count($this->request_headers)) { + $temp_headers = array(); + + foreach ($this->request_headers as $k => $v) { + $temp_headers[] = $k . ': ' . $v; + } + + // fix "Expect: 100-continue" + $temp_headers[] = 'Expect:'; + curl_setopt($curl_handle, CURLOPT_HTTPHEADER, $temp_headers); + } + + switch ($this->method) { + case self::HTTP_PUT: + //unset($this->read_stream); + curl_setopt($curl_handle, CURLOPT_CUSTOMREQUEST, 'PUT'); + if (isset($this->read_stream)) { + if (!isset($this->read_stream_size) || $this->read_stream_size < 0) { + throw new RequestCore_Exception('The stream size for the streaming upload cannot be determined.'); + } + curl_setopt($curl_handle, CURLOPT_INFILESIZE, $this->read_stream_size); + curl_setopt($curl_handle, CURLOPT_UPLOAD, true); + } else { + curl_setopt($curl_handle, CURLOPT_POSTFIELDS, $this->request_body); + } + break; + + case self::HTTP_POST: + curl_setopt($curl_handle, CURLOPT_CUSTOMREQUEST, 'POST'); + if (isset($this->read_stream)) { + if (!isset($this->read_stream_size) || $this->read_stream_size < 0) { + throw new RequestCore_Exception('The stream size for the streaming upload cannot be determined.'); + } + curl_setopt($curl_handle, CURLOPT_INFILESIZE, $this->read_stream_size); + curl_setopt($curl_handle, CURLOPT_UPLOAD, true); + } else { + curl_setopt($curl_handle, CURLOPT_POSTFIELDS, $this->request_body); + } + break; + + case self::HTTP_HEAD: + curl_setopt($curl_handle, CURLOPT_CUSTOMREQUEST, self::HTTP_HEAD); + curl_setopt($curl_handle, CURLOPT_NOBODY, 1); + break; + + default: // Assumed GET + curl_setopt($curl_handle, CURLOPT_CUSTOMREQUEST, $this->method); + if (isset($this->write_stream) || isset($this->write_file)) { + curl_setopt($curl_handle, CURLOPT_WRITEFUNCTION, array($this, 'streaming_write_callback')); + curl_setopt($curl_handle, CURLOPT_HEADER, false); + } else { + curl_setopt($curl_handle, CURLOPT_POSTFIELDS, $this->request_body); + } + break; + } + + // Merge in the CURLOPTs + if (isset($this->curlopts) && sizeof($this->curlopts) > 0) { + foreach ($this->curlopts as $k => $v) { + curl_setopt($curl_handle, $k, $v); + } + } + + return $curl_handle; + } + + /** + * Take the post-processed cURL data and break it down into useful header/body/info chunks. Uses the + * data stored in the `curl_handle` and `response` properties unless replacement data is passed in via + * parameters. + * + * @param resource|\CurlHandle|null|false $curl_handle (Optional) The reference to the already executed cURL request. Receive CurlHandle instance from PHP8.0 + * @param string $response (Optional) The actual response content itself that needs to be parsed. + * @return ResponseCore A object containing a parsed HTTP response. + */ + public function process_response($curl_handle = null, $response = null) + { + // Accept a custom one if it's passed. + if ($curl_handle && $response) { + $this->response = $response; + } + + // As long as this came back as a valid resource or CurlHandle instance... + if (is_resource($curl_handle) || (is_object($curl_handle) && in_array(get_class($curl_handle),array('CurlHandle','Swoole\Curl\Handler', 'Swoole\Coroutine\Curl\Handle'),true))) { + // Determine what's what. + $header_size = curl_getinfo($curl_handle, CURLINFO_HEADER_SIZE); + $this->response_headers = substr($this->response, 0, $header_size); + $this->response_body = substr($this->response, $header_size); + $this->response_code = curl_getinfo($curl_handle, CURLINFO_HTTP_CODE); + $this->response_info = curl_getinfo($curl_handle); + + if (intval($this->response_code) / 100 != 2 && isset($this->write_file)) + { + $this->response_headers = $this->response_raw_headers; + $this->response_body = $this->response_error_body; + } + + // Parse out the headers + $this->response_headers = explode("\r\n\r\n", trim($this->response_headers)); + $this->response_headers = array_pop($this->response_headers); + $this->response_headers = explode("\r\n", $this->response_headers); + array_shift($this->response_headers); + + // Loop through and split up the headers. + $header_assoc = array(); + foreach ($this->response_headers as $header) { + $kv = explode(': ', $header); + $header_assoc[strtolower($kv[0])] = isset($kv[1]) ? $kv[1] : ''; + } + + // Reset the headers to the appropriate property. + $this->response_headers = $header_assoc; + $this->response_headers['info'] = $this->response_info; + $this->response_headers['info']['method'] = $this->method; + + if ($curl_handle && $response) { + return new ResponseCore($this->response_headers, $this->response_body, $this->response_code); + } + } + + // Return false + return false; + } + + /** + * Send the request, calling necessary utility functions to update built-in properties. + * + * @param boolean $parse (Optional) Whether to parse the response with ResponseCore or not. + * @return string The resulting unparsed data from the request. + */ + public function send_request($parse = false) + { + set_time_limit(0); + + $curl_handle = $this->prep_request(); + $this->response = curl_exec($curl_handle); + + if ($this->response === false) { + throw new RequestCore_Exception('cURL error: ' . curl_error($curl_handle) . ' (' . curl_errno($curl_handle) . ')'); + } + + $parsed_response = $this->process_response($curl_handle, $this->response); + + curl_close($curl_handle); + unset($curl_handle); + + if ($parse) { + return $parsed_response; + } + + return $this->response; + } + + /*%******************************************************************************************%*/ + // RESPONSE METHODS + + /** + * Get the HTTP response headers from the request. + * + * @param string $header (Optional) A specific header value to return. Defaults to all headers. + * @return string|array All or selected header values. + */ + public function get_response_header($header = null) + { + if ($header) { + return $this->response_headers[strtolower($header)]; + } + return $this->response_headers; + } + + /** + * Get the HTTP response body from the request. + * + * @return string The response body. + */ + public function get_response_body() + { + return $this->response_body; + } + + /** + * Get the HTTP response code from the request. + * + * @return string The HTTP response code. + */ + public function get_response_code() + { + return $this->response_code; + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Http/RequestCore_Exception.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Http/RequestCore_Exception.php new file mode 100644 index 0000000..cb4e83c --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Http/RequestCore_Exception.php @@ -0,0 +1,8 @@ +). + * @param string $body (Required) XML-formatted response from OSS. + * @param integer $status (Optional) HTTP response status code from the request. + * @return Mixed Contains an `header` property (HTTP headers as an associative array), a or `body` property, and an `status` code. + */ + public function __construct($header, $body, $status = null) + { + $this->header = $header; + $this->body = $body; + $this->status = $status; + + return $this; + } + + /** + * Did we receive the status code we expected? + * + * @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. + * @return boolean Whether we received the expected status code or not. + */ + public function isOK($codes = array(200, 201, 204, 206)) + { + if (is_array($codes)) { + return in_array($this->status, $codes); + } + + return $this->status === $codes; + } +} \ No newline at end of file diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/BucketInfo.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/BucketInfo.php new file mode 100644 index 0000000..e211eed --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/BucketInfo.php @@ -0,0 +1,181 @@ +location = $location; + $this->createDate = $createDate; + $this->name = $name; + } + + /** + * Get bucket location + * + * @return string + */ + public function getLocation() + { + return $this->location; + } + + /** + * Get bucket name + * + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Get bucket creation time. + * + * @return string + */ + public function getCreateDate() + { + return $this->createDate; + } + + /** + * Get bucket storage class. + * + * @return string + */ + public function getStorageClass() + { + return $this->storageClass; + } + + /** + * Get bucket extranet endpoint. + * + * @return string + */ + public function getExtranetEndpoint() + { + return $this->extranetEndpoint; + } + + /** + * Get bucket intranet endpoint. + * + * @return string + */ + public function getIntranetEndpoint() + { + return $this->intranetEndpoint; + } + + /** + * Get bucket intranet endpoint. + * + * @return string + */ + public function getRegion() + { + return $this->region; + } + + + /** + * Parse bucket information from node. + * + * @param xml $xml + * @throws OssException + * @return null + */ + public function parseFromXmlNode($xml) + { + if (isset($xml->Location)) { + $this->location = strval($xml->Location); + } + if (isset($xml->Name)) { + $this->name = strval($xml->Name); + } + if (isset($xml->CreationDate)) { + $this->createDate = strval($xml->CreationDate); + } + if (isset($xml->StorageClass)) { + $this->storageClass = strval($xml->StorageClass); + } + if (isset($xml->ExtranetEndpoint)) { + $this->extranetEndpoint = strval($xml->ExtranetEndpoint); + } + if (isset($xml->IntranetEndpoint)) { + $this->intranetEndpoint = strval($xml->IntranetEndpoint); + } + if (isset($xml->IntranetEndpoint)) { + $this->intranetEndpoint = strval($xml->IntranetEndpoint); + } + if (isset($xml->Region)) { + $this->region = strval($xml->Region); + } + } + + /** + * bucket region + * + * @var string + */ + private $location; + /** + * bucket name + * + * @var string + */ + private $name; + + /** + * bucket creation time + * + * @var string + */ + private $createDate; + + /** + * bucket storage class + * + * @var string + */ + private $storageClass; + + /** + * bucket extranet endpoint + * + * @var string + */ + private $extranetEndpoint; + + /** + * bucket intranet endpoint + * + * @var string + */ + private $intranetEndpoint; + + /** + * bucket region + * + * @var string + */ + private $region; +} \ No newline at end of file diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/BucketListInfo.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/BucketListInfo.php new file mode 100644 index 0000000..ce03a0d --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/BucketListInfo.php @@ -0,0 +1,39 @@ +bucketList = $bucketList; + } + + /** + * Get the BucketInfo list + * + * @return BucketInfo[] + */ + public function getBucketList() + { + return $this->bucketList; + } + + /** + * BucketInfo list + * + * @var array + */ + private $bucketList = array(); +} \ No newline at end of file diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/BucketStat.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/BucketStat.php new file mode 100644 index 0000000..60c7e55 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/BucketStat.php @@ -0,0 +1,331 @@ +storage; + } + + /** + * Get object count + * + * @return int + */ + public function getObjectCount() + { + return $this->objectCount; + } + + /** + * Get multipart upload count. + * + * @return int + */ + public function getMultipartUploadCount() + { + return $this->multipartUploadCount; + } + + /** + * Get live channel count + * + * @return int + */ + public function getLiveChannelCount() + { + return $this->liveChannelCount; + } + + /** + * Get last modified time + * + * @return int + */ + public function getLastModifiedTime() + { + return $this->lastModifiedTime; + } + + /** + * Get standard storage + * + * @return int + */ + public function getStandardStorage() + { + return $this->standardStorage; + } + + /** + * Get standard object count + * + * @return int + */ + public function getStandardObjectCount() + { + return $this->standardObjectCount; + } + + /** + * Get infrequent access storage + * + * @return int + */ + public function getInfrequentAccessStorage() + { + return $this->infrequentAccessStorage; + } + + /** + * Get infrequent access real storage + * + * @return int + */ + public function getInfrequentAccessRealStorage() + { + return $this->infrequentAccessRealStorage; + } + + /** + * Get infrequent access object count + * + * @return int + */ + public function getInfrequentAccessObjectCount() + { + return $this->infrequentAccessObjectCount; + } + + /** + * Get archive storage + * + * @return int + */ + public function getArchiveStorage() + { + return $this->archiveStorage; + } + + /** + * Get archive real storage + * + * @return int + */ + public function getArchiveRealStorage() + { + return $this->archiveRealStorage; + } + /** + * Get archive object count + * + * @return int + */ + public function getArchiveObjectCount() + { + return $this->archiveObjectCount; + } + + /** + * Get cold archive storage + * + * @return int + */ + public function getColdArchiveStorage() + { + return $this->coldArchiveStorage; + } + + /** + * Get cold archive real storage + * + * @return int + */ + public function getColdArchiveRealStorage() + { + return $this->coldArchiveRealStorage; + } + + /** + * Get cold archive object count + * + * @return int + */ + public function getColdArchiveObjectCount() + { + return $this->coldArchiveObjectCount; + } + + /** + * Parse stat from the xml. + * + * @param string $strXml + * @throws OssException + * @return null + */ + public function parseFromXml($strXml) + { + $xml = simplexml_load_string($strXml); + if (isset($xml->Storage) ) { + $this->storage = intval($xml->Storage); + } + if (isset($xml->ObjectCount) ) { + $this->objectCount = intval($xml->ObjectCount); + } + if (isset($xml->MultipartUploadCount) ) { + $this->multipartUploadCount = intval($xml->MultipartUploadCount); + } + if (isset($xml->LiveChannelCount) ) { + $this->liveChannelCount = intval($xml->LiveChannelCount); + } + if (isset($xml->LastModifiedTime) ) { + $this->lastModifiedTime = intval($xml->LastModifiedTime); + } + if (isset($xml->StandardStorage) ) { + $this->standardStorage = intval($xml->StandardStorage); + } + if (isset($xml->StandardObjectCount) ) { + $this->standardObjectCount = intval($xml->StandardObjectCount); + } + if (isset($xml->InfrequentAccessStorage) ) { + $this->infrequentAccessStorage = intval($xml->InfrequentAccessStorage); + } + if (isset($xml->InfrequentAccessRealStorage) ) { + $this->infrequentAccessRealStorage = intval($xml->InfrequentAccessRealStorage); + } + if (isset($xml->InfrequentAccessObjectCount) ) { + $this->infrequentAccessObjectCount = intval($xml->InfrequentAccessObjectCount); + } + if (isset($xml->ArchiveStorage) ) { + $this->archiveStorage = intval($xml->ArchiveStorage); + } + if (isset($xml->ArchiveRealStorage) ) { + $this->archiveRealStorage = intval($xml->ArchiveRealStorage); + } + if (isset($xml->ArchiveObjectCount) ) { + $this->archiveObjectCount = intval($xml->ArchiveObjectCount); + } + if (isset($xml->ColdArchiveStorage) ) { + $this->coldArchiveStorage = intval($xml->ColdArchiveStorage); + } + if (isset($xml->ColdArchiveRealStorage) ) { + $this->coldArchiveRealStorage = intval($xml->ColdArchiveRealStorage); + } + if (isset($xml->ColdArchiveObjectCount) ) { + $this->coldArchiveObjectCount = intval($xml->ColdArchiveObjectCount); + } + } + + /** + * current storage + * + * @var int + */ + private $storage; + /** + * object count + * + * @var int + */ + private $objectCount; + + /** + * multipart upload count + * + * @var int + */ + private $multipartUploadCount; + + /** + * live channel count + * @var int + */ + private $liveChannelCount; + + /** + * last modified time + * @var int + */ + private $lastModifiedTime; + + /** + * standard storage + * @var int + */ + private $standardStorage; + + /** + * standard object count + * @var int + */ + private $standardObjectCount; + + /** + * infrequent access storage + * @var int + */ + private $infrequentAccessStorage; + + /** + * infrequent access real storage + * @var int + */ + private $infrequentAccessRealStorage; + + /** + * infrequent access object Count + * @var int + */ + private $infrequentAccessObjectCount; + + /** + * archive storage + * @var int + */ + private $archiveStorage; + + /** + * archive real storage + * @var int + */ + private $archiveRealStorage; + + /** + * archive object count + * @var int + */ + private $archiveObjectCount; + + /** + * cold archive storage + * @var int + */ + private $coldArchiveStorage; + + /** + * cold archive real storage + * @var int + */ + private $coldArchiveRealStorage; + + /** + * cold archive object count + * @var int + */ + private $coldArchiveObjectCount; + +} \ No newline at end of file diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/CnameConfig.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/CnameConfig.php new file mode 100644 index 0000000..f3597d2 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/CnameConfig.php @@ -0,0 +1,99 @@ +cnameList = array(); + } + + /** + * @return array + * @example + * array(2) { + * [0]=> + * array(3) { + * ["Domain"]=> + * string(11) "www.foo.com" + * ["Status"]=> + * string(7) "enabled" + * ["LastModified"]=> + * string(8) "20150101" + * } + * [1]=> + * array(3) { + * ["Domain"]=> + * string(7) "bar.com" + * ["Status"]=> + * string(8) "disabled" + * ["LastModified"]=> + * string(8) "20160101" + * } + * } + */ + public function getCnames() + { + return $this->cnameList; + } + + + public function addCname($cname) + { + if (count($this->cnameList) >= self::OSS_MAX_RULES) { + throw new OssException( + "num of cname in the config exceeds self::OSS_MAX_RULES: " . strval(self::OSS_MAX_RULES)); + } + $this->cnameList[] = array('Domain' => $cname); + } + + public function parseFromXml($strXml) + { + $xml = simplexml_load_string($strXml); + if (!isset($xml->Cname)) return; + foreach ($xml->Cname as $entry) { + $cname = array(); + foreach ($entry as $key => $value) { + $cname[strval($key)] = strval($value); + } + $this->cnameList[] = $cname; + } + } + + public function serializeToXml() + { + $strXml = << + + +EOF; + $xml = new \SimpleXMLElement($strXml); + foreach ($this->cnameList as $cname) { + $node = $xml->addChild('Cname'); + foreach ($cname as $key => $value) { + $node->addChild($key, $value); + } + } + return $xml->asXML(); + } + + public function __toString() + { + return $this->serializeToXml(); + } + + const OSS_MAX_RULES = 10; + + private $cnameList = array(); +} \ No newline at end of file diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/CnameTokenInfo.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/CnameTokenInfo.php new file mode 100644 index 0000000..295cfbd --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/CnameTokenInfo.php @@ -0,0 +1,105 @@ +bucket; + } + + /** + * Get cname + * + * @return string + */ + public function getCname() + { + return $this->cname; + } + + /** + * Get token. + * + * @return string + */ + public function getToken() + { + return $this->token; + } + + /** + * Get expireTime. + * + * @return string + */ + public function getExpireTime() + { + return $this->expireTime; + } + + /** + * Parse cname token from the xml. + * + * @param string $strXml + * @throws OssException + * @return null + */ + public function parseFromXml($strXml) + { + $xml = simplexml_load_string($strXml); + if (isset($xml->Bucket) ) { + $this->bucket = strval($xml->Bucket); + } + if (isset($xml->Cname) ) { + $this->cname = strval($xml->Cname); + } + if (isset($xml->Token) ) { + $this->token = strval($xml->Token); + } + if (isset($xml->ExpireTime) ) { + $this->expireTime = strval($xml->ExpireTime); + } + } + + /** + * bucket name + * + * @var string + */ + private $bucket; + /** + * cname + * + * @var string + */ + private $cname; + + /** + * token + * + * @var string + */ + private $token; + + /** + * expire time + * + * @var string + */ + private $expireTime; + +} \ No newline at end of file diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/CorsConfig.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/CorsConfig.php new file mode 100644 index 0000000..e0f1892 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/CorsConfig.php @@ -0,0 +1,140 @@ +rules = array(); + } + + /** + * Get CorsRule list + * + * @return CorsRule[] + */ + public function getRules() + { + return $this->rules; + } + + + /** + * Add a new CorsRule + * + * @param CorsRule $rule + * @throws OssException + */ + public function addRule($rule) + { + if (count($this->rules) >= self::OSS_MAX_RULES) { + throw new OssException("num of rules in the config exceeds self::OSS_MAX_RULES: " . strval(self::OSS_MAX_RULES)); + } + $this->rules[] = $rule; + } + /** + * @param boolean $value + */ + public function setResponseVary($value) + { + $this->responseVary = $value; + } + + /** + * @return boolean + */ + public function getResponseVary(){ + if (isset($this->responseVary)) { + return $this->responseVary; + } + return false; + } + + /** + * Parse CorsConfig from the xml. + * @param string $strXml + * @throws OssException + * @return null + */ + public function parseFromXml($strXml) + { + $xml = simplexml_load_string($strXml); + if(isset($xml->ResponseVary)){ + $this->responseVary = + (strval($xml->ResponseVary) === 'TRUE' || strval($xml->ResponseVary) === 'true') ? true : false; + } + if (!isset($xml->CORSRule)) return; + foreach ($xml->CORSRule as $rule) { + $corsRule = new CorsRule(); + foreach ($rule as $key => $value) { + if ($key === self::OSS_CORS_ALLOWED_HEADER) { + $corsRule->addAllowedHeader(strval($value)); + } elseif ($key === self::OSS_CORS_ALLOWED_METHOD) { + $corsRule->addAllowedMethod(strval($value)); + } elseif ($key === self::OSS_CORS_ALLOWED_ORIGIN) { + $corsRule->addAllowedOrigin(strval($value)); + } elseif ($key === self::OSS_CORS_EXPOSE_HEADER) { + $corsRule->addExposeHeader(strval($value)); + } elseif ($key === self::OSS_CORS_MAX_AGE_SECONDS) { + $corsRule->setMaxAgeSeconds(strval($value)); + } + } + $this->addRule($corsRule); + } + } + + /** + * Serialize the object into xml string. + * + * @return string + */ + public function serializeToXml() + { + $xml = new \SimpleXMLElement(''); + foreach ($this->rules as $rule) { + $xmlRule = $xml->addChild('CORSRule'); + $rule->appendToXml($xmlRule); + } + if(isset($this->responseVary)){ + if ($this->responseVary) { + $xml->addChild('ResponseVary', 'true'); + } else { + $xml->addChild('ResponseVary', 'false'); + } + } + return $xml->asXML(); + } + + public function __toString() + { + return $this->serializeToXml(); + } + + const OSS_CORS_ALLOWED_ORIGIN = 'AllowedOrigin'; + const OSS_CORS_ALLOWED_METHOD = 'AllowedMethod'; + const OSS_CORS_ALLOWED_HEADER = 'AllowedHeader'; + const OSS_CORS_EXPOSE_HEADER = 'ExposeHeader'; + const OSS_CORS_MAX_AGE_SECONDS = 'MaxAgeSeconds'; + const OSS_MAX_RULES = 10; + + /** + * CorsRule list + * + * @var CorsRule[] + */ + private $rules = array(); + private $responseVary; +} \ No newline at end of file diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/CorsRule.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/CorsRule.php new file mode 100644 index 0000000..08353a0 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/CorsRule.php @@ -0,0 +1,150 @@ +allowedOrigins[] = $allowedOrigin; + } + } + + /** + * Add an allowedMethod rule + * + * @param string $allowedMethod + */ + public function addAllowedMethod($allowedMethod) + { + if (!empty($allowedMethod)) { + $this->allowedMethods[] = $allowedMethod; + } + } + + /** + * Add an allowedHeader rule + * + * @param string $allowedHeader + */ + public function addAllowedHeader($allowedHeader) + { + if (!empty($allowedHeader)) { + $this->allowedHeaders[] = $allowedHeader; + } + } + + /** + * Add an exposeHeader rule + * + * @param string $exposeHeader + */ + public function addExposeHeader($exposeHeader) + { + if (!empty($exposeHeader)) { + $this->exposeHeaders[] = $exposeHeader; + } + } + + /** + * @return int + */ + public function getMaxAgeSeconds() + { + return $this->maxAgeSeconds; + } + + /** + * @param int $maxAgeSeconds + */ + public function setMaxAgeSeconds($maxAgeSeconds) + { + $this->maxAgeSeconds = $maxAgeSeconds; + } + + /** + * Get the AllowedHeaders list + * + * @return string[] + */ + public function getAllowedHeaders() + { + return $this->allowedHeaders; + } + + /** + * Get the AllowedOrigins list + * + * @return string[] + */ + public function getAllowedOrigins() + { + return $this->allowedOrigins; + } + + /** + * Get the AllowedMethods list + * + * @return string[] + */ + public function getAllowedMethods() + { + return $this->allowedMethods; + } + + /** + * Get the ExposeHeaders list + * + * @return string[] + */ + public function getExposeHeaders() + { + return $this->exposeHeaders; + } + + /** + * Serialize all the rules into the xml represented by parameter $xmlRule + * + * @param \SimpleXMLElement $xmlRule + * @throws OssException + */ + public function appendToXml(&$xmlRule) + { + if (!isset($this->maxAgeSeconds)) { + throw new OssException("maxAgeSeconds is not set in the Rule"); + } + foreach ($this->allowedOrigins as $allowedOrigin) { + $xmlRule->addChild(CorsConfig::OSS_CORS_ALLOWED_ORIGIN, $allowedOrigin); + } + foreach ($this->allowedMethods as $allowedMethod) { + $xmlRule->addChild(CorsConfig::OSS_CORS_ALLOWED_METHOD, $allowedMethod); + } + foreach ($this->allowedHeaders as $allowedHeader) { + $xmlRule->addChild(CorsConfig::OSS_CORS_ALLOWED_HEADER, $allowedHeader); + } + foreach ($this->exposeHeaders as $exposeHeader) { + $xmlRule->addChild(CorsConfig::OSS_CORS_EXPOSE_HEADER, $exposeHeader); + } + $xmlRule->addChild(CorsConfig::OSS_CORS_MAX_AGE_SECONDS, strval($this->maxAgeSeconds)); + } + + private $allowedHeaders = array(); + private $allowedOrigins = array(); + private $allowedMethods = array(); + private $exposeHeaders = array(); + private $maxAgeSeconds = null; +} \ No newline at end of file diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/DeleteMarkerInfo.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/DeleteMarkerInfo.php new file mode 100644 index 0000000..c129e99 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/DeleteMarkerInfo.php @@ -0,0 +1,65 @@ +key = $key; + $this->versionId = $versionId; + $this->lastModified = $lastModified; + $this->isLatest = $isLatest; + } + + /** + * @return string + */ + public function getKey() + { + return $this->key; + } + + /** + * @return string + */ + public function getVersionId() + { + return $this->versionId; + } + + /** + * @return string + */ + public function getLastModified() + { + return $this->lastModified; + } + + /** + * @return string + */ + public function getIsLatest() + { + return $this->isLatest; + } + + private $key = ""; + private $versionId = ""; + private $lastModified = ""; + private $isLatest = ""; +} \ No newline at end of file diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/DeleteObjectInfo.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/DeleteObjectInfo.php new file mode 100644 index 0000000..806eafb --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/DeleteObjectInfo.php @@ -0,0 +1,41 @@ +key = $key; + $this->versionId = $versionId; + } + + /** + * @return string + */ + public function getKey() + { + return $this->key; + } + + /** + * @return string + */ + public function getVersionId() + { + return $this->versionId; + } + + private $key = ""; + private $versionId = ""; +} \ No newline at end of file diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/DeletedObjectInfo.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/DeletedObjectInfo.php new file mode 100644 index 0000000..6bba39a --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/DeletedObjectInfo.php @@ -0,0 +1,63 @@ +key = $key; + $this->versionId = $versionId; + $this->deleteMarker = $deleteMarker; + $this->deleteMarkerVersionId = $deleteMarkerVersionId; + } + + /** + * @return string + */ + public function getKey() + { + return $this->key; + } + + /** + * @return string + */ + public function getVersionId() + { + return $this->versionId; + } + + /** + * @return string + */ + public function getDeleteMarker() + { + return $this->deleteMarker; + } + + /** + * @return string + */ + public function getDeleteMarkerVersionId() + { + return $this->deleteMarkerVersionId; + } + + private $key = ""; + private $versionId = ""; + private $deleteMarker = ""; + private $deleteMarkerVersionId = ""; +} \ No newline at end of file diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/ExtendWormConfig.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/ExtendWormConfig.php new file mode 100644 index 0000000..5e62287 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/ExtendWormConfig.php @@ -0,0 +1,64 @@ +day = $day; + } + + /** + * Parse ExtendWormConfig from the xml. + * + * @param string $strXml + * @throws OssException + * @return null + */ + public function parseFromXml($strXml) + { + throw new OssException("Not implemented."); + } + + /** + * Serialize the object into xml string. + * + * @return string + */ + public function serializeToXml() + { + $xml = new \SimpleXMLElement(''); + if (isset($this->day)) { + $xml->addChild('RetentionPeriodInDays', $this->day); + } + return $xml->asXML(); + } + + public function __toString() + { + return $this->serializeToXml(); + } + + /** + * @return int + */ + public function getDay() + { + return $this->day; + } + + private $day = 0; +} \ No newline at end of file diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/GetLiveChannelHistory.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/GetLiveChannelHistory.php new file mode 100644 index 0000000..e6d518a --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/GetLiveChannelHistory.php @@ -0,0 +1,37 @@ +liveRecordList; + } + + public function parseFromXml($strXml) + { + $xml = simplexml_load_string($strXml); + + if (isset($xml->LiveRecord)) { + foreach ($xml->LiveRecord as $record) { + $liveRecord = new LiveChannelHistory(); + $liveRecord->parseFromXmlNode($record); + $this->liveRecordList[] = $liveRecord; + } + } + } + + public function serializeToXml() + { + throw new OssException("Not implemented."); + } + + private $liveRecordList = array(); +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/GetLiveChannelInfo.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/GetLiveChannelInfo.php new file mode 100644 index 0000000..0b5edfc --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/GetLiveChannelInfo.php @@ -0,0 +1,68 @@ +description; + } + + public function getStatus() + { + return $this->status; + } + + public function getType() + { + return $this->type; + } + + public function getFragDuration() + { + return $this->fragDuration; + } + + public function getFragCount() + { + return $this->fragCount; + } + + public function getPlayListName() + { + return $this->playlistName; + } + + public function parseFromXml($strXml) + { + $xml = simplexml_load_string($strXml); + + $this->description = strval($xml->Description); + $this->status = strval($xml->Status); + + if (isset($xml->Target)) { + foreach ($xml->Target as $target) { + $this->type = strval($target->Type); + $this->fragDuration = strval($target->FragDuration); + $this->fragCount = strval($target->FragCount); + $this->playlistName = strval($target->PlaylistName); + } + } + } + + public function serializeToXml() + { + throw new OssException("Not implemented."); + } + + private $description; + private $status; + private $type; + private $fragDuration; + private $fragCount; + private $playlistName; +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/GetLiveChannelStatus.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/GetLiveChannelStatus.php new file mode 100644 index 0000000..2ee7a68 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/GetLiveChannelStatus.php @@ -0,0 +1,107 @@ +status; + } + + public function getConnectedTime() + { + return $this->connectedTime; + } + + public function getRemoteAddr() + { + return $this->remoteAddr; + } + + public function getVideoWidth() + { + return $this->videoWidth; + } + public function getVideoHeight() + { + return $this->videoHeight; + } + public function getVideoFrameRate() + { + return $this->videoFrameRate; + } + public function getVideoBandwidth() + { + return $this->videoBandwidth; + } + public function getVideoCodec() + { + return $this->videoCodec; + } + + public function getAudioBandwidth() + { + return $this->audioBandwidth; + } + public function getAudioSampleRate() + { + return $this->audioSampleRate; + } + public function getAudioCodec() + { + return $this->audioCodec; + } + + + public function parseFromXml($strXml) + { + $xml = simplexml_load_string($strXml); + $this->status = strval($xml->Status); + $this->connectedTime = strval($xml->ConnectedTime); + $this->remoteAddr = strval($xml->RemoteAddr); + + if (isset($xml->Video)) { + foreach ($xml->Video as $video) { + $this->videoWidth = intval($video->Width); + $this->videoHeight = intval($video->Height); + $this->videoFrameRate = intval($video->FrameRate); + $this->videoBandwidth = intval($video->Bandwidth); + $this->videoCodec = strval($video->Codec); + } + } + + if (isset($xml->Video)) { + foreach ($xml->Audio as $audio) { + $this->audioBandwidth = intval($audio->Bandwidth); + $this->audioSampleRate = intval($audio->SampleRate); + $this->audioCodec = strval($audio->Codec); + } + } + + } + + public function serializeToXml() + { + throw new OssException("Not implemented."); + } + + private $status; + private $connectedTime; + private $remoteAddr; + + private $videoWidth; + private $videoHeight; + private $videoFrameRate; + private $videoBandwidth; + private $videoCodec; + + private $audioBandwidth; + private $audioSampleRate; + private $audioCodec; + + +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/InitiateWormConfig.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/InitiateWormConfig.php new file mode 100644 index 0000000..572ceed --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/InitiateWormConfig.php @@ -0,0 +1,64 @@ +day = $day; + } + + /** + * Parse InitiateWormConfig from the xml. + * + * @param string $strXml + * @throws OssException + * @return null + */ + public function parseFromXml($strXml) + { + throw new OssException("Not implemented."); + } + + /** + * Serialize the object into xml string. + * + * @return string + */ + public function serializeToXml() + { + $xml = new \SimpleXMLElement(''); + if (isset($this->day)) { + $xml->addChild('RetentionPeriodInDays', $this->day); + } + return $xml->asXML(); + } + + public function __toString() + { + return $this->serializeToXml(); + } + + /** + * @return int + */ + public function getDay() + { + return $this->day; + } + + private $day = 0; +} \ No newline at end of file diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LifecycleAction.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LifecycleAction.php new file mode 100644 index 0000000..a0e2126 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LifecycleAction.php @@ -0,0 +1,88 @@ +action = $action; + $this->timeSpec = $timeSpec; + $this->timeValue = $timeValue; + } + + /** + * @return LifecycleAction + */ + public function getAction() + { + return $this->action; + } + + /** + * @param string $action + */ + public function setAction($action) + { + $this->action = $action; + } + + /** + * @return string + */ + public function getTimeSpec() + { + return $this->timeSpec; + } + + /** + * @param string $timeSpec + */ + public function setTimeSpec($timeSpec) + { + $this->timeSpec = $timeSpec; + } + + /** + * @return string + */ + public function getTimeValue() + { + return $this->timeValue; + } + + /** + * @param string $timeValue + */ + public function setTimeValue($timeValue) + { + $this->timeValue = $timeValue; + } + + /** + * Use appendToXml to insert actions into xml. + * + * @param \SimpleXMLElement $xmlRule + */ + public function appendToXml(&$xmlRule) + { + $xmlAction = $xmlRule->addChild($this->action); + $xmlAction->addChild($this->timeSpec, $this->timeValue); + } + + private $action; + private $timeSpec; + private $timeValue; + +} \ No newline at end of file diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LifecycleConfig.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LifecycleConfig.php new file mode 100644 index 0000000..f2d2dc3 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LifecycleConfig.php @@ -0,0 +1,107 @@ +rules = array(); + $xml = simplexml_load_string($strXml); + if (!isset($xml->Rule)) return; + $this->rules = array(); + foreach ($xml->Rule as $rule) { + $id = strval($rule->ID); + $prefix = strval($rule->Prefix); + $status = strval($rule->Status); + $actions = array(); + foreach ($rule as $key => $value) { + if ($key === 'ID' || $key === 'Prefix' || $key === 'Status') continue; + $action = $key; + $timeSpec = null; + $timeValue = null; + foreach ($value as $timeSpecKey => $timeValueValue) { + $timeSpec = $timeSpecKey; + $timeValue = strval($timeValueValue); + } + $actions[] = new LifecycleAction($action, $timeSpec, $timeValue); + } + $this->rules[] = new LifecycleRule($id, $prefix, $status, $actions); + } + return; + } + + + /** + * Serialize the object to xml + * + * @return string + */ + public function serializeToXml() + { + + $xml = new \SimpleXMLElement(''); + foreach ($this->rules as $rule) { + $xmlRule = $xml->addChild('Rule'); + $rule->appendToXml($xmlRule); + } + return $xml->asXML(); + } + + /** + * + * Add a LifecycleRule + * + * @param LifecycleRule $lifecycleRule + * @throws OssException + */ + public function addRule($lifecycleRule) + { + if (!isset($lifecycleRule)) { + throw new OssException("lifecycleRule is null"); + } + $this->rules[] = $lifecycleRule; + } + + /** + * Serialize the object into xml string. + * + * @return string + */ + public function __toString() + { + return $this->serializeToXml(); + } + + /** + * Get all lifecycle rules. + * + * @return LifecycleRule[] + */ + public function getRules() + { + return $this->rules; + } + + /** + * @var LifecycleRule[] + */ + private $rules; +} + + diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LifecycleRule.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LifecycleRule.php new file mode 100644 index 0000000..73c6cc3 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LifecycleRule.php @@ -0,0 +1,126 @@ +id; + } + + /** + * @param string $id Rule Id + */ + public function setId($id) + { + $this->id = $id; + } + + /** + * Get a file prefix + * + * @return string + */ + public function getPrefix() + { + return $this->prefix; + } + + /** + * Set a file prefix + * + * @param string $prefix The file prefix + */ + public function setPrefix($prefix) + { + $this->prefix = $prefix; + } + + /** + * Get Lifecycle status + * + * @return string + */ + public function getStatus() + { + return $this->status; + } + + /** + * Set Lifecycle status + * + * @param string $status + */ + public function setStatus($status) + { + $this->status = $status; + } + + /** + * + * @return LifecycleAction[] + */ + public function getActions() + { + return $this->actions; + } + + /** + * @param LifecycleAction[] $actions + */ + public function setActions($actions) + { + $this->actions = $actions; + } + + + /** + * LifecycleRule constructor. + * + * @param string $id rule Id + * @param string $prefix File prefix + * @param string $status Rule status, which has the following valid values: [self::LIFECYCLE_STATUS_ENABLED, self::LIFECYCLE_STATUS_DISABLED] + * @param LifecycleAction[] $actions + */ + public function __construct($id, $prefix, $status, $actions) + { + $this->id = $id; + $this->prefix = $prefix; + $this->status = $status; + $this->actions = $actions; + } + + /** + * @param \SimpleXMLElement $xmlRule + */ + public function appendToXml(&$xmlRule) + { + $xmlRule->addChild('ID', $this->id); + $xmlRule->addChild('Prefix', $this->prefix); + $xmlRule->addChild('Status', $this->status); + foreach ($this->actions as $action) { + $action->appendToXml($xmlRule); + } + } + + private $id; + private $prefix; + private $status; + private $actions = array(); + + const LIFECYCLE_STATUS_ENABLED = 'Enabled'; + const LIFECYCLE_STATUS_DISABLED = 'Disabled'; +} \ No newline at end of file diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/ListMultipartUploadInfo.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/ListMultipartUploadInfo.php new file mode 100644 index 0000000..105d005 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/ListMultipartUploadInfo.php @@ -0,0 +1,134 @@ +bucket = $bucket; + $this->keyMarker = $keyMarker; + $this->uploadIdMarker = $uploadIdMarker; + $this->nextKeyMarker = $nextKeyMarker; + $this->nextUploadIdMarker = $nextUploadIdMarker; + $this->delimiter = $delimiter; + $this->prefix = $prefix; + $this->maxUploads = $maxUploads; + $this->isTruncated = $isTruncated; + $this->uploads = $uploads; + } + + /** + * 得到bucket名称 + * + * @return string + */ + public function getBucket() + { + return $this->bucket; + } + + /** + * @return string + */ + public function getKeyMarker() + { + return $this->keyMarker; + } + + /** + * + * @return string + */ + public function getUploadIdMarker() + { + return $this->uploadIdMarker; + } + + /** + * @return string + */ + public function getNextKeyMarker() + { + return $this->nextKeyMarker; + } + + /** + * @return string + */ + public function getNextUploadIdMarker() + { + return $this->nextUploadIdMarker; + } + + /** + * @return string + */ + public function getDelimiter() + { + return $this->delimiter; + } + + /** + * @return string + */ + public function getPrefix() + { + return $this->prefix; + } + + /** + * @return int + */ + public function getMaxUploads() + { + return $this->maxUploads; + } + + /** + * @return string + */ + public function getIsTruncated() + { + return $this->isTruncated; + } + + /** + * @return UploadInfo[] + */ + public function getUploads() + { + return $this->uploads; + } + + private $bucket = ""; + private $keyMarker = ""; + private $uploadIdMarker = ""; + private $nextKeyMarker = ""; + private $nextUploadIdMarker = ""; + private $delimiter = ""; + private $prefix = ""; + private $maxUploads = 0; + private $isTruncated = "false"; + private $uploads = array(); +} \ No newline at end of file diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/ListPartsInfo.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/ListPartsInfo.php new file mode 100644 index 0000000..f1d10ee --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/ListPartsInfo.php @@ -0,0 +1,97 @@ +bucket = $bucket; + $this->key = $key; + $this->uploadId = $uploadId; + $this->nextPartNumberMarker = $nextPartNumberMarker; + $this->maxParts = $maxParts; + $this->isTruncated = $isTruncated; + $this->listPart = $listPart; + } + + /** + * @return string + */ + public function getBucket() + { + return $this->bucket; + } + + /** + * @return string + */ + public function getKey() + { + return $this->key; + } + + /** + * @return string + */ + public function getUploadId() + { + return $this->uploadId; + } + + /** + * @return int + */ + public function getNextPartNumberMarker() + { + return $this->nextPartNumberMarker; + } + + /** + * @return int + */ + public function getMaxParts() + { + return $this->maxParts; + } + + /** + * @return string + */ + public function getIsTruncated() + { + return $this->isTruncated; + } + + /** + * @return array + */ + public function getListPart() + { + return $this->listPart; + } + + private $bucket = ""; + private $key = ""; + private $uploadId = ""; + private $nextPartNumberMarker = 0; + private $maxParts = 0; + private $isTruncated = ""; + private $listPart = array(); +} \ No newline at end of file diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LiveChannelConfig.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LiveChannelConfig.php new file mode 100644 index 0000000..dadedc9 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LiveChannelConfig.php @@ -0,0 +1,121 @@ +description = $option['description']; + } + if (isset($option['status'])) { + $this->status = $option['status']; + } + if (isset($option['type'])) { + $this->type = $option['type']; + } + if (isset($option['fragDuration'])) { + $this->fragDuration = $option['fragDuration']; + } + if (isset($option['fragCount'])) { + $this->fragCount = $option['fragCount']; + } + if (isset($option['playListName'])) { + $this->playListName = $option['playListName']; + } + } + + public function getDescription() + { + return $this->description; + } + + public function getStatus() + { + return $this->status; + } + + public function getType() + { + return $this->type; + } + + public function getFragDuration() + { + return $this->fragDuration; + } + + public function getFragCount() + { + return $this->fragCount; + } + + public function getPlayListName() + { + return $this->playListName; + } + + public function parseFromXml($strXml) + { + $xml = simplexml_load_string($strXml); + $this->description = strval($xml->Description); + $this->status = strval($xml->Status); + $target = $xml->Target; + $this->type = strval($target->Type); + $this->fragDuration = intval($target->FragDuration); + $this->fragCount = intval($target->FragCount); + $this->playListName = strval($target->PlayListName); + } + + public function serializeToXml() + { + $strXml = << + + +EOF; + $xml = new \SimpleXMLElement($strXml); + if (isset($this->description)) { + $xml->addChild('Description', $this->description); + } + + if (isset($this->status)) { + $xml->addChild('Status', $this->status); + } + + $node = $xml->addChild('Target'); + $node->addChild('Type', $this->type); + + if (isset($this->fragDuration)) { + $node->addChild('FragDuration', $this->fragDuration); + } + + if (isset($this->fragCount)) { + $node->addChild('FragCount', $this->fragCount); + } + + if (isset($this->playListName)) { + $node->addChild('PlayListName', $this->playListName); + } + + return $xml->asXML(); + } + + public function __toString() + { + return $this->serializeToXml(); + } + + private $description; + private $status = "enabled"; + private $type; + private $fragDuration = 5; + private $fragCount = 3; + private $playListName = "playlist.m3u8"; +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LiveChannelHistory.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LiveChannelHistory.php new file mode 100644 index 0000000..1c1fd4d --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LiveChannelHistory.php @@ -0,0 +1,59 @@ +startTime; + } + + public function getEndTime() + { + return $this->endTime; + } + + public function getRemoteAddr() + { + return $this->remoteAddr; + } + + public function parseFromXmlNode($xml) + { + if (isset($xml->StartTime)) { + $this->startTime = strval($xml->StartTime); + } + + if (isset($xml->EndTime)) { + $this->endTime = strval($xml->EndTime); + } + + if (isset($xml->RemoteAddr)) { + $this->remoteAddr = strval($xml->RemoteAddr); + } + } + + public function parseFromXml($strXml) + { + $xml = simplexml_load_string($strXml); + $this->parseFromXmlNode($xml); + } + + public function serializeToXml() + { + throw new OssException("Not implemented."); + } + + private $startTime; + private $endTime; + private $remoteAddr; +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LiveChannelInfo.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LiveChannelInfo.php new file mode 100644 index 0000000..c63ec54 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LiveChannelInfo.php @@ -0,0 +1,107 @@ +name = $name; + $this->description = $description; + $this->publishUrls = array(); + $this->playUrls = array(); + } + + public function getName() + { + return $this->name; + } + + public function setName($name) + { + $this->name = $name; + } + + public function getPublishUrls() + { + return $this->publishUrls; + } + + public function getPlayUrls() + { + return $this->playUrls; + } + + public function getStatus() + { + return $this->status; + } + + public function getLastModified() + { + return $this->lastModified; + } + + public function getDescription() + { + return $this->description; + } + + public function setDescription($description) + { + $this->description = $description; + } + + public function parseFromXmlNode($xml) + { + if (isset($xml->Name)) { + $this->name = strval($xml->Name); + } + + if (isset($xml->Description)) { + $this->description = strval($xml->Description); + } + + if (isset($xml->Status)) { + $this->status = strval($xml->Status); + } + + if (isset($xml->LastModified)) { + $this->lastModified = strval($xml->LastModified); + } + + if (isset($xml->PublishUrls)) { + foreach ($xml->PublishUrls as $url) { + $this->publishUrls[] = strval($url->Url); + } + } + + if (isset($xml->PlayUrls)) { + foreach ($xml->PlayUrls as $url) { + $this->playUrls[] = strval($url->Url); + } + } + } + + public function parseFromXml($strXml) + { + $xml = simplexml_load_string($strXml); + $this->parseFromXmlNode($xml); + } + + public function serializeToXml() + { + throw new OssException("Not implemented."); + } + + private $name; + private $description; + private $publishUrls; + private $playUrls; + private $status; + private $lastModified; +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LiveChannelListInfo.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LiveChannelListInfo.php new file mode 100644 index 0000000..f4ee02f --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LiveChannelListInfo.php @@ -0,0 +1,107 @@ +bucket; + } + + public function setBucketName($name) + { + $this->bucket = $name; + } + + /** + * @return string + */ + public function getPrefix() + { + return $this->prefix; + } + + /** + * @return string + */ + public function getMarker() + { + return $this->marker; + } + + /** + * @return int + */ + public function getMaxKeys() + { + return $this->maxKeys; + } + + /** + * @return mixed + */ + public function getIsTruncated() + { + return $this->isTruncated; + } + + /** + * @return LiveChannelInfo[] + */ + public function getChannelList() + { + return $this->channelList; + } + + /** + * @return string + */ + public function getNextMarker() + { + return $this->nextMarker; + } + + public function parseFromXml($strXml) + { + $xml = simplexml_load_string($strXml); + + $this->prefix = strval($xml->Prefix); + $this->marker = strval($xml->Marker); + $this->maxKeys = intval($xml->MaxKeys); + $this->isTruncated = (strval($xml->IsTruncated) == 'true'); + $this->nextMarker = strval($xml->NextMarker); + + if (isset($xml->LiveChannel)) { + foreach ($xml->LiveChannel as $chan) { + $channel = new LiveChannelInfo(); + $channel->parseFromXmlNode($chan); + $this->channelList[] = $channel; + } + } + } + + public function serializeToXml() + { + throw new OssException("Not implemented."); + } + + private $bucket = ''; + private $prefix = ''; + private $marker = ''; + private $nextMarker = ''; + private $maxKeys = 100; + private $isTruncated = 'false'; + private $channelList = array(); +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LoggingConfig.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LoggingConfig.php new file mode 100644 index 0000000..ed9fb1d --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LoggingConfig.php @@ -0,0 +1,86 @@ +targetBucket = $targetBucket; + $this->targetPrefix = $targetPrefix; + } + + /** + * @param $strXml + * @return null + */ + public function parseFromXml($strXml) + { + $xml = simplexml_load_string($strXml); + if (!isset($xml->LoggingEnabled)) return; + foreach ($xml->LoggingEnabled as $status) { + foreach ($status as $key => $value) { + if ($key === 'TargetBucket') { + $this->targetBucket = strval($value); + } elseif ($key === 'TargetPrefix') { + $this->targetPrefix = strval($value); + } + } + break; + } + } + + /** + * Serialize to xml string + * + */ + public function serializeToXml() + { + $xml = new \SimpleXMLElement(''); + if (isset($this->targetBucket) && isset($this->targetPrefix)) { + $loggingEnabled = $xml->addChild('LoggingEnabled'); + $loggingEnabled->addChild('TargetBucket', $this->targetBucket); + $loggingEnabled->addChild('TargetPrefix', $this->targetPrefix); + } + return $xml->asXML(); + } + + /** + * @return string + */ + public function __toString() + { + return $this->serializeToXml(); + } + + /** + * @return string + */ + public function getTargetBucket() + { + return $this->targetBucket; + } + + /** + * @return string + */ + public function getTargetPrefix() + { + return $this->targetPrefix; + } + + private $targetBucket = ""; + private $targetPrefix = ""; + +} \ No newline at end of file diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/ObjectInfo.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/ObjectInfo.php new file mode 100644 index 0000000..9e538bf --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/ObjectInfo.php @@ -0,0 +1,129 @@ +key = $key; + $this->lastModified = $lastModified; + $this->eTag = $eTag; + $this->type = $type; + $this->size = $size; + $this->storageClass = $storageClass; + $this->owner = $owner; + $this->restoreInfo = $restoreInfo; + } + + /** + * @return string + */ + public function getKey() + { + return $this->key; + } + + /** + * @return string + */ + public function getLastModified() + { + return $this->lastModified; + } + + /** + * @return string + */ + public function getETag() + { + return $this->eTag; + } + + /** + * @return string + */ + public function getType() + { + return $this->type; + } + + /** + * php7 && 64bit can use it + * @return int + */ + public function getSize() + { + return (int)$this->size; + } + + + /** + * php5.x or 32bit must use it + * @return string + */ + public function getSizeStr() + { + return $this->size; + } + + /** + * @return string + */ + public function getStorageClass() + { + return $this->storageClass; + } + + /** + * @return string + */ + public function getRestoreInfo() + { + return $this->restoreInfo; + } + + + /** + * @return Owner|null + */ + public function getOwner() + { + return $this->owner; + } + + private $key = ""; + private $lastModified = ""; + private $eTag = ""; + private $type = ""; + private $size = "0"; + private $storageClass = ""; + /** + * @var Owner + */ + private $owner; + private $restoreInfo; +} \ No newline at end of file diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/ObjectListInfo.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/ObjectListInfo.php new file mode 100644 index 0000000..81c5d27 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/ObjectListInfo.php @@ -0,0 +1,126 @@ +bucketName = $bucketName; + $this->prefix = $prefix; + $this->marker = $marker; + $this->nextMarker = $nextMarker; + $this->maxKeys = $maxKeys; + $this->delimiter = $delimiter; + $this->isTruncated = $isTruncated; + $this->objectList = $objectList; + $this->prefixList = $prefixList; + } + + /** + * @return string + */ + public function getBucketName() + { + return $this->bucketName; + } + + /** + * @return string + */ + public function getPrefix() + { + return $this->prefix; + } + + /** + * @return string + */ + public function getMarker() + { + return $this->marker; + } + + /** + * @return int + */ + public function getMaxKeys() + { + return $this->maxKeys; + } + + /** + * @return string + */ + public function getDelimiter() + { + return $this->delimiter; + } + + /** + * @return mixed + */ + public function getIsTruncated() + { + return $this->isTruncated; + } + + /** + * Get the ObjectInfo list. + * + * @return ObjectInfo[] + */ + public function getObjectList() + { + return $this->objectList; + } + + /** + * Get the PrefixInfo list + * + * @return PrefixInfo[] + */ + public function getPrefixList() + { + return $this->prefixList; + } + + /** + * @return string + */ + public function getNextMarker() + { + return $this->nextMarker; + } + + private $bucketName = ""; + private $prefix = ""; + private $marker = ""; + private $nextMarker = ""; + private $maxKeys = 0; + private $delimiter = ""; + private $isTruncated = null; + private $objectList = array(); + private $prefixList = array(); +} \ No newline at end of file diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/ObjectListInfoV2.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/ObjectListInfoV2.php new file mode 100644 index 0000000..c1fef22 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/ObjectListInfoV2.php @@ -0,0 +1,147 @@ +bucketName = $bucketName; + $this->prefix = $prefix; + $this->maxKeys = $maxKeys; + $this->delimiter = $delimiter; + $this->isTruncated = $isTruncated; + $this->objectList = $objectList; + $this->prefixList = $prefixList; + $this->continuationToken = $continuationToken; + $this->nextContinuationToken = $nextContinuationToken; + $this->startAfter = $startAfter; + $this->keyCount = $keyCount; + } + + /** + * @return string + */ + public function getBucketName() + { + return $this->bucketName; + } + + /** + * @return string + */ + public function getPrefix() + { + return $this->prefix; + } + + /** + * @return int + */ + public function getMaxKeys() + { + return $this->maxKeys; + } + + /** + * @return string + */ + public function getDelimiter() + { + return $this->delimiter; + } + + /** + * @return mixed + */ + public function getIsTruncated() + { + return $this->isTruncated; + } + + /** + * Get the ObjectInfo list. + * + * @return ObjectInfo[] + */ + public function getObjectList() + { + return $this->objectList; + } + + /** + * Get the PrefixInfo list + * + * @return PrefixInfo[] + */ + public function getPrefixList() + { + return $this->prefixList; + } + + /** + * @return string + */ + public function getContinuationToken() + { + return $this->continuationToken; + } + + /** + * @return string + */ + public function getNextContinuationToken() + { + return $this->nextContinuationToken; + } + + /** + * @return string + */ + public function getStartAfter() + { + return $this->startAfter; + } + + /** + * @return int + */ + public function getKeyCount() + { + return $this->keyCount; + } + + private $bucketName = ""; + private $prefix = ""; + private $maxKeys = 0; + private $delimiter = ""; + private $isTruncated = null; + private $objectList = array(); + private $prefixList = array(); + private $nextContinuationToken = ""; + private $continuationToken = ""; + private $startAfter = ""; + private $keyCount = 0; +} \ No newline at end of file diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/ObjectVersionInfo.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/ObjectVersionInfo.php new file mode 100644 index 0000000..663bd0b --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/ObjectVersionInfo.php @@ -0,0 +1,125 @@ +key = $key; + $this->versionId = $versionId; + $this->lastModified = $lastModified; + $this->eTag = $eTag; + $this->type = $type; + $this->size = $size; + $this->storageClass = $storageClass; + $this->isLatest = $isLatest; + } + + /** + * @return string + */ + public function getKey() + { + return $this->key; + } + + /** + * @return string + */ + public function getVersionId() + { + return $this->versionId; + } + + /** + * @return string + */ + public function getLastModified() + { + return $this->lastModified; + } + + /** + * @return string + */ + public function getETag() + { + return $this->eTag; + } + + /** + * @return string + */ + public function getType() + { + return $this->type; + } + + /** + * php7 && 64bit can use it + * @return int + */ + public function getSize() + { + return (int)$this->size; + } + + + /** + * php5.x or 32bit must use it + * @return string + */ + public function getSizeStr() + { + return $this->size; + } + + /** + * @return string + */ + public function getStorageClass() + { + return $this->storageClass; + } + + /** + * @return string + */ + public function getIsLatest() + { + return $this->isLatest; + } + + private $key = ""; + private $versionId = ""; + private $lastModified = ""; + private $eTag = ""; + private $type = ""; + private $size = "0"; + private $storageClass = ""; + private $isLatest = ""; +} \ No newline at end of file diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/ObjectVersionListInfo.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/ObjectVersionListInfo.php new file mode 100644 index 0000000..f976b7e --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/ObjectVersionListInfo.php @@ -0,0 +1,162 @@ +bucketName = $bucketName; + $this->prefix = $prefix; + $this->keyMarker = $keyMarker; + $this->nextKeyMarker = $nextKeyMarker; + $this->versionIdMarker = $versionIdMarker; + $this->nextVersionIdMarker = $nextVersionIdMarker; + $this->maxKeys = $maxKeys; + $this->delimiter = $delimiter; + $this->isTruncated = $isTruncated; + $this->objectVersionList = $objectversionList; + $this->deleteMarkerList = $deleteMarkerList; + $this->prefixList = $prefixList; + } + + /** + * @return string + */ + public function getBucketName() + { + return $this->bucketName; + } + + /** + * @return string + */ + public function getPrefix() + { + return $this->prefix; + } + + /** + * @return string + */ + public function getKeyMarker() + { + return $this->keyMarker; + } + + /** + * @return string + */ + public function getNextKeyMarker() + { + return $this->nextKeyMarker; + } + + /** + * @return string + */ + public function getVersionIdMarker() + { + return $this->versionIdMarker; + } + + /** + * @return string + */ + public function getNextVersionIdMarker() + { + return $this->nextVersionIdMarker; + } + + /** + * @return int + */ + public function getMaxKeys() + { + return $this->maxKeys; + } + + /** + * @return string + */ + public function getDelimiter() + { + return $this->delimiter; + } + + /** + * @return mixed + */ + public function getIsTruncated() + { + return $this->isTruncated; + } + + /** + * Get the ObjectVersionInfo list. + * + * @return ObjectVersionInfo[] + */ + public function getObjectVersionList() + { + return $this->objectVersionList; + } + + /** + * Get the DeleteMarkerInfo list. + * + * @return DeleteMarkerInfo[] + */ + public function getDeleteMarkerList() + { + return $this->deleteMarkerList; + } + + /** + * Get the PrefixInfo list + * + * @return PrefixInfo[] + */ + public function getPrefixList() + { + return $this->prefixList; + } + + private $bucketName = ""; + private $prefix = ""; + private $keyMarker = ""; + private $nextKeyMarker = ""; + private $versionIdMarker = ""; + private $nextVersionIdMarker = ""; + private $maxKeys = 0; + private $delimiter = ""; + private $isTruncated = null; + private $objectVersionList = array(); + private $deleteMarkerList = array(); + private $prefixList = array(); +} \ No newline at end of file diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/Owner.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/Owner.php new file mode 100644 index 0000000..5de8bcf --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/Owner.php @@ -0,0 +1,46 @@ +id = $id; + $this->displayName = $displayName; + } + + /** + * @return string + */ + public function getId() + { + return $this->id; + } + + /** + * @return string + */ + public function getDisplayName() + { + return $this->displayName; + } + + private $id; + private $displayName; +} \ No newline at end of file diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/PartInfo.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/PartInfo.php new file mode 100644 index 0000000..07df576 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/PartInfo.php @@ -0,0 +1,74 @@ +partNumber = $partNumber; + $this->lastModified = $lastModified; + $this->eTag = $eTag; + $this->size = $size; + } + + /** + * @return int + */ + public function getPartNumber() + { + return $this->partNumber; + } + + /** + * @return string + */ + public function getLastModified() + { + return $this->lastModified; + } + + /** + * @return string + */ + public function getETag() + { + return $this->eTag; + } + + /** + * php7 && 64bit can use it + * @return int + */ + public function getSize() + { + return (int)$this->size; + } + + + /** + * php5.x or 32bit must use it + * @return string + */ + public function getSizeStr() + { + return $this->size; + } + + private $partNumber = 0; + private $lastModified = ""; + private $eTag = ""; + private $size = "0"; +} \ No newline at end of file diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/PrefixInfo.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/PrefixInfo.php new file mode 100644 index 0000000..27920b9 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/PrefixInfo.php @@ -0,0 +1,36 @@ +prefix = $prefix; + } + + /** + * @return string + */ + public function getPrefix() + { + return $this->prefix; + } + + private $prefix; +} \ No newline at end of file diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/RefererConfig.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/RefererConfig.php new file mode 100644 index 0000000..0830143 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/RefererConfig.php @@ -0,0 +1,93 @@ +AllowEmptyReferer)) return; + if (!isset($xml->RefererList)) return; + $this->allowEmptyReferer = + (strval($xml->AllowEmptyReferer) === 'TRUE' || strval($xml->AllowEmptyReferer) === 'true') ? true : false; + + foreach ($xml->RefererList->Referer as $key => $refer) { + $this->refererList[] = strval($refer); + } + } + + + /** + * serialize the RefererConfig object into xml string + * + * @return string + */ + public function serializeToXml() + { + $xml = new \SimpleXMLElement(''); + if ($this->allowEmptyReferer) { + $xml->addChild('AllowEmptyReferer', 'true'); + } else { + $xml->addChild('AllowEmptyReferer', 'false'); + } + $refererList = $xml->addChild('RefererList'); + foreach ($this->refererList as $referer) { + $refererList->addChild('Referer', $referer); + } + return $xml->asXML(); + } + + /** + * @return string + */ + function __toString() + { + return $this->serializeToXml(); + } + + /** + * @param boolean $allowEmptyReferer + */ + public function setAllowEmptyReferer($allowEmptyReferer) + { + $this->allowEmptyReferer = $allowEmptyReferer; + } + + /** + * @param string $referer + */ + public function addReferer($referer) + { + $this->refererList[] = $referer; + } + + /** + * @return boolean + */ + public function isAllowEmptyReferer() + { + return $this->allowEmptyReferer; + } + + /** + * @return array + */ + public function getRefererList() + { + return $this->refererList; + } + + private $allowEmptyReferer = true; + private $refererList = array(); +} \ No newline at end of file diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/RequestPaymentConfig.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/RequestPaymentConfig.php new file mode 100644 index 0000000..6b32060 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/RequestPaymentConfig.php @@ -0,0 +1,68 @@ +payer = $payer; + } + + /** + * Parse ServerSideEncryptionConfig from the xml. + * + * @param string $strXml + * @throws OssException + * @return null + */ + public function parseFromXml($strXml) + { + $xml = simplexml_load_string($strXml); + if (isset($xml->Payer)) { + $this->payer = strval($xml->Payer); + } + } + + /** + * Serialize the object into xml string. + * + * @return string + */ + public function serializeToXml() + { + $xml = new \SimpleXMLElement(''); + if (isset($this->payer)) { + $xml->addChild('Payer', $this->payer); + } + return $xml->asXML(); + } + + public function __toString() + { + return $this->serializeToXml(); + } + + /** + * @return string + */ + public function getPayer() + { + return $this->payer; + } + + private $payer = ""; +} \ No newline at end of file diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/RestoreConfig.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/RestoreConfig.php new file mode 100644 index 0000000..156852a --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/RestoreConfig.php @@ -0,0 +1,77 @@ +day = $day; + $this->tier = $tier; + } + + /** + * Parse RestoreConfig from the xml. + * + * @param string $strXml + * @throws OssException + * @return null + */ + public function parseFromXml($strXml) + { + throw new OssException("Not implemented."); + } + + /** + * Serialize the object into xml string. + * + * @return string + */ + public function serializeToXml() + { + $xml = new \SimpleXMLElement(''); + $xml->addChild('Days', strval($this->day)); + if (isset($this->tier)) { + $xml_param = $xml->addChild('JobParameters'); + $xml_param->addChild('Tier', $this->tier); + } + return $xml->asXML(); + } + + public function __toString() + { + return $this->serializeToXml(); + } + + /** + * @return int + */ + public function getDay() + { + return $this->day; + } + + /** + * @return string + */ + public function getTier() + { + return $this->tier; + } + + private $day = 1; + private $tier = 'Standard'; +} \ No newline at end of file diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/ServerSideEncryptionConfig.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/ServerSideEncryptionConfig.php new file mode 100644 index 0000000..e3a190b --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/ServerSideEncryptionConfig.php @@ -0,0 +1,91 @@ +sseAlgorithm = $sseAlgorithm; + $this->kmsMasterKeyID = $kmsMasterKeyID; + } + + /** + * Parse ServerSideEncryptionConfig from the xml. + * + * @param string $strXml + * @throws OssException + * @return null + */ + public function parseFromXml($strXml) + { + $xml = simplexml_load_string($strXml); + if (!isset($xml->ApplyServerSideEncryptionByDefault)) return; + foreach ($xml->ApplyServerSideEncryptionByDefault as $default) { + foreach ($default as $key => $value) { + if ($key === 'SSEAlgorithm') { + $this->sseAlgorithm = strval($value); + } elseif ($key === 'KMSMasterKeyID') { + $this->kmsMasterKeyID = strval($value); + } + } + break; + } + } + + /** + * Serialize the object into xml string. + * + * @return string + */ + public function serializeToXml() + { + $xml = new \SimpleXMLElement(''); + $default = $xml->addChild('ApplyServerSideEncryptionByDefault'); + if (isset($this->sseAlgorithm)) { + $default->addChild('SSEAlgorithm', $this->sseAlgorithm); + } + if (isset($this->kmsMasterKeyID)) { + $default->addChild('KMSMasterKeyID', $this->kmsMasterKeyID); + } + return $xml->asXML(); + } + + public function __toString() + { + return $this->serializeToXml(); + } + + /** + * @return string + */ + public function getSSEAlgorithm() + { + return $this->sseAlgorithm; + } + + /** + * @return string + */ + public function getKMSMasterKeyID() + { + return $this->kmsMasterKeyID; + } + + private $sseAlgorithm = ""; + private $kmsMasterKeyID = ""; +} \ No newline at end of file diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/StorageCapacityConfig.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/StorageCapacityConfig.php new file mode 100644 index 0000000..39a9e72 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/StorageCapacityConfig.php @@ -0,0 +1,76 @@ +storageCapacity = $storageCapacity; + } + + /** + * Not implemented + */ + public function parseFromXml($strXml) + { + throw new OssException("Not implemented."); + } + + /** + * Serialize StorageCapacityConfig into xml + * + * @return string + */ + public function serializeToXml() + { + $xml = new \SimpleXMLElement(''); + $xml->addChild('StorageCapacity', strval($this->storageCapacity)); + return $xml->asXML(); + } + + /** + * To string + * + * @return string + */ + function __toString() + { + return $this->serializeToXml(); + } + + /** + * Set storage capacity + * + * @param int $storageCapacity + */ + public function setStorageCapacity($storageCapacity) + { + $this->storageCapacity = $storageCapacity; + } + + /** + * Get storage capacity + * + * @return int + */ + public function getStorageCapacity() + { + return $this->storageCapacity; + } + + private $storageCapacity = 0; +} \ No newline at end of file diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/Tag.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/Tag.php new file mode 100644 index 0000000..509bd6e --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/Tag.php @@ -0,0 +1,41 @@ +key = $key; + $this->value = $value; + } + + /** + * @return string + */ + public function getKey() + { + return $this->key; + } + + /** + * @return string + */ + public function getValue() + { + return $this->value; + } + + private $key = ""; + private $value = ""; +} \ No newline at end of file diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/TaggingConfig.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/TaggingConfig.php new file mode 100644 index 0000000..09fa323 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/TaggingConfig.php @@ -0,0 +1,89 @@ +tags = array(); + } + + /** + * Get Tag list + * + * @return Tag[] + */ + public function getTags() + { + return $this->tags; + } + + + /** + * Add a new Tag + * + * @param Tag $tag + * @throws OssException + */ + public function addTag($tag) + { + $this->tags[] = $tag; + } + + /** + * Parse TaggingConfig from the xml. + * + * @param string $strXml + * @throws OssException + * @return null + */ + public function parseFromXml($strXml) + { + $xml = simplexml_load_string($strXml); + if (!isset($xml->TagSet) || !isset($xml->TagSet->Tag)) return; + foreach ($xml->TagSet->Tag as $tag) { + $this->addTag(new Tag($tag->Key, $tag->Value)); + } + } + + /** + * Serialize the object into xml string. + * + * @return string + */ + public function serializeToXml() + { + $xml = new \SimpleXMLElement(''); + $xmlTagSet = $xml->addChild('TagSet'); + foreach ($this->tags as $tag) { + $xmlTag = $xmlTagSet->addChild('Tag'); + $xmlTag->addChild('Key', strval($tag->getKey())); + $xmlTag->addChild('Value', strval($tag->getValue())); + } + return $xml->asXML(); + } + + public function __toString() + { + return $this->serializeToXml(); + } + + /** + * Tag list + * + * @var Tag[] + */ + private $tags = array(); +} \ No newline at end of file diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/TransferAccelerationConfig.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/TransferAccelerationConfig.php new file mode 100644 index 0000000..187fb24 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/TransferAccelerationConfig.php @@ -0,0 +1,73 @@ +Enabled)) { + $this->enabled = (strval($xml->Enabled) === 'TRUE' || strval($xml->Enabled) === 'true') ? true : false; + } + } + + /** + * Serialize the object into xml string. + * + * @return string + */ + public function serializeToXml() + { + $xml = new \SimpleXMLElement(''); + if (isset($this->enabled)) { + if($this->enabled === true){ + $xml->addChild('Enabled','true'); + } else { + $xml->addChild('Enabled','false'); + } + } + return $xml->asXML(); + } + + public function __toString() + { + return $this->serializeToXml(); + } + + + /** + * @return bool + */ + public function getEnabled() + { + return $this->enabled; + } + + /** + * @param boolean enabled + */ + public function setEnabled($enabled) + { + $this->enabled = $enabled; + } + + /** + * @var $enabled boolean + */ + private $enabled = false; +} + + diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/UploadInfo.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/UploadInfo.php new file mode 100644 index 0000000..49aa414 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/UploadInfo.php @@ -0,0 +1,55 @@ +key = $key; + $this->uploadId = $uploadId; + $this->initiated = $initiated; + } + + /** + * @return string + */ + public function getKey() + { + return $this->key; + } + + /** + * @return string + */ + public function getUploadId() + { + return $this->uploadId; + } + + /** + * @return string + */ + public function getInitiated() + { + return $this->initiated; + } + + private $key = ""; + private $uploadId = ""; + private $initiated = ""; +} \ No newline at end of file diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/VersioningConfig.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/VersioningConfig.php new file mode 100644 index 0000000..992a80f --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/VersioningConfig.php @@ -0,0 +1,67 @@ +status = $status; + } + + /** + * Parse VersioningConfig from the xml. + * + * @param string $strXml + * @throws OssException + * @return null + */ + public function parseFromXml($strXml) + { + $xml = simplexml_load_string($strXml); + if (isset($xml->Status)) { + $this->status = strval($xml->Status); + } + } + + /** + * Serialize the object into xml string. + * + * @return string + */ + public function serializeToXml() + { + $xml = new \SimpleXMLElement(''); + if (isset($this->status)) { + $xml->addChild('Status', $this->status); + } + return $xml->asXML(); + } + + public function __toString() + { + return $this->serializeToXml(); + } + + /** + * @return string + */ + public function getStatus() + { + return $this->status; + } + + private $status = ""; +} \ No newline at end of file diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/WebsiteConfig.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/WebsiteConfig.php new file mode 100644 index 0000000..e298eb4 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/WebsiteConfig.php @@ -0,0 +1,76 @@ +indexDocument = $indexDocument; + $this->errorDocument = $errorDocument; + } + + /** + * @param string $strXml + * @return null + */ + public function parseFromXml($strXml) + { + $xml = simplexml_load_string($strXml); + if (isset($xml->IndexDocument) && isset($xml->IndexDocument->Suffix)) { + $this->indexDocument = strval($xml->IndexDocument->Suffix); + } + if (isset($xml->ErrorDocument) && isset($xml->ErrorDocument->Key)) { + $this->errorDocument = strval($xml->ErrorDocument->Key); + } + } + + /** + * Serialize the WebsiteConfig object into xml string. + * + * @return string + * @throws OssException + */ + public function serializeToXml() + { + $xml = new \SimpleXMLElement(''); + $index_document_part = $xml->addChild('IndexDocument'); + $error_document_part = $xml->addChild('ErrorDocument'); + $index_document_part->addChild('Suffix', $this->indexDocument); + $error_document_part->addChild('Key', $this->errorDocument); + return $xml->asXML(); + } + + /** + * @return string + */ + public function getIndexDocument() + { + return $this->indexDocument; + } + + /** + * @return string + */ + public function getErrorDocument() + { + return $this->errorDocument; + } + + private $indexDocument = ""; + private $errorDocument = ""; +} \ No newline at end of file diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/WormConfig.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/WormConfig.php new file mode 100644 index 0000000..6a48956 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/WormConfig.php @@ -0,0 +1,90 @@ +WormId)) { + $this->wormId = strval($xml->WormId); + } + if (isset($xml->State)) { + $this->state = strval($xml->State); + } + if (isset($xml->RetentionPeriodInDays)) { + $this->day = intval($xml->RetentionPeriodInDays); + } + if (isset($xml->CreationDate)) { + $this->creationDate = strval($xml->CreationDate); + } + } + + /** + * Serialize the object into xml string. + * + * @return string + */ + public function serializeToXml() + { + throw new OssException("Not implemented."); + } + + public function __toString() + { + return $this->serializeToXml(); + } + + /** + * @return string + */ + public function getWormId() + { + return $this->wormId; + } + + /** + * @return string + */ + public function getState() + { + return $this->state; + } + + /** + * @return int + */ + public function getDay() + { + return $this->day; + } + + /** + * @return string + */ + public function getCreationDate() + { + return $this->creationDate; + } + + private $wormId = ''; + private $state = ''; + private $creationDate = ''; + private $day = 0; +} \ No newline at end of file diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/XmlConfig.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/XmlConfig.php new file mode 100644 index 0000000..8c0a0db --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/XmlConfig.php @@ -0,0 +1,27 @@ + $endpoint, + 'cname' => $isCName, + 'request_proxy' => $requestProxy, + 'provider' => $provider + ); + $this->__initNewClient($config); + } + + /** + * @param array $config + * @throws OssException + */ + private function __initNewClient($config = array()) + { + $isCName = isset($config['cname']) ? $config['cname'] : false; + $endpoint = isset($config['endpoint']) ? $config['endpoint'] : ''; + $requestProxy = isset($config['request_proxy']) ? $config['request_proxy'] : null; + $provider = isset($config['provider']) ? $config['provider'] : ''; + if (empty($endpoint)) { + throw new OssException("endpoint is empty"); + } + $this->hostname = $this->checkEndpoint($endpoint, $isCName); + if (isset($config['forcePathStyle'])) { + if ($config['forcePathStyle'] === true) { + $this->hostType = self::OSS_HOST_TYPE_PATH_STYLE; + } + } + $this->requestProxy = $requestProxy; + if (!$provider instanceof CredentialsProvider) { + throw new OssException("provider must be an instance of CredentialsProvider"); + } + $this->provider = $provider; + + $this->region = isset($config['region']) ? $config['region'] : ''; + $this->cloudBoxId = isset($config['cloudBoxId']) ? $config['cloudBoxId'] : ''; + + // $enableStrictObjName + $this->enableStrictObjName = true; + if (isset($config['strictObjectName'])) { + if ($config['strictObjectName'] === false) { + $this->enableStrictObjName = false; + } + } + + // sign version + $signatureVersion = self::OSS_SIGNATURE_VERSION_V1; + if (isset($config['signatureVersion']) && $config['signatureVersion'] === self::OSS_SIGNATURE_VERSION_V4) { + $signatureVersion = self::OSS_SIGNATURE_VERSION_V4; + } + if ($signatureVersion === self::OSS_SIGNATURE_VERSION_V4) { + $this->enableStrictObjName = false; + $this->signer = new SignerV4(); + } else { + $this->signer = new SignerV1(); + } + + //checkObjectEncoding + $this->checkObjectEncoding = false; + if (isset($config['checkObjectEncoding'])) { + if ($config['checkObjectEncoding'] === true) { + $this->checkObjectEncoding = true; + } + } + + //filePathCompatible + $this->filePathCompatible = false; + if (version_compare(phpversion(), '7.0.0', '<')) { + if (OssUtil::isWin()) { + $this->filePathCompatible = true; + } + } + if (isset($config['filePathCompatible'])) { + if ($config['filePathCompatible'] === true) { + $this->filePathCompatible = true; + } else if ($config['filePathCompatible'] === false) { + $this->filePathCompatible = false; + } + } + + self::checkEnv(); + } + + /** + * Lists the Bucket [GetService]. Not applicable if the endpoint is CName (because CName must be binded to a specific bucket). + * + * @param array $options + * @return BucketListInfo|null + * @throws OssException|RequestCore_Exception + */ + public function listBuckets($options = NULL) + { + if ($this->hostType === self::OSS_HOST_TYPE_CNAME) { + throw new OssException("operation is not permitted with CName host"); + } + $this->precheckOptions($options); + $options[self::OSS_BUCKET] = ''; + $options[self::OSS_METHOD] = self::OSS_HTTP_GET; + $response = $this->auth($options); + $result = new ListBucketsResult($response); + return $result->getData(); + } + + /** + * Creates bucket,The ACL of the bucket created by default is OssClient::OSS_ACL_TYPE_PRIVATE + * + * @param string $bucket + * @param string $acl + * @param array $options + * @return null + * @throws OssException|RequestCore_Exception + */ + public function createBucket($bucket, $acl = self::OSS_ACL_TYPE_PRIVATE, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_PUT; + $options[self::OSS_HEADERS][self::OSS_ACL] = $acl; + if (isset($options[self::OSS_STORAGE])) { + $this->precheckStorage($options[self::OSS_STORAGE]); + $options[self::OSS_CONTENT] = OssUtil::createBucketXmlBody($options[self::OSS_STORAGE]); + unset($options[self::OSS_STORAGE]); + } + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Deletes bucket + * The deletion will not succeed if the bucket is not empty (either has objects or parts) + * To delete a bucket, all its objects and parts must be deleted first. + * + * @param string $bucket + * @param array $options + * @return null + * @throws OssException|RequestCore_Exception + */ + public function deleteBucket($bucket, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_DELETE; + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Checks if a bucket exists + * + * @param string $bucket + * @return bool|null + * @throws OssException|RequestCore_Exception + */ + public function doesBucketExist($bucket) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_GET; + $options[self::OSS_SUB_RESOURCE] = 'acl'; + $response = $this->auth($options); + $result = new ExistResult($response); + return $result->getData(); + } + + /** + * Get the data center location information for the bucket + * + * @param string $bucket + * @param array $options + * @return string|null + * @throws OssException|RequestCore_Exception + */ + public function getBucketLocation($bucket, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_GET; + $options[self::OSS_SUB_RESOURCE] = 'location'; + $response = $this->auth($options); + $result = new GetLocationResult($response); + return $result->getData(); + } + + /** + * Get the Meta information for the Bucket + * + * @param string $bucket + * @param array $options Refer to the SDK documentation + * @return array|null + * @throws OssException|RequestCore_Exception + */ + public function getBucketMeta($bucket, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_HEAD; + $response = $this->auth($options); + $result = new HeaderResult($response); + return $result->getData(); + } + + /** + * Gets the bucket ACL + * + * @param string $bucket + * @param array $options + * @return string|null + * @throws OssException|RequestCore_Exception + */ + public function getBucketAcl($bucket, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_GET; + $options[self::OSS_SUB_RESOURCE] = 'acl'; + $response = $this->auth($options); + $result = new AclResult($response); + return $result->getData(); + } + + /** + * Sets the bucket ACL + * + * @param string $bucket bucket name + * @param string $acl access permissions, valid values are ['private', 'public-read', 'public-read-write'] + * @param array $options by default is empty + * @return null + * @throws OssException|RequestCore_Exception + */ + public function putBucketAcl($bucket, $acl, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_PUT; + $options[self::OSS_HEADERS][self::OSS_ACL] = $acl; + $options[self::OSS_SUB_RESOURCE] = 'acl'; + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Gets object ACL + * + * @param string $bucket + * @param string $object + * @param array $options + * @return string|null + * @throws OssException|RequestCore_Exception + */ + public function getObjectAcl($bucket, $object, $options = NULL) + { + $this->precheckCommon($bucket, $object, $options, true); + $options[self::OSS_METHOD] = self::OSS_HTTP_GET; + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_OBJECT] = $object; + $options[self::OSS_SUB_RESOURCE] = 'acl'; + $response = $this->auth($options); + $result = new AclResult($response); + return $result->getData(); + } + + /** + * Sets the object ACL + * + * @param string $bucket bucket name + * @param string $object object name + * @param string $acl access permissions, valid values are ['default', 'private', 'public-read', 'public-read-write'] + * @param array $options + * @return null + * @throws OssException|RequestCore_Exception + */ + public function putObjectAcl($bucket, $object, $acl, $options = NULL) + { + $this->precheckCommon($bucket, $object, $options, true); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_PUT; + $options[self::OSS_OBJECT] = $object; + $options[self::OSS_HEADERS][self::OSS_OBJECT_ACL] = $acl; + $options[self::OSS_SUB_RESOURCE] = 'acl'; + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Gets the bucket logging config + * + * @param string $bucket bucket name + * @param array $options by default is empty + * @return LoggingConfig|null + * @throws OssException|RequestCore_Exception + */ + public function getBucketLogging($bucket, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_GET; + $options[self::OSS_SUB_RESOURCE] = 'logging'; + $response = $this->auth($options); + $result = new GetLoggingResult($response); + return $result->getData(); + } + + /** + * Sets the bycket logging config. Only owner can call this API. + * + * @param string $bucket bucket name + * @param string $targetBucket The logging file's bucket + * @param string $targetPrefix The logging file's prefix + * @param array $options By default is empty. + * @return null + * @throws OssException|RequestCore_Exception + */ + public function putBucketLogging($bucket, $targetBucket, $targetPrefix, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $this->precheckBucket($targetBucket, 'targetbucket is not allowed empty'); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_PUT; + $options[self::OSS_SUB_RESOURCE] = 'logging'; + $options[self::OSS_CONTENT_TYPE] = 'application/xml'; + + $loggingConfig = new LoggingConfig($targetBucket, $targetPrefix); + $options[self::OSS_CONTENT] = $loggingConfig->serializeToXml(); + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Deletes the bucket logging config + * + * @param string $bucket bucket name + * @param array $options + * @return null + * @throws OssException|RequestCore_Exception + */ + public function deleteBucketLogging($bucket, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_DELETE; + $options[self::OSS_SUB_RESOURCE] = 'logging'; + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Sets the website config in bucket---that is could make the bucket as a static website once the CName is binded. + * + * @param string $bucket bucket name + * @param WebsiteConfig $websiteConfig + * @param array $options + * @return null + * @throws OssException|RequestCore_Exception + */ + public function putBucketWebsite($bucket, $websiteConfig, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_PUT; + $options[self::OSS_SUB_RESOURCE] = 'website'; + $options[self::OSS_CONTENT_TYPE] = 'application/xml'; + $options[self::OSS_CONTENT] = $websiteConfig->serializeToXml(); + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Gets the website config in the bucket + * + * @param string $bucket bucket name + * @param array $options + * @return WebsiteConfig|null + * @throws OssException|RequestCore_Exception + */ + public function getBucketWebsite($bucket, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_GET; + $options[self::OSS_SUB_RESOURCE] = 'website'; + $response = $this->auth($options); + $result = new GetWebsiteResult($response); + return $result->getData(); + } + + /** + * Deletes the website config in the bucket + * + * @param string $bucket bucket name + * @param array $options + * @return null + * @throws OssException|RequestCore_Exception + */ + public function deleteBucketWebsite($bucket, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_DELETE; + $options[self::OSS_SUB_RESOURCE] = 'website'; + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Sets the cross-origin-resource-sharing (CORS) rule. It would overwrite the originl one. + * + * @param string $bucket bucket name + * @param CorsConfig $corsConfig CORS config. Check out the details from OSS API document + * @param array $options array + * @return null + * @throws OssException|RequestCore_Exception + */ + public function putBucketCors($bucket, $corsConfig, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_PUT; + $options[self::OSS_SUB_RESOURCE] = 'cors'; + $options[self::OSS_CONTENT_TYPE] = 'application/xml'; + $options[self::OSS_CONTENT] = $corsConfig->serializeToXml(); + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Gets the bucket CORS config + * + * @param string $bucket bucket name + * @param array $options + * @return CorsConfig|null + * @throws OssException|RequestCore_Exception + */ + public function getBucketCors($bucket, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_GET; + $options[self::OSS_SUB_RESOURCE] = 'cors'; + $response = $this->auth($options); + $result = new GetCorsResult($response); + return $result->getData(); + } + + /** + * Deletes the bucket's CORS config and disable the CORS on the bucket. + * + * @param string $bucket bucket name + * @param array $options + * @return null + * @throws OssException|RequestCore_Exception + */ + public function deleteBucketCors($bucket, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_DELETE; + $options[self::OSS_SUB_RESOURCE] = 'cors'; + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Bind a CName for the bucket + * + * @param string $bucket bucket name + * @param string $cname + * @param array $options + * @return null + * @throws OssException|RequestCore_Exception + */ + public function addBucketCname($bucket, $cname, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_POST; + $options[self::OSS_CONTENT_TYPE] = 'application/xml'; + $cnameConfig = new CnameConfig(); + $cnameConfig->addCname($cname); + $options[self::OSS_CONTENT] = $cnameConfig->serializeToXml(); + $options[self::OSS_COMP] = 'add'; + $options[self::OSS_CNAME] = ''; + + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Gets the binded CName list of the bucket + * + * @param string $bucket bucket name + * @param array $options + * @return CnameConfig|null + * @throws OssException|RequestCore_Exception + */ + public function getBucketCname($bucket, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_GET; + $options[self::OSS_CNAME] = ''; + $response = $this->auth($options); + $result = new GetCnameResult($response); + return $result->getData(); + } + + /** + * Remove a CName binding from the bucket + * + * @param string $bucket bucket name + * @param CnameConfig $cname + * @param array $options + * @return null + * @throws OssException|RequestCore_Exception + */ + public function deleteBucketCname($bucket, $cname, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_POST; + $options[self::OSS_CONTENT_TYPE] = 'application/xml'; + $cnameConfig = new CnameConfig(); + $cnameConfig->addCname($cname); + $options[self::OSS_CONTENT] = $cnameConfig->serializeToXml(); + $options[self::OSS_COMP] = 'delete'; + $options[self::OSS_CNAME] = ''; + + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * create a cname token for a bucket + * + * @param string $bucket bucket name + * @param array $options + * @return CnameTokenInfo|null + * @throws OssException|RequestCore_Exception + */ + public function createBucketCnameToken($bucket, $cname, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_POST; + $options[self::OSS_CONTENT_TYPE] = 'application/xml'; + $cnameConfig = new CnameConfig(); + $cnameConfig->addCname($cname); + $options[self::OSS_CONTENT] = $cnameConfig->serializeToXml(); + $options[self::OSS_COMP] = 'token'; + $options[self::OSS_CNAME] = ''; + $response = $this->auth($options); + $result = new CreateBucketCnameTokenResult($response); + return $result->getData(); + } + + /** + * get a cname token for a bucket + * + * @param string $bucket bucket name + * @param array $options + * @return CnameTokenInfo|null + * @throws OssException|RequestCore_Exception + */ + public function getBucketCnameToken($bucket, $cname, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_GET; + $options[self::OSS_COMP] = 'token'; + $options[self::OSS_CNAME] = $cname; + $response = $this->auth($options); + $result = new GetBucketCnameTokenResult($response); + return $result->getData(); + } + + /** + * Creates a Live Channel under a bucket + * + * @param string $bucket bucket name + * @param string channelName $channelName + * @param LiveChannelConfig $channelConfig + * @param array $options + * @return LiveChannelInfo|null + * @throws OssException|RequestCore_Exception + */ + public function putBucketLiveChannel($bucket, $channelName, $channelConfig, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_PUT; + $options[self::OSS_OBJECT] = $channelName; + $options[self::OSS_SUB_RESOURCE] = 'live'; + $options[self::OSS_CONTENT_TYPE] = 'application/xml'; + $options[self::OSS_CONTENT] = $channelConfig->serializeToXml(); + + $response = $this->auth($options); + $result = new PutLiveChannelResult($response); + $info = $result->getData(); + $info->setName($channelName); + $info->setDescription($channelConfig->getDescription()); + + return $info; + } + + /** + * Sets the LiveChannel status + * + * @param string $bucket bucket name + * @param string channelName $channelName + * @param string channelStatus $channelStatus enabled or disabled + * @param array $options + * @return null + * @throws OssException|RequestCore_Exception + */ + public function putLiveChannelStatus($bucket, $channelName, $channelStatus, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_PUT; + $options[self::OSS_OBJECT] = $channelName; + $options[self::OSS_SUB_RESOURCE] = 'live'; + $options[self::OSS_LIVE_CHANNEL_STATUS] = $channelStatus; + + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Gets the LiveChannel information by the channel name + * + * @param string $bucket bucket name + * @param string channelName $channelName + * @param array $options + * @return GetLiveChannelInfo|null + * @throws OssException|RequestCore_Exception + */ + public function getLiveChannelInfo($bucket, $channelName, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_GET; + $options[self::OSS_OBJECT] = $channelName; + $options[self::OSS_SUB_RESOURCE] = 'live'; + + $response = $this->auth($options); + $result = new GetLiveChannelInfoResult($response); + return $result->getData(); + } + + /** + * Gets the status of LiveChannel + * + * @param string $bucket bucket name + * @param string channelName $channelName + * @param array $options + * @return GetLiveChannelStatus|null + * @throws OssException|RequestCore_Exception + */ + public function getLiveChannelStatus($bucket, $channelName, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_GET; + $options[self::OSS_OBJECT] = $channelName; + $options[self::OSS_SUB_RESOURCE] = 'live'; + $options[self::OSS_COMP] = 'stat'; + + $response = $this->auth($options); + $result = new GetLiveChannelStatusResult($response); + return $result->getData(); + } + + /** + * Gets the LiveChannel pushing streaming record + * + * @param string $bucket bucket name + * @param string channelName $channelName + * @param array $options + * @return GetLiveChannelHistory|null + * @throws OssException|RequestCore_Exception + */ + public function getLiveChannelHistory($bucket, $channelName, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_GET; + $options[self::OSS_OBJECT] = $channelName; + $options[self::OSS_SUB_RESOURCE] = 'live'; + $options[self::OSS_COMP] = 'history'; + + $response = $this->auth($options); + $result = new GetLiveChannelHistoryResult($response); + return $result->getData(); + } + + /** + *Gets the live channel list under a bucket. + * + * @param string $bucket bucket name + * @param array $options + * @return LiveChannelListInfo|null + * @throws OssException|RequestCore_Exception + */ + public function listBucketLiveChannels($bucket, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_GET; + $options[self::OSS_SUB_RESOURCE] = 'live'; + $options[self::OSS_QUERY_STRING] = array( + 'prefix' => isset($options['prefix']) ? $options['prefix'] : '', + 'marker' => isset($options['marker']) ? $options['marker'] : '', + 'max-keys' => isset($options['max-keys']) ? $options['max-keys'] : '', + ); + $response = $this->auth($options); + $result = new ListLiveChannelResult($response); + $list = $result->getData(); + $list->setBucketName($bucket); + + return $list; + } + + /** + * Creates a play list file for the LiveChannel + * + * @param string $bucket bucket name + * @param string channelName $channelName + * @param string $playlistName The playlist name, must end with ".m3u8". + * @param array $setTime startTime and EndTime in unix time. No more than 1 day. + * @return null + * @throws OssException|RequestCore_Exception + */ + public function postVodPlaylist($bucket, $channelName, $playlistName, $setTime) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_POST; + $options[self::OSS_OBJECT] = $channelName . '/' . $playlistName; + $options[self::OSS_SUB_RESOURCE] = 'vod'; + $options[self::OSS_LIVE_CHANNEL_END_TIME] = $setTime['EndTime']; + $options[self::OSS_LIVE_CHANNEL_START_TIME] = $setTime['StartTime']; + + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Deletes the Bucket LiveChannel + * + * @param string $bucket bucket name + * @param string channelName $channelName + * @param array $options + * @return null + * @throws OssException|RequestCore_Exception + */ + public function deleteBucketLiveChannel($bucket, $channelName, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_DELETE; + $options[self::OSS_OBJECT] = $channelName; + $options[self::OSS_SUB_RESOURCE] = 'live'; + + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Generates the signed pushing streaming url + * + * @param string $bucket bucket name + * @param string channelName $channelName + * @param int timeout timeout value in seconds + * @param array $options + * @return string The signed pushing streaming url + * @throws OssException + */ + public function signRtmpUrl($bucket, $channelName, $timeout = 60, $options = NULL) + { + $this->precheckCommon($bucket, $channelName, $options, false); + $expires = time() + $timeout; + $proto = 'rtmp://'; + $hostname = $this->generateHostname($bucket); + $cano_params = ''; + $query_items = array(); + $params = isset($options['params']) ? $options['params'] : array(); + uksort($params, 'strnatcasecmp'); + foreach ($params as $key => $value) { + $cano_params = $cano_params . $key . ':' . $value . "\n"; + $query_items[] = rawurlencode($key) . '=' . rawurlencode($value); + } + $resource = '/' . $bucket . '/' . $channelName; + + $string_to_sign = $expires . "\n" . $cano_params . $resource; + $cred = $this->provider->getCredentials(); + $this->checkCredentials($cred); + + $signature = base64_encode(hash_hmac('sha1', $string_to_sign, $cred->getAccessKeySecret(), true)); + + $query_items[] = 'OSSAccessKeyId=' . rawurlencode($cred->getAccessKeyId()); + $query_items[] = 'Expires=' . rawurlencode($expires); + $query_items[] = 'Signature=' . rawurlencode($signature); + + return $proto . $hostname . '/live/' . $channelName . '?' . implode('&', $query_items); + } + + /** + * Generates the signed pushing streaming url + * + * @param string $bucket bucket name + * @param string $channelName channel name + * @param int $expiration expiration time of the Url, unix epoch, since 1970.1.1 00.00.00 UTC + * @param array $options + * @return string The signed pushing streaming url + * @throws OssException + */ + public function generatePresignedRtmpUrl($bucket, $channelName, $expiration, $options = NULL) + { + $this->precheckCommon($bucket, $channelName, $options, false); + $proto = 'rtmp://'; + $hostname = $this->generateHostname($bucket); + $cano_params = ''; + $query_items = array(); + $params = isset($options['params']) ? $options['params'] : array(); + uksort($params, 'strnatcasecmp'); + foreach ($params as $key => $value) { + $cano_params = $cano_params . $key . ':' . $value . "\n"; + $query_items[] = rawurlencode($key) . '=' . rawurlencode($value); + } + $resource = '/' . $bucket . '/' . $channelName; + + $string_to_sign = $expiration . "\n" . $cano_params . $resource; + $cred = $this->provider->getCredentials(); + $this->checkCredentials($cred); + + $signature = base64_encode(hash_hmac('sha1', $string_to_sign, $cred->getAccessKeySecret(), true)); + + $query_items[] = 'OSSAccessKeyId=' . rawurlencode($cred->getAccessKeyId()); + $query_items[] = 'Expires=' . rawurlencode($expiration); + $query_items[] = 'Signature=' . rawurlencode($signature); + + return $proto . $hostname . '/live/' . $channelName . '?' . implode('&', $query_items); + } + + /** + * Precheck the CORS request. Before sending a CORS request, a preflight request (OPTIONS) is sent with the specific origin. + * HTTP METHOD and headers information are sent to OSS as well for evaluating if the CORS request is allowed. + * + * Note: OSS could enable the CORS on the bucket by calling putBucketCors. Once CORS is enabled, the OSS could evaluate accordingto the preflight request. + * + * @param string $bucket bucket name + * @param string $object object name + * @param string $origin the origin of the request + * @param string $request_method The actual HTTP method which will be used in CORS request + * @param string $request_headers The actual HTTP headers which will be used in CORS request + * @param array $options + * @return array|null + * @throws OssException|RequestCore_Exception + */ + public function optionsObject($bucket, $object, $origin, $request_method, $request_headers, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_OPTIONS; + $options[self::OSS_OBJECT] = $object; + $options[self::OSS_HEADERS][self::OSS_OPTIONS_ORIGIN] = $origin; + $options[self::OSS_HEADERS][self::OSS_OPTIONS_REQUEST_HEADERS] = $request_headers; + $options[self::OSS_HEADERS][self::OSS_OPTIONS_REQUEST_METHOD] = $request_method; + $response = $this->auth($options); + $result = new HeaderResult($response); + return $result->getData(); + } + + /** + * Sets the bucket's lifecycle config + * + * @param string $bucket bucket name + * @param LifecycleConfig $lifecycleConfig LifecycleConfig instance + * @param array $options + * @return array|null + * @throws OssException|RequestCore_Exception + */ + public function putBucketLifecycle($bucket, $lifecycleConfig, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_PUT; + $options[self::OSS_SUB_RESOURCE] = 'lifecycle'; + $options[self::OSS_CONTENT_TYPE] = 'application/xml'; + $options[self::OSS_CONTENT] = $lifecycleConfig->serializeToXml(); + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Gets bucket's lifecycle config + * + * @param string $bucket bucket name + * @param array $options + * @return LifecycleConfig|null + * @throws OssException|RequestCore_Exception + */ + public function getBucketLifecycle($bucket, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_GET; + $options[self::OSS_SUB_RESOURCE] = 'lifecycle'; + $response = $this->auth($options); + $result = new GetLifecycleResult($response); + return $result->getData(); + } + + /** + * Deletes the bucket's lifecycle config + * + * @param string $bucket bucket name + * @param array $options + * @return array|null + * @throws OssException|RequestCore_Exception + */ + public function deleteBucketLifecycle($bucket, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_DELETE; + $options[self::OSS_SUB_RESOURCE] = 'lifecycle'; + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Sets a bucket's referer, which has a whitelist of referrer and specifies if empty referer is allowed. + * Checks out API document for more details about "Bucket Referer" + * + * @param string $bucket bucket name + * @param RefererConfig $refererConfig + * @param array $options + * @return array|null + * @throws OssException|RequestCore_Exception + */ + public function putBucketReferer($bucket, $refererConfig, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_PUT; + $options[self::OSS_SUB_RESOURCE] = 'referer'; + $options[self::OSS_CONTENT_TYPE] = 'application/xml'; + $options[self::OSS_CONTENT] = $refererConfig->serializeToXml(); + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Gets the bucket's Referer + * Checks out API document for more details about "Bucket Referer" + * + * @param string $bucket bucket name + * @param array $options + * @return RefererConfig|null + * @throws OssException|RequestCore_Exception + */ + public function getBucketReferer($bucket, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_GET; + $options[self::OSS_SUB_RESOURCE] = 'referer'; + $response = $this->auth($options); + $result = new GetRefererResult($response); + return $result->getData(); + } + + /** + * Set the size of the bucket,the unit is GB + * When the capacity of the bucket is bigger than the set, it's forbidden to continue writing + * + * @param string $bucket bucket name + * @param int $storageCapacity + * @param array $options + * @return array|null + * @throws OssException|RequestCore_Exception + */ + public function putBucketStorageCapacity($bucket, $storageCapacity, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_PUT; + $options[self::OSS_SUB_RESOURCE] = 'qos'; + $options[self::OSS_CONTENT_TYPE] = 'application/xml'; + $storageCapacityConfig = new StorageCapacityConfig($storageCapacity); + $options[self::OSS_CONTENT] = $storageCapacityConfig->serializeToXml(); + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Get the capacity of the bucket, the unit is GB + * + * @param string $bucket bucket name + * @param array $options + * @return int|null + * @throws OssException|RequestCore_Exception + */ + public function getBucketStorageCapacity($bucket, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_GET; + $options[self::OSS_SUB_RESOURCE] = 'qos'; + $response = $this->auth($options); + $result = new GetStorageCapacityResult($response); + return $result->getData(); + } + + /** + * Get the information of the bucket + * + * @param string $bucket bucket name + * @param array $options + * @return BucketInfo|null + * @throws OssException|RequestCore_Exception + */ + public function getBucketInfo($bucket, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_GET; + $options[self::OSS_SUB_RESOURCE] = 'bucketInfo'; + $response = $this->auth($options); + $result = new GetBucketInfoResult($response); + return $result->getData(); + } + + /** + * Get the stat of the bucket + * + * @param string $bucket bucket name + * @param array $options + * @return BucketStat|null + * @throws OssException|RequestCore_Exception + */ + public function getBucketStat($bucket, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_GET; + $options[self::OSS_SUB_RESOURCE] = 'stat'; + $response = $this->auth($options); + $result = new GetBucketStatResult($response); + return $result->getData(); + } + + /** + * Sets the bucket's policy + * + * @param string $bucket bucket name + * @param string $policy policy json format content + * @param array $options + * @return array|null + * @throws OssException|RequestCore_Exception + */ + public function putBucketPolicy($bucket, $policy, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_PUT; + $options[self::OSS_SUB_RESOURCE] = 'policy'; + $options[self::OSS_CONTENT_TYPE] = 'application/json'; + $options[self::OSS_CONTENT] = $policy; + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Gets bucket's policy + * + * @param string $bucket bucket name + * @param array $options + * @return string|null policy json content + * @throws OssException|RequestCore_Exception + */ + public function getBucketPolicy($bucket, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_GET; + $options[self::OSS_SUB_RESOURCE] = 'policy'; + $response = $this->auth($options); + $result = new BodyResult($response); + return $result->getData(); + } + + /** + * Deletes the bucket's policy + * + * @param string $bucket bucket name + * @param array $options + * @return array|null + * @throws OssException|RequestCore_Exception + */ + public function deleteBucketPolicy($bucket, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_DELETE; + $options[self::OSS_SUB_RESOURCE] = 'policy'; + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Sets the bucket's encryption + * + * @param string $bucket bucket name + * @param ServerSideEncryptionConfig $sseConfig + * @param array $options + * @return array|null + * @throws OssException|RequestCore_Exception + */ + public function putBucketEncryption($bucket, $sseConfig, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_PUT; + $options[self::OSS_SUB_RESOURCE] = 'encryption'; + $options[self::OSS_CONTENT_TYPE] = 'application/xml'; + $options[self::OSS_CONTENT] = $sseConfig->serializeToXml(); + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Gets bucket's encryption + * + * @param string $bucket bucket name + * @param array $options + * @return ServerSideEncryptionConfig|null + * @throws OssException|RequestCore_Exception + */ + public function getBucketEncryption($bucket, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_GET; + $options[self::OSS_SUB_RESOURCE] = 'encryption'; + $response = $this->auth($options); + $result = new GetBucketEncryptionResult($response); + return $result->getData(); + } + + /** + * Deletes the bucket's encryption + * + * @param string $bucket bucket name + * @param array $options + * @return array|null + * @throws OssException|RequestCore_Exception + */ + public function deleteBucketEncryption($bucket, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_DELETE; + $options[self::OSS_SUB_RESOURCE] = 'encryption'; + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Set the request playment of the bucket, Can be BucketOwner and Requester + * + * @param string $bucket bucket name + * @param string $payer + * @param array $options + * @return array|null + * @throws OssException|RequestCore_Exception + */ + public function putBucketRequestPayment($bucket, $payer, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_PUT; + $options[self::OSS_SUB_RESOURCE] = 'requestPayment'; + $options[self::OSS_CONTENT_TYPE] = 'application/xml'; + $config = new RequestPaymentConfig($payer); + $options[self::OSS_CONTENT] = $config->serializeToXml(); + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Get the request playment of the bucket + * + * @param string $bucket bucket name + * @param array $options + * @return string|null + * @throws OssException|RequestCore_Exception + */ + public function getBucketRequestPayment($bucket, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_GET; + $options[self::OSS_SUB_RESOURCE] = 'requestPayment'; + $response = $this->auth($options); + $result = new GetBucketRequestPaymentResult($response); + return $result->getData(); + } + + /** + * Sets the bucket's tags + * + * @param string $bucket bucket name + * @param TaggingConfig $taggingConfig + * @param array $options + * @return null + * @throws OssException|RequestCore_Exception + */ + public function putBucketTags($bucket, $taggingConfig, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_PUT; + $options[self::OSS_SUB_RESOURCE] = self::OSS_TAGGING; + $options[self::OSS_CONTENT_TYPE] = 'application/xml'; + $options[self::OSS_CONTENT] = $taggingConfig->serializeToXml(); + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Gets bucket's tags + * + * @param string $bucket bucket name + * @param array $options + * @return TaggingConfig|null + * @throws OssException|RequestCore_Exception + */ + public function getBucketTags($bucket, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_GET; + $options[self::OSS_SUB_RESOURCE] = self::OSS_TAGGING; + $response = $this->auth($options); + $result = new GetBucketTagsResult($response); + return $result->getData(); + } + + /** + * Deletes the bucket's tags + * If want to delete specified tags for a bucket, please set the $tags + * + * @param string $bucket bucket name + * @param tag[] $tags (optional) + * @param array $options + * @return array|null + * @throws OssException|RequestCore_Exception + */ + public function deleteBucketTags($bucket, $tags = NULL, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_DELETE; + if (empty($tags)) { + $options[self::OSS_SUB_RESOURCE] = self::OSS_TAGGING; + } else { + $value = ''; + foreach ($tags as $tag) { + $value .= $tag->getKey() . ','; + } + $value = rtrim($value, ','); + $options[self::OSS_TAGGING] = $value; + } + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Set the versioning of the bucket, Can be BucketOwner and Requester + * + * @param string $bucket bucket name + * @param string $status + * @param array $options + * @return array|null + * @throws OssException|RequestCore_Exception + */ + public function putBucketVersioning($bucket, $status, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_PUT; + $options[self::OSS_SUB_RESOURCE] = 'versioning'; + $options[self::OSS_CONTENT_TYPE] = 'application/xml'; + $config = new VersioningConfig($status); + $options[self::OSS_CONTENT] = $config->serializeToXml(); + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Get the versioning of the bucket + * + * @param string $bucket bucket name + * @param array $options + * @return string|null + * @throws OssException|RequestCore_Exception + */ + public function getBucketVersioning($bucket, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_GET; + $options[self::OSS_SUB_RESOURCE] = 'versioning'; + $response = $this->auth($options); + $result = new GetBucketVersioningResult($response); + return $result->getData(); + } + + /** + * Initialize a bucket's worm + * + * @param string $bucket bucket name + * @param int $day + * @param array $options + * @return string|null returns upload id + * @throws OssException|RequestCore_Exception + */ + public function initiateBucketWorm($bucket, $day, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_METHOD] = self::OSS_HTTP_POST; + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_SUB_RESOURCE] = 'worm'; + $options[self::OSS_CONTENT_TYPE] = 'application/xml'; + $config = new InitiateWormConfig($day); + $options[self::OSS_CONTENT] = $config->serializeToXml(); + $response = $this->auth($options); + $result = new InitiateBucketWormResult($response); + return $result->getData(); + } + + /** + * Aborts the bucket's worm + * + * @param string $bucket bucket name + * @param array $options + * @return array|null + * @throws OssException|RequestCore_Exception + */ + public function abortBucketWorm($bucket, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_DELETE; + $options[self::OSS_SUB_RESOURCE] = 'worm'; + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Complete a bucket's worm + * + * @param string $bucket bucket name + * @param string $wormId + * @param array $options + * @return string|null returns upload id + * @throws OssException|RequestCore_Exception + */ + public function completeBucketWorm($bucket, $wormId, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_METHOD] = self::OSS_HTTP_POST; + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_WORM_ID] = $wormId; + $options[self::OSS_CONTENT] = ''; + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Extend a bucket's worm + * + * @param string $bucket bucket name + * @param string $wormId + * @param int $day + * @param array $options + * @return string|null returns upload id + * @throws OssException|RequestCore_Exception + */ + public function extendBucketWorm($bucket, $wormId, $day, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_METHOD] = self::OSS_HTTP_POST; + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_WORM_ID] = $wormId; + $options[self::OSS_SUB_RESOURCE] = 'wormExtend'; + $options[self::OSS_CONTENT_TYPE] = 'application/xml'; + $config = new ExtendWormConfig($day); + $options[self::OSS_CONTENT] = $config->serializeToXml(); + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Get a bucket's worm + * + * @param string $bucket bucket name + * @param array $options + * @return string|null + * @throws OssException|RequestCore_Exception + */ + public function getBucketWorm($bucket, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_GET; + $options[self::OSS_SUB_RESOURCE] = 'worm'; + $response = $this->auth($options); + $result = new GetBucketWormResult($response); + return $result->getData(); + } + + + /** + * Put Bucket TransferAcceleration + * @param $bucket + * @param $enabled boolean + * @param array $options + * @return array|null + * @throws OssException|RequestCore_Exception + */ + + public function putBucketTransferAcceleration($bucket, $enabled, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_PUT; + $options[self::OSS_SUB_RESOURCE] = 'transferAcceleration'; + $options[self::OSS_CONTENT_TYPE] = 'application/xml'; + $config = new TransferAccelerationConfig(); + $config->setEnabled($enabled); + $options[self::OSS_CONTENT] = $config->serializeToXml(); + $response = $this->auth($options); + $result = new HeaderResult($response); + return $result->getData(); + } + + /** + * Put Bucket TransferAcceleration + * @param $bucket + * @param array $options + * @return boolean|null + * @throws OssException|RequestCore_Exception + */ + public function getBucketTransferAcceleration($bucket, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_GET; + $options[self::OSS_SUB_RESOURCE] = 'transferAcceleration'; + $options[self::OSS_CONTENT_TYPE] = 'application/xml'; + $response = $this->auth($options); + $result = new GetBucketTransferAccelerationResult($response); + return $result->getData(); + } + + /** + * Lists the bucket's object list (in ObjectListInfo) + * + * @param string $bucket + * @param array $options are defined below: + * $options = array( + * 'max-keys' => specifies max object count to return. By default is 100 and max value could be 1000. + * 'prefix' => specifies the key prefix the returned objects must have. Note that the returned keys still contain the prefix. + * 'delimiter' => The delimiter of object name for grouping object. When it's specified, listObjects will differeniate the object and folder. And it will return subfolder's objects. + * 'marker' => The key of returned object must be greater than the 'marker'. + *) + * Prefix and marker are for filtering and paging. Their length must be less than 256 bytes + * @return ObjectListInfo|null + * @throws OssException|RequestCore_Exception + */ + public function listObjects($bucket, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_GET; + $query = isset($options[self::OSS_QUERY_STRING]) ? $options[self::OSS_QUERY_STRING] : array(); + $options[self::OSS_QUERY_STRING] = array_merge( + $query, + array(self::OSS_ENCODING_TYPE => self::OSS_ENCODING_TYPE_URL, + self::OSS_DELIMITER => isset($options[self::OSS_DELIMITER]) ? $options[self::OSS_DELIMITER] : '/', + self::OSS_PREFIX => isset($options[self::OSS_PREFIX]) ? $options[self::OSS_PREFIX] : '', + self::OSS_MAX_KEYS => isset($options[self::OSS_MAX_KEYS]) ? $options[self::OSS_MAX_KEYS] : self::OSS_MAX_KEYS_VALUE, + self::OSS_MARKER => isset($options[self::OSS_MARKER]) ? $options[self::OSS_MARKER] : '') + ); + + $response = $this->auth($options); + $result = new ListObjectsResult($response); + return $result->getData(); + } + + + /** + * Lists the bucket's object list v2 (in ObjectListInfoV2) + * + * @param string $bucket + * @param array $options are defined below: + * $options = array( + * 'max-keys' => specifies max object count to return. By default is 100 and max value could be 1000. + * 'prefix' => specifies the key prefix the returned objects must have. Note that the returned keys still contain the prefix. + * 'delimiter' => The delimiter of object name for grouping object. When it's specified, listObjects will differeniate the object and folder. And it will return subfolder's objects. + * 'start-after' => The key of returned object must be greater than the 'start-after'. + * 'continuation-token' => The token from which the list operation must start. + *) + * Prefix, start-after and continuation-token are for filtering and paging. Their length must be less than 256 bytes + * @return ObjectListInfoV2|null + * @throws OssException|RequestCore_Exception + */ + public function listObjectsV2($bucket, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_GET; + $query = isset($options[self::OSS_QUERY_STRING]) ? $options[self::OSS_QUERY_STRING] : array(); + $temp = array( + self::OSS_LIST_TYPE => 2, + self::OSS_ENCODING_TYPE => self::OSS_ENCODING_TYPE_URL, + self::OSS_DELIMITER => isset($options[self::OSS_DELIMITER]) ? $options[self::OSS_DELIMITER] : '/', + self::OSS_PREFIX => isset($options[self::OSS_PREFIX]) ? $options[self::OSS_PREFIX] : '', + self::OSS_MAX_KEYS => isset($options[self::OSS_MAX_KEYS]) ? $options[self::OSS_MAX_KEYS] : self::OSS_MAX_KEYS_VALUE, + self::OSS_START_AFTER => isset($options[self::OSS_START_AFTER]) ? $options[self::OSS_START_AFTER] : '', + ); + if (isset($options[self::OSS_CONTINUATION_TOKEN])) { + $temp[self::OSS_CONTINUATION_TOKEN] = $options[self::OSS_CONTINUATION_TOKEN]; + } + $options[self::OSS_QUERY_STRING] = array_merge( + $query, $temp + ); + $response = $this->auth($options); + $result = new ListObjectsV2Result($response); + return $result->getData(); + } + + /** + * Lists the bucket's object with version information (in ObjectListInfo) + * + * @param string $bucket + * @param array $options are defined below: + * $options = array( + * 'max-keys' => specifies max object count to return. By default is 100 and max value could be 1000. + * 'prefix' => specifies the key prefix the returned objects must have. Note that the returned keys still contain the prefix. + * 'delimiter' => The delimiter of object name for grouping object. When it's specified, listObjectVersions will differeniate the object and folder. And it will return subfolder's objects. + * 'key-marker' => The key of returned object must be greater than the 'key-marker'. + * 'version-id-marker' => The version id of returned object must be greater than the 'version-id-marker'. + *) + * Prefix and marker are for filtering and paging. Their length must be less than 256 bytes + * @return ObjectVersionListInfo|null + * @throws OssException|RequestCore_Exception + */ + public function listObjectVersions($bucket, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_GET; + $options[self::OSS_SUB_RESOURCE] = 'versions'; + $query = isset($options[self::OSS_QUERY_STRING]) ? $options[self::OSS_QUERY_STRING] : array(); + $options[self::OSS_QUERY_STRING] = array_merge( + $query, + array(self::OSS_ENCODING_TYPE => self::OSS_ENCODING_TYPE_URL, + self::OSS_DELIMITER => isset($options[self::OSS_DELIMITER]) ? $options[self::OSS_DELIMITER] : '/', + self::OSS_PREFIX => isset($options[self::OSS_PREFIX]) ? $options[self::OSS_PREFIX] : '', + self::OSS_MAX_KEYS => isset($options[self::OSS_MAX_KEYS]) ? $options[self::OSS_MAX_KEYS] : self::OSS_MAX_KEYS_VALUE, + self::OSS_KEY_MARKER => isset($options[self::OSS_KEY_MARKER]) ? $options[self::OSS_KEY_MARKER] : '', + self::OSS_VERSION_ID_MARKER => isset($options[self::OSS_VERSION_ID_MARKER]) ? $options[self::OSS_VERSION_ID_MARKER] : '') + ); + + $response = $this->auth($options); + $result = new ListObjectVersionsResult($response); + return $result->getData(); + } + + /** + * Creates a virtual 'folder' in OSS. The name should not end with '/' because the method will append the name with a '/' anyway. + * + * Internal use only. + * + * @param string $bucket bucket name + * @param string $object object name + * @param array $options + * @return array|null + * @throws OssException|RequestCore_Exception + */ + public function createObjectDir($bucket, $object, $options = NULL) + { + $this->precheckCommon($bucket, $object, $options); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_PUT; + $options[self::OSS_OBJECT] = $object . '/'; + $options[self::OSS_CONTENT_LENGTH] = array(self::OSS_CONTENT_LENGTH => 0); + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Uploads the $content object to OSS. + * + * @param string $bucket bucket name + * @param string $object objcet name + * @param string $content The content object + * @param array $options + * @return array|null + * @throws OssException|RequestCore_Exception + */ + public function putObject($bucket, $object, $content, $options = NULL) + { + $this->precheckCommon($bucket, $object, $options); + + $options[self::OSS_CONTENT] = $content; + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_PUT; + $options[self::OSS_OBJECT] = $object; + + if (!isset($options[self::OSS_LENGTH])) { + $options[self::OSS_CONTENT_LENGTH] = strlen($options[self::OSS_CONTENT]); + } else { + $options[self::OSS_CONTENT_LENGTH] = $options[self::OSS_LENGTH]; + } + + $is_check_md5 = $this->isCheckMD5($options); + if ($is_check_md5) { + $content_md5 = base64_encode(md5($content, true)); + $options[self::OSS_CONTENT_MD5] = $content_md5; + } + + if (!isset($options[self::OSS_CONTENT_TYPE])) { + $options[self::OSS_CONTENT_TYPE] = $this->getMimeType($object); + } + $response = $this->auth($options); + + if (isset($options[self::OSS_CALLBACK]) && !empty($options[self::OSS_CALLBACK])) { + $result = new CallbackResult($response); + } else { + $result = new PutSetDeleteResult($response); + } + + return $result->getData(); + } + + + /** + * creates symlink + * @param string $bucket bucket name + * @param string $symlink symlink name + * @param string $targetObject targetObject name + * @param array $options + * @return array|null + * @throws OssException|RequestCore_Exception + */ + public function putSymlink($bucket, $symlink, $targetObject, $options = NULL) + { + $this->precheckCommon($bucket, $symlink, $options); + + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_PUT; + $options[self::OSS_OBJECT] = $symlink; + $options[self::OSS_SUB_RESOURCE] = self::OSS_SYMLINK; + $options[self::OSS_HEADERS][self::OSS_SYMLINK_TARGET] = rawurlencode($targetObject); + + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Gets symlink + * @param string $bucket bucket name + * @param string $symlink symlink name + * @param array $options + * @return array|null + * @throws OssException|RequestCore_Exception + */ + public function getSymlink($bucket, $symlink, $options = NULL) + { + $this->precheckCommon($bucket, $symlink, $options); + + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_GET; + $options[self::OSS_OBJECT] = $symlink; + $options[self::OSS_SUB_RESOURCE] = self::OSS_SYMLINK; + + $response = $this->auth($options); + $result = new SymlinkResult($response); + return $result->getData(); + } + + /** + * Uploads a local file + * + * @param string $bucket bucket name + * @param string $object object name + * @param string $file local file path + * @param array $options + * @return array|null + * @throws OssException|RequestCore_Exception + */ + public function uploadFile($bucket, $object, $file, $options = NULL) + { + $this->precheckCommon($bucket, $object, $options); + OssUtil::throwOssExceptionWithMessageIfEmpty($file, "file path is invalid"); + $file = $this->encodeFilePath($file); + if (!file_exists($file)) { + throw new OssException($file . " file does not exist"); + } + $options[self::OSS_FILE_UPLOAD] = $file; + $file_size = sprintf('%u', filesize($options[self::OSS_FILE_UPLOAD])); + $is_check_md5 = $this->isCheckMD5($options); + if ($is_check_md5) { + $content_md5 = base64_encode(md5_file($options[self::OSS_FILE_UPLOAD], true)); + $options[self::OSS_CONTENT_MD5] = $content_md5; + } + if (!isset($options[self::OSS_CONTENT_TYPE])) { + $options[self::OSS_CONTENT_TYPE] = $this->getMimeType($object, $file); + } + $options[self::OSS_METHOD] = self::OSS_HTTP_PUT; + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_OBJECT] = $object; + $options[self::OSS_CONTENT_LENGTH] = $file_size; + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Uploads object from file handle + * + * @param string $bucket bucket name + * @param string $object object name + * @param resource $handle file handle + * @param array $options + * @return array|null + * @throws OssException|RequestCore_Exception + */ + public function uploadStream($bucket, $object, $handle, $options = NULL) + { + $this->precheckCommon($bucket, $object, $options); + if (!is_resource($handle)) { + throw new OssException("The handle must be an opened stream"); + } + $options[self::OSS_FILE_UPLOAD] = $handle; + if ($this->isCheckMD5($options)) { + rewind($handle); + $ctx = hash_init('md5'); + hash_update_stream($ctx, $handle); + $content_md5 = base64_encode(hash_final($ctx, true)); + rewind($handle); + $options[self::OSS_CONTENT_MD5] = $content_md5; + } + if (!isset($options[self::OSS_CONTENT_TYPE])) { + $options[self::OSS_CONTENT_TYPE] = $this->getMimeType($object); + } + $options[self::OSS_METHOD] = self::OSS_HTTP_PUT; + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_OBJECT] = $object; + if (!isset($options[self::OSS_CONTENT_LENGTH])) { + $stat = fstat($handle); + $options[self::OSS_CONTENT_LENGTH] = $stat[self::OSS_SIZE]; + } + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Append the object with the content at the specified position. + * The specified position is typically the lengh of the current file. + * @param string $bucket bucket name + * @param string $object objcet name + * @param string $content content to append + * @param array $options + * @return int|null next append position + * @throws OssException|RequestCore_Exception + */ + public function appendObject($bucket, $object, $content, $position, $options = NULL) + { + $this->precheckCommon($bucket, $object, $options); + + $options[self::OSS_CONTENT] = $content; + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_POST; + $options[self::OSS_OBJECT] = $object; + $options[self::OSS_SUB_RESOURCE] = 'append'; + $options[self::OSS_POSITION] = strval($position); + if (!isset($options[self::OSS_LENGTH])) { + $options[self::OSS_CONTENT_LENGTH] = strlen($options[self::OSS_CONTENT]); + } else { + $options[self::OSS_CONTENT_LENGTH] = $options[self::OSS_LENGTH]; + } + + $is_check_md5 = $this->isCheckMD5($options); + if ($is_check_md5) { + $content_md5 = base64_encode(md5($content, true)); + $options[self::OSS_CONTENT_MD5] = $content_md5; + } + + if (!isset($options[self::OSS_CONTENT_TYPE])) { + $options[self::OSS_CONTENT_TYPE] = $this->getMimeType($object); + } + $response = $this->auth($options); + $result = new AppendResult($response); + return $result->getData(); + } + + /** + * Append the object with a local file + * + * @param string $bucket bucket name + * @param string $object object name + * @param string $file The local file path to append with + * @param array $options + * @return int|null next append position + * @throws OssException|RequestCore_Exception + */ + public function appendFile($bucket, $object, $file, $position, $options = NULL) + { + $this->precheckCommon($bucket, $object, $options); + + OssUtil::throwOssExceptionWithMessageIfEmpty($file, "file path is invalid"); + $file = $this->encodeFilePath($file); + if (!file_exists($file)) { + throw new OssException($file . " file does not exist"); + } + $options[self::OSS_FILE_UPLOAD] = $file; + $file_size = sprintf('%u', filesize($options[self::OSS_FILE_UPLOAD])); + $is_check_md5 = $this->isCheckMD5($options); + if ($is_check_md5) { + $content_md5 = base64_encode(md5_file($options[self::OSS_FILE_UPLOAD], true)); + $options[self::OSS_CONTENT_MD5] = $content_md5; + } + if (!isset($options[self::OSS_CONTENT_TYPE])) { + $options[self::OSS_CONTENT_TYPE] = $this->getMimeType($object, $file); + } + + $options[self::OSS_METHOD] = self::OSS_HTTP_POST; + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_OBJECT] = $object; + $options[self::OSS_CONTENT_LENGTH] = $file_size; + $options[self::OSS_SUB_RESOURCE] = 'append'; + $options[self::OSS_POSITION] = strval($position); + + $response = $this->auth($options); + $result = new AppendResult($response); + return $result->getData(); + } + + /** + * Copy from an existing OSS object to another OSS object. If the target object exists already, it will be overwritten. + * + * @param string $fromBucket Source bucket name + * @param string $fromObject Source object name + * @param string $toBucket Target bucket name + * @param string $toObject Target object name + * @param array $options + * @return null + * @throws OssException|RequestCore_Exception + */ + public function copyObject($fromBucket, $fromObject, $toBucket, $toObject, $options = NULL) + { + $this->precheckCommon($fromBucket, $fromObject, $options); + $this->precheckCommon($toBucket, $toObject, $options); + $options[self::OSS_BUCKET] = $toBucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_PUT; + $options[self::OSS_OBJECT] = $toObject; + $param = '/' . $fromBucket . '/' . rawurlencode($fromObject); + if (isset($options[self::OSS_VERSION_ID])) { + $param = $param . '?versionId=' . $options[self::OSS_VERSION_ID]; + unset($options[self::OSS_VERSION_ID]); + } + $options[self::OSS_HEADERS][self::OSS_OBJECT_COPY_SOURCE] = $param; + $response = $this->auth($options); + $result = new CopyObjectResult($response); + return $result->getData(); + } + + /** + * Gets Object metadata + * + * @param string $bucket bucket name + * @param string $object object name + * @param string $options Checks out the SDK document for the detail + * @return array|null + * @throws OssException|RequestCore_Exception + */ + public function getObjectMeta($bucket, $object, $options = NULL) + { + $this->precheckCommon($bucket, $object, $options); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_HEAD; + $options[self::OSS_OBJECT] = $object; + $response = $this->auth($options); + $result = new HeaderResult($response); + return $result->getData(); + } + + /** + * Gets the simplified metadata of a object. + * Simplified metadata includes ETag, Size, LastModified. + * + * @param string $bucket bucket name + * @param string $object object name + * @param string $options Checks out the SDK document for the detail + * @return array|null + * @throws OssException|RequestCore_Exception + */ + public function getSimplifiedObjectMeta($bucket, $object, $options = NULL) + { + $this->precheckCommon($bucket, $object, $options); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_HEAD; + $options[self::OSS_OBJECT] = $object; + $options[self::OSS_SUB_RESOURCE] = 'objectMeta'; + $response = $this->auth($options); + $result = new HeaderResult($response); + return $result->getData(); + } + + /** + * Deletes a object + * + * @param string $bucket bucket name + * @param string $object object name + * @param array $options + * @return array|null + * @throws OssException|RequestCore_Exception + */ + public function deleteObject($bucket, $object, $options = NULL) + { + $this->precheckCommon($bucket, $object, $options); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_DELETE; + $options[self::OSS_OBJECT] = $object; + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Deletes multiple objects in a bucket + * + * @param string $bucket bucket name + * @param array $objects object list + * @param array $options + * @return array|null + * @throws OssException|RequestCore_Exception + */ + public function deleteObjects($bucket, $objects, $options = null) + { + $this->precheckCommon($bucket, NULL, $options, false); + if (!is_array($objects) || !$objects) { + throw new OssException('objects must be array'); + } + $options[self::OSS_METHOD] = self::OSS_HTTP_POST; + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_SUB_RESOURCE] = 'delete'; + $options[self::OSS_CONTENT_TYPE] = 'application/xml'; + $quiet = 'false'; + if (isset($options['quiet'])) { + if (is_bool($options['quiet'])) { //Boolean + $quiet = $options['quiet'] ? 'true' : 'false'; + } elseif (is_string($options['quiet'])) { // string + $quiet = ($options['quiet'] === 'true') ? 'true' : 'false'; + } + } + $xmlBody = OssUtil::createDeleteObjectsXmlBody($objects, $quiet); + $options[self::OSS_CONTENT] = $xmlBody; + $response = $this->auth($options); + $result = new DeleteObjectsResult($response); + return $result->getData(); + } + + /** + * Deletes multiple objects with version id in a bucket + * + * @param string $bucket bucket name + * @param array $objects DeleteObjectInfo list + * @param array $options + * @return DeletedObjectInfo|null + * @throws OssException|RequestCore_Exception + */ + public function deleteObjectVersions($bucket, $objects, $options = null) + { + $this->precheckCommon($bucket, NULL, $options, false); + if (!is_array($objects) || !$objects) { + throw new OssException('objects must be array'); + } + $options[self::OSS_METHOD] = self::OSS_HTTP_POST; + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_SUB_RESOURCE] = 'delete'; + $options[self::OSS_CONTENT_TYPE] = 'application/xml'; + $quiet = 'false'; + if (isset($options['quiet'])) { + if (is_bool($options['quiet'])) { //Boolean + $quiet = $options['quiet'] ? 'true' : 'false'; + } elseif (is_string($options['quiet'])) { // string + $quiet = ($options['quiet'] === 'true') ? 'true' : 'false'; + } + } + $xmlBody = OssUtil::createDeleteObjectVersionsXmlBody($objects, $quiet); + $options[self::OSS_CONTENT] = $xmlBody; + $response = $this->auth($options); + $result = new DeleteObjectVersionsResult($response); + return $result->getData(); + } + + /** + * Gets Object content + * + * @param string $bucket bucket name + * @param string $object object name + * @param array $options It must contain ALIOSS::OSS_FILE_DOWNLOAD. And ALIOSS::OSS_RANGE is optional and empty means to download the whole file. + * @return string|null + * @throws OssException|RequestCore_Exception + */ + public function getObject($bucket, $object, $options = NULL) + { + $this->precheckCommon($bucket, $object, $options); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_GET; + $options[self::OSS_OBJECT] = $object; + if (isset($options[self::OSS_LAST_MODIFIED])) { + $options[self::OSS_HEADERS][self::OSS_IF_MODIFIED_SINCE] = $options[self::OSS_LAST_MODIFIED]; + unset($options[self::OSS_LAST_MODIFIED]); + } + if (isset($options[self::OSS_ETAG])) { + $options[self::OSS_HEADERS][self::OSS_IF_NONE_MATCH] = $options[self::OSS_ETAG]; + unset($options[self::OSS_ETAG]); + } + if (isset($options[self::OSS_RANGE])) { + $range = $options[self::OSS_RANGE]; + $options[self::OSS_HEADERS][self::OSS_RANGE] = "bytes=$range"; + unset($options[self::OSS_RANGE]); + } + $response = $this->auth($options); + $result = new BodyResult($response); + return $result->getData(); + } + + /** + * Checks if the object exists + * It's implemented by getObjectMeta(). + * + * @param string $bucket bucket name + * @param string $object object name + * @param array $options + * @return bool|null True:object exists; False:object does not exist + * @throws OssException|RequestCore_Exception| + */ + public function doesObjectExist($bucket, $object, $options = NULL) + { + $this->precheckCommon($bucket, $object, $options); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_HEAD; + $options[self::OSS_OBJECT] = $object; + $response = $this->auth($options); + $result = new ExistResult($response); + return $result->getData(); + } + + /** + * Object reading for Archive type + * Use Restore to enable the server to perform the thawing task + * + * @param string $bucket bucket name + * @param string $object object name + * @return array|null + * @throws OssException|RequestCore_Exception + */ + public function restoreObject($bucket, $object, $options = NULL) + { + $this->precheckCommon($bucket, $object, $options); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_POST; + $options[self::OSS_OBJECT] = $object; + $options[self::OSS_SUB_RESOURCE] = self::OSS_RESTORE; + if (isset($options[self::OSS_RESTORE_CONFIG])) { + $config = $options[self::OSS_RESTORE_CONFIG]; + $options[self::OSS_CONTENT_TYPE] = 'application/xml'; + $options[self::OSS_CONTENT] = $config->serializeToXml(); + } + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Sets the object tagging + * + * @param string $bucket bucket name + * @param string $object object name + * @param TaggingConfig $taggingConfig + * @return array|null + * @throws OssException|RequestCore_Exception + */ + public function putObjectTagging($bucket, $object, $taggingConfig, $options = NULL) + { + $this->precheckCommon($bucket, $object, $options, true); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_PUT; + $options[self::OSS_OBJECT] = $object; + $options[self::OSS_SUB_RESOURCE] = self::OSS_TAGGING; + $options[self::OSS_CONTENT_TYPE] = 'application/xml'; + $options[self::OSS_CONTENT] = $taggingConfig->serializeToXml(); + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Gets the object tagging + * + * @param string $bucket + * @param string $object + * @return TaggingConfig|null + * @throws OssException|RequestCore_Exception + */ + public function getObjectTagging($bucket, $object, $options = NULL) + { + $this->precheckCommon($bucket, $object, $options, true); + $options[self::OSS_METHOD] = self::OSS_HTTP_GET; + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_OBJECT] = $object; + $options[self::OSS_SUB_RESOURCE] = self::OSS_TAGGING; + $response = $this->auth($options); + $result = new GetBucketTagsResult($response); + return $result->getData(); + } + + /** + * Deletes the object tagging + * + * @param string $bucket + * @param string $object + * @return null + * @throws OssException|RequestCore_Exception + */ + public function deleteObjectTagging($bucket, $object, $options = NULL) + { + $this->precheckCommon($bucket, $object, $options, true); + $options[self::OSS_METHOD] = self::OSS_HTTP_DELETE; + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_OBJECT] = $object; + $options[self::OSS_SUB_RESOURCE] = self::OSS_TAGGING; + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Processes the object + * + * @param string $bucket bucket name + * @param string $object object name + * @param string $process process script + * @return string|null process result, json format + * @throws OssException|RequestCore_Exception| + */ + public function processObject($bucket, $object, $process, $options = NULL) + { + $this->precheckCommon($bucket, $object, $options); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_POST; + $options[self::OSS_OBJECT] = $object; + $options[self::OSS_SUB_RESOURCE] = 'x-oss-process'; + $options[self::OSS_CONTENT_TYPE] = 'application/octet-stream'; + $options[self::OSS_CONTENT] = 'x-oss-process=' . $process; + $response = $this->auth($options); + $result = new BodyResult($response); + return $result->getData(); + } + + + /** + * Async Process the object + * + * @param string $bucket bucket name + * @param string $object object name + * @param string $asyncProcess async process script + * @param null $options + * @return string|null process result, json format + * @throws OssException + * @throws RequestCore_Exception + */ + public function asyncProcessObject($bucket, $object, $asyncProcess, $options = NULL) + { + $this->precheckCommon($bucket, $object, $options); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_POST; + $options[self::OSS_OBJECT] = $object; + $options[self::OSS_SUB_RESOURCE] = 'x-oss-async-process'; + $options[self::OSS_CONTENT_TYPE] = 'application/octet-stream'; + $options[self::OSS_CONTENT] = 'x-oss-async-process=' . $asyncProcess; + $response = $this->auth($options); + $result = new BodyResult($response); + return $result->getData(); + } + + /** + * Gets the part size according to the preferred part size. + * If the specified part size is too small or too big, it will return a min part or max part size instead. + * Otherwise returns the specified part size. + * @param int $partSize + * @return int + */ + private function computePartSize($partSize) + { + $partSize = (integer)$partSize; + if ($partSize <= self::OSS_MIN_PART_SIZE) { + $partSize = self::OSS_MIN_PART_SIZE; + } elseif ($partSize > self::OSS_MAX_PART_SIZE) { + $partSize = self::OSS_MAX_PART_SIZE; + } + return $partSize; + } + + /** + * Computes the parts count, size and start position according to the file size and the part size. + * It must be only called by upload_Part(). + * + * @param integer $file_size File size + * @param integer $partSize part size. Default is 5MB + * @return array An array contains key-value pairs--the key is `seekTo`and value is `length`. + */ + public function generateMultiuploadParts($file_size, $partSize = 5242880) + { + $i = 0; + $size_count = $file_size; + $values = array(); + $partSize = $this->computePartSize($partSize); + while ($size_count > 0) { + $size_count -= $partSize; + $values[] = array( + self::OSS_SEEK_TO => ($partSize * $i), + self::OSS_LENGTH => (($size_count > 0) ? $partSize : ($size_count + $partSize)), + ); + $i++; + } + return $values; + } + + /** + * Initialize a multi-part upload + * + * @param string $bucket bucket name + * @param string $object object name + * @param array $options Key-Value array + * @return string|null returns upload id + * @throws OssException|RequestCore_Exception + */ + public function initiateMultipartUpload($bucket, $object, $options = NULL) + { + $this->precheckCommon($bucket, $object, $options); + $options[self::OSS_METHOD] = self::OSS_HTTP_POST; + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_OBJECT] = $object; + $options[self::OSS_SUB_RESOURCE] = 'uploads'; + $options[self::OSS_CONTENT] = ''; + + if (!isset($options[self::OSS_CONTENT_TYPE])) { + $options[self::OSS_CONTENT_TYPE] = $this->getMimeType($object); + } + if (!isset($options[self::OSS_HEADERS])) { + $options[self::OSS_HEADERS] = array(); + } + $response = $this->auth($options); + $result = new InitiateMultipartUploadResult($response); + return $result->getData(); + } + + /** + * Upload a part in a multiparts upload. + * + * @param string $bucket bucket name + * @param string $object object name + * @param string $uploadId + * @param array $options Key-Value array + * @return string|null eTag + * @throws OssException|RequestCore_Exception + */ + public function uploadPart($bucket, $object, $uploadId, $options = null) + { + $this->precheckCommon($bucket, $object, $options); + $this->precheckParam($options, self::OSS_FILE_UPLOAD, __FUNCTION__); + $this->precheckParam($options, self::OSS_PART_NUM, __FUNCTION__); + + $options[self::OSS_METHOD] = self::OSS_HTTP_PUT; + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_OBJECT] = $object; + $options[self::OSS_UPLOAD_ID] = $uploadId; + + if (isset($options[self::OSS_LENGTH])) { + $options[self::OSS_CONTENT_LENGTH] = $options[self::OSS_LENGTH]; + } + $response = $this->auth($options); + $result = new UploadPartResult($response); + return $result->getData(); + } + + /** + * Gets the uploaded parts. + * + * @param string $bucket bucket name + * @param string $object object name + * @param string $uploadId uploadId + * @param array $options Key-Value array + * @return ListPartsInfo|null + * @throws OssException|RequestCore_Exception + */ + public function listParts($bucket, $object, $uploadId, $options = null) + { + $this->precheckCommon($bucket, $object, $options); + $options[self::OSS_METHOD] = self::OSS_HTTP_GET; + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_OBJECT] = $object; + $options[self::OSS_UPLOAD_ID] = $uploadId; + $options[self::OSS_QUERY_STRING] = array(); + foreach (array('max-parts', 'part-number-marker') as $param) { + if (isset($options[$param])) { + $options[self::OSS_QUERY_STRING][$param] = $options[$param]; + unset($options[$param]); + } + } + $response = $this->auth($options); + $result = new ListPartsResult($response); + return $result->getData(); + } + + /** + * Abort a multiparts upload + * + * @param string $bucket bucket name + * @param string $object object name + * @param string $uploadId uploadId + * @param array $options Key-Value name + * @return null + * @throws OssException|RequestCore_Exception + */ + public function abortMultipartUpload($bucket, $object, $uploadId, $options = NULL) + { + $this->precheckCommon($bucket, $object, $options); + $options[self::OSS_METHOD] = self::OSS_HTTP_DELETE; + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_OBJECT] = $object; + $options[self::OSS_UPLOAD_ID] = $uploadId; + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Completes a multiparts upload, after all parts are uploaded. + * + * @param string $bucket bucket name + * @param string $object object name + * @param string $uploadId uploadId + * @param array $listParts array( array("PartNumber"=> int, "ETag"=>string)) + * @param array $options Key-Value array + * @return null + * @throws OssException|RequestCore_Exception + */ + public function completeMultipartUpload($bucket, $object, $uploadId, $listParts, $options = NULL) + { + $this->precheckCommon($bucket, $object, $options); + $options[self::OSS_METHOD] = self::OSS_HTTP_POST; + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_OBJECT] = $object; + $options[self::OSS_UPLOAD_ID] = $uploadId; + $options[self::OSS_CONTENT_TYPE] = 'application/xml'; + if (is_array($listParts)) { + $options[self::OSS_CONTENT] = OssUtil::createCompleteMultipartUploadXmlBody($listParts); + } else { + $options[self::OSS_CONTENT] = ""; + } + + $response = $this->auth($options); + if (isset($options[self::OSS_CALLBACK]) && !empty($options[self::OSS_CALLBACK])) { + $result = new CallbackResult($response); + } else { + $result = new PutSetDeleteResult($response); + } + return $result->getData(); + } + + /** + * Lists all ongoing multipart upload events, which means all initialized but not completed or aborted multipart uploads. + * + * @param string $bucket bucket + * @param array $options key-value array--expected keys are 'delimiter', 'key-marker', 'max-uploads', 'prefix', 'upload-id-marker' + * @return ListMultipartUploadInfo|null + * @throws OssException|RequestCore_Exception + */ + public function listMultipartUploads($bucket, $options = null) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_METHOD] = self::OSS_HTTP_GET; + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_SUB_RESOURCE] = 'uploads'; + + foreach (array('delimiter', 'key-marker', 'max-uploads', 'prefix', 'upload-id-marker') as $param) { + if (isset($options[$param])) { + $options[self::OSS_QUERY_STRING][$param] = $options[$param]; + unset($options[$param]); + } + } + $query = isset($options[self::OSS_QUERY_STRING]) ? $options[self::OSS_QUERY_STRING] : array(); + $options[self::OSS_QUERY_STRING] = array_merge( + $query, + array(self::OSS_ENCODING_TYPE => self::OSS_ENCODING_TYPE_URL) + ); + + $response = $this->auth($options); + $result = new ListMultipartUploadResult($response); + return $result->getData(); + } + + /** + * Copy an existing file as a part + * + * @param string $fromBucket source bucket name + * @param string $fromObject source object name + * @param string $toBucket target bucket name + * @param string $toObject target object name + * @param int $partNumber Part number + * @param string $uploadId Upload Id + * @param array $options Key-Value array---it should have 'start' or 'end' key to specify the range of the source object to copy. If it's not specifed, the whole object is copied. + * @return null + * @throws OssException|RequestCore_Exception + */ + public function uploadPartCopy($fromBucket, $fromObject, $toBucket, $toObject, $partNumber, $uploadId, $options = NULL) + { + $this->precheckCommon($fromBucket, $fromObject, $options); + $this->precheckCommon($toBucket, $toObject, $options); + + //If $options['isFullCopy'] is not set, copy from the beginning + $start_range = "0"; + if (isset($options['start'])) { + $start_range = $options['start']; + } + $end_range = ""; + if (isset($options['end'])) { + $end_range = $options['end']; + } + $options[self::OSS_METHOD] = self::OSS_HTTP_PUT; + $options[self::OSS_BUCKET] = $toBucket; + $options[self::OSS_OBJECT] = $toObject; + $options[self::OSS_PART_NUM] = $partNumber; + $options[self::OSS_UPLOAD_ID] = $uploadId; + + if (!isset($options[self::OSS_HEADERS])) { + $options[self::OSS_HEADERS] = array(); + } + + $param = '/' . $fromBucket . '/' . rawurlencode($fromObject); + if (isset($options[self::OSS_VERSION_ID])) { + $param = $param . '?versionId=' . $options[self::OSS_VERSION_ID]; + unset($options[self::OSS_VERSION_ID]); + } + + $options[self::OSS_HEADERS][self::OSS_OBJECT_COPY_SOURCE] = $param; + $options[self::OSS_HEADERS][self::OSS_OBJECT_COPY_SOURCE_RANGE] = "bytes=" . $start_range . "-" . $end_range; + $response = $this->auth($options); + $result = new UploadPartResult($response); + return $result->getData(); + } + + /** + * A higher level API for uploading a file with multipart upload. It consists of initialization, parts upload and completion. + * + * @param string $bucket bucket name + * @param string $object object name + * @param string $file The local file to upload + * @param array $options Key-Value array + * @return null + * @throws OssException|RequestCore_Exception + */ + public function multiuploadFile($bucket, $object, $file, $options = null) + { + $this->precheckCommon($bucket, $object, $options); + if (isset($options[self::OSS_LENGTH])) { + $options[self::OSS_CONTENT_LENGTH] = $options[self::OSS_LENGTH]; + unset($options[self::OSS_LENGTH]); + } + if (empty($file)) { + throw new OssException("parameter invalid, file is empty"); + } + $uploadFile = $this->encodeFilePath($file); + if (!isset($options[self::OSS_CONTENT_TYPE])) { + $options[self::OSS_CONTENT_TYPE] = $this->getMimeType($object, $uploadFile); + } + + $upload_position = isset($options[self::OSS_SEEK_TO]) ? (integer)$options[self::OSS_SEEK_TO] : 0; + + if (isset($options[self::OSS_CONTENT_LENGTH])) { + $upload_file_size = (integer)$options[self::OSS_CONTENT_LENGTH]; + } else { + $upload_file_size = sprintf('%u', filesize($uploadFile)); + + if ($upload_file_size !== false) { + $upload_file_size -= $upload_position; + } + } + + if ($upload_position === false || !isset($upload_file_size) || $upload_file_size === false || $upload_file_size < 0) { + throw new OssException('The size of `fileUpload` cannot be determined in ' . __FUNCTION__ . '().'); + } + // Computes the part size and assign it to options. + if (isset($options[self::OSS_PART_SIZE])) { + $options[self::OSS_PART_SIZE] = $this->computePartSize($options[self::OSS_PART_SIZE]); + } else { + $options[self::OSS_PART_SIZE] = self::OSS_MID_PART_SIZE; + } + + $is_check_md5 = $this->isCheckMD5($options); + // if the file size is less than part size, use simple file upload. + if ($upload_file_size < $options[self::OSS_PART_SIZE] && !isset($options[self::OSS_UPLOAD_ID])) { + return $this->uploadFile($bucket, $object, $uploadFile, $options); + } + + // Using multipart upload, initialize if no OSS_UPLOAD_ID is specified in options. + if (isset($options[self::OSS_UPLOAD_ID])) { + $uploadId = $options[self::OSS_UPLOAD_ID]; + } else { + // initialize + $uploadId = $this->initiateMultipartUpload($bucket, $object, $options); + } + + // generates the parts information and upload them one by one + $pieces = $this->generateMultiuploadParts($upload_file_size, (integer)$options[self::OSS_PART_SIZE]); + $response_upload_part = array(); + foreach ($pieces as $i => $piece) { + $from_pos = $upload_position + (integer)$piece[self::OSS_SEEK_TO]; + $to_pos = (integer)$piece[self::OSS_LENGTH] + $from_pos - 1; + $up_options = array( + self::OSS_FILE_UPLOAD => $uploadFile, + self::OSS_PART_NUM => ($i + 1), + self::OSS_SEEK_TO => $from_pos, + self::OSS_LENGTH => $to_pos - $from_pos + 1, + self::OSS_CHECK_MD5 => $is_check_md5, + ); + if ($is_check_md5) { + $content_md5 = OssUtil::getMd5SumForFile($uploadFile, $from_pos, $to_pos); + $up_options[self::OSS_CONTENT_MD5] = $content_md5; + } + $response_upload_part[] = $this->uploadPart($bucket, $object, $uploadId, $up_options); + } + + $uploadParts = array(); + foreach ($response_upload_part as $i => $etag) { + $uploadParts[] = array( + 'PartNumber' => ($i + 1), + 'ETag' => $etag, + ); + } + + //build complete options + $cmp_options = null; + if (isset($options[self::OSS_HEADERS]) && isset($options[self::OSS_HEADERS][self::OSS_REQUEST_PAYER])) { + $cmp_options = array( + OssClient::OSS_HEADERS => array( + OssClient::OSS_REQUEST_PAYER => $options[self::OSS_HEADERS][self::OSS_REQUEST_PAYER], + )); + } + return $this->completeMultipartUpload($bucket, $object, $uploadId, $uploadParts, $cmp_options); + } + + /** + * Uploads the local directory to the specified bucket into specified folder (prefix) + * + * @param string $bucket bucket name + * @param string $prefix The object key prefix. Typically it's folder name. The name should not end with '/' as the API appends it automatically. + * @param string $localDirectory The local directory to upload + * @param string $exclude To excluded directories + * @param bool $recursive Recursive flag. True: Recursively upload all datas under the local directory; False: only upload first layer's files. + * @param bool $checkMd5 + * @return array Returns two list: array("succeededList" => array("object"), "failedList" => array("object"=>"errorMessage")) + * @throws OssException + */ + public function uploadDir($bucket, $prefix, $localDirectory, $exclude = '.|..|.svn|.git', $recursive = false, $checkMd5 = true) + { + $retArray = array("succeededList" => array(), "failedList" => array()); + if (empty($bucket)) throw new OssException("parameter error, bucket is empty"); + if (!is_string($prefix)) throw new OssException("parameter error, prefix is not string"); + if (empty($localDirectory)) throw new OssException("parameter error, localDirectory is empty"); + $directory = $localDirectory; + $directory = $this->encodeFilePath($directory); + //If it's not the local directory, throw OSSException. + if (!is_dir($directory)) { + throw new OssException('parameter error: ' . $directory . ' is not a directory, please check it'); + } + //read directory + $file_list_array = OssUtil::readDir($directory, $exclude, $recursive); + if (!$file_list_array) { + throw new OssException($directory . ' is empty...'); + } + foreach ($file_list_array as $k => $item) { + if (is_dir($item['path'])) { + continue; + } + $options = array( + self::OSS_PART_SIZE => self::OSS_MIN_PART_SIZE, + self::OSS_CHECK_MD5 => $checkMd5, + ); + //mbstring to utf-8 + $fileName = $this->decodeFilePath($item['file']); + $realObject = (!empty($prefix) ? $prefix . '/' : '') . $fileName; + + try { + $this->multiuploadFile($bucket, $realObject, $item['path'], $options); + $retArray["succeededList"][] = $realObject; + } catch (OssException $e) { + $retArray["failedList"][$realObject] = $e->getMessage(); + } + } + return $retArray; + } + + /** + * Sign URL with specified expiration time in seconds (timeout) and HTTP method. + * The signed URL could be used to access the object directly. + * + * @param string $bucket + * @param string $object + * @param int $timeout expiration time in seconds. + * @param string $method + * @param array $options Key-Value array + * @return string + * @throws OssException + */ + public function signUrl($bucket, $object, $timeout = 60, $method = self::OSS_HTTP_GET, $options = NULL) + { + $expiration = time() + $timeout; + return $this->generatePresignedUrl($bucket, $object, $expiration, $method, $options); + } + + /** + * Sign URL with specified expiration time in seconds and HTTP method. + * The signed URL could be used to access the object directly. + * + * @param string $bucket + * @param string $object + * @param int $expiration expiration time of the Url, unix epoch, since 1970.1.1 00.00.00 UTC + * @param string $method + * @param array $options Key-Value array + * @return string + * @throws OssException + */ + public function generatePresignedUrl($bucket, $object, $expiration, $method = self::OSS_HTTP_GET, $options = NULL) + { + $this->precheckObjectExt($object, $this->enableStrictObjName); + $this->precheckCommon($bucket, $object, $options); + $cred = $this->provider->getCredentials(); + //method + if (self::OSS_HTTP_GET !== $method && self::OSS_HTTP_PUT !== $method) { + throw new OssException("method is invalid"); + } + // Should https or http be used? + $scheme = $this->useSSL ? 'https://' : 'http://'; + // gets the host name. If the host name is public domain or private domain, form a third level domain by prefixing the bucket name on the domain name. + $hostname = $this->generateHostname($bucket); + $path = $this->generatePath($bucket, $object); + $headers = $this->generateHeaders($options, ''); + $query_string = $this->generateQueryString($options); + $query_string = empty($query_string) ? '' : '?' . $query_string; + $requestUrl = $scheme . $hostname . $path . $query_string; + //Creates the request + $request = new RequestCore($requestUrl); + $request->set_method($method); + if (isset($options[self::OSS_CALLBACK])) { + $headers[self::OSS_CALLBACK] = base64_encode($options[self::OSS_CALLBACK]); + } + if (isset($options[self::OSS_CALLBACK_VAR])) { + $headers[self::OSS_CALLBACK_VAR] = base64_encode($options[self::OSS_CALLBACK_VAR]); + } + foreach ($headers as $header_key => $header_value) { + $header_value = trim($header_value); + if (empty($header_value)) { + continue; + } + $request->add_header($header_key, $header_value); + } + $signingOpt = array( + 'bucket' => $bucket, + 'key' => $object, + 'region' => $this->getRegion(), + 'product' => $this->getProduct(), + 'expiration' => $expiration, + ); + $this->signer->presign($request, $cred, $signingOpt); + return $request->request_url; + } + + /** + * validates options. Create a empty array if it's NULL. + * + * @param array $options + * @throws OssException + */ + private function precheckOptions(&$options) + { + OssUtil::validateOptions($options); + if (!$options) { + $options = array(); + } + } + + /** + * Validates bucket parameter + * + * @param string $bucket + * @param string $errMsg + * @throws OssException + */ + private function precheckBucket($bucket, $errMsg = 'bucket is not allowed empty') + { + OssUtil::throwOssExceptionWithMessageIfEmpty($bucket, $errMsg); + if (!OssUtil::validateBucket($bucket)) { + throw new OssException('"' . $bucket . '"' . 'bucket name is invalid'); + } + } + + /** + * validates object parameter + * + * @param string $object + * @throws OssException + */ + private function precheckObject($object) + { + OssUtil::throwOssExceptionWithMessageIfEmpty($object, "object name is empty"); + if (!OssUtil::validateObject($object)) { + throw new OssException('"' . $object . '"' . ' object name is invalid'); + } + } + + /** + * validates object name start with ? or not + * @param $object string + * @param $strict boolean + * @throws OssException + */ + private function precheckObjectExt($object, $strict) + { + $this->precheckObject($object); + if ($strict) { + if (is_string($object) && $object[0] === "?") { + throw new OssException('"' . $object . '"' . ' object name cannot start with `?`'); + } + } + } + + /** + * Check option restore + * + * @param $storage string + * @throws OssException + */ + private function precheckStorage($storage) + { + if (is_string($storage)) { + switch ($storage) { + case self::OSS_STORAGE_ARCHIVE: + return; + case self::OSS_STORAGE_IA: + return; + case self::OSS_STORAGE_STANDARD: + return; + case self::OSS_STORAGE_COLDARCHIVE: + return; + default: + break; + } + } + throw new OssException('storage name is invalid'); + } + + /** + * Validates bucket,options parameters and optionally validate object parameter. + * + * @param string $bucket + * @param string $object + * @param array $options + * @param bool $isCheckObject + */ + private function precheckCommon($bucket, $object, &$options, $isCheckObject = true) + { + if ($isCheckObject) { + $this->precheckObject($object); + } + $this->precheckOptions($options); + $this->precheckBucket($bucket); + } + + /** + * checks parameters + * + * @param array $options + * @param string $param + * @param string $funcName + * @throws OssException + */ + private function precheckParam($options, $param, $funcName) + { + if (!isset($options[$param])) { + throw new OssException('The `' . $param . '` options is required in ' . $funcName . '().'); + } + } + + /** + * Checks md5 + * + * @param array $options + * @return bool|null + */ + private function isCheckMD5($options) + { + return $this->getValue($options, self::OSS_CHECK_MD5, false, true, true); + } + + /** + * Gets value of the specified key from the options + * + * @param array $options + * @param string $key + * @param string $default + * @param bool $isCheckEmpty + * @param bool $isCheckBool + * @return bool|null + */ + private function getValue($options, $key, $default = NULL, $isCheckEmpty = false, $isCheckBool = false) + { + $value = $default; + if (isset($options[$key])) { + if ($isCheckEmpty) { + if (!empty($options[$key])) { + $value = $options[$key]; + } + } else { + $value = $options[$key]; + } + unset($options[$key]); + } + if ($isCheckBool) { + if ($value !== true && $value !== false) { + $value = false; + } + } + return $value; + } + + /** + * Gets mimetype + * + * @param string $object + * @return string + */ + private function getMimeType($object, $file = null) + { + if (!is_null($file)) { + $type = MimeTypes::getMimetype($file); + if (!is_null($type)) { + return $type; + } + } + + $type = MimeTypes::getMimetype($object); + if (!is_null($type)) { + return $type; + } + + return self::DEFAULT_CONTENT_TYPE; + } + + /** + * Validates and executes the request according to OSS API protocol. + * + * @param array $options + * @return ResponseCore|string + * @throws OssException + * @throws RequestCore_Exception + */ + private function auth($options) + { + OssUtil::validateOptions($options); + //Object Encoding + $this->authPrecheckObjectEncoding($options); + //Validates ACL + $this->authPrecheckAcl($options); + $cred = $this->provider->getCredentials(); + $this->checkCredentials($cred); + + $bucket = isset($options[self::OSS_BUCKET]) ? $options[self::OSS_BUCKET] : ''; + $object = isset($options[self::OSS_OBJECT]) ? $options[self::OSS_OBJECT] : ''; + + // Should https or http be used? + $scheme = $this->useSSL ? 'https://' : 'http://'; + // gets the host name. If the host name is public domain or private domain, form a third level domain by prefixing the bucket name on the domain name. + $hostname = $this->generateHostname($bucket); + $path = $this->generatePath($bucket, $object); + $headers = $this->generateHeaders($options, $hostname); + $query_string = $this->generateQueryString($options); + $query_string = empty($query_string) ? '' : '?' . $query_string; + $requestUrl = $scheme . $hostname . $path . $query_string; + + //Creates the request + $request = new RequestCore($requestUrl, $this->requestProxy); + $request->set_useragent($this->generateUserAgent()); + // Streaming uploads + if (isset($options[self::OSS_FILE_UPLOAD])) { + if (is_resource($options[self::OSS_FILE_UPLOAD])) { + $length = null; + + if (isset($options[self::OSS_CONTENT_LENGTH])) { + $length = $options[self::OSS_CONTENT_LENGTH]; + } elseif (isset($options[self::OSS_SEEK_TO])) { + $stats = fstat($options[self::OSS_FILE_UPLOAD]); + if ($stats && $stats[self::OSS_SIZE] >= 0) { + $length = $stats[self::OSS_SIZE] - (integer)$options[self::OSS_SEEK_TO]; + } + } + $request->set_read_stream($options[self::OSS_FILE_UPLOAD], $length); + } else { + $request->set_read_file($options[self::OSS_FILE_UPLOAD]); + $length = $request->read_stream_size; + if (isset($options[self::OSS_CONTENT_LENGTH])) { + $length = $options[self::OSS_CONTENT_LENGTH]; + } elseif (isset($options[self::OSS_SEEK_TO]) && isset($length)) { + $length -= (integer)$options[self::OSS_SEEK_TO]; + } + $request->set_read_stream_size($length); + } + } + if (isset($options[self::OSS_SEEK_TO])) { + $request->set_seek_position((integer)$options[self::OSS_SEEK_TO]); + } + if (isset($options[self::OSS_FILE_DOWNLOAD])) { + if (is_resource($options[self::OSS_FILE_DOWNLOAD])) { + $request->set_write_stream($options[self::OSS_FILE_DOWNLOAD]); + } else { + $request->set_write_file($options[self::OSS_FILE_DOWNLOAD]); + } + } + if (isset($options[self::OSS_METHOD])) { + $request->set_method($options[self::OSS_METHOD]); + } + if (isset($options[self::OSS_CONTENT])) { + $request->set_body($options[self::OSS_CONTENT]); + if (isset($headers[self::OSS_CONTENT_TYPE]) && $headers[self::OSS_CONTENT_TYPE] === 'application/x-www-form-urlencoded') { + $headers[self::OSS_CONTENT_TYPE] = 'application/octet-stream'; + } + + $headers[self::OSS_CONTENT_LENGTH] = strlen($options[self::OSS_CONTENT]); + $headers[self::OSS_CONTENT_MD5] = base64_encode(md5($options[self::OSS_CONTENT], true)); + } + + if (isset($options[self::OSS_CALLBACK])) { + $headers[self::OSS_CALLBACK] = base64_encode($options[self::OSS_CALLBACK]); + } + if (isset($options[self::OSS_CALLBACK_VAR])) { + $headers[self::OSS_CALLBACK_VAR] = base64_encode($options[self::OSS_CALLBACK_VAR]); + } + + if (!isset($headers[self::OSS_ACCEPT_ENCODING])) { + $headers[self::OSS_ACCEPT_ENCODING] = ''; + } + + if (!isset($headers[self::OSS_CONTENT_TYPE])) { + $headers[self::OSS_CONTENT_TYPE] = self::DEFAULT_CONTENT_TYPE; + } + + foreach ($headers as $header_key => $header_value) { + $header_value = trim($header_value); + if (empty($header_value)) { + continue; + } + $request->add_header($header_key, $header_value); + } + + // sign request + $signingOpt = array( + 'bucket' => $bucket, + 'key' => $object, + 'region' => $this->getRegion(), + 'product' => $this->getProduct(), + ); + if (isset($options[self::OSS_ADDITIONAL_HEADERS])) { + $signingOpt['additionalHeaders'] = $options[self::OSS_ADDITIONAL_HEADERS]; + } + + $this->signer->sign($request, $cred, $signingOpt); + $string_to_sign = isset($signingOpt['string_to_sign']) ? $signingOpt['string_to_sign'] : ''; + + if ($this->timeout !== 0) { + $request->timeout = $this->timeout; + } + if ($this->connectTimeout !== 0) { + $request->connect_timeout = $this->connectTimeout; + } + + try { + $request->send_request(); + } catch (RequestCore_Exception $e) { + throw(new OssException('RequestCoreException: ' . $e->getMessage())); + } + $response_header = $request->get_response_header(); + $response_header['oss-request-url'] = $requestUrl; + $response_header['oss-redirects'] = $this->redirects; + $response_header['oss-stringtosign'] = $string_to_sign; + $response_header['oss-requestheaders'] = $request->request_headers; + + $data = new ResponseCore($response_header, $request->get_response_body(), $request->get_response_code()); + //retry if OSS Internal Error + if ((integer)$request->get_response_code() === 500) { + if ($this->redirects <= $this->maxRetries) { + //Sets the sleep time betwen each retry. + $delay = (integer)(pow(4, $this->redirects) * 100000); + usleep($delay); + $this->redirects++; + $data = $this->auth($options); + } + } + + $this->redirects = 0; + return $data; + } + + /** + * Sets the max retry count + * + * @param int $maxRetries + * @return void + */ + public function setMaxTries($maxRetries = 3) + { + $this->maxRetries = $maxRetries; + } + + /** + * Gets the max retry count + * + * @return int + */ + public function getMaxRetries() + { + return $this->maxRetries; + } + + /** + * Enaable/disable STS in the URL. This is to determine the $sts value passed from constructor take effect or not. + * + * @param boolean $enable + */ + public function setSignStsInUrl($enable) + { + } + + /** + * @return boolean + */ + public function isUseSSL() + { + return $this->useSSL; + } + + /** + * @param boolean $useSSL + */ + public function setUseSSL($useSSL) + { + $this->useSSL = $useSSL; + } + + /** + * Checks the object's encoding. Convert it to UTF8 if it's in GBK or GB2312 + * + * @param mixed $options parameter + */ + private function authPrecheckObjectEncoding(&$options) + { + if ($this->checkObjectEncoding !== true) { + return; + } + + if (!isset($options[self::OSS_OBJECT])) { + return; + } + + try { + $tmp_object = $options[self::OSS_OBJECT]; + $encoding = array('UTF-8', 'GB2312', 'GBK'); + $encode = mb_detect_encoding($tmp_object, $encoding); + if ($encode === 'UTF-8' || $encode === false) { + return; + } + $tmp_object = iconv($encode, "UTF-8", $tmp_object); + if ($tmp_object === false) { + return; + } + $options[self::OSS_OBJECT] = $tmp_object; + } catch (\Exception $e) { + //IGNORE + } + } + + /** + * Checks if the ACL is one of the 3 predefined one. Throw OSSException if not. + * + * @param $options + * @throws OssException + */ + private function authPrecheckAcl($options) + { + if (isset($options[self::OSS_HEADERS][self::OSS_ACL]) && !empty($options[self::OSS_HEADERS][self::OSS_ACL])) { + if (!in_array(strtolower($options[self::OSS_HEADERS][self::OSS_ACL]), self::$OSS_ACL_TYPES)) { + throw new OssException($options[self::OSS_HEADERS][self::OSS_ACL] . ':' . 'acl is invalid(private,public-read,public-read-write)'); + } + } + } + + /** + * Gets the host name for the current request. + * It could be either a third level domain (prefixed by bucket name) or second level domain if it's CName or IP + * + * @param $bucket + * @return string The host name without the protocol scheem (e.g. https://) + */ + private function generateHostname($bucket) + { + if ($this->hostType === self::OSS_HOST_TYPE_IP || $this->hostType === self::OSS_HOST_TYPE_PATH_STYLE) { + $hostname = $this->hostname; + } elseif ($this->hostType === self::OSS_HOST_TYPE_CNAME) { + $hostname = $this->hostname; + } else { + // Private domain or public domain + $hostname = ($bucket == '') ? $this->hostname : ($bucket . '.') . $this->hostname; + } + return $hostname; + } + + /** + * Gets the Uri path in the current request + * + * @param $bucket + * @param $object + * @return string return the resource uri. + */ + private function generatePath($bucket, $object) + { + $paths = array(); + // +bucket + if ('' !== $bucket) { + if ($this->hostType === self::OSS_HOST_TYPE_IP || $this->hostType === self::OSS_HOST_TYPE_PATH_STYLE) { + $paths[] = $bucket; + if ('' === $object) { + $paths[] = ''; + } + } + } + // + object + if ('' !== $object && '/' !== $object) { + $paths[] = str_replace(array('%2F'), array('/'), rawurlencode($object)); + } + return '/' . implode('/', $paths); + } + + /** + * generates query string + * + * @param mixed $options + * @return string + */ + private function generateQueryString($options) + { + //query parameters + $query = array(); + $queryList = array( + self::OSS_PART_NUM, + 'response-content-type', + 'response-content-language', + 'response-cache-control', + 'response-content-encoding', + 'response-expires', + 'response-content-disposition', + self::OSS_UPLOAD_ID, + self::OSS_COMP, + self::OSS_LIVE_CHANNEL_STATUS, + self::OSS_LIVE_CHANNEL_START_TIME, + self::OSS_LIVE_CHANNEL_END_TIME, + self::OSS_PROCESS, + self::OSS_POSITION, + self::OSS_SYMLINK, + self::OSS_RESTORE, + self::OSS_TAGGING, + self::OSS_WORM_ID, + self::OSS_TRAFFIC_LIMIT, + self::OSS_VERSION_ID, + self::OSS_CONTINUATION_TOKEN, + self::OSS_CNAME, + ); + foreach ($queryList as $item) { + if (isset($options[$item])) { + $query[$item] = $options[$item]; + } + } + if (isset($options[self::OSS_QUERY_STRING])) { + $query = array_merge($query, $options[self::OSS_QUERY_STRING]); + } + if (isset($options[self::OSS_SUB_RESOURCE])) { + $query[$options[self::OSS_SUB_RESOURCE]] = ''; + } + + return OssUtil::toQueryString($query); + } + + /** + * Initialize headers + * + * @param mixed $options + * @param string $hostname hostname + * @return array + */ + private function generateHeaders($options, $hostname) + { + $headers = array(); + + if (!empty($hostname)) { + $headers[self::OSS_HOST] = $hostname; + } + + if (isset($options[self::OSS_CONTENT_TYPE])) { + $headers[self::OSS_CONTENT_TYPE] = $options[self::OSS_CONTENT_TYPE]; + } + + if (isset($options[self::OSS_DATE])) { + $headers[self::OSS_DATE] = $options[self::OSS_DATE]; + } + + if (isset($options[self::OSS_CONTENT_MD5])) { + $headers[self::OSS_CONTENT_MD5] = $options[self::OSS_CONTENT_MD5]; + } + + //Merge HTTP headers + if (isset($options[self::OSS_HEADERS])) { + $headers = array_merge($headers, $options[self::OSS_HEADERS]); + } + return $headers; + } + + /** + * Generates UserAgent + * + * @return string + */ + private function generateUserAgent() + { + return self::OSS_NAME . "/" . self::OSS_VERSION . " (" . php_uname('s') . "/" . php_uname('r') . "/" . php_uname('m') . ";" . PHP_VERSION . ")"; + } + + /** + * Checks endpoint type and returns the endpoint without the protocol schema. + * Figures out the domain's type (ip, cname or private/public domain). + * + * @param string $endpoint + * @param boolean $isCName + * @return string The domain name without the protocol schema. + * @throws OssException + */ + private function checkEndpoint($endpoint, $isCName) + { + $ret_endpoint = null; + if (strpos($endpoint, 'http://') === 0) { + $ret_endpoint = substr($endpoint, strlen('http://')); + } elseif (strpos($endpoint, 'https://') === 0) { + $ret_endpoint = substr($endpoint, strlen('https://')); + $this->useSSL = true; + } else { + $ret_endpoint = $endpoint; + } + + $ret_endpoint = OssUtil::getHostPortFromEndpoint($ret_endpoint); + + if ($isCName) { + $this->hostType = self::OSS_HOST_TYPE_CNAME; + } elseif (OssUtil::isIPFormat($ret_endpoint)) { + $this->hostType = self::OSS_HOST_TYPE_IP; + } else { + $this->hostType = self::OSS_HOST_TYPE_NORMAL; + } + return $ret_endpoint; + } + + /** + * @param Credentials $credential + * @throws OssException + */ + private function checkCredentials($credential) + { + if (empty($credential)) { + throw new OssException("credentials is empty."); + } + if (strlen($credential->getAccessKeyId()) == 0) { + throw new OssException("access key id is empty"); + } + if (strlen($credential->getAccessKeySecret()) == 0) { + throw new OssException("access key secret is empty"); + } + } + + /** + * For get Sign Product + * @return string + */ + private function getProduct() + { + if (!empty($this->cloudBoxId)) { + return self::OSS_CLOUDBOX_PRODUCT; + } + return self::OSS_DEFAULT_PRODUCT; + } + + /** + * For get Sign Region + * @return mixed + */ + private function getRegion() + { + if (!empty($this->cloudBoxId)) { + return $this->cloudBoxId; + } + return $this->region; + } + + /** + * Encodes the file path from UTF-8 to GBK. + * + * @param $filepath + * @return string + */ + private function encodeFilePath($filepath) + { + if ($this->filePathCompatible !== true) { + return $filepath; + } + + if (empty($filepath)) { + return $filepath; + } + + try { + $encoding = array('UTF-8', 'GB2312', 'GBK'); + $encode = mb_detect_encoding($filepath, $encoding); + if ($encode !== 'UTF-8') { + return $filepath; + } + $tmp = iconv($encode, 'GBK', $filepath); + if ($tmp !== false) { + $filepath = $tmp; + } + } catch (\Exception $e) { + //IGNORE + } + return $filepath; + } + + /** + * Decodes the file path from GBK to UTF-8. + * + * @param $filepath + * @return string + */ + private function decodeFilePath($filepath) + { + if ($this->filePathCompatible !== true) { + return $filepath; + } + if (empty($filepath)) { + return $filepath; + } + + try { + $encoding = array('UTF-8', 'GB2312', 'GBK'); + $encode = mb_detect_encoding($filepath, $encoding); + if ($encode === 'UTF-8' || $encode === false) { + return $filepath; + } + $tmp = iconv($encode, 'UTF-8', $filepath); + if ($tmp !== false) { + $filepath = $tmp; + } + } catch (\Exception $e) { + //IGNORE + } + return $filepath; + } + + /** + * Check if all dependent extensions are installed correctly. + * For now only "curl" is needed. + * @throws OssException + */ + public static function checkEnv() + { + if (function_exists('get_loaded_extensions')) { + //Test curl extension + $enabled_extension = array("curl"); + $extensions = get_loaded_extensions(); + if ($extensions) { + foreach ($enabled_extension as $item) { + if (!in_array($item, $extensions)) { + throw new OssException("Extension {" . $item . "} is not installed or not enabled, please check your php env."); + } + } + } else { + throw new OssException("function get_loaded_extensions not found."); + } + } else { + throw new OssException('Function get_loaded_extensions has been disabled, please check php config.'); + } + } + + /** + * Sets the http's timeout (in seconds) + * + * @param int $timeout + */ + public function setTimeout($timeout) + { + $this->timeout = $timeout; + } + + /** + * Sets the http's connection timeout (in seconds) + * + * @param int $connectTimeout + */ + public function setConnectTimeout($connectTimeout) + { + $this->connectTimeout = $connectTimeout; + } + + // Constants for Life cycle + const OSS_LIFECYCLE_EXPIRATION = "Expiration"; + const OSS_LIFECYCLE_TIMING_DAYS = "Days"; + const OSS_LIFECYCLE_TIMING_DATE = "Date"; + //OSS Internal constants + const OSS_BUCKET = 'bucket'; + const OSS_OBJECT = 'object'; + const OSS_HEADERS = OssUtil::OSS_HEADERS; + const OSS_ADDITIONAL_HEADERS = 'additionalHeaders'; + const OSS_METHOD = 'method'; + const OSS_QUERY = 'query'; + const OSS_BASENAME = 'basename'; + const OSS_MAX_KEYS = 'max-keys'; + const OSS_UPLOAD_ID = 'uploadId'; + const OSS_PART_NUM = 'partNumber'; + const OSS_COMP = 'comp'; + const OSS_LIVE_CHANNEL_STATUS = 'status'; + const OSS_LIVE_CHANNEL_START_TIME = 'startTime'; + const OSS_LIVE_CHANNEL_END_TIME = 'endTime'; + const OSS_POSITION = 'position'; + const OSS_MAX_KEYS_VALUE = 100; + const OSS_MAX_OBJECT_GROUP_VALUE = OssUtil::OSS_MAX_OBJECT_GROUP_VALUE; + const OSS_MAX_PART_SIZE = OssUtil::OSS_MAX_PART_SIZE; + const OSS_MID_PART_SIZE = OssUtil::OSS_MID_PART_SIZE; + const OSS_MIN_PART_SIZE = OssUtil::OSS_MIN_PART_SIZE; + const OSS_FILE_SLICE_SIZE = 8192; + const OSS_PREFIX = 'prefix'; + const OSS_DELIMITER = 'delimiter'; + const OSS_MARKER = 'marker'; + const OSS_FETCH_OWNER = 'fetch-owner'; + const OSS_START_AFTER = 'start-after'; + const OSS_CONTINUATION_TOKEN = 'continuation-token'; + const OSS_ACCEPT_ENCODING = 'Accept-Encoding'; + const OSS_CONTENT_MD5 = 'Content-Md5'; + const OSS_SELF_CONTENT_MD5 = 'x-oss-meta-md5'; + const OSS_CONTENT_TYPE = 'Content-Type'; + const OSS_CONTENT_LENGTH = 'Content-Length'; + const OSS_IF_MODIFIED_SINCE = 'If-Modified-Since'; + const OSS_IF_UNMODIFIED_SINCE = 'If-Unmodified-Since'; + const OSS_IF_MATCH = 'If-Match'; + const OSS_IF_NONE_MATCH = 'If-None-Match'; + const OSS_CACHE_CONTROL = 'Cache-Control'; + const OSS_EXPIRES = 'Expires'; + + const OSS_CONTENT_COING = 'Content-Coding'; + const OSS_CONTENT_DISPOSTION = 'Content-Disposition'; + const OSS_RANGE = 'range'; + const OSS_ETAG = 'etag'; + const OSS_LAST_MODIFIED = 'lastmodified'; + const OS_CONTENT_RANGE = 'Content-Range'; + const OSS_CONTENT = OssUtil::OSS_CONTENT; + const OSS_BODY = 'body'; + const OSS_LENGTH = OssUtil::OSS_LENGTH; + const OSS_HOST = 'Host'; + const OSS_DATE = 'Date'; + const OSS_AUTHORIZATION = 'Authorization'; + const OSS_FILE_DOWNLOAD = 'fileDownload'; + const OSS_FILE_UPLOAD = 'fileUpload'; + const OSS_PART_SIZE = 'partSize'; + const OSS_SEEK_TO = 'seekTo'; + const OSS_SIZE = 'size'; + const OSS_QUERY_STRING = 'query_string'; + const OSS_SUB_RESOURCE = 'sub_resource'; + const OSS_DEFAULT_PREFIX = 'x-oss-'; + const OSS_CHECK_MD5 = 'checkmd5'; + const OSS_CHECK_OBJECT = 'checkobject'; + const DEFAULT_CONTENT_TYPE = 'application/octet-stream'; + const OSS_SYMLINK_TARGET = 'x-oss-symlink-target'; + const OSS_SYMLINK = 'symlink'; + const OSS_HTTP_CODE = 'http_code'; + const OSS_REQUEST_ID = 'x-oss-request-id'; + const OSS_INFO = 'info'; + const OSS_STORAGE = 'storage'; + const OSS_RESTORE = 'restore'; + const OSS_STORAGE_STANDARD = 'Standard'; + const OSS_STORAGE_IA = 'IA'; + const OSS_STORAGE_ARCHIVE = 'Archive'; + const OSS_STORAGE_COLDARCHIVE = 'ColdArchive'; + const OSS_TAGGING = 'tagging'; + const OSS_WORM_ID = 'wormId'; + const OSS_RESTORE_CONFIG = 'restore-config'; + const OSS_KEY_MARKER = 'key-marker'; + const OSS_VERSION_ID_MARKER = 'version-id-marker'; + const OSS_VERSION_ID = 'versionId'; + const OSS_HEADER_VERSION_ID = 'x-oss-version-id'; + const OSS_CNAME = 'cname'; + + //private URLs + const OSS_URL_ACCESS_KEY_ID = 'OSSAccessKeyId'; + const OSS_URL_EXPIRES = 'Expires'; + const OSS_URL_SIGNATURE = 'Signature'; + //HTTP METHOD + const OSS_HTTP_GET = 'GET'; + const OSS_HTTP_PUT = 'PUT'; + const OSS_HTTP_HEAD = 'HEAD'; + const OSS_HTTP_POST = 'POST'; + const OSS_HTTP_DELETE = 'DELETE'; + const OSS_HTTP_OPTIONS = 'OPTIONS'; + //Others + const OSS_ACL = 'x-oss-acl'; + const OSS_OBJECT_ACL = 'x-oss-object-acl'; + const OSS_OBJECT_GROUP = 'x-oss-file-group'; + const OSS_MULTI_PART = 'uploads'; + const OSS_MULTI_DELETE = 'delete'; + const OSS_OBJECT_COPY_SOURCE = 'x-oss-copy-source'; + const OSS_OBJECT_COPY_SOURCE_RANGE = "x-oss-copy-source-range"; + const OSS_PROCESS = "x-oss-process"; + const OSS_CALLBACK = "x-oss-callback"; + const OSS_CALLBACK_VAR = "x-oss-callback-var"; + const OSS_REQUEST_PAYER = "x-oss-request-payer"; + const OSS_TRAFFIC_LIMIT = "x-oss-traffic-limit"; + //Constants for STS SecurityToken + const OSS_SECURITY_TOKEN = "x-oss-security-token"; + const OSS_ACL_TYPE_PRIVATE = 'private'; + const OSS_ACL_TYPE_PUBLIC_READ = 'public-read'; + const OSS_ACL_TYPE_PUBLIC_READ_WRITE = 'public-read-write'; + const OSS_ENCODING_TYPE = "encoding-type"; + const OSS_ENCODING_TYPE_URL = "url"; + + const OSS_LIST_TYPE = "list-type"; + + // Domain Types + const OSS_HOST_TYPE_NORMAL = "normal";//http://bucket.oss-cn-hangzhou.aliyuncs.com/object + const OSS_HOST_TYPE_IP = "ip"; //http://1.1.1.1/bucket/object + const OSS_HOST_TYPE_SPECIAL = 'special'; //http://bucket.guizhou.gov/object + const OSS_HOST_TYPE_CNAME = "cname"; //http://mydomain.com/object + const OSS_HOST_TYPE_PATH_STYLE = "path-style"; //http://oss-cn-hangzhou.aliyuncs.com/bucket/object + //OSS ACL array + static $OSS_ACL_TYPES = array( + self::OSS_ACL_TYPE_PRIVATE, + self::OSS_ACL_TYPE_PUBLIC_READ, + self::OSS_ACL_TYPE_PUBLIC_READ_WRITE + ); + // OssClient version information + const OSS_NAME = "aliyun-sdk-php"; + const OSS_VERSION = "2.7.2"; + const OSS_BUILD = "20241028"; + const OSS_AUTHOR = ""; + const OSS_OPTIONS_ORIGIN = 'Origin'; + const OSS_OPTIONS_REQUEST_METHOD = 'Access-Control-Request-Method'; + const OSS_OPTIONS_REQUEST_HEADERS = 'Access-Control-Request-Headers'; + + // signatrue version information + const OSS_SIGNATURE_VERSION_V1 = "v1"; + const OSS_SIGNATURE_VERSION_V4 = "v4"; + const OSS_DEFAULT_PRODUCT = "oss"; + const OSS_CLOUDBOX_PRODUCT = "oss-cloudbox"; + + //use ssl flag + private $useSSL = false; + private $maxRetries = 3; + private $redirects = 0; + + // user's domain type. It could be one of the four: OSS_HOST_TYPE_NORMAL, OSS_HOST_TYPE_IP, OSS_HOST_TYPE_SPECIAL, OSS_HOST_TYPE_CNAME + private $hostType = self::OSS_HOST_TYPE_NORMAL; + private $requestProxy = null; + /** + * @var CredentialsProvider + */ + private $provider; + private $hostname; + private $enableStrictObjName; + private $timeout = 0; + private $connectTimeout = 0; + private $cloudBoxId = null; + private $region = null; + /** + * @var SignerV1|SignerV4 + */ + private $signer; + + private $checkObjectEncoding = false; + + private $filePathCompatible; +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/AclResult.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/AclResult.php new file mode 100644 index 0000000..7061ff0 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/AclResult.php @@ -0,0 +1,31 @@ +rawResponse->body; + if (empty($content)) { + throw new OssException("body is null"); + } + $xml = simplexml_load_string($content); + if (isset($xml->AccessControlList->Grant)) { + return strval($xml->AccessControlList->Grant); + } else { + throw new OssException("xml format exception"); + } + } +} \ No newline at end of file diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/AppendResult.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/AppendResult.php new file mode 100644 index 0000000..d898d58 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/AppendResult.php @@ -0,0 +1,27 @@ +rawResponse->header; + if (isset($header["x-oss-next-append-position"])) { + return intval($header["x-oss-next-append-position"]); + } + throw new OssException("cannot get next-append-position"); + } +} \ No newline at end of file diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/BodyResult.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/BodyResult.php new file mode 100644 index 0000000..44ba15e --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/BodyResult.php @@ -0,0 +1,19 @@ +rawResponse->body) ? "" : $this->rawResponse->body; + } +} \ No newline at end of file diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/CallbackResult.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/CallbackResult.php new file mode 100644 index 0000000..514e985 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/CallbackResult.php @@ -0,0 +1,21 @@ +rawResponse->status; + if ((int)(intval($status) / 100) == 2 && (int)(intval($status)) !== 203) { + return true; + } + return false; + } + +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/CopyObjectResult.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/CopyObjectResult.php new file mode 100644 index 0000000..6ed67c6 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/CopyObjectResult.php @@ -0,0 +1,30 @@ +rawResponse->body; + $xml = simplexml_load_string($body); + $result = array(); + + if (isset($xml->LastModified)) { + $result[] = $xml->LastModified; + } + if (isset($xml->ETag)) { + $result[] = $xml->ETag; + } + + return array_merge($result, $this->rawResponse->header); + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/CreateBucketCnameTokenResult.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/CreateBucketCnameTokenResult.php new file mode 100644 index 0000000..a38ca0d --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/CreateBucketCnameTokenResult.php @@ -0,0 +1,19 @@ +rawResponse->body; + $info = new CnameTokenInfo(); + $info->parseFromXml($content); + return $info; + } +} \ No newline at end of file diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/DeleteObjectVersionsResult.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/DeleteObjectVersionsResult.php new file mode 100644 index 0000000..69f52a7 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/DeleteObjectVersionsResult.php @@ -0,0 +1,39 @@ +rawResponse->body); + $encodingType = isset($xml->EncodingType) ? strval($xml->EncodingType) : ""; + return $this->parseDeletedList($xml, $encodingType); + } + + private function parseDeletedList($xml, $encodingType) + { + $retList = array(); + if (isset($xml->Deleted)) { + foreach ($xml->Deleted as $content) { + $key = isset($content->Key) ? strval($content->Key) : ""; + $key = OssUtil::decodeKey($key, $encodingType); + $versionId = isset($content->VersionId) ? strval($content->VersionId) : ""; + $deleteMarker = isset($content->DeleteMarker) ? strval($content->DeleteMarker) : ""; + $deleteMarkerVersionId = isset($content->DeleteMarkerVersionId) ? strval($content->DeleteMarkerVersionId) : ""; + $retList[] = new DeletedObjectInfo($key, $versionId, $deleteMarker, $deleteMarkerVersionId); + } + } + return $retList; + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/DeleteObjectsResult.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/DeleteObjectsResult.php new file mode 100644 index 0000000..dc373b8 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/DeleteObjectsResult.php @@ -0,0 +1,27 @@ +rawResponse->body; + $xml = simplexml_load_string($body); + $objects = array(); + + if (isset($xml->Deleted)) { + foreach($xml->Deleted as $deleteKey) + $objects[] = $deleteKey->Key; + } + return $objects; + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/ExistResult.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/ExistResult.php new file mode 100644 index 0000000..e9522d4 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/ExistResult.php @@ -0,0 +1,34 @@ +rawResponse->status) === 200 ? true : false; + } + + /** + * Check if the response status is OK according to the http status code. + * [200-299]: OK; [404]: Not found. It means the object or bucket is not found--it's a valid response too. + * + * @return bool + */ + protected function isResponseOk() + { + $status = $this->rawResponse->status; + if ((int)(intval($status) / 100) == 2 || (int)(intval($status)) === 404) { + return true; + } + return false; + } + +} \ No newline at end of file diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketCnameTokenResult.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketCnameTokenResult.php new file mode 100644 index 0000000..b524d3f --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketCnameTokenResult.php @@ -0,0 +1,19 @@ +rawResponse->body; + $info = new CnameTokenInfo(); + $info->parseFromXml($content); + return $info; + } +} \ No newline at end of file diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketEncryptionResult.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketEncryptionResult.php new file mode 100644 index 0000000..3987cc9 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketEncryptionResult.php @@ -0,0 +1,26 @@ +rawResponse->body; + $config = new ServerSideEncryptionConfig(); + $config->parseFromXml($content); + return $config; + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketInfoResult.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketInfoResult.php new file mode 100644 index 0000000..d467851 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketInfoResult.php @@ -0,0 +1,37 @@ +rawResponse->body; + if (empty($content)) { + throw new OssException("body is null"); + } + $xml = simplexml_load_string($content); + if (isset($xml->Bucket)) { + $info = new BucketInfo(); + $info->parseFromXmlNode($xml->Bucket); + return $info; + } else { + throw new OssException("xml format exception"); + } + } +} \ No newline at end of file diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketRequestPaymentResult.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketRequestPaymentResult.php new file mode 100644 index 0000000..5107de3 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketRequestPaymentResult.php @@ -0,0 +1,26 @@ +rawResponse->body; + $config = new RequestPaymentConfig(); + $config->parseFromXml($content); + return $config->getPayer(); + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketStatResult.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketStatResult.php new file mode 100644 index 0000000..aa310cf --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketStatResult.php @@ -0,0 +1,26 @@ +rawResponse->body; + $stat = new BucketStat(); + $stat->parseFromXml($content); + return $stat; + } +} \ No newline at end of file diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketTagsResult.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketTagsResult.php new file mode 100644 index 0000000..59b4dd7 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketTagsResult.php @@ -0,0 +1,26 @@ +rawResponse->body; + $config = new TaggingConfig(); + $config->parseFromXml($content); + return $config; + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketTransferAccelerationResult.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketTransferAccelerationResult.php new file mode 100644 index 0000000..a300d62 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketTransferAccelerationResult.php @@ -0,0 +1,22 @@ +rawResponse->body; + $config = new TransferAccelerationConfig(); + $config->parseFromXml($content); + return $config->getEnabled(); + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketVersioningResult.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketVersioningResult.php new file mode 100644 index 0000000..225190c --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketVersioningResult.php @@ -0,0 +1,26 @@ +rawResponse->body; + $config = new VersioningConfig(); + $config->parseFromXml($content); + return $config->getStatus(); + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketWormResult.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketWormResult.php new file mode 100644 index 0000000..9587204 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketWormResult.php @@ -0,0 +1,26 @@ +rawResponse->body; + $config = new WormConfig(); + $config->parseFromXml($content); + return $config; + } +} \ No newline at end of file diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetCnameResult.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetCnameResult.php new file mode 100644 index 0000000..eed01f9 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetCnameResult.php @@ -0,0 +1,19 @@ +rawResponse->body; + $config = new CnameConfig(); + $config->parseFromXml($content); + return $config; + } +} \ No newline at end of file diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetCorsResult.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetCorsResult.php new file mode 100644 index 0000000..8fb10ea --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetCorsResult.php @@ -0,0 +1,34 @@ +rawResponse->body; + $config = new CorsConfig(); + $config->parseFromXml($content); + return $config; + } + + /** + * 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. + * + * @return bool + */ + protected function isResponseOk() + { + $status = $this->rawResponse->status; + if ((int)(intval($status) / 100) == 2 || (int)(intval($status)) === 404) { + return true; + } + return false; + } + +} \ No newline at end of file diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetLifecycleResult.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetLifecycleResult.php new file mode 100644 index 0000000..e0a9595 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetLifecycleResult.php @@ -0,0 +1,41 @@ +rawResponse->body; + $config = new LifecycleConfig(); + $config->parseFromXml($content); + return $config; + } + + /** + * Check if the response is OK according to the http status. + * [200-299]: OK, and the LifecycleConfig could be got; [404] The Life cycle config is not found. + * + * @return bool + */ + protected function isResponseOk() + { + $status = $this->rawResponse->status; + if ((int)(intval($status) / 100) == 2 || (int)(intval($status)) === 404) { + return true; + } + return false; + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetLiveChannelHistoryResult.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetLiveChannelHistoryResult.php new file mode 100644 index 0000000..5d5bc92 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetLiveChannelHistoryResult.php @@ -0,0 +1,19 @@ +rawResponse->body; + $channelList = new GetLiveChannelHistory(); + $channelList->parseFromXml($content); + return $channelList; + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetLiveChannelInfoResult.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetLiveChannelInfoResult.php new file mode 100644 index 0000000..cefe460 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetLiveChannelInfoResult.php @@ -0,0 +1,19 @@ +rawResponse->body; + $channelList = new GetLiveChannelInfo(); + $channelList->parseFromXml($content); + return $channelList; + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetLiveChannelStatusResult.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetLiveChannelStatusResult.php new file mode 100644 index 0000000..6b8a60f --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetLiveChannelStatusResult.php @@ -0,0 +1,19 @@ +rawResponse->body; + $channelList = new GetLiveChannelStatus(); + $channelList->parseFromXml($content); + return $channelList; + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetLocationResult.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetLocationResult.php new file mode 100644 index 0000000..a0c5129 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetLocationResult.php @@ -0,0 +1,30 @@ +rawResponse->body; + if (empty($content)) { + throw new OssException("body is null"); + } + $xml = simplexml_load_string($content); + return $xml; + } +} \ No newline at end of file diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetLoggingResult.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetLoggingResult.php new file mode 100644 index 0000000..eab8c64 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetLoggingResult.php @@ -0,0 +1,41 @@ +rawResponse->body; + $config = new LoggingConfig(); + $config->parseFromXml($content); + return $config; + } + + /** + * Judged according to the return HTTP status code, [200-299] that is OK, get the bucket configuration interface, + * 404 is also considered a valid response + * + * @return bool + */ + protected function isResponseOk() + { + $status = $this->rawResponse->status; + if ((int)(intval($status) / 100) == 2 || (int)(intval($status)) === 404) { + return true; + } + return false; + } +} \ No newline at end of file diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetRefererResult.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetRefererResult.php new file mode 100644 index 0000000..a8a649e --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetRefererResult.php @@ -0,0 +1,41 @@ +rawResponse->body; + $config = new RefererConfig(); + $config->parseFromXml($content); + return $config; + } + + /** + * Judged according to the return HTTP status code, [200-299] that is OK, get the bucket configuration interface, + * 404 is also considered a valid response + * + * @return bool + */ + protected function isResponseOk() + { + $status = $this->rawResponse->status; + if ((int)(intval($status) / 100) == 2 || (int)(intval($status)) === 404) { + return true; + } + return false; + } +} \ No newline at end of file diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetStorageCapacityResult.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetStorageCapacityResult.php new file mode 100644 index 0000000..2f4127b --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetStorageCapacityResult.php @@ -0,0 +1,34 @@ +rawResponse->body; + if (empty($content)) { + throw new OssException("body is null"); + } + $xml = simplexml_load_string($content); + if (isset($xml->StorageCapacity)) { + return intval($xml->StorageCapacity); + } else { + throw new OssException("xml format exception"); + } + } +} \ No newline at end of file diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetWebsiteResult.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetWebsiteResult.php new file mode 100644 index 0000000..64d54fa --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetWebsiteResult.php @@ -0,0 +1,40 @@ +rawResponse->body; + $config = new WebsiteConfig(); + $config->parseFromXml($content); + return $config; + } + + /** + * Judged according to the return HTTP status code, [200-299] that is OK, get the bucket configuration interface, + * 404 is also considered a valid response + * + * @return bool + */ + protected function isResponseOk() + { + $status = $this->rawResponse->status; + if ((int)(intval($status) / 100) == 2 || (int)(intval($status)) === 404) { + return true; + } + return false; + } +} \ No newline at end of file diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/HeaderResult.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/HeaderResult.php new file mode 100644 index 0000000..1ca4d1a --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/HeaderResult.php @@ -0,0 +1,23 @@ +rawResponse->header) ? array() : $this->rawResponse->header; + } + +} \ No newline at end of file diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/InitiateBucketWormResult.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/InitiateBucketWormResult.php new file mode 100644 index 0000000..1cd7a02 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/InitiateBucketWormResult.php @@ -0,0 +1,27 @@ +rawResponse->header; + if (isset($header["x-oss-worm-id"])) { + return strval($header["x-oss-worm-id"]); + } + throw new OssException("cannot get worm-id"); + } +} \ No newline at end of file diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/InitiateMultipartUploadResult.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/InitiateMultipartUploadResult.php new file mode 100644 index 0000000..53a15da --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/InitiateMultipartUploadResult.php @@ -0,0 +1,29 @@ +rawResponse->body; + $xml = simplexml_load_string($content); + if (isset($xml->UploadId)) { + return strval($xml->UploadId); + } + throw new OssException("cannot get UploadId"); + } +} \ No newline at end of file diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/ListBucketsResult.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/ListBucketsResult.php new file mode 100644 index 0000000..1dd037b --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/ListBucketsResult.php @@ -0,0 +1,32 @@ +rawResponse->body; + $xml = new \SimpleXMLElement($content); + if (isset($xml->Buckets) && isset($xml->Buckets->Bucket)) { + foreach ($xml->Buckets->Bucket as $bucket) { + $bucketInfo = new BucketInfo(); + $bucketInfo->parseFromXmlNode($bucket); + $bucketList[] = $bucketInfo; + } + } + return new BucketListInfo($bucketList); + } +} \ No newline at end of file diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/ListLiveChannelResult.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/ListLiveChannelResult.php new file mode 100644 index 0000000..1a6e2a4 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/ListLiveChannelResult.php @@ -0,0 +1,16 @@ +rawResponse->body; + $channelList = new LiveChannelListInfo(); + $channelList->parseFromXml($content); + return $channelList; + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/ListMultipartUploadResult.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/ListMultipartUploadResult.php new file mode 100644 index 0000000..3220c86 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/ListMultipartUploadResult.php @@ -0,0 +1,55 @@ +rawResponse->body; + $xml = simplexml_load_string($content); + + $encodingType = isset($xml->EncodingType) ? strval($xml->EncodingType) : ""; + $bucket = isset($xml->Bucket) ? strval($xml->Bucket) : ""; + $keyMarker = isset($xml->KeyMarker) ? strval($xml->KeyMarker) : ""; + $keyMarker = OssUtil::decodeKey($keyMarker, $encodingType); + $uploadIdMarker = isset($xml->UploadIdMarker) ? strval($xml->UploadIdMarker) : ""; + $nextKeyMarker = isset($xml->NextKeyMarker) ? strval($xml->NextKeyMarker) : ""; + $nextKeyMarker = OssUtil::decodeKey($nextKeyMarker, $encodingType); + $nextUploadIdMarker = isset($xml->NextUploadIdMarker) ? strval($xml->NextUploadIdMarker) : ""; + $delimiter = isset($xml->Delimiter) ? strval($xml->Delimiter) : ""; + $delimiter = OssUtil::decodeKey($delimiter, $encodingType); + $prefix = isset($xml->Prefix) ? strval($xml->Prefix) : ""; + $prefix = OssUtil::decodeKey($prefix, $encodingType); + $maxUploads = isset($xml->MaxUploads) ? intval($xml->MaxUploads) : 0; + $isTruncated = isset($xml->IsTruncated) ? strval($xml->IsTruncated) : ""; + $listUpload = array(); + + if (isset($xml->Upload)) { + foreach ($xml->Upload as $upload) { + $key = isset($upload->Key) ? strval($upload->Key) : ""; + $key = OssUtil::decodeKey($key, $encodingType); + $uploadId = isset($upload->UploadId) ? strval($upload->UploadId) : ""; + $initiated = isset($upload->Initiated) ? strval($upload->Initiated) : ""; + $listUpload[] = new UploadInfo($key, $uploadId, $initiated); + } + } + return new ListMultipartUploadInfo($bucket, $keyMarker, $uploadIdMarker, + $nextKeyMarker, $nextUploadIdMarker, + $delimiter, $prefix, $maxUploads, $isTruncated, $listUpload); + } +} \ No newline at end of file diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/ListObjectVersionsResult.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/ListObjectVersionsResult.php new file mode 100644 index 0000000..4503c03 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/ListObjectVersionsResult.php @@ -0,0 +1,98 @@ +rawResponse->body); + $encodingType = isset($xml->EncodingType) ? strval($xml->EncodingType) : ""; + $objectVersionList = $this->parseObjecVersionList($xml, $encodingType); + $deleteMarkerList = $this->parseDeleteMarkerList($xml, $encodingType); + $prefixList = $this->parsePrefixList($xml, $encodingType); + $bucketName = isset($xml->Name) ? strval($xml->Name) : ""; + $prefix = isset($xml->Prefix) ? strval($xml->Prefix) : ""; + $prefix = OssUtil::decodeKey($prefix, $encodingType); + $keyMarker = isset($xml->KeyMarker) ? strval($xml->KeyMarker) : ""; + $keyMarker = OssUtil::decodeKey($keyMarker, $encodingType); + $nextKeyMarker = isset($xml->NextKeyMarker) ? strval($xml->NextKeyMarker) : ""; + $nextKeyMarker = OssUtil::decodeKey($nextKeyMarker, $encodingType); + $versionIdMarker = isset($xml->VersionIdMarker) ? strval($xml->VersionIdMarker) : ""; + $nextVersionIdMarker = isset($xml->NextVersionIdMarker) ? strval($xml->NextVersionIdMarker) : ""; + $maxKeys = isset($xml->MaxKeys) ? intval($xml->MaxKeys) : 0; + $delimiter = isset($xml->Delimiter) ? strval($xml->Delimiter) : ""; + $delimiter = OssUtil::decodeKey($delimiter, $encodingType); + $isTruncated = isset($xml->IsTruncated) ? strval($xml->IsTruncated) : ""; + + return new ObjectVersionListInfo($bucketName, $prefix, $keyMarker, $nextKeyMarker, + $versionIdMarker, $nextVersionIdMarker, $maxKeys, $delimiter, $isTruncated, + $objectVersionList, $deleteMarkerList, $prefixList); + } + + private function parseObjecVersionList($xml, $encodingType) + { + $retList = array(); + if (isset($xml->Version)) { + foreach ($xml->Version as $content) { + $key = isset($content->Key) ? strval($content->Key) : ""; + $key = OssUtil::decodeKey($key, $encodingType); + $versionId = isset($content->VersionId) ? strval($content->VersionId) : ""; + $lastModified = isset($content->LastModified) ? strval($content->LastModified) : ""; + $eTag = isset($content->ETag) ? strval($content->ETag) : ""; + $type = isset($content->Type) ? strval($content->Type) : ""; + $size = isset($content->Size) ? strval($content->Size) : "0"; + $storageClass = isset($content->StorageClass) ? strval($content->StorageClass) : ""; + $isLatest = isset($content->IsLatest) ? strval($content->IsLatest) : ""; + $retList[] = new ObjectVersionInfo($key, $versionId, $lastModified, $eTag, $type, $size, $storageClass, $isLatest); + } + } + return $retList; + } + + private function parseDeleteMarkerList($xml, $encodingType) + { + $retList = array(); + if (isset($xml->DeleteMarker)) { + foreach ($xml->DeleteMarker as $content) { + $key = isset($content->Key) ? strval($content->Key) : ""; + $key = OssUtil::decodeKey($key, $encodingType); + $versionId = isset($content->VersionId) ? strval($content->VersionId) : ""; + $lastModified = isset($content->LastModified) ? strval($content->LastModified) : ""; + $isLatest = isset($content->IsLatest) ? strval($content->IsLatest) : ""; + $retList[] = new DeleteMarkerInfo($key, $versionId, $lastModified, $isLatest); + } + } + return $retList; + } + + private function parsePrefixList($xml, $encodingType) + { + $retList = array(); + if (isset($xml->CommonPrefixes)) { + foreach ($xml->CommonPrefixes as $commonPrefix) { + $prefix = isset($commonPrefix->Prefix) ? strval($commonPrefix->Prefix) : ""; + $prefix = OssUtil::decodeKey($prefix, $encodingType); + $retList[] = new PrefixInfo($prefix); + } + } + return $retList; + } +} \ No newline at end of file diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/ListObjectsResult.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/ListObjectsResult.php new file mode 100644 index 0000000..1246174 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/ListObjectsResult.php @@ -0,0 +1,80 @@ +rawResponse->body); + $encodingType = isset($xml->EncodingType) ? strval($xml->EncodingType) : ""; + $objectList = $this->parseObjectList($xml, $encodingType); + $prefixList = $this->parsePrefixList($xml, $encodingType); + $bucketName = isset($xml->Name) ? strval($xml->Name) : ""; + $prefix = isset($xml->Prefix) ? strval($xml->Prefix) : ""; + $prefix = OssUtil::decodeKey($prefix, $encodingType); + $marker = isset($xml->Marker) ? strval($xml->Marker) : ""; + $marker = OssUtil::decodeKey($marker, $encodingType); + $maxKeys = isset($xml->MaxKeys) ? intval($xml->MaxKeys) : 0; + $delimiter = isset($xml->Delimiter) ? strval($xml->Delimiter) : ""; + $delimiter = OssUtil::decodeKey($delimiter, $encodingType); + $isTruncated = isset($xml->IsTruncated) ? strval($xml->IsTruncated) : ""; + $nextMarker = isset($xml->NextMarker) ? strval($xml->NextMarker) : ""; + $nextMarker = OssUtil::decodeKey($nextMarker, $encodingType); + return new ObjectListInfo($bucketName, $prefix, $marker, $nextMarker, $maxKeys, $delimiter, $isTruncated, $objectList, $prefixList); + } + + private function parseObjectList($xml, $encodingType) + { + $retList = array(); + if (isset($xml->Contents)) { + foreach ($xml->Contents as $content) { + $key = isset($content->Key) ? strval($content->Key) : ""; + $key = OssUtil::decodeKey($key, $encodingType); + $lastModified = isset($content->LastModified) ? strval($content->LastModified) : ""; + $eTag = isset($content->ETag) ? strval($content->ETag) : ""; + $type = isset($content->Type) ? strval($content->Type) : ""; + $size = isset($content->Size) ? strval($content->Size) : "0"; + $storageClass = isset($content->StorageClass) ? strval($content->StorageClass) : ""; + if(isset($content->Owner)){ + $owner = new Owner(strval($content->Owner->ID),strval($content->Owner->DisplayName)); + }else{ + $owner = null; + } + $restoreInfo= isset($content->RestoreInfo) ? strval($content->RestoreInfo) : null; + $retList[] = new ObjectInfo($key, $lastModified, $eTag, $type, $size, $storageClass,$owner,$restoreInfo); + } + } + return $retList; + } + + private function parsePrefixList($xml, $encodingType) + { + $retList = array(); + if (isset($xml->CommonPrefixes)) { + foreach ($xml->CommonPrefixes as $commonPrefix) { + $prefix = isset($commonPrefix->Prefix) ? strval($commonPrefix->Prefix) : ""; + $prefix = OssUtil::decodeKey($prefix, $encodingType); + $retList[] = new PrefixInfo($prefix); + } + } + return $retList; + } +} \ No newline at end of file diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/ListObjectsV2Result.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/ListObjectsV2Result.php new file mode 100644 index 0000000..8293767 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/ListObjectsV2Result.php @@ -0,0 +1,81 @@ +rawResponse->body); + $encodingType = isset($xml->EncodingType) ? strval($xml->EncodingType) : ""; + $objectList = $this->parseObjectList($xml, $encodingType); + $prefixList = $this->parsePrefixList($xml, $encodingType); + $bucketName = isset($xml->Name) ? strval($xml->Name) : ""; + $prefix = isset($xml->Prefix) ? strval($xml->Prefix) : ""; + $prefix = OssUtil::decodeKey($prefix, $encodingType); + $maxKeys = isset($xml->MaxKeys) ? intval($xml->MaxKeys) : 0; + $delimiter = isset($xml->Delimiter) ? strval($xml->Delimiter) : ""; + $delimiter = OssUtil::decodeKey($delimiter, $encodingType); + $isTruncated = isset($xml->IsTruncated) ? strval($xml->IsTruncated) : ""; + $continuationToken = isset($xml->ContinuationToken) ? strval($xml->ContinuationToken) : ""; + $nextContinuationToken = isset($xml->NextContinuationToken) ? strval($xml->NextContinuationToken) : ""; + $startAfter = isset($xml->StartAfter) ? strval($xml->StartAfter) : ""; + $startAfter = OssUtil::decodeKey($startAfter, $encodingType); + $keyCount = isset($xml->KeyCount) ? intval($xml->KeyCount) : 0; + return new ObjectListInfoV2($bucketName, $prefix, $maxKeys, $delimiter, $isTruncated, $objectList, $prefixList, $continuationToken, $nextContinuationToken, $startAfter, $keyCount); + } + + private function parseObjectList($xml, $encodingType) + { + $retList = array(); + if (isset($xml->Contents)) { + foreach ($xml->Contents as $content) { + $key = isset($content->Key) ? strval($content->Key) : ""; + $key = OssUtil::decodeKey($key, $encodingType); + $lastModified = isset($content->LastModified) ? strval($content->LastModified) : ""; + $eTag = isset($content->ETag) ? strval($content->ETag) : ""; + $type = isset($content->Type) ? strval($content->Type) : ""; + $size = isset($content->Size) ? strval($content->Size) : "0"; + $storageClass = isset($content->StorageClass) ? strval($content->StorageClass) : ""; + if(isset($content->Owner)){ + $owner = new Owner(strval($content->Owner->ID),strval($content->Owner->DisplayName)); + }else{ + $owner = null; + } + $restoreInfo= isset($content->RestoreInfo) ? strval($content->RestoreInfo) : null; + $retList[] = new ObjectInfo($key, $lastModified, $eTag, $type, $size, $storageClass,$owner,$restoreInfo); + } + } + return $retList; + } + + private function parsePrefixList($xml, $encodingType) + { + $retList = array(); + if (isset($xml->CommonPrefixes)) { + foreach ($xml->CommonPrefixes as $commonPrefix) { + $prefix = isset($commonPrefix->Prefix) ? strval($commonPrefix->Prefix) : ""; + $prefix = OssUtil::decodeKey($prefix, $encodingType); + $retList[] = new PrefixInfo($prefix); + } + } + return $retList; + } +} \ No newline at end of file diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/ListPartsResult.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/ListPartsResult.php new file mode 100644 index 0000000..6641b5b --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/ListPartsResult.php @@ -0,0 +1,42 @@ +rawResponse->body; + $xml = simplexml_load_string($content); + $bucket = isset($xml->Bucket) ? strval($xml->Bucket) : ""; + $key = isset($xml->Key) ? strval($xml->Key) : ""; + $uploadId = isset($xml->UploadId) ? strval($xml->UploadId) : ""; + $nextPartNumberMarker = isset($xml->NextPartNumberMarker) ? intval($xml->NextPartNumberMarker) : ""; + $maxParts = isset($xml->MaxParts) ? intval($xml->MaxParts) : ""; + $isTruncated = isset($xml->IsTruncated) ? strval($xml->IsTruncated) : ""; + $partList = array(); + if (isset($xml->Part)) { + foreach ($xml->Part as $part) { + $partNumber = isset($part->PartNumber) ? intval($part->PartNumber) : ""; + $lastModified = isset($part->LastModified) ? strval($part->LastModified) : ""; + $eTag = isset($part->ETag) ? strval($part->ETag) : ""; + $size = isset($part->Size) ? strval($part->Size) : ""; + $partList[] = new PartInfo($partNumber, $lastModified, $eTag, $size); + } + } + return new ListPartsInfo($bucket, $key, $uploadId, $nextPartNumberMarker, $maxParts, $isTruncated, $partList); + } +} \ No newline at end of file diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/PutLiveChannelResult.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/PutLiveChannelResult.php new file mode 100644 index 0000000..dcac86b --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/PutLiveChannelResult.php @@ -0,0 +1,16 @@ +rawResponse->body; + $channel = new LiveChannelInfo(); + $channel->parseFromXml($content); + return $channel; + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/PutSetDeleteResult.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/PutSetDeleteResult.php new file mode 100644 index 0000000..97af003 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/PutSetDeleteResult.php @@ -0,0 +1,20 @@ + $this->rawResponse->body); + return array_merge($this->rawResponse->header, $body); + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/Result.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/Result.php new file mode 100644 index 0000000..597ac5a --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/Result.php @@ -0,0 +1,213 @@ +rawResponse = $response; + $this->parseResponse(); + } + + /** + * Get requestId + * + * @return string + */ + public function getRequestId() + { + if (isset($this->rawResponse) && + isset($this->rawResponse->header) && + isset($this->rawResponse->header['x-oss-request-id']) + ) { + return $this->rawResponse->header['x-oss-request-id']; + } else { + return ''; + } + } + + /** + * Get the returned data, different request returns the data format is different + * + * $return mixed + */ + public function getData() + { + return $this->parsedData; + } + + /** + * Subclass implementation, different requests return data has different analytical logic, implemented by subclasses + * + * @return mixed + */ + abstract protected function parseDataFromResponse(); + + /** + * Whether the operation is successful + * + * @return mixed + */ + public function isOK() + { + return $this->isOk; + } + + /** + * @throws OssException + */ + public function parseResponse() + { + $this->isOk = $this->isResponseOk(); + if ($this->isOk) { + $this->parsedData = $this->parseDataFromResponse(); + } else { + $httpStatus = strval($this->rawResponse->status); + $requestId = strval($this->getRequestId()); + $code = $this->retrieveErrorCode($this->rawResponse->body); + $message = $this->retrieveErrorMessage($this->rawResponse->body); + $body = $this->rawResponse->body; + + $details = array( + 'status' => $httpStatus, + 'request-id' => $requestId, + 'code' => $code, + 'message' => $message, + 'body' => $body + ); + throw new OssException($details); + } + } + + /** + * Try to get the error message from body + * + * @param $body + * @return string + */ + private function retrieveErrorMessage($body) + { + if (empty($body) || false === strpos($body, 'Message)) { + return strval($xml->Message); + } + $flag = true; + } catch (\Exception $e) { + $flag = true; + } + if ($flag === true) { + $start = strpos($body, ''); + if ($start === false) { + return ''; + } + $start += 9; + $end = strpos($body, '', $start); + if ($end === false) { + return ''; + } + return substr($body, $start, $end - $start); + } + + return ''; + } + + /** + * Try to get the error Code from body + * + * @param $body + * @return string + */ + private function retrieveErrorCode($body) + { + if (empty($body) || false === strpos($body, 'Code)) { + return strval($xml->Code); + } + $flag = true; + } catch (\Exception $e) { + $flag = true; + } + if ($flag === true) { + $start = strpos($body, ''); + if ($start === false) { + return ''; + } + $start += 6; + $end = strpos($body, '', $start); + if ($end === false) { + return ''; + } + return substr($body, $start, $end - $start); + } + + return ''; + } + + /** + * Judging from the return http status code, [200-299] that is OK + * + * @return bool + */ + protected function isResponseOk() + { + $status = $this->rawResponse->status; + if ((int)(intval($status) / 100) == 2) { + return true; + } + return false; + } + + /** + * Return the original return data + * + * @return ResponseCore + */ + public function getRawResponse() + { + return $this->rawResponse; + } + + /** + * Indicate whether the request is successful + */ + protected $isOk = false; + /** + * Data parsed by subclasses + */ + protected $parsedData = null; + /** + * Store the original Response returned by the auth function + * + * @var ResponseCore + */ + protected $rawResponse; +} \ No newline at end of file diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/SymlinkResult.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/SymlinkResult.php new file mode 100644 index 0000000..9c6d861 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/SymlinkResult.php @@ -0,0 +1,24 @@ +rawResponse->header[OssClient::OSS_SYMLINK_TARGET] = rawurldecode($this->rawResponse->header[OssClient::OSS_SYMLINK_TARGET]); + return $this->rawResponse->header; + } +} + diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/UploadPartResult.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/UploadPartResult.php new file mode 100644 index 0000000..c6b66d4 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/UploadPartResult.php @@ -0,0 +1,28 @@ +rawResponse->header; + if (isset($header["etag"])) { + return $header["etag"]; + } + throw new OssException("cannot get ETag"); + + } +} \ No newline at end of file diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Signer/SignerInterface.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Signer/SignerInterface.php new file mode 100644 index 0000000..c592a4f --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Signer/SignerInterface.php @@ -0,0 +1,12 @@ +request_headers['Date'])) { + $request->add_header('Date', gmdate('D, d M Y H:i:s \G\M\T')); + } + // Credentials information + if (!empty($credentials->getSecurityToken())) { + $request->add_header("x-oss-security-token", $credentials->getSecurityToken()); + } + $headers = $request->request_headers; + $method = strtoupper($request->method); + $date = $headers['Date']; + $resourcePath = $this->getResourcePath($options); + $queryString = parse_url($request->request_url, PHP_URL_QUERY); + $query = array(); + if ($queryString !== null) { + parse_str($queryString, $query); + } + $stringToSign = $this->calcStringToSign($method, $date, $headers, $resourcePath, $query); +// printf("sign str:%s" . PHP_EOL, $stringToSign); + $options['string_to_sign'] = $stringToSign; + $signature = base64_encode(hash_hmac('sha1', $stringToSign, $credentials->getAccessKeySecret(), true)); + $request->add_header('Authorization', 'OSS ' . $credentials->getAccessKeyId() . ':' . $signature); + } + + public function presign(RequestCore $request, Credentials $credentials, array &$options) + { + $headers = $request->request_headers; + // Date + $expiration = $options['expiration']; + if (!isset($request->request_headers['Date'])) { + $request->add_header('Date', gmdate('D, d M Y H:i:s \G\M\T')); + } + $parsed_url = parse_url($request->request_url); + $queryString = isset($parsed_url['query']) ? $parsed_url['query'] : ''; + $query = array(); + if ($queryString !== null) { + parse_str($queryString, $query); + } + // Credentials information + if (!empty($credentials->getSecurityToken())) { + $query["security-token"] = $credentials->getSecurityToken(); + } + $method = strtoupper($request->method); + $date = $expiration . ""; + $resourcePath = $this->getResourcePath($options); + $stringToSign = $this->calcStringToSign($method, $date, $headers, $resourcePath, $query); + $options['string_to_sign'] = $stringToSign; + $signature = base64_encode(hash_hmac('sha1', $stringToSign, $credentials->getAccessKeySecret(), true)); + $query['OSSAccessKeyId'] = $credentials->getAccessKeyId(); + $query['Expires'] = $date; + $query['Signature'] = $signature; + $queryString = OssUtil::toQueryString($query); + $parsed_url['query'] = $queryString; + $request->request_url = OssUtil::unparseUrl($parsed_url); + } + + private function getResourcePath(array $options) + { + $resourcePath = '/'; + if (strlen($options['bucket']) > 0) { + $resourcePath .= $options['bucket'] . '/'; + } + if (strlen($options['key']) > 0) { + $resourcePath .= $options['key']; + } + return $resourcePath; + } + + private function calcStringToSign($method, $date, array $headers, $resourcePath, array $query) + { + /* + SignToString = + VERB + "\n" + + Content-MD5 + "\n" + + Content-Type + "\n" + + Date + "\n" + + CanonicalizedOSSHeaders + + CanonicalizedResource + Signature = base64(hmac-sha1(AccessKeySecret, SignToString)) + */ + $contentMd5 = ''; + $contentType = ''; + // CanonicalizedOSSHeaders + $signheaders = array(); + foreach ($headers as $key => $value) { + $lowk = strtolower($key); + if (strncmp($lowk, "x-oss-", 6) == 0) { + $signheaders[$lowk] = $value; + } else if ($lowk === 'content-md5') { + $contentMd5 = $value; + } else if ($lowk === 'content-type') { + $contentType = $value; + } + } + ksort($signheaders); + $canonicalizedOSSHeaders = ''; + foreach ($signheaders as $key => $value) { + $canonicalizedOSSHeaders .= $key . ':' . $value . "\n"; + } + // CanonicalizedResource + $signquery = array(); + foreach ($query as $key => $value) { + if (in_array($key, $this->signKeyList)) { + $signquery[$key] = $value; + } + } + ksort($signquery); + $sortedQueryList = array(); + foreach ($signquery as $key => $value) { + if (strlen($value) > 0) { + $sortedQueryList[] = $key . '=' . $value; + } else { + $sortedQueryList[] = $key; + } + } + $queryStringSorted = implode('&', $sortedQueryList); + $canonicalizedResource = $resourcePath; + if (!empty($queryStringSorted)) { + $canonicalizedResource .= '?' . $queryStringSorted; + } + return $method . "\n" . $contentMd5 . "\n" . $contentType . "\n" . $date . "\n" . $canonicalizedOSSHeaders . $canonicalizedResource; + } + + private $signKeyList = array( + "acl", "uploads", "location", "cors", + "logging", "website", "referer", "lifecycle", + "delete", "append", "tagging", "objectMeta", + "uploadId", "partNumber", "security-token", "x-oss-security-token", + "position", "img", "style", "styleName", + "replication", "replicationProgress", + "replicationLocation", "cname", "bucketInfo", + "comp", "qos", "live", "status", "vod", + "startTime", "endTime", "symlink", + "x-oss-process", "response-content-type", "x-oss-traffic-limit", + "response-content-language", "response-expires", + "response-cache-control", "response-content-disposition", + "response-content-encoding", "udf", "udfName", "udfImage", + "udfId", "udfImageDesc", "udfApplication", + "udfApplicationLog", "restore", "callback", "callback-var", "qosInfo", + "policy", "stat", "encryption", "versions", "versioning", "versionId", "requestPayment", + "x-oss-request-payer", "sequential", + "inventory", "inventoryId", "continuation-token", "asyncFetch", + "worm", "wormId", "wormExtend", "withHashContext", + "x-oss-enable-md5", "x-oss-enable-sha1", "x-oss-enable-sha256", + "x-oss-hash-ctx", "x-oss-md5-ctx", "transferAcceleration", + "regionList", "cloudboxes", "x-oss-ac-source-ip", "x-oss-ac-subnet-mask", "x-oss-ac-vpc-id", "x-oss-ac-forward-allow", + "metaQuery", "resourceGroup", "rtc", "x-oss-async-process", "responseHeader" + ); +} \ No newline at end of file diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Signer/SignerV4.php b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Signer/SignerV4.php new file mode 100644 index 0000000..039b04a --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/src/OSS/Signer/SignerV4.php @@ -0,0 +1,244 @@ +request_headers['Date'])) { + $request->add_header('Date', gmdate('D, d M Y H:i:s \G\M\T')); + } + $timestamp = strtotime($request->request_headers['Date']); + if ($timestamp === false) { + $timestamp = time(); + } + $datetime = gmdate('Ymd\THis\Z', $timestamp); + $date = substr($datetime, 0, 8); + $request->add_header("x-oss-date", $datetime); + if (!isset($request->request_headers['x-oss-content-sha256'])) { + $request->add_header("x-oss-content-sha256", 'UNSIGNED-PAYLOAD'); + } + // Credentials information + if (!empty($credentials->getSecurityToken())) { + $request->add_header("x-oss-security-token", $credentials->getSecurityToken()); + } + $headers = $request->request_headers; + $method = strtoupper($request->method); + $region = $options['region']; + $product = $options['product']; + $scope = $this->buildScope($date, $region, $product); + $resourcePath = $this->getResourcePath($options); + $additionalHeaders = $this->getCommonAdditionalHeaders($request, $options); + $queryString = parse_url($request->request_url, PHP_URL_QUERY); + $query = array(); + if ($queryString !== null) { + parse_str($queryString, $query); + } + $canonicalRequest = $this->calcCanonicalRequest($method, $resourcePath, $query, $headers, $additionalHeaders); + $stringToSign = $this->calcStringToSign($datetime, $scope, $canonicalRequest); +// printf('canonical request:%s' . PHP_EOL, $canonicalRequest); +// printf('sign str:%s' . PHP_EOL, $stringToSign); + $options['string_to_sign'] = $stringToSign; + $signature = $this->calcSignature($credentials->getAccessKeySecret(), $date, $region, $product, $stringToSign); + $authorization = 'OSS4-HMAC-SHA256 Credential=' . $credentials->getAccessKeyId() . '/' . $scope; + $additionalHeadersString = implode(';', $additionalHeaders); + if ($additionalHeadersString !== '') { + $authorization .= ',AdditionalHeaders=' . $additionalHeadersString; + } + $authorization .= ',Signature=' . $signature; + $request->add_header('Authorization', $authorization); + } + + public function presign(RequestCore $request, Credentials $credentials, array &$options) + { + if (!isset($request->request_headers['Date'])) { + $request->add_header('Date', gmdate('D, d M Y H:i:s \G\M\T')); + } + $timestamp = strtotime($request->request_headers['Date']); + if ($timestamp === false) { + $timestamp = time(); + } + $datetime = gmdate('Ymd\THis\Z', $timestamp); + $expiration = $options['expiration']; + $date = substr($datetime, 0, 8); + $expires = $expiration - $timestamp; + $headers = $request->request_headers; + $method = strtoupper($request->method); + $region = $options['region']; + $product = $options['product']; + $scope = $this->buildScope($date, $region, $product); + $resourcePath = $this->getResourcePath($options); + $additionalHeaders = $this->getCommonAdditionalHeaders($request, $options); + $queryString = parse_url($request->request_url, PHP_URL_QUERY); + $query = array(); + if ($queryString !== null) { + parse_str($queryString, $query); + } + if (!empty($credentials->getSecurityToken())) { + $query["x-oss-security-token"] = $credentials->getSecurityToken(); + } + $query["x-oss-signature-version"] = 'OSS4-HMAC-SHA256'; + $query["x-oss-date"] = $datetime; + $query["x-oss-expires"] = $expires; + $query["x-oss-credential"] = $credentials->getAccessKeyId() . '/' . $scope; + if (count($additionalHeaders) > 0) { + $query["x-oss-additional-headers"] = implode(";", $additionalHeaders); + } + $canonicalRequest = $this->calcCanonicalRequest($method, $resourcePath, $query, $headers, $additionalHeaders); + $stringToSign = $this->calcStringToSign($datetime, $scope, $canonicalRequest); +// printf('canonical request:%s' . PHP_EOL, $canonicalRequest); +// printf('sign str:%s' . PHP_EOL, $stringToSign); + $options['string_to_sign'] = $stringToSign; + $signature = $this->calcSignature($credentials->getAccessKeySecret(), $date, $region, $product, $stringToSign); + $query["x-oss-signature"] = $signature; + $queryStr = OssUtil::toQueryString($query); + $explodeUrl = explode('?', $request->request_url); + $index = count($explodeUrl); + if ($index === 1) { + $request->request_url .= '?' . $queryStr; + } else { + $baseUrl = $explodeUrl[0]; + $request->request_url = $baseUrl . '?' . $queryStr; + } + } + + private function getResourcePath(array $options) + { + $resourcePath = '/'; + if (strlen($options['bucket']) > 0) { + $resourcePath .= $options['bucket'] . '/'; + } + if (strlen($options['key']) > 0) { + $resourcePath .= $options['key']; + } + return $resourcePath; + } + + private function getCommonAdditionalHeaders(RequestCore $request, array $options) + { + if (isset($options[OssClient::OSS_ADDITIONAL_HEADERS])) { + $addHeaders = array(); + foreach ($options[OssClient::OSS_ADDITIONAL_HEADERS] as $key) { + $lowk = strtolower($key); + if ($this->isDefaultSignedHeader($lowk)) { + continue; + } + $addHeaders[$lowk] = ''; + } + $headers = array(); + foreach ($request->request_headers as $key => $value) { + $lowk = strtolower($key); + if (isset($addHeaders[$lowk])) { + $headers[$lowk] = ''; + } + } + ksort($headers); + return array_keys($headers); + } + return array(); + } + + private function isDefaultSignedHeader($low) + { + if (strncmp($low, "x-oss-", 6) == 0 || + $low === "content-type" || + $low === "content-md5") { + return true; + } + return false; + } + + private function calcStringToSign($datetime, $scope, $canonicalRequest) + { + /* + StringToSign + "OSS4-HMAC-SHA256" + "\n" + + TimeStamp + "\n" + + Scope + "\n" + + Hex(SHA256Hash(Canonical Request)) + */ + $hashedRequest = hash('sha256', $canonicalRequest); + return "OSS4-HMAC-SHA256" . "\n" . $datetime . "\n" . $scope . "\n" . $hashedRequest; + } + + private function calcCanonicalRequest($method, $resourcePath, array $query, array $headers, array $additionalHeaders) + { + /* + Canonical Request + HTTP Verb + "\n" + + Canonical URI + "\n" + + Canonical Query String + "\n" + + Canonical Headers + "\n" + + Additional Headers + "\n" + + Hashed PayLoad + */ + + //Canonical Uri + $canonicalUri = str_replace(array('%2F'), array('/'), rawurlencode($resourcePath)); + //Canonical Query + $querySigned = array(); + foreach ($query as $key => $value) { + $querySigned[rawurlencode($key)] = rawurlencode($value); + } + ksort($querySigned); + $sortedQueryList = array(); + foreach ($querySigned as $key => $value) { + if (strlen($value) > 0) { + $sortedQueryList[] = $key . '=' . $value; + } else { + $sortedQueryList[] = $key; + } + } + $canonicalQuery = implode('&', $sortedQueryList); + //Canonical Headers + $headersSigned = array(); + foreach ($headers as $key => $value) { + $lowk = strtolower($key); + if (SignerV4::isDefaultSignedHeader($lowk) || + in_array($lowk, $additionalHeaders)) { + $headersSigned[$lowk] = trim($value); + } + } + ksort($headersSigned); + $canonicalizedHeaders = ''; + foreach ($headersSigned as $key => $value) { + $canonicalizedHeaders .= $key . ':' . $value . "\n"; + } + //Additional Headers + $canonicalAdditionalHeaders = implode(';', $additionalHeaders); + $hashPayload = "UNSIGNED-PAYLOAD"; + if (isset($headersSigned['x-oss-content-sha256'])) { + $hashPayload = $headersSigned['x-oss-content-sha256']; + } + + $stringToSign = $method . "\n" + . $canonicalUri . "\n" + . $canonicalQuery . "\n" + . $canonicalizedHeaders . "\n" + . $canonicalAdditionalHeaders . "\n" + . $hashPayload; + return $stringToSign; + } + + private function buildScope($date, $region, $product) + { + return $date . "/" . $region . "/" . $product . "/aliyun_v4_request"; + } + + private function calcSignature($secret, $date, $region, $product, $stringToSign) + { + $h1Key = hash_hmac("sha256", $date, "aliyun_v4" . $secret, true); + $h2Key = hash_hmac("sha256", $region, $h1Key, true); + $h3Key = hash_hmac("sha256", $product, $h2Key, true); + $h4Key = hash_hmac("sha256", "aliyun_v4_request", $h3Key, true); + return bin2hex(hash_hmac("sha256", $stringToSign, $h4Key, true)); + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/AclResultTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/AclResultTest.php new file mode 100644 index 0000000..82168d0 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/AclResultTest.php @@ -0,0 +1,59 @@ + + + + 00220120222 + user_example + + + public-read + + +BBBB; + + private $invalidXml = << + + +BBBB; + + public function testParseValidXml() + { + $response = new ResponseCore(array(), $this->validXml, 200); + $result = new AclResult($response); + $this->assertEquals("public-read", $result->getData()); + } + + public function testParseNullXml() + { + $response = new ResponseCore(array(), "", 200); + try { + new AclResult($response); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertEquals('body is null', $e->getMessage()); + } + } + + public function testParseInvalidXml() + { + $response = new ResponseCore(array(), $this->invalidXml, 200); + try { + new AclResult($response); + $this->assertFalse(true); + } catch (OssException $e) { + $this->assertEquals("xml format exception", $e->getMessage()); + } + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/AssumeRole.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/AssumeRole.php new file mode 100644 index 0000000..e47f705 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/AssumeRole.php @@ -0,0 +1,32 @@ +$name = $value; + } + + public function __construct() + { + parent::__construct(); + $this->RoleSessionName = "sts"; + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/BodyResultTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/BodyResultTest.php new file mode 100644 index 0000000..290e61a --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/BodyResultTest.php @@ -0,0 +1,26 @@ +assertTrue($result->isOK()); + $this->assertEquals($result->getData(), "hi"); + } + + public function testParseInvalid404() + { + $response = new ResponseCore(array(), null, 200); + $result = new BodyResult($response); + $this->assertTrue($result->isOK()); + $this->assertEquals($result->getData(), ""); + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/BucketCnameTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/BucketCnameTest.php new file mode 100644 index 0000000..290f585 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/BucketCnameTest.php @@ -0,0 +1,65 @@ +client = Common::getOssClient(); + $this->bucketName = 'php-sdk-test-bucket-' . strval(rand(0, 10000)); + $this->client->createBucket($this->bucketName); + } + + protected function tearDown(): void + { + $this->client->deleteBucket($this->bucketName); + } + + public function testBucketWithoutCname() + { + $cnameConfig = $this->client->getBucketCname($this->bucketName); + $this->assertEquals(0, count($cnameConfig->getCnames())); + } + + public function testAddCname() + { + try { + $this->client->addBucketCname($this->bucketName, 'www.baidu.com'); + } catch (OssException $e) { + print_r($e->getMessage()); + $this->assertTrue(true); + } + + try { + $ret = $this->client->getBucketCname($this->bucketName); + $this->assertEquals(0, count($ret->getCnames())); + } catch (OssException $e) { + $this->assertTrue(false); + } + } + + public function testDeleteCname() + { + try { + $this->client->deleteBucketCname($this->bucketName, 'www.not-exist.com'); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $ret = $this->client->getBucketCname($this->bucketName); + $this->assertEquals(0, count($ret->getCnames())); + } catch (OssException $e) { + $this->assertTrue(false); + } + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/BucketInfoTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/BucketInfoTest.php new file mode 100644 index 0000000..f99bcee --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/BucketInfoTest.php @@ -0,0 +1,21 @@ +assertNotNull($bucketInfo); + $this->assertEquals('cn-beijing', $bucketInfo->getLocation()); + $this->assertEquals('name', $bucketInfo->getName()); + $this->assertEquals('today', $bucketInfo->getCreateDate()); + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/BucketLiveChannelTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/BucketLiveChannelTest.php new file mode 100644 index 0000000..dacae0b --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/BucketLiveChannelTest.php @@ -0,0 +1,320 @@ +client = Common::getOssClient(); + $this->bucketName = 'php-sdk-test-rtmp-bucket-name-' . strval(rand(0, 10000)); + $this->client->createBucket($this->bucketName); + Common::waitMetaSync(); + }catch(\Exception $e) { + + } + } + + protected function tearDown(): void + { + ////to delete created bucket + //1. delele live channel + $list = $this->client->listBucketLiveChannels($this->bucketName); + if (count($list->getChannelList()) != 0) + { + foreach($list->getChannelList() as $list) + { + $this->client->deleteBucketLiveChannel($this->bucketName, $list->getName()); + } + } + //2. delete exsited object + $prefix = 'live-test/'; + $delimiter = '/'; + $nextMarker = ''; + $maxkeys = 1000; + $options = array( + 'delimiter' => $delimiter, + 'prefix' => $prefix, + 'max-keys' => $maxkeys, + 'marker' => $nextMarker, + ); + + try { + $listObjectInfo = $this->client->listObjects($this->bucketName, $options); + } catch (OssException $e) { + printf($e->getMessage() . "\n"); + return; + } + + $objectList = $listObjectInfo->getObjectList(); // 文件列表 + if (!empty($objectList)) + { + foreach($objectList as $objectInfo) + $this->client->deleteObject($this->bucketName, $objectInfo->getKey()); + } + //3. delete the bucket + $this->client->deleteBucket($this->bucketName); + } + + public function testPutLiveChannel() + { + $config = new LiveChannelConfig(array( + 'description' => 'live channel 1', + 'type' => 'HLS', + 'fragDuration' => 10, + 'fragCount' => 5, + 'playListName' => 'hello.m3u8' + )); + $info = $this->client->putBucketLiveChannel($this->bucketName, 'live-1', $config); + $this->client->deleteBucketLiveChannel($this->bucketName, 'live-1'); + + $this->assertEquals('live-1', $info->getName()); + $this->assertEquals('live channel 1', $info->getDescription()); + $this->assertEquals(1, count($info->getPublishUrls())); + $this->assertEquals(1, count($info->getPlayUrls())); + } + + public function testPutLiveChannelWithDefaultParams() + { + $config = new LiveChannelConfig(array( + 'description' => 'live channel 1', + 'type' => 'HLS', + )); + $info = $this->client->putBucketLiveChannel($this->bucketName, 'live-1', $config); + $this->client->deleteBucketLiveChannel($this->bucketName, 'live-1'); + + $this->assertEquals('live-1', $info->getName()); + $this->assertEquals('live channel 1', $info->getDescription()); + $this->assertEquals(1, count($info->getPublishUrls())); + $this->assertEquals(1, count($info->getPlayUrls())); + } + + public function testListLiveChannels() + { + $config = new LiveChannelConfig(array( + 'description' => 'live channel 1', + 'type' => 'HLS', + 'fragDuration' => 10, + 'fragCount' => 5, + 'playListName' => 'hello.m3u8' + )); + $this->client->putBucketLiveChannel($this->bucketName, 'live-1', $config); + + $config = new LiveChannelConfig(array( + 'description' => 'live channel 2', + 'type' => 'HLS', + 'fragDuration' => 10, + 'fragCount' => 5, + 'playListName' => 'hello.m3u8' + )); + $this->client->putBucketLiveChannel($this->bucketName, 'live-2', $config); + + $list = $this->client->listBucketLiveChannels($this->bucketName); + + $this->assertEquals($this->bucketName, $list->getBucketName()); + $this->assertEquals(false, $list->getIsTruncated()); + $channels = $list->getChannelList(); + $this->assertEquals(2, count($channels)); + + $chan1 = $channels[0]; + $this->assertEquals('live-1', $chan1->getName()); + $this->assertEquals('live channel 1', $chan1->getDescription()); + $this->assertEquals(1, count($chan1->getPublishUrls())); + $this->assertEquals(1, count($chan1->getPlayUrls())); + + $chan2 = $channels[1]; + $this->assertEquals('live-2', $chan2->getName()); + $this->assertEquals('live channel 2', $chan2->getDescription()); + $this->assertEquals(1, count($chan2->getPublishUrls())); + $this->assertEquals(1, count($chan2->getPlayUrls())); + + $list = $this->client->listBucketLiveChannels($this->bucketName, array( + 'prefix' => 'live-', + 'marker' => 'live-1', + 'max-keys' => 10 + )); + $channels = $list->getChannelList(); + $this->assertEquals(1, count($channels)); + $chan2 = $channels[0]; + $this->assertEquals('live-2', $chan2->getName()); + $this->assertEquals('live channel 2', $chan2->getDescription()); + $this->assertEquals(1, count($chan2->getPublishUrls())); + $this->assertEquals(1, count($chan2->getPlayUrls())); + + $this->client->deleteBucketLiveChannel($this->bucketName, 'live-1'); + $this->client->deleteBucketLiveChannel($this->bucketName, 'live-2'); + $list = $this->client->listBucketLiveChannels($this->bucketName, array( + 'prefix' => 'live-' + )); + $this->assertEquals(0, count($list->getChannelList())); + } + + public function testDeleteLiveChannel() + { + $channelName = 'live-to-delete'; + $config = new LiveChannelConfig(array( + 'description' => 'live channel to delete', + 'type' => 'HLS', + 'fragDuration' => 10, + 'fragCount' => 5, + 'playListName' => 'hello.m3u8' + )); + $this->client->putBucketLiveChannel($this->bucketName, $channelName, $config); + + $this->client->deleteBucketLiveChannel($this->bucketName, $channelName); + $list = $this->client->listBucketLiveChannels($this->bucketName, array( + 'prefix' => $channelName + )); + + $this->assertEquals(0, count($list->getChannelList())); + } + + public function testSignRtmpUrl() + { + $channelName = '90475'; + $bucket = 'douyu'; + $now = time(); + $url = $this->client->signRtmpUrl($bucket, $channelName, 900, array( + 'params' => array( + 'playlistName' => 'playlist.m3u8' + ) + )); + + $ret = parse_url($url); + $this->assertEquals('rtmp', $ret['scheme']); + parse_str($ret['query'], $query); + + $this->assertTrue(isset($query['OSSAccessKeyId'])); + $this->assertTrue(isset($query['Signature'])); + $this->assertTrue(intval($query['Expires']) - ($now + 900) < 3); + $this->assertEquals('playlist.m3u8', $query['playlistName']); + } + + public function testGetgenPreSignedRtmpUrlVsSignedRtmpUrl() + { + $channelName = '90475'; + $bucket = 'douyu'; + $url1 = '245'; + $url2 = '123'; + $expiration = 0; + + do { + $begin = time(); + $expiration = time() + 900; + $url1 = $this->client->generatePresignedRtmpUrl($bucket, $channelName, $expiration, array( + 'params' => array( + 'playlistName' => 'playlist.m3u8' + ) + )); + + $url2 = $this->client->signRtmpUrl($bucket, $channelName, 900, array( + 'params' => array( + 'playlistName' => 'playlist.m3u8' + ) + )); + + $end = time(); + + if ($begin == $end) + break; + usleep(500000); + } while (true); + $this->assertEquals($url1, $url1); + $this->assertTrue(strpos($url1, 'Expires='.$expiration) !== false); + } + + public function testLiveChannelInfo() + { + $channelName = 'live-to-put-status'; + $config = new LiveChannelConfig(array( + 'description' => 'test live channel info', + 'type' => 'HLS', + 'fragDuration' => 10, + 'fragCount' => 5, + 'playListName' => 'hello.m3u8' + )); + $this->client->putBucketLiveChannel($this->bucketName, $channelName, $config); + + $info = $this->client->getLiveChannelInfo($this->bucketName, $channelName); + $this->assertEquals('test live channel info', $info->getDescription()); + $this->assertEquals('enabled', $info->getStatus()); + $this->assertEquals('HLS', $info->getType()); + $this->assertEquals(10, $info->getFragDuration()); + $this->assertEquals(5, $info->getFragCount()); + $this->assertEquals('playlist.m3u8', $info->getPlayListName()); + + $this->client->deleteBucketLiveChannel($this->bucketName, $channelName); + $list = $this->client->listBucketLiveChannels($this->bucketName, array( + 'prefix' => $channelName + )); + $this->assertEquals(0, count($list->getChannelList())); + } + + public function testPutLiveChannelStatus() + { + $channelName = 'live-to-put-status'; + $config = new LiveChannelConfig(array( + 'description' => 'test live channel info', + 'type' => 'HLS', + 'fragDuration' => 10, + 'fragCount' => 5, + 'playListName' => 'hello.m3u8' + )); + $this->client->putBucketLiveChannel($this->bucketName, $channelName, $config); + + $info = $this->client->getLiveChannelInfo($this->bucketName, $channelName); + $this->assertEquals('test live channel info', $info->getDescription()); + $this->assertEquals('enabled', $info->getStatus()); + $this->assertEquals('HLS', $info->getType()); + $this->assertEquals(10, $info->getFragDuration()); + $this->assertEquals(5, $info->getFragCount()); + $this->assertEquals('playlist.m3u8', $info->getPlayListName()); + $status = $this->client->getLiveChannelStatus($this->bucketName, $channelName); + $this->assertEquals('Idle', $status->getStatus()); + + + $resp = $this->client->putLiveChannelStatus($this->bucketName, $channelName, "disabled"); + $info = $this->client->getLiveChannelInfo($this->bucketName, $channelName); + $this->assertEquals('test live channel info', $info->getDescription()); + $this->assertEquals('disabled', $info->getStatus()); + $this->assertEquals('HLS', $info->getType()); + $this->assertEquals(10, $info->getFragDuration()); + $this->assertEquals(5, $info->getFragCount()); + $this->assertEquals('playlist.m3u8', $info->getPlayListName()); + + $status = $this->client->getLiveChannelStatus($this->bucketName, $channelName); + //getLiveChannelInfo + $this->assertEquals('Disabled', $status->getStatus()); + + $this->client->deleteBucketLiveChannel($this->bucketName, $channelName); + $list = $this->client->listBucketLiveChannels($this->bucketName, array( + 'prefix' => $channelName + )); + $this->assertEquals(0, count($list->getChannelList())); + + } + public function testLiveChannelHistory() + { + $channelName = 'live-test-history'; + $config = new LiveChannelConfig(array( + 'description' => 'test live channel info', + 'type' => 'HLS', + 'fragDuration' => 10, + 'fragCount' => 5, + 'playListName' => 'hello.m3u8' + )); + $this->client->putBucketLiveChannel($this->bucketName, $channelName, $config); + + $history = $this->client->getLiveChannelHistory($this->bucketName, $channelName); + $this->assertEquals(0, count($history->getLiveRecordList())); + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/CallbackTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/CallbackTest.php new file mode 100644 index 0000000..feb0801 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/CallbackTest.php @@ -0,0 +1,297 @@ +ossClient->putObject($this->bucket, $copiedObject, file_get_contents(__FILE__)); + + /** + * step 1. Initialize a block upload event, which is initialized to upload Multipart, get the upload id + */ + try { + $upload_id = $this->ossClient->initiateMultipartUpload($this->bucket, $object); + } catch (OssException $e) { + $this->assertFalse(true); + } + /* + * step 2. uploadPartCopy + */ + $copyId = 1; + $eTag = $this->ossClient->uploadPartCopy($this->bucket, $copiedObject, $this->bucket, $object, $copyId, $upload_id); + $upload_parts[] = array( + 'PartNumber' => $copyId, + 'ETag' => $eTag, + ); + + try { + $listPartsInfo = $this->ossClient->listParts($this->bucket, $object, $upload_id); + $this->assertNotNull($listPartsInfo); + } catch (OssException $e) { + $this->assertTrue(false); + } + + /** + * step 3. + */ + $json = + '{ + "callbackUrl":"' . Common::getCallbackUrl() . '",' . + ' "callbackHost":"oss-cn-hangzhou.aliyuncs.com", + "callbackBody":"{\"mimeType\":${mimeType},\"size\":${size},\"x:var1\":${x:var1},\"x:var2\":${x:var2}}", + "callbackBodyType":"application/json" + }'; + + $var = + '{ + "x:var1":"value1", + "x:var2":"值2" + }'; + $options = array(OssClient::OSS_CALLBACK => $json, + OssClient::OSS_CALLBACK_VAR => $var + ); + + try { + $result = $this->ossClient->completeMultipartUpload($this->bucket, $object, $upload_id, $upload_parts, $options); + $this->assertEquals("200", $result['info']['http_code']); + } catch (OssException $e) { + $this->assertTrue(false); + } + } + + public function testMultipartUploadCallbackFailed() + { + $object = "multipart-callback-test.txt"; + $copiedObject = "multipart-callback-test.txt.copied"; + $this->ossClient->putObject($this->bucket, $copiedObject, file_get_contents(__FILE__)); + + /** + * step 1. Initialize a block upload event, which is initialized to upload Multipart, get the upload id + */ + try { + $upload_id = $this->ossClient->initiateMultipartUpload($this->bucket, $object); + } catch (OssException $e) { + $this->assertFalse(true); + } + /* + * step 2. uploadPartCopy + */ + $copyId = 1; + $eTag = $this->ossClient->uploadPartCopy($this->bucket, $copiedObject, $this->bucket, $object, $copyId, $upload_id); + $upload_parts[] = array( + 'PartNumber' => $copyId, + 'ETag' => $eTag, + ); + + try { + $listPartsInfo = $this->ossClient->listParts($this->bucket, $object, $upload_id); + $this->assertNotNull($listPartsInfo); + } catch (OssException $e) { + $this->assertTrue(false); + } + + /** + * step 3. + */ + + $json = + '{ + "callbackUrl":"www.baidu.com", + "callbackHost":"oss-cn-hangzhou.aliyuncs.com", + "callbackBody":"{\"mimeType\":${mimeType},\"size\":${size},\"x:var1\":${x:var1},\"x:var2\":${x:var2}}", + "callbackBodyType":"application/json" + }'; + + $var = + '{ + "x:var1":"value1", + "x:var2":"值2" + }'; + $options = array(OssClient::OSS_CALLBACK => $json, + OssClient::OSS_CALLBACK_VAR => $var + ); + + try { + $result = $this->ossClient->completeMultipartUpload($this->bucket, $object, $upload_id, $upload_parts, $options); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + $this->assertEquals("203", $e->getHTTPStatus()); + } + + } + + public function testPutObjectCallbackNormal() + { + //json + { + $json = + '{ + "callbackUrl":"' . Common::getCallbackUrl() . '",' . + ' "callbackHost":"oss-cn-hangzhou.aliyuncs.com", + "callbackBody":"{\"mimeType\":${mimeType},\"size\":${size}}", + "callbackBodyType":"application/json" + }'; + $options = array(OssClient::OSS_CALLBACK => $json); + $this->putObjectCallbackOk($options, "200"); + } + //url + { + $url = + '{ + "callbackUrl":"' . Common::getCallbackUrl() . '",' . + ' "callbackHost":"oss-cn-hangzhou.aliyuncs.com", + "callbackBody":"bucket=${bucket}&object=${object}&etag=${etag}&size=${size}&mimeType=${mimeType}&imageInfo.height=${imageInfo.height}&imageInfo.width=${imageInfo.width}&imageInfo.format=${imageInfo.format}", + "callbackBodyType":"application/x-www-form-urlencoded" + }'; + $options = array(OssClient::OSS_CALLBACK => $url); + $this->putObjectCallbackOk($options, "200"); + } + // Unspecified typre + { + $url = + '{ + "callbackUrl":"' . Common::getCallbackUrl() . '",' . + ' "callbackHost":"oss-cn-hangzhou.aliyuncs.com", + "callbackBody":"bucket=${bucket}&object=${object}&etag=${etag}&size=${size}&mimeType=${mimeType}&imageInfo.height=${imageInfo.height}&imageInfo.width=${imageInfo.width}&imageInfo.format=${imageInfo.format}" + }'; + $options = array(OssClient::OSS_CALLBACK => $url); + $this->putObjectCallbackOk($options, "200"); + } + //json and body is chinese + { + $json = + '{ + "callbackUrl":"' . Common::getCallbackUrl() . '",' . + ' "callbackHost":"oss-cn-hangzhou.aliyuncs.com", + "callbackBody":"{\" 春水碧于天,画船听雨眠。\":\"垆边人似月,皓腕凝霜雪。\"}", + "callbackBodyType":"application/json" + }'; + $options = array(OssClient::OSS_CALLBACK => $json); + $this->putObjectCallbackOk($options, "200"); + } + //url and body is chinese + { + $url = + '{ + "callbackUrl":"' . Common::getCallbackUrl() . '",' . + ' "callbackHost":"oss-cn-hangzhou.aliyuncs.com", + "callbackBody":"春水碧于天,画船听雨眠。垆边人似月,皓腕凝霜雪", + "callbackBodyType":"application/x-www-form-urlencoded" + }'; + $options = array(OssClient::OSS_CALLBACK => $url); + $this->putObjectCallbackOk($options, "200"); + } + //json and add callback_var + { + $json = + '{ + "callbackUrl":"' . Common::getCallbackUrl() . '",' . + ' "callbackHost":"oss-cn-hangzhou.aliyuncs.com", + "callbackBody":"{\"mimeType\":${mimeType},\"size\":${size},\"x:var1\":${x:var1},\"x:var2\":${x:var2}}", + "callbackBodyType":"application/json" + }'; + + $var = + '{ + "x:var1":"value1", + "x:var2":"aliyun.com" + }'; + $options = array(OssClient::OSS_CALLBACK => $json, + OssClient::OSS_CALLBACK_VAR => $var + ); + $this->putObjectCallbackOk($options, "200"); + } + //url and add callback_var + { + $url = + '{ + "callbackUrl":"' . Common::getCallbackUrl() . '",' . + ' "callbackHost":"oss-cn-hangzhou.aliyuncs.com", + "callbackBody":"bucket=${bucket}&object=${object}&etag=${etag}&size=${size}&mimeType=${mimeType}&imageInfo.height=${imageInfo.height}&imageInfo.width=${imageInfo.width}&imageInfo.format=${imageInfo.format}&my_var1=${x:var1}&my_var2=${x:var2}", + "callbackBodyType":"application/x-www-form-urlencoded" + }'; + $var = + '{ + "x:var1":"value1凌波不过横塘路,但目送,芳", + "x:var2":"值2" + }'; + $options = array(OssClient::OSS_CALLBACK => $url, + OssClient::OSS_CALLBACK_VAR => $var + ); + $this->putObjectCallbackOk($options, "200"); + } + + } + + public function testPutCallbackWithCallbackFailed() + { + { + $json = + '{ + "callbackUrl":"http://www.baidu.com", + "callbackHost":"oss-cn-hangzhou.aliyuncs.com", + "callbackBody":"{\"mimeType\":${mimeType},\"size\":${size}}", + "callbackBodyType":"application/json" + }'; + $options = array(OssClient::OSS_CALLBACK => $json); + $this->putObjectCallbackFailed($options, "203"); + } + + { + $url = + '{ + "callbackUrl":"http://www.baidu.com", + "callbackHost":"oss-cn-hangzhou.aliyuncs.com", + "callbackBody":"bucket=${bucket}&object=${object}&etag=${etag}&size=${size}&mimeType=${mimeType}&imageInfo.height=${imageInfo.height}&imageInfo.width=${imageInfo.width}&imageInfo.format=${imageInfo.format}&my_var1=${x:var1}&my_var2=${x:var2}", + "callbackBodyType":"application/x-www-form-urlencoded" + }'; + $options = array(OssClient::OSS_CALLBACK => $url); + $this->putObjectCallbackFailed($options, "203"); + } + + } + + private function putObjectCallbackOk($options, $status) + { + $object = "oss-php-sdk-callback-test.txt"; + $content = file_get_contents(__FILE__); + try { + $result = $this->ossClient->putObject($this->bucket, $object, $content, $options); + $this->assertEquals($status, $result['info']['http_code']); + } catch (OssException $e) { + $this->assertFalse(true); + } + } + + private function putObjectCallbackFailed($options, $status) + { + $object = "oss-php-sdk-callback-test.txt"; + $content = file_get_contents(__FILE__); + try { + $result = $this->ossClient->putObject($this->bucket, $object, $content, $options); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertEquals($status, $e->getHTTPStatus()); + $this->assertTrue(true); + } + } + + protected function setUp(): void + { + parent::setUp(); + if (strlen(Common::getCallbackUrl()) == 0) { + throw new OssException("callback url can not be empty!"); + } + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/CnameConfigTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/CnameConfigTest.php new file mode 100644 index 0000000..8f7529c --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/CnameConfigTest.php @@ -0,0 +1,77 @@ + + + + www.foo.com + enabled + 20150101 + + + bar.com + disabled + 20160101 + + +BBBB; + + public function testFromXml() + { + $cnameConfig = new CnameConfig(); + $cnameConfig->parseFromXml($this->xml1); + + $cnames = $cnameConfig->getCnames(); + $this->assertEquals(2, count($cnames)); + $this->assertEquals('www.foo.com', $cnames[0]['Domain']); + $this->assertEquals('enabled', $cnames[0]['Status']); + $this->assertEquals('20150101', $cnames[0]['LastModified']); + + $this->assertEquals('bar.com', $cnames[1]['Domain']); + $this->assertEquals('disabled', $cnames[1]['Status']); + $this->assertEquals('20160101', $cnames[1]['LastModified']); + } + + public function testToXml() + { + $cnameConfig = new CnameConfig(); + $cnameConfig->addCname('www.foo.com'); + $cnameConfig->addCname('bar.com'); + + $xml = $cnameConfig->serializeToXml(); + $comp = new CnameConfig(); + $comp->parseFromXml($xml); + + $cnames1 = $cnameConfig->getCnames(); + $cnames2 = $comp->getCnames(); + + $this->assertEquals(count($cnames1), count($cnames2)); + $this->assertEquals(count($cnames1[0]), count($cnames2[0])); + $this->assertEquals(1, count($cnames1[0])); + $this->assertEquals($cnames1[0]['Domain'], $cnames2[0]['Domain']); + } + + public function testCnameNumberLimit() + { + $cnameConfig = new CnameConfig(); + for ($i = 0; $i < CnameConfig::OSS_MAX_RULES; $i += 1) { + $cnameConfig->addCname(strval($i) . '.foo.com'); + } + try { + $cnameConfig->addCname('www.foo.com'); + $this->assertFalse(true); + } catch (OssException $e) { + $this->assertEquals( + $e->getMessage(), + "num of cname in the config exceeds self::OSS_MAX_RULES: " . strval(CnameConfig::OSS_MAX_RULES)); + } + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/CnameTokenInfoTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/CnameTokenInfoTest.php new file mode 100644 index 0000000..082118e --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/CnameTokenInfoTest.php @@ -0,0 +1,31 @@ + + + bucket + www.foo.com + 1234 + 20150101 + +BBBB; + + public function testFromXml() + { + $info = new CnameTokenInfo(); + $info->parseFromXml($this->xml1); + + $this->assertEquals('bucket', $info->getBucket()); + $this->assertEquals('www.foo.com', $info->getCname()); + $this->assertEquals('1234', $info->getToken()); + $this->assertEquals('20150101', $info->getExpireTime()); + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/Common.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/Common.php new file mode 100644 index 0000000..5b76a76 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/Common.php @@ -0,0 +1,169 @@ + self::getRegion(), + 'endpoint' => self::getEndpoint(), + 'provider' => $provider, + 'signatureVersion' => self::getSignVersion() + ); + + if ($conf != null) { + foreach ($conf as $key => $value) { + $config[$key] = $value; + } + } + + $ossClient = new OssClient($config); + + } catch (OssException $e) { + printf(__FUNCTION__ . "creating OssClient instance: FAILED\n"); + printf($e->getMessage() . "\n"); + } + return $ossClient; + } + + public static function getStsOssClient($conf = NULL) + { + $stsClient = new StsClient(); + $assumeRole = new AssumeRole(); + $stsClient->AccessSecret = getenv('OSS_ACCESS_KEY_SECRET'); + $assumeRole->AccessKeyId = getenv('OSS_ACCESS_KEY_ID'); + $assumeRole->RoleArn = getenv('OSS_TEST_RAM_ROLE_ARN'); + $params = $assumeRole->getAttributes(); + $response = $stsClient->doAction($params); + + try { + $provider = new StaticCredentialsProvider( + $response->Credentials->AccessKeyId, + $response->Credentials->AccessKeySecret, + $response->Credentials->SecurityToken + ); + $config = array( + 'region' => self::getRegion(), + 'endpoint' => self::getEndpoint(), + 'provider' => $provider, + 'signatureVersion' => self::getSignVersion() + ); + + if ($conf != null) { + foreach ($conf as $key => $value) { + $config[$key] = $value; + } + } + + $ossStsClient = new OssClient($config); + + } catch (OssException $e) { + printf(__FUNCTION__ . "creating OssClient instance: FAILED\n"); + printf($e->getMessage() . "\n"); + return null; + } + return $ossStsClient; + } + + public static function getBucketName() + { + $name = getenv('OSS_BUCKET'); + if (empty($name)) { + return "skyranch-php-test"; + } + return $name; + } + + public static function getRegion() + { + return getenv('OSS_TEST_REGION'); + } + + public static function getEndpoint() + { + return getenv('OSS_TEST_ENDPOINT'); + } + + public static function getCallbackUrl() + { + return getenv('OSS_TEST_CALLBACK_URL'); + } + + public static function getPayerUid() + { + return getenv('OSS_TEST_PAYER_UID'); + } + + public static function getPayerAccessKeyId() + { + return getenv('OSS_TEST_PAYER_ACCESS_KEY_ID'); + } + + public static function getPayerAccessKeySecret() + { + return getenv('OSS_TEST_PAYER_ACCESS_KEY_SECRET'); + } + + public static function getSignVersion() + { + return OssClient::OSS_SIGNATURE_VERSION_V1; + } + + public static function getPathStyleBucket() + { + return getenv('OSS_TEST_PATHSTYLE_BUCKET'); + } + + /** + * Tool method, create a bucket + */ + public static function createBucket() + { + $ossClient = self::getOssClient(); + if (is_null($ossClient)) exit(1); + $bucket = self::getBucketName(); + $acl = OssClient::OSS_ACL_TYPE_PUBLIC_READ; + try { + $ossClient->createBucket($bucket, $acl); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); + } + + /** + * Wait for bucket meta sync + */ + public static function waitMetaSync() + { + if (getenv('TRAVIS')) { + sleep(10); + } + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/ContentTypeTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/ContentTypeTest.php new file mode 100644 index 0000000..98c5998 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/ContentTypeTest.php @@ -0,0 +1,123 @@ +ossClient; + $headers = $client->getObjectMeta($bucket, $object); + return $headers['content-type']; + } + + public function testByFileName() + { + $client = $this->ossClient; + $bucket = $this->bucket; + + $file = __DIR__ . DIRECTORY_SEPARATOR . 'x.html'; + $object = 'test/x'; + OssUtil::generateFile($file, 5); + + $client->uploadFile($bucket, $object, $file); + $type = $this->getContentType($bucket, $object); + $this->assertEquals('text/html', $type); + unlink($file); + + $file = __DIR__ . DIRECTORY_SEPARATOR . 'x.json'; + $object = 'test/y'; + OssUtil::generateFile($file, 100 * 1024); + + $client->multiuploadFile($bucket, $object, $file, array('partSize' => 100)); + $type = $this->getContentType($bucket, $object); + unlink($file); + $this->assertEquals('application/json', $type); + } + + public function testByObjectKey() + { + $client = $this->ossClient; + $bucket = $this->bucket; + + $object = "test/x.txt"; + $client->putObject($bucket, $object, "hello world"); + $type = $this->getContentType($bucket, $object); + $this->assertEquals('text/plain', $type); + + $file = __DIR__ . DIRECTORY_SEPARATOR . 'x.html'; + $object = 'test/x.txt'; + OssUtil::generateFile($file, 5); + $client->uploadFile($bucket, $object, $file); + unlink($file); + $type = $this->getContentType($bucket, $object); + $this->assertEquals('text/html', $type); + + $file = __DIR__ . DIRECTORY_SEPARATOR . 'x.none'; + $object = 'test/x.txt'; + OssUtil::generateFile($file, 5); + $client->uploadFile($bucket, $object, $file); + unlink($file); + $type = $this->getContentType($bucket, $object); + $this->assertEquals('text/plain', $type); + + $file = __DIR__ . DIRECTORY_SEPARATOR . 'x.mp3'; + OssUtil::generateFile($file, 1024 * 100); + $object = 'test/y.json'; + $client->multiuploadFile($bucket, $object, $file, array('partSize' => 100)); + unlink($file); + $type = $this->getContentType($bucket, $object); + $this->assertEquals('audio/mpeg', $type); + $file = __DIR__ . DIRECTORY_SEPARATOR . 'x.none'; + OssUtil::generateFile($file, 1024 * 100); + $object = 'test/y.json'; + $client->multiuploadFile($bucket, $object, $file, array('partSize' => 100)); + unlink($file); + $type = $this->getContentType($bucket, $object); + $this->assertEquals('application/json', $type); + } + + public function testByUser() + { + $client = $this->ossClient; + $bucket = $this->bucket; + + $object = "test/x.txt"; + $client->putObject($bucket, $object, "hello world", array( + 'Content-Type' => 'text/html' + )); + $type = $this->getContentType($bucket, $object); + + $this->assertEquals('text/html', $type); + + $file = __DIR__ . DIRECTORY_SEPARATOR . 'x.html'; + $object = 'test/x'; + OssUtil::generateFile($file, 100); + + $client->uploadFile($bucket, $object, $file, array(OssClient::OSS_HEADERS => array( + 'Content-Type' => 'application/json' + ))); + unlink($file); + $type = $this->getContentType($bucket, $object); + + $this->assertEquals('application/json', $type); + + $file = __DIR__ . DIRECTORY_SEPARATOR . 'x.json'; + $object = 'test/y'; + OssUtil::generateFile($file, 100 * 1024); + + $client->multiuploadFile($bucket, $object, $file, array( + 'partSize' => 100, + 'Content-Type' => 'audio/mpeg' + )); + unlink($file); + $type = $this->getContentType($bucket, $object); + $this->assertEquals('audio/mpeg', $type); + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/CopyObjectResult.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/CopyObjectResult.php new file mode 100644 index 0000000..7d1b0fb --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/CopyObjectResult.php @@ -0,0 +1,52 @@ + + + Fri, 24 Feb 2012 07:18:48 GMT + "5B3C1A2E053D763E1B002CC607C5A0FE" + +BBBB; + + public function testNullResponse() + { + $response = null; + try { + new CopyObjectResult($response); + $this->assertFalse(true); + } catch (OssException $e) { + $this->assertEquals('raw response is null', $e->getMessage()); + } + } + + public function testOkResponse() + { + $header= array(); + $response = new ResponseCore($header, $this->body, 200); + $result = new CopyObjectResult($response); + $data = $result->getData(); + $this->assertTrue($result->isOK()); + $this->assertEquals("Fri, 24 Feb 2012 07:18:48 GMT", $data[0]); + $this->assertEquals("\"5B3C1A2E053D763E1B002CC607C5A0FE\"", $data[1]); + } + + public function testFailResponse() + { + $response = new ResponseCore(array(), "", 404); + try { + new CopyObjectResult($response); + $this->assertFalse(true); + } catch (OssException $e) { + $this->assertFalse(false); + } + } + +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/CorsConfigTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/CorsConfigTest.php new file mode 100644 index 0000000..42a46fa --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/CorsConfigTest.php @@ -0,0 +1,211 @@ + + + +http://www.b.com +http://www.a.com +http://www.a.com +GET +PUT +POST +x-oss-test +x-oss-test2 +x-oss-test2 +x-oss-test3 +x-oss-test1 +x-oss-test1 +x-oss-test2 +10 + + +http://www.b.com +GET +x-oss-test +x-oss-test1 +110 + +false + +BBBB; + + private $validXml2 = << + + +http://www.b.com +http://www.a.com +http://www.a.com +GET +PUT +POST +x-oss-test +x-oss-test2 +x-oss-test2 +x-oss-test3 +x-oss-test1 +x-oss-test1 +x-oss-test2 +10 + + +BBBB; + + private $validXml3 = << + + +http://www.b.com +http://www.a.com +http://www.a.com +GET +PUT +POST +x-oss-test +10 + +true + +BBBB; + + public function testParseValidXml() + { + $corsConfig = new CorsConfig(); + $corsConfig->parseFromXml($this->validXml); + $this->assertEquals($this->cleanXml($this->validXml), $this->cleanXml($corsConfig->serializeToXml())); + $this->assertNotNull($corsConfig->getRules()); + $rules = $corsConfig->getRules(); + $this->assertNotNull($rules[0]->getAllowedHeaders()); + $this->assertNotNull($rules[0]->getAllowedMethods()); + $this->assertNotNull($rules[0]->getAllowedOrigins()); + $this->assertNotNull($rules[0]->getExposeHeaders()); + $this->assertNotNull($rules[0]->getMaxAgeSeconds()); + } + + public function testParseValidXml2() + { + $corsConfig = new CorsConfig(); + $corsConfig->parseFromXml($this->validXml2); + $this->assertEquals($this->cleanXml($this->validXml2), $this->cleanXml($corsConfig->serializeToXml())); + } + + public function testParseValidXml3() + { + $corsConfig = new CorsConfig(); + $corsConfig->parseFromXml($this->validXml3); + $this->assertEquals($this->cleanXml($this->validXml3), $this->cleanXml($corsConfig->serializeToXml())); + $this->assertTrue($corsConfig->getResponseVary()); + } + + public function testResponseValidXml3() + { + $response = new ResponseCore(array(), $this->validXml, 200); + $result = new GetCorsResult($response); + $this->assertTrue($result->isOK()); + $this->assertNotNull($result->getData()); + $this->assertNotNull($result->getRawResponse()); + $this->assertNotNull($result->getRawResponse()->body); + $corsConfig = $result->getData(); + $this->assertEquals($this->cleanXml($this->validXml), $this->cleanXml($corsConfig->serializeToXml())); + $this->assertNotNull($corsConfig->getRules()); + $rules = $corsConfig->getRules(); + $this->assertNotNull($rules[0]->getAllowedHeaders()); + $this->assertNotNull($rules[0]->getAllowedMethods()); + $this->assertNotNull($rules[0]->getAllowedOrigins()); + $this->assertNotNull($rules[0]->getExposeHeaders()); + $this->assertNotNull($rules[0]->getMaxAgeSeconds()); + $this->assertFalse($corsConfig->getResponseVary()); + + } + + public function testResponseValidXml4() + { + $response = new ResponseCore(array(), $this->validXml3, 200); + $result = new GetCorsResult($response); + $this->assertTrue($result->isOK()); + $this->assertNotNull($result->getData()); + $this->assertNotNull($result->getRawResponse()); + $this->assertNotNull($result->getRawResponse()->body); + $corsConfig = $result->getData(); + $this->assertEquals($this->cleanXml($this->validXml3), $this->cleanXml($corsConfig->serializeToXml())); + $this->assertNotNull($corsConfig->getRules()); + $rules = $corsConfig->getRules(); + $this->assertNotNull($rules[0]->getAllowedHeaders()); + $this->assertNotNull($rules[0]->getAllowedMethods()); + $this->assertNotNull($rules[0]->getAllowedOrigins()); + $this->assertNotNull($rules[0]->getExposeHeaders()); + $this->assertNotNull($rules[0]->getMaxAgeSeconds()); + $this->assertTrue($corsConfig->getResponseVary()); + + } + + public function testCreateCorsConfigFromMoreThan10Rules() + { + $corsConfig = new CorsConfig(); + $rule = new CorsRule(); + for ($i = 0; $i < CorsConfig::OSS_MAX_RULES; $i += 1) { + $corsConfig->addRule($rule); + } + try { + $corsConfig->addRule($rule); + $this->assertFalse(true); + } catch (OssException $e) { + $this->assertEquals($e->getMessage(), "num of rules in the config exceeds self::OSS_MAX_RULES: " . strval(CorsConfig::OSS_MAX_RULES)); + } + } + + public function testCreateCorsConfigParamAbsent() + { + $corsConfig = new CorsConfig(); + $rule = new CorsRule(); + $corsConfig->addRule($rule); + + try { + $xml = $corsConfig->serializeToXml(); + $this->assertFalse(true); + } catch (OssException $e) { + $this->assertEquals($e->getMessage(), "maxAgeSeconds is not set in the Rule"); + } + } + + public function testCreateCorsConfigFromScratch() + { + $corsConfig = new CorsConfig(); + $rule = new CorsRule(); + $rule->addAllowedHeader("x-oss-test"); + $rule->addAllowedHeader("x-oss-test2"); + $rule->addAllowedHeader("x-oss-test2"); + $rule->addAllowedHeader("x-oss-test3"); + $rule->addAllowedOrigin("http://www.b.com"); + $rule->addAllowedOrigin("http://www.a.com"); + $rule->addAllowedOrigin("http://www.a.com"); + $rule->addAllowedMethod("GET"); + $rule->addAllowedMethod("PUT"); + $rule->addAllowedMethod("POST"); + $rule->addExposeHeader("x-oss-test1"); + $rule->addExposeHeader("x-oss-test1"); + $rule->addExposeHeader("x-oss-test2"); + $rule->setMaxAgeSeconds(10); + $corsConfig->addRule($rule); + $this->assertEquals($this->cleanXml($this->validXml2), $this->cleanXml($corsConfig->serializeToXml())); + $this->assertEquals($this->cleanXml($this->validXml2), $this->cleanXml(strval($corsConfig))); + } + + private function cleanXml($xml) + { + return str_replace("\n", "", str_replace("\r", "", $xml)); + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/DeleteObjectVersionsResultTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/DeleteObjectVersionsResultTest.php new file mode 100644 index 0000000..2419e55 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/DeleteObjectVersionsResultTest.php @@ -0,0 +1,187 @@ + + + + demo.jpg + CAEQNRiBgICEoPiC0BYiIGMxZWJmYmMzYjE0OTQ0ZmZhYjgzNzkzYjc2NjZk**** + true + 111111 + + +BBBB; + + private $validXml1 = << + + + multipart.data + CAEQNRiBgIDyz.6C0BYiIGQ2NWEwNmVhNTA3ZTQ3MzM5ODliYjM1ZTdjYjA4**** + + +BBBB; + + private $validXml2 = << + + + multipart.data + true + CAEQMhiBgIDXiaaB0BYiIGQzYmRkZGUxMTM1ZDRjOTZhNjk4YjRjMTAyZjhl**** + + + test.jpg + true + CAEQMhiBgIDB3aWB0BYiIGUzYTA3YzliMzVmNzRkZGM5NjllYTVlMjYyYWEy**** + + +BBBB; + + private $validXml3 = << + + + multipart.data + + + test.jpg + + + demo.jpg + + +BBBB; + + private $validXml4 = << + + url + + multipart%2F.data + + + test%2F.jpg + + + demo%2F.jpg + + +BBBB; + + private $invalidXml = << + + +BBBB; + + public function testParseValidXml() + { + $response = new ResponseCore(array(), $this->validXml, 200); + $result = new DeleteObjectVersionsResult($response); + $this->assertTrue($result->isOK()); + $this->assertNotNull($result->getData()); + $this->assertNotNull($result->getRawResponse()); + $list = $result->getData(); + $this->assertEquals(1, count($list)); + $this->assertEquals('demo.jpg', $list[0]->getKey()); + $this->assertEquals('CAEQNRiBgICEoPiC0BYiIGMxZWJmYmMzYjE0OTQ0ZmZhYjgzNzkzYjc2NjZk****', $list[0]->getVersionId()); + $this->assertEquals('true', $list[0]->getDeleteMarker()); + $this->assertEquals('111111', $list[0]->getDeleteMarkerVersionId()); + + + $response = new ResponseCore(array(), $this->validXml1, 200); + $result = new DeleteObjectVersionsResult($response); + $this->assertTrue($result->isOK()); + $this->assertNotNull($result->getData()); + $this->assertNotNull($result->getRawResponse()); + $list = $result->getData(); + $this->assertEquals(1, count($list)); + $this->assertEquals('multipart.data', $list[0]->getKey()); + $this->assertEquals('CAEQNRiBgIDyz.6C0BYiIGQ2NWEwNmVhNTA3ZTQ3MzM5ODliYjM1ZTdjYjA4****', $list[0]->getVersionId()); + $this->assertEquals('', $list[0]->getDeleteMarker()); + $this->assertEquals('', $list[0]->getDeleteMarkerVersionId()); + + $response = new ResponseCore(array(), $this->validXml2, 200); + $result = new DeleteObjectVersionsResult($response); + $this->assertTrue($result->isOK()); + $this->assertNotNull($result->getData()); + $this->assertNotNull($result->getRawResponse()); + $list = $result->getData(); + $this->assertEquals(2, count($list)); + $this->assertEquals('multipart.data', $list[0]->getKey()); + $this->assertEquals('', $list[0]->getVersionId()); + $this->assertEquals('true', $list[0]->getDeleteMarker()); + $this->assertEquals('CAEQMhiBgIDXiaaB0BYiIGQzYmRkZGUxMTM1ZDRjOTZhNjk4YjRjMTAyZjhl****', $list[0]->getDeleteMarkerVersionId()); + $this->assertEquals('test.jpg', $list[1]->getKey()); + $this->assertEquals('', $list[1]->getVersionId()); + $this->assertEquals('true', $list[1]->getDeleteMarker()); + $this->assertEquals('CAEQMhiBgIDB3aWB0BYiIGUzYTA3YzliMzVmNzRkZGM5NjllYTVlMjYyYWEy****', $list[1]->getDeleteMarkerVersionId()); + + + $response = new ResponseCore(array(), $this->validXml3, 200); + $result = new DeleteObjectVersionsResult($response); + $this->assertTrue($result->isOK()); + $this->assertNotNull($result->getData()); + $this->assertNotNull($result->getRawResponse()); + $list = $result->getData(); + $this->assertEquals(3, count($list)); + $this->assertEquals('multipart.data', $list[0]->getKey()); + $this->assertEquals('', $list[0]->getVersionId()); + $this->assertEquals('', $list[0]->getDeleteMarker()); + $this->assertEquals('', $list[0]->getDeleteMarkerVersionId()); + $this->assertEquals('test.jpg', $list[1]->getKey()); + $this->assertEquals('', $list[1]->getVersionId()); + $this->assertEquals('', $list[1]->getDeleteMarker()); + $this->assertEquals('', $list[1]->getDeleteMarkerVersionId()); + $this->assertEquals('demo.jpg', $list[2]->getKey()); + $this->assertEquals('', $list[2]->getVersionId()); + $this->assertEquals('', $list[2]->getDeleteMarker()); + $this->assertEquals('', $list[2]->getDeleteMarkerVersionId()); + + $response = new ResponseCore(array(), $this->validXml4, 200); + $result = new DeleteObjectVersionsResult($response); + $this->assertTrue($result->isOK()); + $this->assertNotNull($result->getData()); + $this->assertNotNull($result->getRawResponse()); + $list = $result->getData(); + $this->assertEquals(3, count($list)); + $this->assertEquals('multipart/.data', $list[0]->getKey()); + $this->assertEquals('', $list[0]->getVersionId()); + $this->assertEquals('', $list[0]->getDeleteMarker()); + $this->assertEquals('', $list[0]->getDeleteMarkerVersionId()); + $this->assertEquals('test/.jpg', $list[1]->getKey()); + $this->assertEquals('', $list[1]->getVersionId()); + $this->assertEquals('', $list[1]->getDeleteMarker()); + $this->assertEquals('', $list[1]->getDeleteMarkerVersionId()); + $this->assertEquals('demo/.jpg', $list[2]->getKey()); + $this->assertEquals('', $list[2]->getVersionId()); + $this->assertEquals('', $list[2]->getDeleteMarker()); + $this->assertEquals('', $list[2]->getDeleteMarkerVersionId()); + } + + public function testParseNullXml() + { + $response = new ResponseCore(array(), "", 200); + $result = new DeleteObjectVersionsResult($response); + $list = $result->getData(); + $this->assertEquals(0, count($list)); + } + + public function testParseInvalidXml() + { + $response = new ResponseCore(array(), $this->invalidXml, 200); + $result = new DeleteObjectVersionsResult($response); + $list = $result->getData(); + $this->assertEquals(0, count($list)); + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/ExistResultTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/ExistResultTest.php new file mode 100644 index 0000000..f9c552e --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/ExistResultTest.php @@ -0,0 +1,38 @@ +assertTrue($result->isOK()); + $this->assertEquals($result->getData(), true); + } + + public function testParseInvalid404() + { + $response = new ResponseCore(array(), "", 404); + $result = new ExistResult($response); + $this->assertTrue($result->isOK()); + $this->assertEquals($result->getData(), false); + } + + public function testInvalidResponse() + { + $response = new ResponseCore(array(), "", 300); + try { + new ExistResult($response); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + } + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetBucketEncryptionResultTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetBucketEncryptionResultTest.php new file mode 100644 index 0000000..87e4996 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetBucketEncryptionResultTest.php @@ -0,0 +1,95 @@ + + + + AES256 + + + +BBBB; + + private $validXml1 = << + + + KMS + kms-id + + +BBBB; + + private $validXml2 = << + + +KMS + + +BBBB; + + private $invalidXml = << + + +BBBB; + + public function testParseValidXml() + { + $response = new ResponseCore(array(), $this->validXml, 200); + $result = new GetBucketEncryptionResult($response); + $this->assertTrue($result->isOK()); + $this->assertNotNull($result->getData()); + $this->assertNotNull($result->getRawResponse()); + $config = $result->getData(); + $this->assertEquals("AES256", $config->getSSEAlgorithm()); + $this->assertEquals("", $config->getKMSMasterKeyID()); + + + $response = new ResponseCore(array(), $this->validXml1, 200); + $result = new GetBucketEncryptionResult($response); + $this->assertTrue($result->isOK()); + $this->assertNotNull($result->getData()); + $this->assertNotNull($result->getRawResponse()); + $config = $result->getData(); + $this->assertEquals("KMS", $config->getSSEAlgorithm()); + $this->assertEquals("kms-id", $config->getKMSMasterKeyID()); + + $response = new ResponseCore(array(), $this->validXml2, 200); + $result = new GetBucketEncryptionResult($response); + $this->assertTrue($result->isOK()); + $this->assertNotNull($result->getData()); + $this->assertNotNull($result->getRawResponse()); + $config = $result->getData(); + $this->assertEquals("KMS", $config->getSSEAlgorithm()); + $this->assertEquals(null, $config->getKMSMasterKeyID()); + } + + public function testParseNullXml() + { + $response = new ResponseCore(array(), "", 200); + $result = new GetBucketEncryptionResult($response); + $config = $result->getData(); + $this->assertEquals(null, $config->getSSEAlgorithm()); + $this->assertEquals(null, $config->getKMSMasterKeyID()); + } + + public function testParseInvalidXml() + { + $response = new ResponseCore(array(), $this->invalidXml, 200); + $result = new GetBucketEncryptionResult($response); + $config = $result->getData(); + $this->assertEquals(null, $config->getSSEAlgorithm()); + $this->assertEquals(null, $config->getKMSMasterKeyID()); + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetBucketRequestPaymentResultTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetBucketRequestPaymentResultTest.php new file mode 100644 index 0000000..227028b --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetBucketRequestPaymentResultTest.php @@ -0,0 +1,66 @@ + + + Requester + +BBBB; + + private $validXml2 = << + + BucketOwner + +BBBB; + + private $invalidXml = << + + +BBBB; + + public function testParseValidXml() + { + $response = new ResponseCore(array(), $this->validXml, 200); + $result = new GetBucketRequestPaymentResult($response); + $this->assertTrue($result->isOK()); + $this->assertNotNull($result->getData()); + $this->assertNotNull($result->getRawResponse()); + $payer = $result->getData(); + $this->assertEquals("Requester", $payer); + + $response = new ResponseCore(array(), $this->validXml2, 200); + $result = new GetBucketRequestPaymentResult($response); + $this->assertTrue($result->isOK()); + $this->assertNotNull($result->getData()); + $this->assertNotNull($result->getRawResponse()); + $payer = $result->getData(); + $this->assertEquals("BucketOwner", $payer); + } + + public function testParseNullXml() + { + $response = new ResponseCore(array(), "", 200); + $result = new GetBucketRequestPaymentResult($response); + $payer = $result->getData(); + $this->assertEquals(null, $payer); + } + + public function testParseInvalidXml() + { + $response = new ResponseCore(array(), $this->invalidXml, 200); + $result = new GetBucketRequestPaymentResult($response); + $payer = $result->getData(); + $this->assertEquals(null, $payer); + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetBucketStatResultTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetBucketStatResultTest.php new file mode 100644 index 0000000..74cb04a --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetBucketStatResultTest.php @@ -0,0 +1,85 @@ + + + 1600 + 230 + 40 + 4 + 1643341269 + 430 + 66 + 2359296 + 360 + 54 + 2949120 + 450 + 74 + 2359296 + 360 + 36 + +BBBB; + +private $invalidXml = << + + +BBBB; + + public function testParseValidXml() + { + $response = new ResponseCore(array(), $this->validXml, 200); + $result = new GetBucketStatResult($response); + $this->assertTrue($result->isOK()); + $this->assertNotNull($result->getData()); + $this->assertNotNull($result->getRawResponse()); + $stat = $result->getData(); + $this->assertEquals(1600, $stat->getStorage()); + $this->assertEquals(230, $stat->getObjectCount()); + $this->assertEquals(40, $stat->getMultipartUploadCount()); + $this->assertEquals(4, $stat->getLiveChannelCount()); + $this->assertEquals(1643341269, $stat->getLastModifiedTime()); + $this->assertEquals(430, $stat->getStandardStorage()); + $this->assertEquals(66, $stat->getStandardObjectCount()); + $this->assertEquals(2359296, $stat->getInfrequentAccessStorage()); + $this->assertEquals(360, $stat->getInfrequentAccessRealStorage()); + $this->assertEquals(54, $stat->getInfrequentAccessObjectCount()); + $this->assertEquals(2949120, $stat->getArchiveStorage()); + $this->assertEquals(450, $stat->getArchiveRealStorage()); + $this->assertEquals(74, $stat->getArchiveObjectCount()); + $this->assertEquals(2359296, $stat->getColdArchiveStorage()); + $this->assertEquals(360, $stat->getColdArchiveRealStorage()); + $this->assertEquals(36, $stat->getColdArchiveObjectCount()); + } + + public function testParseNullXml() + { + $response = new ResponseCore(array(), "", 200); + $result = new GetBucketStatResult($response); + $stat = $result->getData(); + $this->assertEquals(0, $stat->getStorage()); + $this->assertEquals(0, $stat->getObjectCount()); + $this->assertEquals(0, $stat->getMultipartUploadCount()); + } + + public function testParseInvalidXml() + { + $response = new ResponseCore(array(), $this->invalidXml, 200); + $result = new GetBucketStatResult($response); + $stat = $result->getData(); + $this->assertEquals(0, $stat->getStorage()); + $this->assertEquals(0, $stat->getObjectCount()); + $this->assertEquals(0, $stat->getMultipartUploadCount()); + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetBucketTagsResultTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetBucketTagsResultTest.php new file mode 100644 index 0000000..b292309 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetBucketTagsResultTest.php @@ -0,0 +1,77 @@ + + + + + testa + value1-test + + + testb + value2-test + + + +BBBB; + + private $invalidXml = << + + +BBBB; + + private $invalidXml2 = << + + + + +BBBB; + + public function testParseValidXml() + { + $response = new ResponseCore(array(), $this->validXml, 200); + $result = new GetBucketTagsResult($response); + $this->assertTrue($result->isOK()); + $this->assertNotNull($result->getData()); + $this->assertNotNull($result->getRawResponse()); + $config = $result->getData(); + $this->assertEquals(2, count($config->getTags())); + $this->assertEquals("testa", $config->getTags()[0]->getKey()); + $this->assertEquals("value1-test", $config->getTags()[0]->getValue()); + $this->assertEquals("testb", $config->getTags()[1]->getKey()); + $this->assertEquals("value2-test", $config->getTags()[1]->getValue()); + } + + public function testParseNullXml() + { + $response = new ResponseCore(array(), "", 200); + $result = new GetBucketTagsResult($response); + $config = $result->getData(); + $this->assertEquals(0, count($config->getTags())); + + } + + public function testParseInvalidXml() + { + $response = new ResponseCore(array(), $this->invalidXml, 200); + $result = new GetBucketTagsResult($response); + $config = $result->getData(); + $this->assertEquals(0, count($config->getTags())); + + $response = new ResponseCore(array(), $this->invalidXml2, 200); + $result = new GetBucketTagsResult($response); + $config = $result->getData(); + $this->assertEquals(0, count($config->getTags())); + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetBucketTransferAccelerationResultTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetBucketTransferAccelerationResultTest.php new file mode 100644 index 0000000..56a3dd4 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetBucketTransferAccelerationResultTest.php @@ -0,0 +1,61 @@ + +true + +BBBB; + private $validXml1 = << +false + +BBBB; + + private $invalidXml2 = << + + +BBBB; + + public function testParseValidXml() + { + $response = new ResponseCore(array(), $this->validXml, 200); + $result = new GetBucketTransferAccelerationResult($response); + $this->assertTrue($result->isOK()); + $this->assertNotNull($result->getData()); + $this->assertNotNull($result->getRawResponse()); + $enabled = $result->getData(); + $this->assertEquals(true, $enabled); + } + + public function testParseValidXml1() + { + $response = new ResponseCore(array(), $this->validXml1, 200); + $result = new GetBucketTransferAccelerationResult($response); + $this->assertTrue($result->isOK()); + $this->assertNotNull($result->getData()); + $this->assertNotNull($result->getRawResponse()); + $enabled = $result->getData(); + $this->assertEquals(false, $enabled); + } + + public function testParseInvalidXml2() + { + $response = new ResponseCore(array(), $this->invalidXml2, 200); + $result = new GetBucketTransferAccelerationResult($response); + $this->assertTrue($result->isOK()); + $this->assertNotNull($result->getData()); + $this->assertNotNull($result->getRawResponse()); + $this->assertNotNull($result->getRawResponse()->body); + $enabled = $result->getData(); + $this->assertEquals(false, $enabled); + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetBucketWormResultTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetBucketWormResultTest.php new file mode 100644 index 0000000..3bb90da --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetBucketWormResultTest.php @@ -0,0 +1,84 @@ + + +ID1 +Locked +1 +2018-08-14T15:50:32 + +BBBB; + + private $validXml2 = << + + ID2 + InProgress + 10 + 2018-09-14T15:50:32 + +BBBB; + + private $invalidXml = << + + +BBBB; + + public function testParseValidXml() + { + $response = new ResponseCore(array(), $this->validXml, 200); + $result = new GetBucketWormResult($response); + $this->assertTrue($result->isOK()); + $this->assertNotNull($result->getData()); + $this->assertNotNull($result->getRawResponse()); + $config = $result->getData(); + $this->assertEquals("ID1", $config->getWormId()); + $this->assertEquals("Locked", $config->getState()); + $this->assertEquals(1, $config->getDay()); + $this->assertEquals("2018-08-14T15:50:32", $config->getCreationDate()); + + $response = new ResponseCore(array(), $this->validXml2, 200); + $result = new GetBucketWormResult($response); + $this->assertTrue($result->isOK()); + $this->assertNotNull($result->getData()); + $this->assertNotNull($result->getRawResponse()); + $config = $result->getData(); + $this->assertEquals("ID2", $config->getWormId()); + $this->assertEquals("InProgress", $config->getState()); + $this->assertEquals(10, $config->getDay()); + $this->assertEquals("2018-09-14T15:50:32", $config->getCreationDate()); + } + + public function testParseNullXml() + { + $response = new ResponseCore(array(), "", 200); + $result = new GetBucketWormResult($response); + $config = $result->getData(); + $this->assertEquals("", $config->getWormId()); + $this->assertEquals("", $config->getState()); + $this->assertEquals(0, $config->getDay()); + $this->assertEquals("", $config->getCreationDate()); + } + + public function testParseInvalidXml() + { + $response = new ResponseCore(array(), $this->invalidXml, 200); + $result = new GetBucketWormResult($response); + $config = $result->getData(); + $this->assertEquals("", $config->getWormId()); + $this->assertEquals("", $config->getState()); + $this->assertEquals(0, $config->getDay()); + $this->assertEquals("", $config->getCreationDate()); + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetCorsResultTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetCorsResultTest.php new file mode 100644 index 0000000..76d87dc --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetCorsResultTest.php @@ -0,0 +1,67 @@ + + + +http://www.b.com +http://www.a.com +http://www.a.com +GET +PUT +POST +x-oss-test +x-oss-test2 +x-oss-test2 +x-oss-test3 +x-oss-test1 +x-oss-test1 +x-oss-test2 +10 + + +http://www.b.com +GET +x-oss-test +x-oss-test1 +110 + + +BBBB; + + public function testParseValidXml() + { + $response = new ResponseCore(array(), $this->validXml, 200); + $result = new GetCorsResult($response); + $this->assertTrue($result->isOK()); + $this->assertNotNull($result->getData()); + $this->assertNotNull($result->getRawResponse()); + $corsConfig = $result->getData(); + $this->assertEquals($this->cleanXml($this->validXml), $this->cleanXml($corsConfig->serializeToXml())); + } + + private function cleanXml($xml) + { + return str_replace("\n", "", str_replace("\r", "", $xml)); + } + + public function testInvalidResponse() + { + $response = new ResponseCore(array(), $this->validXml, 300); + try { + $result = new GetCorsResult($response); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + } + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetLifecycleResultTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetLifecycleResultTest.php new file mode 100644 index 0000000..e6d9a72 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetLifecycleResultTest.php @@ -0,0 +1,59 @@ + + + +delete obsoleted files +obsoleted/ +Enabled +3 + + +delete temporary files +temporary/ +Enabled +2022-10-12T00:00:00.000Z +2022-10-12T00:00:00.000Z + + +BBBB; + + public function testParseValidXml() + { + $response = new ResponseCore(array(), $this->validXml, 200); + $result = new GetLifecycleResult($response); + $this->assertTrue($result->isOK()); + $this->assertNotNull($result->getData()); + $this->assertNotNull($result->getRawResponse()); + $lifecycleConfig = $result->getData(); + $this->assertEquals($this->cleanXml($this->validXml), $this->cleanXml($lifecycleConfig->serializeToXml())); + } + + private function cleanXml($xml) + { + return str_replace("\n", "", str_replace("\r", "", $xml)); + } + + public function testInvalidResponse() + { + $response = new ResponseCore(array(), $this->validXml, 300); + try { + $result = new GetLifecycleResult($response); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + } + } + +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetLoggingResultTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetLoggingResultTest.php new file mode 100644 index 0000000..35f7436 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetLoggingResultTest.php @@ -0,0 +1,51 @@ + + + +TargetBucket +TargetPrefix + + +BBBB; + + public function testParseValidXml() + { + $response = new ResponseCore(array(), $this->validXml, 200); + $result = new GetLoggingResult($response); + $this->assertTrue($result->isOK()); + $this->assertNotNull($result->getData()); + $this->assertNotNull($result->getRawResponse()); + $loggingConfig = $result->getData(); + $this->assertEquals($this->cleanXml($this->validXml), $this->cleanXml($loggingConfig->serializeToXml())); + $this->assertEquals("TargetBucket", $loggingConfig->getTargetBucket()); + $this->assertEquals("TargetPrefix", $loggingConfig->getTargetPrefix()); + } + + private function cleanXml($xml) + { + return str_replace("\n", "", str_replace("\r", "", $xml)); + } + + public function testInvalidResponse() + { + $response = new ResponseCore(array(), $this->validXml, 300); + try { + $result = new GetLoggingResult($response); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + } + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetRefererResultTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetRefererResultTest.php new file mode 100644 index 0000000..774aae9 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetRefererResultTest.php @@ -0,0 +1,51 @@ + + +true + +http://www.aliyun.com +https://www.aliyun.com +http://www.*.com +https://www.?.aliyuncs.com + + +BBBB; + + public function testParseValidXml() + { + $response = new ResponseCore(array(), $this->validXml, 200); + $result = new GetRefererResult($response); + $this->assertTrue($result->isOK()); + $this->assertNotNull($result->getData()); + $this->assertNotNull($result->getRawResponse()); + $refererConfig = $result->getData(); + $this->assertEquals($this->cleanXml($this->validXml), $this->cleanXml($refererConfig->serializeToXml())); + } + + private function cleanXml($xml) + { + return str_replace("\n", "", str_replace("\r", "", $xml)); + } + + public function testInvalidResponse() + { + $response = new ResponseCore(array(), $this->validXml, 300); + try { + $result = new GetRefererResult($response); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + } + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetWebsiteResultTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetWebsiteResultTest.php new file mode 100644 index 0000000..d853306 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetWebsiteResultTest.php @@ -0,0 +1,50 @@ + + + +index.html + + +errorDocument.html + + +BBBB; + + public function testParseValidXml() + { + $response = new ResponseCore(array(), $this->validXml, 200); + $result = new GetWebsiteResult($response); + $this->assertTrue($result->isOK()); + $this->assertNotNull($result->getData()); + $this->assertNotNull($result->getRawResponse()); + $websiteConfig = $result->getData(); + $this->assertEquals($this->cleanXml($this->validXml), $this->cleanXml($websiteConfig->serializeToXml())); + } + + private function cleanXml($xml) + { + return str_replace("\n", "", str_replace("\r", "", $xml)); + } + + public function testInvalidResponse() + { + $response = new ResponseCore(array(), $this->validXml, 300); + try { + $result = new GetWebsiteResult($response); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + } + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/HeaderResultTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/HeaderResultTest.php new file mode 100644 index 0000000..9354422 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/HeaderResultTest.php @@ -0,0 +1,23 @@ + 'value'), "", 200); + $result = new HeaderResult($response); + $this->assertTrue($result->isOK()); + $this->assertTrue(is_array($result->getData())); + $data = $result->getData(); + $this->assertEquals($data['key'], 'value'); + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/HttpTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/HttpTest.php new file mode 100644 index 0000000..989644c --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/HttpTest.php @@ -0,0 +1,77 @@ +assertFalse($res->isOK()); + $this->assertTrue($res->isOK(500)); + } + + public function testGet() + { + $httpCore = new RequestCore("http://www.baidu.com"); + $httpResponse = $httpCore->send_request(); + $this->assertNotNull($httpResponse); + } + + public function testSetProxyAndTimeout() + { + $httpCore = new RequestCore("http://www.baidu.com"); + $httpCore->set_proxy("1.0.2.1:8888"); + $httpCore->connect_timeout = 1; + try { + $httpResponse = $httpCore->send_request(); + $this->assertTrue(false); + } catch (RequestCore_Exception $e) { + $this->assertTrue(true); + } + } + + public function testGetParseTrue() + { + $httpCore = new RequestCore("http://www.baidu.com"); + $httpCore->curlopts = array(CURLOPT_HEADER => true); + $url = $httpCore->send_request(true); + foreach ($httpCore->get_response_header() as $key => $value) { + $this->assertEquals($httpCore->get_response_header($key), $value); + } + $this->assertNotNull($url); + } + + public function testParseResponse() + { + $httpCore = new RequestCore("http://www.baidu.com"); + $response = $httpCore->send_request(); + $parsed = $httpCore->process_response(null, $response); + $this->assertNotNull($parsed); + } + + public function testExceptionGet() + { + $httpCore = null; + $exception = false; + try { + $httpCore = new RequestCore("http://www.notexistsitexx.com"); + $httpCore->set_body(""); + $httpCore->set_method("GET"); + $httpCore->connect_timeout = 10; + $httpCore->timeout = 10; + $res = $httpCore->send_request(); + } catch (RequestCore_Exception $e) { + $exception = true; + } + $this->assertTrue($exception); + } +} + + diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/InitiateMultipartUploadResultTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/InitiateMultipartUploadResultTest.php new file mode 100644 index 0000000..76b10a6 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/InitiateMultipartUploadResultTest.php @@ -0,0 +1,47 @@ + + + multipart_upload + multipart.data + 0004B9894A22E5B1888A1E29F8236E2D + +BBBB; + + private $invalidXml = << + + multipart_upload + multipart.data + +BBBB; + + + public function testParseValidXml() + { + $response = new ResponseCore(array(), $this->validXml, 200); + $result = new InitiateMultipartUploadResult($response); + $this->assertEquals("0004B9894A22E5B1888A1E29F8236E2D", $result->getData()); + } + + public function testParseInvalidXml() + { + $response = new ResponseCore(array(), $this->invalidXml, 200); + try { + $result = new InitiateMultipartUploadResult($response); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + } + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/LifecycleConfigTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/LifecycleConfigTest.php new file mode 100644 index 0000000..063e436 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/LifecycleConfigTest.php @@ -0,0 +1,130 @@ + + + +delete obsoleted files +obsoleted/ +Enabled +3 + + +delete temporary files +temporary/ +Enabled +2022-10-12T00:00:00.000Z +2022-10-12T00:00:00.000Z + + +BBBB; + + private $validLifecycle2 = << + +delete temporary files +temporary/ +Enabled +2022-10-12T00:00:00.000Z +2022-10-12T00:00:00.000Z + + +BBBB; + + private $nullLifecycle = << + +BBBB; + + public function testConstructValidConfig() + { + $lifecycleConfig = new LifecycleConfig(); + $actions = array(); + $actions[] = new LifecycleAction("Expiration", "Days", 3); + $lifecycleRule = new LifecycleRule("delete obsoleted files", "obsoleted/", "Enabled", $actions); + $lifecycleConfig->addRule($lifecycleRule); + $actions = array(); + $actions[] = new LifecycleAction("Expiration", "Date", '2022-10-12T00:00:00.000Z'); + $actions[] = new LifecycleAction("Expiration2", "Date", '2022-10-12T00:00:00.000Z'); + $lifecycleRule = new LifecycleRule("delete temporary files", "temporary/", "Enabled", $actions); + $lifecycleConfig->addRule($lifecycleRule); + try { + $lifecycleConfig->addRule(null); + $this->assertFalse(true); + } catch (OssException $e) { + $this->assertEquals('lifecycleRule is null', $e->getMessage()); + } + $this->assertEquals($this->cleanXml(strval($lifecycleConfig)), $this->cleanXml($this->validLifecycle)); + } + + public function testParseValidXml() + { + $lifecycleConfig = new LifecycleConfig(); + $lifecycleConfig->parseFromXml($this->validLifecycle); + $this->assertEquals($this->cleanXml($lifecycleConfig->serializeToXml()), $this->cleanXml($this->validLifecycle)); + $this->assertEquals(2, count($lifecycleConfig->getRules())); + $rules = $lifecycleConfig->getRules(); + $this->assertEquals('delete temporary files', $rules[1]->getId()); + } + + public function testParseValidXml2() + { + $lifecycleConfig = new LifecycleConfig(); + $lifecycleConfig->parseFromXml($this->validLifecycle2); + $this->assertEquals($this->cleanXml($lifecycleConfig->serializeToXml()), $this->cleanXml($this->validLifecycle2)); + $this->assertEquals(1, count($lifecycleConfig->getRules())); + $rules = $lifecycleConfig->getRules(); + $this->assertEquals('delete temporary files', $rules[0]->getId()); + } + + public function testParseNullXml() + { + $lifecycleConfig = new LifecycleConfig(); + $lifecycleConfig->parseFromXml($this->nullLifecycle); + $this->assertEquals($this->cleanXml($lifecycleConfig->serializeToXml()), $this->cleanXml($this->nullLifecycle)); + $this->assertEquals(0, count($lifecycleConfig->getRules())); + } + + public function testLifecycleRule() + { + $lifecycleRule = new LifecycleRule("x", "x", "x", array('x')); + $lifecycleRule->setId("id"); + $lifecycleRule->setPrefix("prefix"); + $lifecycleRule->setStatus("Enabled"); + $lifecycleRule->setActions(array()); + + $this->assertEquals('id', $lifecycleRule->getId()); + $this->assertEquals('prefix', $lifecycleRule->getPrefix()); + $this->assertEquals('Enabled', $lifecycleRule->getStatus()); + $this->assertEmpty($lifecycleRule->getActions()); + } + + public function testLifecycleAction() + { + $action = new LifecycleAction('x', 'x', 'x'); + $this->assertEquals($action->getAction(), 'x'); + $this->assertEquals($action->getTimeSpec(), 'x'); + $this->assertEquals($action->getTimeValue(), 'x'); + $action->setAction('y'); + $action->setTimeSpec('y'); + $action->setTimeValue('y'); + $this->assertEquals($action->getAction(), 'y'); + $this->assertEquals($action->getTimeSpec(), 'y'); + $this->assertEquals($action->getTimeValue(), 'y'); + } + + private function cleanXml($xml) + { + return str_replace("\n", "", str_replace("\r", "", $xml)); + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/ListBucketsResultTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/ListBucketsResultTest.php new file mode 100644 index 0000000..959b011 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/ListBucketsResultTest.php @@ -0,0 +1,168 @@ + + + + ut_test_put_bucket + ut_test_put_bucket + + + + oss-cn-hangzhou-a + xz02tphky6fjfiuc0 + 2014-05-15T11:18:32.000Z + + + oss-cn-hangzhou-a + xz02tphky6fjfiuc1 + 2014-05-15T11:18:32.000Z + + + +BBBB; + + private $nullXml = << + + + ut_test_put_bucket + ut_test_put_bucket + + + + +BBBB; + + + private $errorBody = <<< BBBB + + + NoSuchBucket + The specified bucket does not exist. + 566B870D207FB3044302EB0A + hello.oss-test.aliyun-inc.com + hello + +BBBB; + + private $xml = << + + + ut_test_put_bucket + ut_test_put_bucket + + + + 2015-12-17T18:12:43.000Z + oss-cn-shanghai.aliyuncs.com + oss-cn-shanghai-internal.aliyuncs.com + oss-cn-shanghai + app-base-oss + cn-shanghai + Standard + + + 2014-12-25T11:21:04.000Z + oss-cn-hangzhou.aliyuncs.com + oss-cn-hangzhou-internal.aliyuncs.com + oss-cn-hangzhou + atestleo23 + cn-hangzhou + IA + + + 2014-12-25T11:21:04.000Z + oss-cn-hangzhou + atestleo23 + + + +BBBB; + + public function testParseValidXml() + { + $response = new ResponseCore(array(), $this->validXml, 200); + $result = new ListBucketsResult($response); + $this->assertTrue($result->isOK()); + $this->assertNotNull($result->getData()); + $this->assertNotNull($result->getRawResponse()); + $bucketListInfo = $result->getData(); + $this->assertEquals(2, count($bucketListInfo->getBucketList())); + } + + public function testParseNullXml() + { + $response = new ResponseCore(array(), $this->nullXml, 200); + $result = new ListBucketsResult($response); + $this->assertTrue($result->isOK()); + $this->assertNotNull($result->getData()); + $this->assertNotNull($result->getRawResponse()); + $bucketListInfo = $result->getData(); + $this->assertEquals(0, count($bucketListInfo->getBucketList())); + } + + public function test403() + { + $errorHeader = array( + 'x-oss-request-id' => '1a2b-3c4d' + ); + $response = new ResponseCore($errorHeader, $this->errorBody, 403); + try { + new ListBucketsResult($response); + } catch (OssException $e) { + $this->assertEquals( + $e->getMessage(), + 'NoSuchBucket: The specified bucket does not exist. RequestId: 1a2b-3c4d'); + $this->assertEquals($e->getHTTPStatus(), '403'); + $this->assertEquals($e->getRequestId(), '1a2b-3c4d'); + $this->assertEquals($e->getErrorCode(), 'NoSuchBucket'); + $this->assertEquals($e->getErrorMessage(), 'The specified bucket does not exist.'); + $this->assertEquals($e->getDetails(), $this->errorBody); + } + } + + public function testParseXml2() + { + $response = new ResponseCore(array(), $this->xml, 200); + $result = new ListBucketsResult($response); + $this->assertTrue($result->isOK()); + $this->assertNotNull($result->getData()); + $this->assertNotNull($result->getRawResponse()); + $bucketListInfo = $result->getData(); + $this->assertEquals(3, count($bucketListInfo->getBucketList())); + $this->assertEquals("2015-12-17T18:12:43.000Z", $bucketListInfo->getBucketList()[0]->getCreateDate()); + $this->assertEquals("oss-cn-shanghai", $bucketListInfo->getBucketList()[0]->getLocation()); + $this->assertEquals("app-base-oss", $bucketListInfo->getBucketList()[0]->getName()); + $this->assertEquals("oss-cn-shanghai.aliyuncs.com", $bucketListInfo->getBucketList()[0]->getExtranetEndpoint()); + $this->assertEquals("oss-cn-shanghai-internal.aliyuncs.com", $bucketListInfo->getBucketList()[0]->getIntranetEndpoint()); + $this->assertEquals("cn-shanghai", $bucketListInfo->getBucketList()[0]->getRegion()); + $this->assertEquals("Standard", $bucketListInfo->getBucketList()[0]->getStorageClass()); + + $this->assertEquals("2014-12-25T11:21:04.000Z", $bucketListInfo->getBucketList()[1]->getCreateDate()); + $this->assertEquals("oss-cn-hangzhou", $bucketListInfo->getBucketList()[1]->getLocation()); + $this->assertEquals("atestleo23", $bucketListInfo->getBucketList()[1]->getName()); + $this->assertEquals("oss-cn-hangzhou.aliyuncs.com", $bucketListInfo->getBucketList()[1]->getExtranetEndpoint()); + $this->assertEquals("oss-cn-hangzhou-internal.aliyuncs.com", $bucketListInfo->getBucketList()[1]->getIntranetEndpoint()); + $this->assertEquals("cn-hangzhou", $bucketListInfo->getBucketList()[1]->getRegion()); + $this->assertEquals("IA", $bucketListInfo->getBucketList()[1]->getStorageClass()); + + $this->assertEquals("2014-12-25T11:21:04.000Z", $bucketListInfo->getBucketList()[2]->getCreateDate()); + $this->assertEquals("oss-cn-hangzhou", $bucketListInfo->getBucketList()[2]->getLocation()); + $this->assertEquals("atestleo23", $bucketListInfo->getBucketList()[2]->getName()); + $this->assertEquals(null, $bucketListInfo->getBucketList()[2]->getExtranetEndpoint()); + $this->assertEquals(null, $bucketListInfo->getBucketList()[2]->getIntranetEndpoint()); + $this->assertEquals(null, $bucketListInfo->getBucketList()[2]->getRegion()); + $this->assertEquals(null, $bucketListInfo->getBucketList()[2]->getStorageClass()); + + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/ListMultipartUploadResultTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/ListMultipartUploadResultTest.php new file mode 100644 index 0000000..88bd0a7 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/ListMultipartUploadResultTest.php @@ -0,0 +1,114 @@ + + + oss-example + xx + 3 + oss.avi + 0004B99B8E707874FC2D692FA5D77D3F + x + xx + 1000 + false + + multipart.data + 0004B999EF518A1FE585B0C9360DC4C8 + 2012-02-23T04:18:23.000Z + + + multipart.data + 0004B999EF5A239BB9138C6227D69F95 + 2012-02-23T04:18:23.000Z + + + oss.avi + 0004B99B8E707874FC2D692FA5D77D3F + 2012-02-23T06:14:27.000Z + + +BBBB; + + private $validXmlWithEncodedKey = << + + oss-example + url + php%2Bkey-marker + 3 + php%2Bnext-key-marker + 0004B99B8E707874FC2D692FA5D77D3F + %2F + php%2Bprefix + 1000 + true + + php%2Bkey-1 + 0004B999EF518A1FE585B0C9360DC4C8 + 2012-02-23T04:18:23.000Z + + + php%2Bkey-2 + 0004B999EF5A239BB9138C6227D69F95 + 2012-02-23T04:18:23.000Z + + + php%2Bkey-3 + 0004B99B8E707874FC2D692FA5D77D3F + 2012-02-23T06:14:27.000Z + + +BBBB; + + public function testParseValidXml() + { + $response = new ResponseCore(array(), $this->validXml, 200); + $result = new ListMultipartUploadResult($response); + $listMultipartUploadInfo = $result->getData(); + $this->assertEquals("oss-example", $listMultipartUploadInfo->getBucket()); + $this->assertEquals("xx", $listMultipartUploadInfo->getKeyMarker()); + $this->assertEquals(3, $listMultipartUploadInfo->getUploadIdMarker()); + $this->assertEquals("oss.avi", $listMultipartUploadInfo->getNextKeyMarker()); + $this->assertEquals("0004B99B8E707874FC2D692FA5D77D3F", $listMultipartUploadInfo->getNextUploadIdMarker()); + $this->assertEquals("x", $listMultipartUploadInfo->getDelimiter()); + $this->assertEquals("xx", $listMultipartUploadInfo->getPrefix()); + $this->assertEquals(1000, $listMultipartUploadInfo->getMaxUploads()); + $this->assertEquals("false", $listMultipartUploadInfo->getIsTruncated()); + $uploads = $listMultipartUploadInfo->getUploads(); + $this->assertEquals("multipart.data", $uploads[0]->getKey()); + $this->assertEquals("0004B999EF518A1FE585B0C9360DC4C8", $uploads[0]->getUploadId()); + $this->assertEquals("2012-02-23T04:18:23.000Z", $uploads[0]->getInitiated()); + } + + public function testParseValidXmlWithEncodedKey() + { + $response = new ResponseCore(array(), $this->validXmlWithEncodedKey, 200); + $result = new ListMultipartUploadResult($response); + $listMultipartUploadInfo = $result->getData(); + $this->assertEquals("oss-example", $listMultipartUploadInfo->getBucket()); + $this->assertEquals("php+key-marker", $listMultipartUploadInfo->getKeyMarker()); + $this->assertEquals("php+next-key-marker", $listMultipartUploadInfo->getNextKeyMarker()); + $this->assertEquals(3, $listMultipartUploadInfo->getUploadIdMarker()); + $this->assertEquals("0004B99B8E707874FC2D692FA5D77D3F", $listMultipartUploadInfo->getNextUploadIdMarker()); + $this->assertEquals("/", $listMultipartUploadInfo->getDelimiter()); + $this->assertEquals("php+prefix", $listMultipartUploadInfo->getPrefix()); + $this->assertEquals(1000, $listMultipartUploadInfo->getMaxUploads()); + $this->assertEquals("true", $listMultipartUploadInfo->getIsTruncated()); + $uploads = $listMultipartUploadInfo->getUploads(); + $this->assertEquals("php+key-1", $uploads[0]->getKey()); + $this->assertEquals("0004B999EF518A1FE585B0C9360DC4C8", $uploads[0]->getUploadId()); + $this->assertEquals("2012-02-23T04:18:23.000Z", $uploads[0]->getInitiated()); + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/ListObjectVersionsResultTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/ListObjectVersionsResultTest.php new file mode 100644 index 0000000..7fdfd7e --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/ListObjectVersionsResultTest.php @@ -0,0 +1,215 @@ + + + oss-example + + example + CAEQMxiBgICbof2D0BYiIGRhZjgwMzJiMjA3MjQ0ODE5MWYxZDYwMzJlZjU1**** + 100 + + false + + example + CAEQMxiBgICAof2D0BYiIDJhMGE3N2M1YTI1NDQzOGY5NTkyNTI3MGYyMzJm**** + false + 2019-04-09T07:27:28.000Z + + 1234512528586**** + 12345125285864390 + + + + example + CAEQMxiBgMDNoP2D0BYiIDE3MWUxNzgxZDQxNTRiODI5OGYwZGMwNGY3MzZjN**** + false + 2019-04-09T07:27:28.000Z + "250F8A0AE989679A22926A875F0A2****" + Normal + 93731 + Standard + + 1234512528586**** + 12345125285864390 + + + + pic.jpg + CAEQMxiBgMCZov2D0BYiIDY4MDllOTc2YmY5MjQxMzdiOGI3OTlhNTU0ODIx**** + true + 2019-04-09T07:27:28.000Z + "3663F7B0B9D3153F884C821E7CF4****" + Normal + 574768 + IA + + 1234512528586**** + 12345125285864390 + + + +BBBB; + + private $validXml1 = << + + oss-example + + example + CAEQMxiBgICbof2D0BYiIGRhZjgwMzJiMjA3MjQ0ODE5MWYxZDYwMzJlZjU1**** + 100 + + false + + example + CAEQMxiBgICAof2D0BYiIDJhMGE3N2M1YTI1NDQzOGY5NTkyNTI3MGYyMzJm**** + true + 2019-04-09T07:27:28.000Z + + 1234512528586**** + 12345125285864390 + + + + example-1 + CAEQMxiBgICAof2D0BYiIDJhMGE3N2M1YTI1NDQzOGY5NTkyNTI3MGYyMzJm**** + 2019-04-09T07:27:28.000Z + + 1234512528586**** + 12345125285864390 + + + + example-2 + CAEQMxiBgMDNoP2D0BYiIDE3MWUxNzgxZDQxNTRiODI5OGYwZGMwNGY3MzZjN**** + 2019-04-09T07:27:28.000Z + "250F8A0AE989679A22926A875F0A2****" + Normal + 93731 + Standard + + 1234512528586**** + 12345125285864390 + + + +BBBB; + + private $invalidXml = << + + +BBBB; + + public function testParseValidXml() + { + $response = new ResponseCore(array(), $this->validXml, 200); + $result = new ListObjectVersionsResult($response); + $this->assertTrue($result->isOK()); + $this->assertNotNull($result->getData()); + $this->assertNotNull($result->getRawResponse()); + $list = $result->getData(); + $this->assertEquals(0, count($list->getPrefixList())); + $this->assertEquals(1, count($list->getDeleteMarkerList())); + $this->assertEquals(2, count($list->getObjectVersionList())); + + $this->assertEquals('oss-example', $list->getBucketName()); + $this->assertEquals('', $list->getPrefix()); + $this->assertEquals('example', $list->getKeyMarker()); + $this->assertEquals('CAEQMxiBgICbof2D0BYiIGRhZjgwMzJiMjA3MjQ0ODE5MWYxZDYwMzJlZjU1****', $list->getVersionIdMarker()); + $this->assertEquals(100, $list->getMaxKeys()); + $this->assertEquals('', $list->getDelimiter()); + $this->assertEquals('false', $list->getIsTruncated()); + + $deleteMarkerList = $list->getDeleteMarkerList(); + $this->assertEquals('example', $deleteMarkerList[0]->getKey()); + $this->assertEquals('CAEQMxiBgICAof2D0BYiIDJhMGE3N2M1YTI1NDQzOGY5NTkyNTI3MGYyMzJm****', $deleteMarkerList[0]->getVersionId()); + $this->assertEquals('false', $deleteMarkerList[0]->getIsLatest()); + $this->assertEquals('2019-04-09T07:27:28.000Z', $deleteMarkerList[0]->getLastModified()); + + $objectVersionList = $list->getObjectVersionList(); + $this->assertEquals('example', $objectVersionList[0]->getKey()); + $this->assertEquals('CAEQMxiBgMDNoP2D0BYiIDE3MWUxNzgxZDQxNTRiODI5OGYwZGMwNGY3MzZjN****', $objectVersionList[0]->getVersionId()); + $this->assertEquals('false', $objectVersionList[0]->getIsLatest()); + $this->assertEquals('2019-04-09T07:27:28.000Z', $objectVersionList[0]->getLastModified()); + $this->assertEquals('"250F8A0AE989679A22926A875F0A2****"', $objectVersionList[0]->getETag()); + $this->assertEquals('Normal', $objectVersionList[0]->getType()); + $this->assertEquals(93731, $objectVersionList[0]->getSize()); + $this->assertEquals('Standard', $objectVersionList[0]->getStorageClass()); + + $this->assertEquals('pic.jpg', $objectVersionList[1]->getKey()); + $this->assertEquals('CAEQMxiBgMCZov2D0BYiIDY4MDllOTc2YmY5MjQxMzdiOGI3OTlhNTU0ODIx****', $objectVersionList[1]->getVersionId()); + $this->assertEquals('true', $objectVersionList[1]->getIsLatest()); + $this->assertEquals('2019-04-09T07:27:28.000Z', $objectVersionList[1]->getLastModified()); + $this->assertEquals('"3663F7B0B9D3153F884C821E7CF4****"', $objectVersionList[1]->getETag()); + $this->assertEquals('Normal', $objectVersionList[1]->getType()); + $this->assertEquals(574768, $objectVersionList[1]->getSize()); + $this->assertEquals('IA', $objectVersionList[1]->getStorageClass()); + + + $response = new ResponseCore(array(), $this->validXml1, 200); + $result = new ListObjectVersionsResult($response); + $this->assertTrue($result->isOK()); + $this->assertNotNull($result->getData()); + $this->assertNotNull($result->getRawResponse()); + $list = $result->getData(); + $this->assertEquals(0, count($list->getPrefixList())); + $this->assertEquals(2, count($list->getDeleteMarkerList())); + $this->assertEquals(1, count($list->getObjectVersionList())); + + $this->assertEquals('oss-example', $list->getBucketName()); + $this->assertEquals('', $list->getPrefix()); + $this->assertEquals('example', $list->getKeyMarker()); + $this->assertEquals('CAEQMxiBgICbof2D0BYiIGRhZjgwMzJiMjA3MjQ0ODE5MWYxZDYwMzJlZjU1****', $list->getVersionIdMarker()); + $this->assertEquals(100, $list->getMaxKeys()); + $this->assertEquals('', $list->getDelimiter()); + $this->assertEquals('false', $list->getIsTruncated()); + + $deleteMarkerList = $list->getDeleteMarkerList(); + $this->assertEquals('example', $deleteMarkerList[0]->getKey()); + $this->assertEquals('CAEQMxiBgICAof2D0BYiIDJhMGE3N2M1YTI1NDQzOGY5NTkyNTI3MGYyMzJm****', $deleteMarkerList[0]->getVersionId()); + $this->assertEquals('true', $deleteMarkerList[0]->getIsLatest()); + $this->assertEquals('2019-04-09T07:27:28.000Z', $deleteMarkerList[0]->getLastModified()); + + $this->assertEquals('example-1', $deleteMarkerList[1]->getKey()); + $this->assertEquals('CAEQMxiBgICAof2D0BYiIDJhMGE3N2M1YTI1NDQzOGY5NTkyNTI3MGYyMzJm****', $deleteMarkerList[1]->getVersionId()); + $this->assertEquals('', $deleteMarkerList[1]->getIsLatest()); + $this->assertEquals('2019-04-09T07:27:28.000Z', $deleteMarkerList[1]->getLastModified()); + + $objectVersionList = $list->getObjectVersionList(); + $this->assertEquals('example-2', $objectVersionList[0]->getKey()); + $this->assertEquals('CAEQMxiBgMDNoP2D0BYiIDE3MWUxNzgxZDQxNTRiODI5OGYwZGMwNGY3MzZjN****', $objectVersionList[0]->getVersionId()); + $this->assertEquals('', $objectVersionList[0]->getIsLatest()); + $this->assertEquals('2019-04-09T07:27:28.000Z', $objectVersionList[0]->getLastModified()); + $this->assertEquals('"250F8A0AE989679A22926A875F0A2****"', $objectVersionList[0]->getETag()); + $this->assertEquals('Normal', $objectVersionList[0]->getType()); + $this->assertEquals(93731, $objectVersionList[0]->getSize()); + $this->assertEquals('Standard', $objectVersionList[0]->getStorageClass()); + } + + public function testParseNullXml() + { + $response = new ResponseCore(array(), "", 200); + $result = new ListObjectVersionsResult($response); + $list = $result->getData(); + $this->assertTrue(true); + } + + public function testParseInvalidXml() + { + $response = new ResponseCore(array(), $this->invalidXml, 200); + $result = new ListObjectVersionsResult($response); + $stat = $result->getData(); + $this->assertTrue(true); + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/ListObjectsResultTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/ListObjectsResultTest.php new file mode 100644 index 0000000..d778c24 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/ListObjectsResultTest.php @@ -0,0 +1,208 @@ + + + testbucket-hf + + + 1000 + / + false + + oss-php-sdk-test/ + + + test/ + + +BBBB; + + private $validXml2 = << + + testbucket-hf + oss-php-sdk-test/ + xx + 1000 + / + false + + oss-php-sdk-test/upload-test-object-name.txt + 2015-11-18T03:36:00.000Z + "89B9E567E7EB8815F2F7D41851F9A2CD" + Normal + 13115 + Standard + + cname_user + cname_user + + + +BBBB; + + private $validXmlWithEncodedKey = << + + testbucket-hf + url + php%2Fprefix + php%2Fmarker + php%2Fnext-marker + 1000 + %2F + true + + php/a%2Bb + 2015-11-18T03:36:00.000Z + "89B9E567E7EB8815F2F7D41851F9A2CD" + Normal + 13115 + Standard + + cname_user + cname_user + + + +BBBB; + + private $validXmlWithResoreInfo = << + + testbucket-hf + url + php%2Fprefix + php%2Fmarker + php%2Fnext-marker + 1000 + %2F + true + + php/a%2Bb + 2015-11-18T03:36:00.000Z + "89B9E567E7EB8815F2F7D41851F9A2CD" + Normal + 13115 + Standard + + cname_user + cname_user + + ongoing-request="false", expiry-date="Tue, 25 Apr 2023 07:30:00 GMT" + + +BBBB; + + public function testParseValidXml1() + { + $response = new ResponseCore(array(), $this->validXml1, 200); + $result = new ListObjectsResult($response); + $this->assertTrue($result->isOK()); + $this->assertNotNull($result->getData()); + $this->assertNotNull($result->getRawResponse()); + $objectListInfo = $result->getData(); + $this->assertEquals(2, count($objectListInfo->getPrefixList())); + $this->assertEquals(0, count($objectListInfo->getObjectList())); + $this->assertEquals('testbucket-hf', $objectListInfo->getBucketName()); + $this->assertEquals('', $objectListInfo->getPrefix()); + $this->assertEquals('', $objectListInfo->getMarker()); + $this->assertEquals(1000, $objectListInfo->getMaxKeys()); + $this->assertEquals('/', $objectListInfo->getDelimiter()); + $this->assertEquals('false', $objectListInfo->getIsTruncated()); + $prefixes = $objectListInfo->getPrefixList(); + $this->assertEquals('oss-php-sdk-test/', $prefixes[0]->getPrefix()); + $this->assertEquals('test/', $prefixes[1]->getPrefix()); + } + + public function testParseValidXml2() + { + $response = new ResponseCore(array(), $this->validXml2, 200); + $result = new ListObjectsResult($response); + $this->assertTrue($result->isOK()); + $this->assertNotNull($result->getData()); + $this->assertNotNull($result->getRawResponse()); + $objectListInfo = $result->getData(); + $this->assertEquals(0, count($objectListInfo->getPrefixList())); + $this->assertEquals(1, count($objectListInfo->getObjectList())); + $this->assertEquals('testbucket-hf', $objectListInfo->getBucketName()); + $this->assertEquals('oss-php-sdk-test/', $objectListInfo->getPrefix()); + $this->assertEquals('xx', $objectListInfo->getMarker()); + $this->assertEquals(1000, $objectListInfo->getMaxKeys()); + $this->assertEquals('/', $objectListInfo->getDelimiter()); + $this->assertEquals('false', $objectListInfo->getIsTruncated()); + $objects = $objectListInfo->getObjectList(); + $this->assertEquals('oss-php-sdk-test/upload-test-object-name.txt', $objects[0]->getKey()); + $this->assertEquals('2015-11-18T03:36:00.000Z', $objects[0]->getLastModified()); + $this->assertEquals('"89B9E567E7EB8815F2F7D41851F9A2CD"', $objects[0]->getETag()); + $this->assertEquals('Normal', $objects[0]->getType()); + $this->assertEquals(13115, $objects[0]->getSize()); + $this->assertEquals('Standard', $objects[0]->getStorageClass()); + } + + public function testParseValidXmlWithEncodedKey() + { + $response = new ResponseCore(array(), $this->validXmlWithEncodedKey, 200); + $result = new ListObjectsResult($response); + $this->assertTrue($result->isOK()); + $this->assertNotNull($result->getData()); + $this->assertNotNull($result->getRawResponse()); + $objectListInfo = $result->getData(); + $this->assertEquals(0, count($objectListInfo->getPrefixList())); + $this->assertEquals(1, count($objectListInfo->getObjectList())); + $this->assertEquals('testbucket-hf', $objectListInfo->getBucketName()); + $this->assertEquals('php/prefix', $objectListInfo->getPrefix()); + $this->assertEquals('php/marker', $objectListInfo->getMarker()); + $this->assertEquals('php/next-marker', $objectListInfo->getNextMarker()); + $this->assertEquals(1000, $objectListInfo->getMaxKeys()); + $this->assertEquals('/', $objectListInfo->getDelimiter()); + $this->assertEquals('true', $objectListInfo->getIsTruncated()); + $objects = $objectListInfo->getObjectList(); + $this->assertEquals('php/a+b', $objects[0]->getKey()); + $this->assertEquals('2015-11-18T03:36:00.000Z', $objects[0]->getLastModified()); + $this->assertEquals('"89B9E567E7EB8815F2F7D41851F9A2CD"', $objects[0]->getETag()); + $this->assertEquals('Normal', $objects[0]->getType()); + $this->assertEquals(13115, $objects[0]->getSize()); + $this->assertEquals('Standard', $objects[0]->getStorageClass()); + } + + + public function testParseValidXmlWithRestoreInfo() + { + $response = new ResponseCore(array(), $this->validXmlWithResoreInfo, 200); + $result = new ListObjectsResult($response); + $this->assertTrue($result->isOK()); + $this->assertNotNull($result->getData()); + $this->assertNotNull($result->getRawResponse()); + $objectListInfo = $result->getData(); + $this->assertEquals(0, count($objectListInfo->getPrefixList())); + $this->assertEquals(1, count($objectListInfo->getObjectList())); + $this->assertEquals('testbucket-hf', $objectListInfo->getBucketName()); + $this->assertEquals('php/prefix', $objectListInfo->getPrefix()); + $this->assertEquals('php/marker', $objectListInfo->getMarker()); + $this->assertEquals('php/next-marker', $objectListInfo->getNextMarker()); + $this->assertEquals(1000, $objectListInfo->getMaxKeys()); + $this->assertEquals('/', $objectListInfo->getDelimiter()); + $this->assertEquals('true', $objectListInfo->getIsTruncated()); + $objects = $objectListInfo->getObjectList(); + $this->assertEquals('php/a+b', $objects[0]->getKey()); + $this->assertEquals('2015-11-18T03:36:00.000Z', $objects[0]->getLastModified()); + $this->assertEquals('"89B9E567E7EB8815F2F7D41851F9A2CD"', $objects[0]->getETag()); + $this->assertEquals('Normal', $objects[0]->getType()); + $this->assertEquals(13115, $objects[0]->getSize()); + $this->assertEquals('Standard', $objects[0]->getStorageClass()); + $this->assertEquals('ongoing-request="false", expiry-date="Tue, 25 Apr 2023 07:30:00 GMT"', $objects[0]->getRestoreInfo()); + $this->assertEquals('cname_user', $objects[0]->getOwner()->getId()); + $this->assertEquals('cname_user', $objects[0]->getOwner()->getDisplayName()); + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/ListObjectsV2ResultTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/ListObjectsV2ResultTest.php new file mode 100644 index 0000000..7f07ecf --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/ListObjectsV2ResultTest.php @@ -0,0 +1,215 @@ + + + testbucket-hf + + + 1000 + / + false + + oss-php-sdk-test/ + + + test/ + + +BBBB; + + private $validXml2 = << + + testbucket-hf + oss-php-sdk-test/ + xx + 1000 + / + false + + oss-php-sdk-test/upload-test-object-name.txt + 2015-11-18T03:36:00.000Z + "89B9E567E7EB8815F2F7D41851F9A2CD" + Normal + 13115 + Standard + + 1 + +BBBB; + + private $validXmlWithEncodedKey = << + + testbucket-hf + url + php%2Fprefix + php%2Fmarker + 1gJiYw-- + CgJiYw-- + 1000 + %2F + true + + php/a%2Bb + 2015-11-18T03:36:00.000Z + "89B9E567E7EB8815F2F7D41851F9A2CD" + Normal + 13115 + Standard + + cname_user + cname_user + + + 1 + +BBBB; + + private $validXmlWithRestoreInfo = << + + testbucket-hf + url + php%2Fprefix + php%2Fmarker + 1gJiYw-- + CgJiYw-- + 1000 + %2F + true + + php/a%2Bb + 2015-11-18T03:36:00.000Z + "89B9E567E7EB8815F2F7D41851F9A2CD" + Normal + 13115 + Standard + + cname_user + cname_user + + ongoing-request="false", expiry-date="Tue, 25 Apr 2023 07:30:00 GMT" + + 1 + +BBBB; + + public function testParseValidXml1() + { + $response = new ResponseCore(array(), $this->validXml1, 200); + $result = new ListObjectsV2Result($response); + $this->assertTrue($result->isOK()); + $this->assertNotNull($result->getData()); + $this->assertNotNull($result->getRawResponse()); + $objectListInfo = $result->getData(); + $this->assertEquals(2, count($objectListInfo->getPrefixList())); + $this->assertEquals(0, count($objectListInfo->getObjectList())); + $this->assertEquals('testbucket-hf', $objectListInfo->getBucketName()); + $this->assertEquals('', $objectListInfo->getPrefix()); + $this->assertEquals('', $objectListInfo->getStartAfter()); + $this->assertEquals(1000, $objectListInfo->getMaxKeys()); + $this->assertEquals('/', $objectListInfo->getDelimiter()); + $this->assertEquals('false', $objectListInfo->getIsTruncated()); + $this->assertEquals(0, $objectListInfo->getKeyCount()); + $prefixes = $objectListInfo->getPrefixList(); + $this->assertEquals('oss-php-sdk-test/', $prefixes[0]->getPrefix()); + $this->assertEquals('test/', $prefixes[1]->getPrefix()); + } + + public function testParseValidXml2() + { + $response = new ResponseCore(array(), $this->validXml2, 200); + $result = new ListObjectsV2Result($response); + $this->assertTrue($result->isOK()); + $this->assertNotNull($result->getData()); + $this->assertNotNull($result->getRawResponse()); + $objectListInfo = $result->getData(); + $this->assertEquals(0, count($objectListInfo->getPrefixList())); + $this->assertEquals(1, count($objectListInfo->getObjectList())); + $this->assertEquals('testbucket-hf', $objectListInfo->getBucketName()); + $this->assertEquals('oss-php-sdk-test/', $objectListInfo->getPrefix()); + $this->assertEquals('xx', $objectListInfo->getStartAfter()); + $this->assertEquals(1000, $objectListInfo->getMaxKeys()); + $this->assertEquals('/', $objectListInfo->getDelimiter()); + $this->assertEquals('false', $objectListInfo->getIsTruncated()); + $this->assertEquals(1, $objectListInfo->getKeyCount()); + $objects = $objectListInfo->getObjectList(); + $this->assertEquals('oss-php-sdk-test/upload-test-object-name.txt', $objects[0]->getKey()); + $this->assertEquals('2015-11-18T03:36:00.000Z', $objects[0]->getLastModified()); + $this->assertEquals('"89B9E567E7EB8815F2F7D41851F9A2CD"', $objects[0]->getETag()); + $this->assertEquals('Normal', $objects[0]->getType()); + $this->assertEquals(13115, $objects[0]->getSize()); + $this->assertEquals('Standard', $objects[0]->getStorageClass()); + } + + public function testParseValidXmlWithEncodedKey() + { + $response = new ResponseCore(array(), $this->validXmlWithEncodedKey, 200); + $result = new ListObjectsV2Result($response); + $this->assertTrue($result->isOK()); + $this->assertNotNull($result->getData()); + $this->assertNotNull($result->getRawResponse()); + $objectListInfo = $result->getData(); + $this->assertEquals(0, count($objectListInfo->getPrefixList())); + $this->assertEquals(1, count($objectListInfo->getObjectList())); + $this->assertEquals('testbucket-hf', $objectListInfo->getBucketName()); + $this->assertEquals('php/prefix', $objectListInfo->getPrefix()); + $this->assertEquals('php/marker', $objectListInfo->getStartAfter()); + $this->assertEquals('CgJiYw--', $objectListInfo->getNextContinuationToken()); + $this->assertEquals('1gJiYw--', $objectListInfo->getContinuationToken()); + $this->assertEquals(1000, $objectListInfo->getMaxKeys()); + $this->assertEquals('/', $objectListInfo->getDelimiter()); + $this->assertEquals('true', $objectListInfo->getIsTruncated()); + $this->assertEquals(1, $objectListInfo->getKeyCount()); + $objects = $objectListInfo->getObjectList(); + $this->assertEquals('php/a+b', $objects[0]->getKey()); + $this->assertEquals('2015-11-18T03:36:00.000Z', $objects[0]->getLastModified()); + $this->assertEquals('"89B9E567E7EB8815F2F7D41851F9A2CD"', $objects[0]->getETag()); + $this->assertEquals('Normal', $objects[0]->getType()); + $this->assertEquals(13115, $objects[0]->getSize()); + $this->assertEquals('Standard', $objects[0]->getStorageClass()); + } + + + public function testParseValidXmlWithRestoreInfo() + { + $response = new ResponseCore(array(), $this->validXmlWithRestoreInfo, 200); + $result = new ListObjectsV2Result($response); + $this->assertTrue($result->isOK()); + $this->assertNotNull($result->getData()); + $this->assertNotNull($result->getRawResponse()); + $objectListInfo = $result->getData(); + $this->assertEquals(0, count($objectListInfo->getPrefixList())); + $this->assertEquals(1, count($objectListInfo->getObjectList())); + $this->assertEquals('testbucket-hf', $objectListInfo->getBucketName()); + $this->assertEquals('php/prefix', $objectListInfo->getPrefix()); + $this->assertEquals('php/marker', $objectListInfo->getStartAfter()); + $this->assertEquals('CgJiYw--', $objectListInfo->getNextContinuationToken()); + $this->assertEquals('1gJiYw--', $objectListInfo->getContinuationToken()); + $this->assertEquals(1000, $objectListInfo->getMaxKeys()); + $this->assertEquals('/', $objectListInfo->getDelimiter()); + $this->assertEquals('true', $objectListInfo->getIsTruncated()); + $this->assertEquals(1, $objectListInfo->getKeyCount()); + $objects = $objectListInfo->getObjectList(); + $this->assertEquals('php/a+b', $objects[0]->getKey()); + $this->assertEquals('2015-11-18T03:36:00.000Z', $objects[0]->getLastModified()); + $this->assertEquals('"89B9E567E7EB8815F2F7D41851F9A2CD"', $objects[0]->getETag()); + $this->assertEquals('Normal', $objects[0]->getType()); + $this->assertEquals(13115, $objects[0]->getSize()); + $this->assertEquals('Standard', $objects[0]->getStorageClass()); + $this->assertEquals('ongoing-request="false", expiry-date="Tue, 25 Apr 2023 07:30:00 GMT"', $objects[0]->getRestoreInfo()); + $this->assertEquals('cname_user', $objects[0]->getOwner()->getId()); + $this->assertEquals('cname_user', $objects[0]->getOwner()->getDisplayName()); + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/ListPartsResultTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/ListPartsResultTest.php new file mode 100644 index 0000000..bdc61a2 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/ListPartsResultTest.php @@ -0,0 +1,62 @@ + + + multipart_upload + multipart.data + 0004B999EF5A239BB9138C6227D69F95 + 5 + 1000 + false + + 1 + 2012-02-23T07:01:34.000Z + "3349DC700140D7F86A078484278075A9" + 6291456 + + + 2 + 2012-02-23T07:01:12.000Z + "3349DC700140D7F86A078484278075A9" + 6291456 + + + 5 + 2012-02-23T07:02:03.000Z + "7265F4D211B56873A381D321F586E4A9" + 1024 + + +BBBB; + + public function testParseValidXml() + { + $response = new ResponseCore(array(), $this->validXml, 200); + $result = new ListPartsResult($response); + $listPartsInfo = $result->getData(); + $this->assertEquals("multipart_upload", $listPartsInfo->getBucket()); + $this->assertEquals("multipart.data", $listPartsInfo->getKey()); + $this->assertEquals("0004B999EF5A239BB9138C6227D69F95", $listPartsInfo->getUploadId()); + $this->assertEquals(5, $listPartsInfo->getNextPartNumberMarker()); + $this->assertEquals(1000, $listPartsInfo->getMaxParts()); + $this->assertEquals("false", $listPartsInfo->getIsTruncated()); + $this->assertEquals(3, count($listPartsInfo->getListPart())); + $parts = $listPartsInfo->getListPart(); + $this->assertEquals(1, $parts[0]->getPartNumber()); + $this->assertEquals('2012-02-23T07:01:34.000Z', $parts[0]->getLastModified()); + $this->assertEquals('"3349DC700140D7F86A078484278075A9"', $parts[0]->getETag()); + $this->assertEquals(6291456, $parts[0]->getSize()); + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/LiveChannelXmlTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/LiveChannelXmlTest.php new file mode 100644 index 0000000..b69ef7c --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/LiveChannelXmlTest.php @@ -0,0 +1,277 @@ + + + xxx + enabled + + hls + 1000 + 5 + hello.m3u8 + + +BBBB; + + private $info = << + + live-1 + xxx + + rtmp://bucket.oss-cn-hangzhou.aliyuncs.com/live/213443245345 + + + http://bucket.oss-cn-hangzhou.aliyuncs.com/213443245345/播放列表.m3u8 + + enabled + 2015-11-24T14:25:31.000Z + +BBBB; + + private $list = << + +xxx + yyy + 100 + false + 121312132 + + 12123214323431 + xxx + + rtmp://bucket.oss-cn-hangzhou.aliyuncs.com/live/1 + + + http://bucket.oss-cn-hangzhou.aliyuncs.com/1/播放列表.m3u8 + + enabled + 2015-11-24T14:25:31.000Z + + + 432423432423 + yyy + + rtmp://bucket.oss-cn-hangzhou.aliyuncs.com/live/2 + + + http://bucket.oss-cn-hangzhou.aliyuncs.com/2/播放列表.m3u8 + + enabled + 2016-11-24T14:25:31.000Z + + +BBBB; + + private $status = << + + Live + 2016-10-20T14:25:31.000Z + 10.1.2.4:47745 + + + +BBBB; + + private $history = << + + + 2013-11-24T14:25:31.000Z + 2013-11-24T15:25:31.000Z + 10.101.194.148:56861 + + + 2014-11-24T14:25:31.000Z + 2014-11-24T15:25:31.000Z + 10.101.194.148:56862 + + + 2015-11-24T14:25:31.000Z + 2015-11-24T15:25:31.000Z + 10.101.194.148:56863 + + +BBBB; + + public function testLiveChannelStatus() + { + $stat = new GetLiveChannelStatus(); + $stat->parseFromXml($this->status); + + $this->assertEquals('Live', $stat->getStatus()); + $this->assertEquals('2016-10-20T14:25:31.000Z', $stat->getConnectedTime()); + $this->assertEquals('10.1.2.4:47745', $stat->getRemoteAddr()); + + $this->assertEquals(1280, $stat->getVideoWidth()); + $this->assertEquals(536, $stat->getVideoHeight()); + $this->assertEquals(24, $stat->getVideoFrameRate()); + $this->assertEquals(72513, $stat->getVideoBandwidth()); + $this->assertEquals('H264', $stat->getVideoCodec()); + $this->assertEquals(6519, $stat->getAudioBandwidth()); + $this->assertEquals(44100, $stat->getAudioSampleRate()); + $this->assertEquals('AAC', $stat->getAudioCodec()); + + } + + public function testGetLiveChannelHistory() + { + $history = new GetLiveChannelHistory(); + $history->parseFromXml($this->history); + + $recordList = $history->getLiveRecordList(); + $this->assertEquals(3, count($recordList)); + + $list0 = $recordList[0]; + $this->assertEquals('2013-11-24T14:25:31.000Z', $list0->getStartTime()); + $this->assertEquals('2013-11-24T15:25:31.000Z', $list0->getEndTime()); + $this->assertEquals('10.101.194.148:56861', $list0->getRemoteAddr()); + + $list1 = $recordList[1]; + $this->assertEquals('2014-11-24T14:25:31.000Z', $list1->getStartTime()); + $this->assertEquals('2014-11-24T15:25:31.000Z', $list1->getEndTime()); + $this->assertEquals('10.101.194.148:56862', $list1->getRemoteAddr()); + + $list2 = $recordList[2]; + $this->assertEquals('2015-11-24T14:25:31.000Z', $list2->getStartTime()); + $this->assertEquals('2015-11-24T15:25:31.000Z', $list2->getEndTime()); + $this->assertEquals('10.101.194.148:56863', $list2->getRemoteAddr()); + + } + + public function testLiveChannelConfig() + { + $config = new LiveChannelConfig(array('name' => 'live-1')); + $config->parseFromXml($this->config); + + $this->assertEquals('xxx', $config->getDescription()); + $this->assertEquals('enabled', $config->getStatus()); + $this->assertEquals('hls', $config->getType()); + $this->assertEquals(1000, $config->getFragDuration()); + $this->assertEquals(5, $config->getFragCount()); + $this->assertEquals('hello.m3u8', $config->getPlayListName()); + + $xml = $config->serializeToXml(); + $config2 = new LiveChannelConfig(array('name' => 'live-2')); + $config2->parseFromXml($xml); + $this->assertEquals('xxx', $config2->getDescription()); + $this->assertEquals('enabled', $config2->getStatus()); + $this->assertEquals('hls', $config2->getType()); + $this->assertEquals(1000, $config2->getFragDuration()); + $this->assertEquals(5, $config2->getFragCount()); + $this->assertEquals('hello.m3u8', $config2->getPlayListName()); + } + + public function testLiveChannelInfo() + { + $info = new LiveChannelInfo(array('name' => 'live-1')); + $info->parseFromXml($this->info); + + $this->assertEquals('live-1', $info->getName()); + $this->assertEquals('xxx', $info->getDescription()); + $this->assertEquals('enabled', $info->getStatus()); + $this->assertEquals('2015-11-24T14:25:31.000Z', $info->getLastModified()); + $pubs = $info->getPublishUrls(); + $this->assertEquals(1, count($pubs)); + $this->assertEquals('rtmp://bucket.oss-cn-hangzhou.aliyuncs.com/live/213443245345', $pubs[0]); + + $plays = $info->getPlayUrls(); + $this->assertEquals(1, count($plays)); + $this->assertEquals('http://bucket.oss-cn-hangzhou.aliyuncs.com/213443245345/播放列表.m3u8', $plays[0]); + } + + public function testLiveChannelList() + { + $list = new LiveChannelListInfo(); + $list->parseFromXml($this->list); + + $this->assertEquals('xxx', $list->getPrefix()); + $this->assertEquals('yyy', $list->getMarker()); + $this->assertEquals(100, $list->getMaxKeys()); + $this->assertEquals(false, $list->getIsTruncated()); + $this->assertEquals('121312132', $list->getNextMarker()); + + $channels = $list->getChannelList(); + $this->assertEquals(2, count($channels)); + + $chan1 = $channels[0]; + $this->assertEquals('12123214323431', $chan1->getName()); + $this->assertEquals('xxx', $chan1->getDescription()); + $this->assertEquals('enabled', $chan1->getStatus()); + $this->assertEquals('2015-11-24T14:25:31.000Z', $chan1->getLastModified()); + $pubs = $chan1->getPublishUrls(); + $this->assertEquals(1, count($pubs)); + $this->assertEquals('rtmp://bucket.oss-cn-hangzhou.aliyuncs.com/live/1', $pubs[0]); + + $plays = $chan1->getPlayUrls(); + $this->assertEquals(1, count($plays)); + $this->assertEquals('http://bucket.oss-cn-hangzhou.aliyuncs.com/1/播放列表.m3u8', $plays[0]); + + $chan2 = $channels[1]; + $this->assertEquals('432423432423', $chan2->getName()); + $this->assertEquals('yyy', $chan2->getDescription()); + $this->assertEquals('enabled', $chan2->getStatus()); + $this->assertEquals('2016-11-24T14:25:31.000Z', $chan2->getLastModified()); + $pubs = $chan2->getPublishUrls(); + $this->assertEquals(1, count($pubs)); + $this->assertEquals('rtmp://bucket.oss-cn-hangzhou.aliyuncs.com/live/2', $pubs[0]); + + $plays = $chan2->getPlayUrls(); + $this->assertEquals(1, count($plays)); + $this->assertEquals('http://bucket.oss-cn-hangzhou.aliyuncs.com/2/播放列表.m3u8', $plays[0]); + } + + public function testLiveChannelHistory() + { + $xml = "2013-11-24T14:25:31.000Z2013-11-24T15:25:31.000Z10.101.194.148:56861"; + $history = new LiveChannelHistory(); + $history->parseFromXml($xml); + + $this->assertEquals('2013-11-24T14:25:31.000Z', $history->getStartTime()); + $this->assertEquals('2013-11-24T15:25:31.000Z', $history->getEndTime()); + $this->assertEquals('10.101.194.148:56861', $history->getRemoteAddr()); + } + + public function testGetLiveChannelHistorySerializeToXml() + { + try { + $history = new GetLiveChannelHistory (); + $history->serializeToXml(); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + if (strpos($e, "Not implemented.") == false) + { + $this->assertTrue(false); + } + } + } + +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/LoggingConfigTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/LoggingConfigTest.php new file mode 100644 index 0000000..05336c8 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/LoggingConfigTest.php @@ -0,0 +1,47 @@ + + + +TargetBucket +TargetPrefix + + +BBBB; + + private $nullXml = << + +BBBB; + + public function testParseValidXml() + { + $loggingConfig = new LoggingConfig(); + $loggingConfig->parseFromXml($this->validXml); + $this->assertEquals($this->cleanXml($this->validXml), $this->cleanXml(strval($loggingConfig))); + } + + public function testConstruct() + { + $loggingConfig = new LoggingConfig('TargetBucket', 'TargetPrefix'); + $this->assertEquals($this->cleanXml($this->validXml), $this->cleanXml($loggingConfig->serializeToXml())); + } + + public function testFailedConstruct() + { + $loggingConfig = new LoggingConfig('TargetBucket', null); + $this->assertEquals($this->cleanXml($this->nullXml), $this->cleanXml($loggingConfig->serializeToXml())); + } + + private function cleanXml($xml) + { + return str_replace("\n", "", str_replace("\r", "", $xml)); + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/MimeTypesTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/MimeTypesTest.php new file mode 100644 index 0000000..1403d09 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/MimeTypesTest.php @@ -0,0 +1,13 @@ +assertEquals('application/xml', MimeTypes::getMimetype('file.xml')); + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/ObjectAclTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/ObjectAclTest.php new file mode 100644 index 0000000..ec003ca --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/ObjectAclTest.php @@ -0,0 +1,29 @@ +ossClient; + $bucket = $this->bucket; + + $object = 'test/object-acl'; + $client->deleteObject($bucket, $object); + $client->putObject($bucket, $object, "hello world"); + + $acl = $client->getObjectAcl($bucket, $object); + $this->assertEquals('default', $acl); + + $client->putObjectAcl($bucket, $object, 'public-read'); + $acl = $client->getObjectAcl($bucket, $object); + $this->assertEquals('public-read', $acl); + + $content = $client->getObject($bucket, $object); + $this->assertEquals('hello world', $content); + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientAsyncProcessObjectTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientAsyncProcessObjectTest.php new file mode 100644 index 0000000..cbf85e3 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientAsyncProcessObjectTest.php @@ -0,0 +1,68 @@ +client = $this->ossClient; + $this->bucketName = $this->bucket; + + $url = 'https://oss-console-img-demo-cn-hangzhou.oss-cn-hangzhou.aliyuncs.com/video.mp4?spm=a2c4g.64555.0.0.515675979u4B8w&file=video.mp4'; + $file_name = "video.mp4"; + $fp = fopen($file_name, 'w'); + $ch = curl_init($url); + curl_setopt($ch, CURLOPT_FILE, $fp); + curl_exec($ch); + curl_close($ch); + fclose($fp); + + $this->local_file = $file_name; + $this->object = "oss-example.mp4"; + + Common::waitMetaSync(); + $this->client->uploadFile($this->bucketName, $this->object, $this->local_file); + } + + protected function tearDown(): void + { + parent::tearDown(); + unlink($this->local_file); + } + + public function testAsyncProcessObject() + { + + try { + $object = 'php-async-copy'; + $process = 'video/convert,f_avi,vcodec_h265,s_1920x1080,vb_2000000,fps_30,acodec_aac,ab_100000,sn_1'. + '|sys/saveas'. + ',o_'.$this->base64url_encode($object). + ',b_'.$this->base64url_encode($this->bucketName); + $result = $this->client->asyncProcessObject($this->bucketName, $this->object, $process); + }catch (OssException $e){ + $this->assertEquals($e->getErrorCode(),"Imm Client"); + $this->assertTrue(strpos($e->getErrorMessage(), "ResourceNotFound, The specified resource Attachment is not found") !== false); + } + + } + + private function base64url_encode($data) + { + return rtrim(strtr(base64_encode($data), '+/', '-_'), '='); + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketCnameTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketCnameTest.php new file mode 100644 index 0000000..dabe93f --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketCnameTest.php @@ -0,0 +1,61 @@ +bucket . '-cname'; + $client = new OssClient( + getenv('OSS_ACCESS_KEY_ID'), + getenv('OSS_ACCESS_KEY_SECRET'), + "oss-ap-southeast-2.aliyuncs.com", false); + + $client->createBucket($bucketName); + + try { + $info1 = $client->createBucketCnameToken($bucketName, "www.example.com"); + $this->assertEquals("www.example.com", $info1->getCname()); + $this->assertEquals($bucketName, $info1->getBucket()); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $info2 = $client->getBucketCnameToken($bucketName, "www.example.com"); + $this->assertEquals("www.example.com", $info2->getCname()); + $this->assertEquals($bucketName, $info2->getBucket()); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $result = $client->addBucketCname($bucketName, "www.example.com"); + } catch (OssException $e) { + $this->assertEquals('NeedVerifyDomainOwnership', $e->getErrorCode()); + } + + try { + $config = $client->getBucketCname($bucketName); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $result = $client->deleteBucketCname($bucketName, "www.example.com"); + } catch (OssException $e) { + $this->assertTrue(false); + } + + $client->deleteBucket($bucketName); + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketCorsTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketCorsTest.php new file mode 100644 index 0000000..bbe11f5 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketCorsTest.php @@ -0,0 +1,125 @@ +addAllowedHeader("x-oss-test"); + $rule->addAllowedHeader("x-oss-test2"); + $rule->addAllowedHeader("x-oss-test2"); + $rule->addAllowedHeader("x-oss-test3"); + $rule->addAllowedOrigin("http://www.b.com"); + $rule->addAllowedOrigin("http://www.a.com"); + $rule->addAllowedOrigin("http://www.a.com"); + $rule->addAllowedMethod("GET"); + $rule->addAllowedMethod("PUT"); + $rule->addAllowedMethod("POST"); + $rule->addExposeHeader("x-oss-test1"); + $rule->addExposeHeader("x-oss-test1"); + $rule->addExposeHeader("x-oss-test2"); + $rule->setMaxAgeSeconds(10); + $corsConfig->addRule($rule); + $rule = new CorsRule(); + $rule->addAllowedHeader("x-oss-test"); + $rule->addAllowedMethod("GET"); + $rule->addAllowedOrigin("http://www.b.com"); + $rule->addExposeHeader("x-oss-test1"); + $rule->setMaxAgeSeconds(110); + $corsConfig->addRule($rule); + $corsConfig->setResponseVary(true); + + try { + $this->ossClient->putBucketCors($this->bucket, $corsConfig); + } catch (OssException $e) { + $this->assertFalse(True); + } + + try { + Common::waitMetaSync(); + $object = "cors/test.txt"; + $this->ossClient->putObject($this->bucket, $object, file_get_contents(__FILE__)); + $headers = $this->ossClient->optionsObject($this->bucket, $object, "http://www.a.com", "GET", "", null); + $this->assertNotEmpty($headers); + } catch (OssException $e) { + var_dump($e->getMessage()); + } + + try { + Common::waitMetaSync(); + $corsConfig2 = $this->ossClient->getBucketCors($this->bucket); + $this->assertNotNull($corsConfig2); + $this->assertEquals($corsConfig->serializeToXml(), $corsConfig2->serializeToXml()); + } catch (OssException $e) { + $this->assertFalse(True); + } + + try { + Common::waitMetaSync(); + $this->ossClient->deleteBucketCors($this->bucket); + } catch (OssException $e) { + $this->assertFalse(True); + } + + try { + Common::waitMetaSync(); + $corsConfig3 = $this->ossClient->getBucketCors($this->bucket); + $this->assertNotNull($corsConfig3); + $this->assertNotEquals($corsConfig->serializeToXml(), $corsConfig3->serializeToXml()); + } catch (OssException $e) { + $this->assertFalse(True); + } + + + try { + Common::waitMetaSync(); + $this->ossClient->deleteBucketCors($this->bucket); + } catch (OssException $e) { + $this->assertFalse(True); + } + + $corsConfig = new CorsConfig(); + $rule = new CorsRule(); + $rule->addAllowedHeader("x-oss-test"); + $rule->addAllowedOrigin("http://www.b.com"); + $rule->addAllowedMethod("GET"); + $rule->addExposeHeader("x-oss-test1"); + $rule->setMaxAgeSeconds(10); + $corsConfig->addRule($rule); + $rule = new CorsRule(); + $rule->addAllowedHeader("x-oss-test"); + $rule->addAllowedMethod("GET"); + $rule->addAllowedOrigin("http://www.b.com"); + $rule->addExposeHeader("x-oss-test1"); + $rule->setMaxAgeSeconds(110); + $corsConfig->addRule($rule); + $corsConfig->setResponseVary(false); + + try { + $this->ossClient->putBucketCors($this->bucket, $corsConfig); + } catch (OssException $e) { + $this->assertFalse(True); + } + + try { + Common::waitMetaSync(); + $corsConfig4 = $this->ossClient->getBucketCors($this->bucket); + $this->assertNotNull($corsConfig4); + $this->assertEquals($corsConfig->serializeToXml(), $corsConfig4->serializeToXml()); + } catch (OssException $e) { + $this->assertFalse(True); + } + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketEncryptionTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketEncryptionTest.php new file mode 100644 index 0000000..42c51b2 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketEncryptionTest.php @@ -0,0 +1,63 @@ +ossClient->putBucketEncryption($this->bucket, $config); + } catch (OssException $e) { + var_dump($e->getMessage()); + $this->assertTrue(false); + } + try { + Common::waitMetaSync(); + $config2 = $this->ossClient->getBucketEncryption($this->bucket); + $this->assertEquals($config->serializeToXml(), $config2->serializeToXml()); + $this->assertEquals("AES256", $config2->getSSEAlgorithm()); + $this->assertEquals(null, $config2->getKMSMasterKeyID()); + } catch (OssException $e) { + $this->assertTrue(false); + } + + $config = new ServerSideEncryptionConfig("KMS", "kms-id"); + try { + $this->ossClient->putBucketEncryption($this->bucket, $config); + } catch (OssException $e) { + var_dump($e->getMessage()); + $this->assertTrue(false); + } + try { + Common::waitMetaSync(); + $config2 = $this->ossClient->getBucketEncryption($this->bucket); + $this->assertEquals($config->serializeToXml(), $config2->serializeToXml()); + $this->assertEquals("KMS", $config2->getSSEAlgorithm()); + $this->assertEquals("kms-id", $config2->getKMSMasterKeyID()); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + Common::waitMetaSync(); + $this->ossClient->deleteBucketEncryption($this->bucket); + } catch (OssException $e) { + $this->assertTrue(false); + } + try { + Common::waitMetaSync(); + $config2 = $this->ossClient->getBucketEncryption($this->bucket); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertEquals("NoSuchServerSideEncryptionRule", $e->getErrorCode()); + } + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketInfoTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketInfoTest.php new file mode 100644 index 0000000..759e536 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketInfoTest.php @@ -0,0 +1,20 @@ +ossClient->getBucketInfo($this->bucket); + $this->assertEquals($this->bucket, $info->getName()); + $this->assertEquals("Standard", $info->getStorageClass()); + } catch (OssException $e) { + $this->assertTrue(false); + } + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketLifecycleTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketLifecycleTest.php new file mode 100644 index 0000000..46da1f0 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketLifecycleTest.php @@ -0,0 +1,57 @@ +addRule($lifecycleRule); + $actions = array(); + $actions[] = new LifecycleAction("Expiration", "Date", '2022-10-12T00:00:00.000Z'); + $lifecycleRule = new LifecycleRule("delete temporary files", "temporary/", "Enabled", $actions); + $lifecycleConfig->addRule($lifecycleRule); + + try { + $this->ossClient->putBucketLifecycle($this->bucket, $lifecycleConfig); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + Common::waitMetaSync(); + $lifecycleConfig2 = $this->ossClient->getBucketLifecycle($this->bucket); + $this->assertEquals($lifecycleConfig->serializeToXml(), $lifecycleConfig2->serializeToXml()); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + Common::waitMetaSync(); + $this->ossClient->deleteBucketLifecycle($this->bucket); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + Common::waitMetaSync(); + $lifecycleConfig3 = $this->ossClient->getBucketLifecycle($this->bucket); + $this->assertNotEquals($lifecycleConfig->serializeToXml(), $lifecycleConfig3->serializeToXml()); + } catch (OssException $e) { + $this->assertTrue(false); + } + + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketLoggingTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketLoggingTest.php new file mode 100644 index 0000000..16a10eb --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketLoggingTest.php @@ -0,0 +1,43 @@ +bucket, 'prefix'); + try { + $this->ossClient->putBucketLogging($this->bucket, $this->bucket, 'prefix'); + } catch (OssException $e) { + var_dump($e->getMessage()); + $this->assertTrue(false); + } + try { + Common::waitMetaSync(); + $loggingConfig2 = $this->ossClient->getBucketLogging($this->bucket); + $this->assertEquals($loggingConfig->serializeToXml(), $loggingConfig2->serializeToXml()); + } catch (OssException $e) { + $this->assertTrue(false); + } + try { + Common::waitMetaSync(); + $this->ossClient->deleteBucketLogging($this->bucket); + } catch (OssException $e) { + $this->assertTrue(false); + } + try { + Common::waitMetaSync(); + $loggingConfig3 = $this->ossClient->getBucketLogging($this->bucket); + $this->assertNotEquals($loggingConfig->serializeToXml(), $loggingConfig3->serializeToXml()); + } catch (OssException $e) { + $this->assertTrue(false); + } + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketPolicyTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketPolicyTest.php new file mode 100644 index 0000000..6007f10 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketPolicyTest.php @@ -0,0 +1,54 @@ +ossClient->deleteBucketPolicy($this->bucket); + $policy = $this->ossClient->getBucketPolicy($this->bucket); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + $this->assertEquals("NoSuchBucketPolicy", $e->getErrorCode()); + } + + try { + $this->ossClient->putBucketPolicy($this->bucket, $policy_str); + $policy = $this->ossClient->getBucketPolicy($this->bucket); + $data1 = json_decode($policy_str, true); + $data2 = json_decode($policy, true); + $this->assertEquals($data1, $data2); + $this->ossClient->deleteBucketPolicy($this->bucket); + } catch (OssException $e) { + $this->assertTrue(false); + } + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketRefererTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketRefererTest.php new file mode 100644 index 0000000..ba7d14f --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketRefererTest.php @@ -0,0 +1,48 @@ +addReferer('http://www.aliyun.com'); + + try { + $this->ossClient->putBucketReferer($this->bucket, $refererConfig); + } catch (OssException $e) { + var_dump($e->getMessage()); + $this->assertTrue(false); + } + try { + Common::waitMetaSync(); + $refererConfig2 = $this->ossClient->getBucketReferer($this->bucket); + $this->assertEquals($refererConfig->serializeToXml(), $refererConfig2->serializeToXml()); + } catch (OssException $e) { + $this->assertTrue(false); + } + try { + Common::waitMetaSync(); + $nullRefererConfig = new RefererConfig(); + $nullRefererConfig->setAllowEmptyReferer(false); + $this->ossClient->putBucketReferer($this->bucket, $nullRefererConfig); + } catch (OssException $e) { + $this->assertTrue(false); + } + try { + Common::waitMetaSync(); + $refererConfig3 = $this->ossClient->getBucketLogging($this->bucket); + $this->assertNotEquals($refererConfig->serializeToXml(), $refererConfig3->serializeToXml()); + } catch (OssException $e) { + $this->assertTrue(false); + } + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketRequestPaymentTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketRequestPaymentTest.php new file mode 100644 index 0000000..9a4b412 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketRequestPaymentTest.php @@ -0,0 +1,51 @@ +ossClient->getBucketRequestPayment($this->bucket); + $this->assertEquals("BucketOwner", $payer); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $this->ossClient->putBucketRequestPayment($this->bucket, "Requester"); + } catch (OssException $e) { + var_dump($e->getMessage()); + $this->assertTrue(false); + } + try { + Common::waitMetaSync(); + $payer = $this->ossClient->getBucketRequestPayment($this->bucket); + $this->assertEquals("Requester", $payer); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $this->ossClient->putBucketRequestPayment($this->bucket, "BucketOwner"); + } catch (OssException $e) { + var_dump($e->getMessage()); + $this->assertTrue(false); + } + try { + Common::waitMetaSync(); + $payer = $this->ossClient->getBucketRequestPayment($this->bucket); + $this->assertEquals("BucketOwner", $payer); + } catch (OssException $e) { + $this->assertTrue(false); + } + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketStatTestTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketStatTestTest.php new file mode 100644 index 0000000..7f847d8 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketStatTestTest.php @@ -0,0 +1,34 @@ +ossClient->putObject($this->bucket, "name-1.txt", $content); + $this->ossClient->putObject($this->bucket, "name-2.txt", $content); + $this->ossClient->putObject($this->bucket, "name-3.txt", $content); + + $object = "multipart-test.txt"; + $upload_id = $this->ossClient->initiateMultipartUpload($this->bucket, $object); + + Common::waitMetaSync(); + Common::waitMetaSync(); + Common::waitMetaSync(); + $stat = $this->ossClient->getBucketStat($this->bucket); + $this->assertEquals(3, $stat->getObjectCount()); + $this->assertEquals(15, $stat->getStorage()); + $this->assertEquals(1, $stat->getMultipartUploadCount()); + + } catch (OssException $e) { + $this->assertTrue(false); + } + } + +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketStorageCapacityTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketStorageCapacityTest.php new file mode 100644 index 0000000..87548f9 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketStorageCapacityTest.php @@ -0,0 +1,56 @@ +ossClient->getBucketStorageCapacity($this->bucket); + $this->assertEquals($storageCapacity, -1); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $this->ossClient->putBucketStorageCapacity($this->bucket, 1000); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + Common::waitMetaSync(); + $storageCapacity = $this->ossClient->getBucketStorageCapacity($this->bucket); + $this->assertEquals($storageCapacity, 1000); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $this->ossClient->putBucketStorageCapacity($this->bucket, 0); + + Common::waitMetaSync(); + + $storageCapacity = $this->ossClient->getBucketStorageCapacity($this->bucket); + $this->assertEquals($storageCapacity, 0); + + $this->ossClient->putObject($this->bucket, 'test-storage-capacity','test-content'); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertEquals('Bucket storage exceed max storage capacity.',$e->getErrorMessage()); + } + + try { + $this->ossClient->putBucketStorageCapacity($this->bucket, -2); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertEquals(400, $e->getHTTPStatus()); + $this->assertEquals('InvalidArgument', $e->getErrorCode()); + } + } + +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketTagsTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketTagsTest.php new file mode 100644 index 0000000..bafa64b --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketTagsTest.php @@ -0,0 +1,76 @@ +ossClient->getBucketTags($this->bucket); + $this->assertEquals(0, count($config->getTags())); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $config = new TaggingConfig(); + $config->addTag(new Tag("key1", "value1")); + $config->addTag(new Tag("key2", "value2")); + $config->addTag(new Tag("key3", "value3")); + $this->ossClient->putBucketTags($this->bucket, $config); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + Common::waitMetaSync(); + $config2 = $this->ossClient->getBucketTags($this->bucket); + $this->assertEquals(3, count($config2->getTags())); + $this->assertEquals("key1", $config2->getTags()[0]->getKey()); + $this->assertEquals("value1", $config2->getTags()[0]->getValue()); + $this->assertEquals("key2", $config2->getTags()[1]->getKey()); + $this->assertEquals("value2", $config2->getTags()[1]->getValue()); + $this->assertEquals("key3", $config2->getTags()[2]->getKey()); + $this->assertEquals("value3", $config2->getTags()[2]->getValue()); + } catch (OssException $e) { + $this->assertTrue(false); + } + + + try { + Common::waitMetaSync(); + //del key1, key3 + $tags = array(); + $tags[] = new Tag("key1", "value1"); + $tags[] = new Tag("key3", "value3"); + + $this->ossClient->deleteBucketTags($this->bucket, $tags); + $config2 = $this->ossClient->getBucketTags($this->bucket); + $this->assertEquals(1, count($config2->getTags())); + $this->assertEquals("key2", $config2->getTags()[0]->getKey()); + $this->assertEquals("value2", $config2->getTags()[0]->getValue()); + } catch (OssException $e) { + $this->assertTrue(false); + } + + + try { + Common::waitMetaSync(); + //del all + $this->ossClient->deleteBucketTags($this->bucket); + $config2 = $this->ossClient->getBucketTags($this->bucket); + $this->assertEquals(0, count($config2->getTags())); + } catch (OssException $e) { + $this->assertTrue(false); + } + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketTest.php new file mode 100644 index 0000000..dc63685 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketTest.php @@ -0,0 +1,140 @@ +ossClient->createBucket("s"); + $this->assertFalse(true); + } catch (OssException $e) { + $this->assertEquals('"s"bucket name is invalid', $e->getMessage()); + } + } + + public function testBucketWithInvalidACL() + { + try { + $this->ossClient->createBucket($this->bucket, "invalid"); + $this->assertFalse(true); + } catch (OssException $e) { + $this->assertEquals('invalid:acl is invalid(private,public-read,public-read-write)', $e->getMessage()); + } + } + + public function testBucket() + { + $this->ossClient->createBucket($this->bucket, OssClient::OSS_ACL_TYPE_PUBLIC_READ_WRITE); + + $bucketListInfo = $this->ossClient->listBuckets(); + $this->assertNotNull($bucketListInfo); + + $bucketList = $bucketListInfo->getBucketList(); + $this->assertTrue(is_array($bucketList)); + $this->assertGreaterThan(0, count($bucketList)); + + $this->ossClient->putBucketAcl($this->bucket, OssClient::OSS_ACL_TYPE_PUBLIC_READ_WRITE); + Common::waitMetaSync(); + $this->assertEquals($this->ossClient->getBucketAcl($this->bucket), OssClient::OSS_ACL_TYPE_PUBLIC_READ_WRITE); + + $this->assertTrue($this->ossClient->doesBucketExist($this->bucket)); + $this->assertFalse($this->ossClient->doesBucketExist($this->bucket . '-notexist')); + + //$this->assertContains(Common::getRegion(), $this->ossClient->getBucketLocation($this->bucket)); + + $res = $this->ossClient->getBucketMeta($this->bucket); + $this->assertEquals('200', $res['info']['http_code']); + //$this->assertContains(Common::getRegion(), $res['x-oss-bucket-region']); + } + + public function testCreateBucketWithStorageType() + { + $object = 'storage-object'; + + $this->ossClient->putObject($this->archiveBucket, $object,'testcontent'); + try { + $this->ossClient->getObject($this->archiveBucket, $object); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertEquals('403', $e->getHTTPStatus()); + $this->assertEquals('InvalidObjectState', $e->getErrorCode()); + } + + $this->ossClient->putObject($this->iaBucket, $object,'testcontent'); + $result = $this->ossClient->getObject($this->iaBucket, $object); + $this->assertEquals($result, 'testcontent'); + + $this->ossClient->putObject($this->bucket, $object,'testcontent'); + $result = $this->ossClient->getObject($this->bucket, $object); + $this->assertEquals($result, 'testcontent'); + } + + public function testCreateBucketWithInvalidStorageType() + { + try { + $options = array( + OssClient::OSS_STORAGE => 'unknown' + ); + $this->ossClient->createBucket('bucket-name', OssClient::OSS_ACL_TYPE_PRIVATE, $options); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + if (strpos($e, "storage name is invalid") == false) + { + $this->assertTrue(false); + } + } + } + + protected function setUp(): void + { + parent::setUp(); + + $this->iaBucket = 'ia-' . $this->bucket; + $this->archiveBucket = 'archive-' . $this->bucket; + $this->standardBucket = 'standard-' . $this->bucket; + + $options = array( + OssClient::OSS_STORAGE => OssClient::OSS_STORAGE_IA + ); + + $this->ossClient->createBucket($this->iaBucket, OssClient::OSS_ACL_TYPE_PRIVATE, $options); + + $options = array( + OssClient::OSS_STORAGE => OssClient::OSS_STORAGE_ARCHIVE + ); + + $this->ossClient->createBucket($this->archiveBucket, OssClient::OSS_ACL_TYPE_PRIVATE, $options); + + $options = array( + OssClient::OSS_STORAGE => OssClient::OSS_STORAGE_STANDARD + ); + + $this->ossClient->createBucket($this->standardBucket, OssClient::OSS_ACL_TYPE_PRIVATE, $options); + } + + protected function tearDown(): void + { + parent::tearDown(); + + $object = 'storage-object'; + + $this->ossClient->deleteObject($this->iaBucket, $object); + $this->ossClient->deleteObject($this->archiveBucket, $object); + $this->ossClient->deleteBucket($this->iaBucket); + $this->ossClient->deleteBucket($this->archiveBucket); + $this->ossClient->deleteBucket($this->standardBucket); + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketTransferAccelerationTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketTransferAccelerationTest.php new file mode 100644 index 0000000..24c8b51 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketTransferAccelerationTest.php @@ -0,0 +1,40 @@ +ossClient->getBucketTransferAcceleration($this->bucket); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertEquals("NoSuchTransferAccelerationConfiguration", $e->getErrorCode()); + } + + try { + $this->ossClient->putBucketTransferAcceleration($this->bucket, true); + Common::waitMetaSync(); + $status = $this->ossClient->getBucketTransferAcceleration($this->bucket); + $this->assertEquals(true, $status); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $this->ossClient->putBucketTransferAcceleration($this->bucket, false); + Common::waitMetaSync(); + $status = $this->ossClient->getBucketTransferAcceleration($this->bucket); + $this->assertEquals(false, $status); + } catch (OssException $e) { + $this->assertTrue(false); + } + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketVersioningTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketVersioningTest.php new file mode 100644 index 0000000..d9aa5a4 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketVersioningTest.php @@ -0,0 +1,40 @@ +ossClient->getBucketVersioning($this->bucket); + $this->assertEquals(null, $status); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $this->ossClient->putBucketVersioning($this->bucket, "Enabled"); + Common::waitMetaSync(); + $status = $this->ossClient->getBucketVersioning($this->bucket); + $this->assertEquals("Enabled", $status); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $this->ossClient->putBucketVersioning($this->bucket, "Suspended"); + Common::waitMetaSync(); + $status = $this->ossClient->getBucketVersioning($this->bucket); + $this->assertEquals("Suspended", $status); + } catch (OssException $e) { + $this->assertTrue(false); + } + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketWebsiteTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketWebsiteTest.php new file mode 100644 index 0000000..dfa9cc1 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketWebsiteTest.php @@ -0,0 +1,46 @@ +ossClient->putBucketWebsite($this->bucket, $websiteConfig); + } catch (OssException $e) { + var_dump($e->getMessage()); + $this->assertTrue(false); + } + + try { + Common::waitMetaSync(); + $websiteConfig2 = $this->ossClient->getBucketWebsite($this->bucket); + $this->assertEquals($websiteConfig->serializeToXml(), $websiteConfig2->serializeToXml()); + } catch (OssException $e) { + $this->assertTrue(false); + } + try { + Common::waitMetaSync(); + $this->ossClient->deleteBucketWebsite($this->bucket); + } catch (OssException $e) { + $this->assertTrue(false); + } + try { + Common::waitMetaSync(); + $websiteConfig3 = $this->ossClient->getBucketLogging($this->bucket); + $this->assertNotEquals($websiteConfig->serializeToXml(), $websiteConfig3->serializeToXml()); + } catch (OssException $e) { + $this->assertTrue(false); + } + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketWormTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketWormTest.php new file mode 100644 index 0000000..85df417 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketWormTest.php @@ -0,0 +1,36 @@ +ossClient->initiateBucketWorm($this->bucket, 30); + $config = $this->ossClient->getBucketWorm($this->bucket); + $this->assertEquals($wormId, $config->getWormId()); + $this->assertEquals("InProgress", $config->getState()); + $this->assertEquals(30, $config->getDay()); + $this->ossClient->abortBucketWorm($this->bucket); + + $wormId = $this->ossClient->initiateBucketWorm($this->bucket, 60); + $this->ossClient->completeBucketWorm($this->bucket, $wormId); + $config = $this->ossClient->getBucketWorm($this->bucket); + + $this->ossClient->ExtendBucketWorm($this->bucket, $wormId, 120); + $config = $this->ossClient->getBucketWorm($this->bucket); + $this->assertEquals($wormId, $config->getWormId()); + $this->assertEquals("Locked", $config->getState()); + $this->assertEquals(120, $config->getDay()); + + } catch (OssException $e) { + $this->assertTrue(false); + } + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientForcePathStyleTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientForcePathStyleTest.php new file mode 100644 index 0000000..a441718 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientForcePathStyleTest.php @@ -0,0 +1,124 @@ + OssClient::OSS_SIGNATURE_VERSION_V4, + 'forcePathStyle' => true, + ); + + $pathStyleClient = Common::getOssClient($config); + + try { + $pathStyleClient->getBucketInfo($this->bucket); + $this->assertTrue(false, "should not here"); + } catch (OssException $e) { + $this->assertEquals($e->getErrorCode(), "SecondLevelDomainForbidden"); + $this->assertTrue(true); + } + + try { + $object = "oss-php-sdk-test/upload-test-object-name.txt"; + $pathStyleClient->putObject($this->bucket, $object, 'hi oss'); + $this->assertTrue(false, "should not here"); + } catch (OssException $e) { + $this->assertEquals($e->getErrorCode(), "SecondLevelDomainForbidden"); + $this->assertTrue(true); + } + + try { + $endpoint = Common::getEndpoint(); + $endpoint = str_replace(array('http://', 'https://'), '', $endpoint); + $strUrl = $endpoint . "/" . $this->bucket . '/' . $object; + $signUrl = $pathStyleClient->signUrl($this->bucket, $object, 3600); + $this->assertTrue(strpos($signUrl, $strUrl) !== false); + } catch (OssException $e) { + $this->assertFalse(true); + } + } + + public function testForcePathStyleOKV1() + { + $bucket = Common::getPathStyleBucket(); + + $this->assertFalse(empty($bucket), "path style bucket is not set."); + + $config = array( + 'signatureVersion' => OssClient::OSS_SIGNATURE_VERSION_V1, + 'forcePathStyle' => true, + ); + + $pathStyleClient = Common::getOssClient($config); + + // bucket + $info = $pathStyleClient->getBucketInfo($bucket); + $this->assertEquals($bucket, $info->getName()); + + // object + $object = "upload-test-object-name.txt"; + $pathStyleClient->putObject($bucket, $object, 'hi oss'); + $res = $pathStyleClient->getObject($bucket, $object); + $this->assertEquals($res, 'hi oss'); + + //presign + $signUrl = $pathStyleClient->signUrl($bucket, $object, 3600); + + $httpCore = new RequestCore($signUrl); + $httpCore->set_body(""); + $httpCore->set_method("GET"); + $httpCore->connect_timeout = 10; + $httpCore->timeout = 10; + $httpCore->add_header("Content-Type", ""); + $httpCore->send_request(); + $this->assertEquals(200, $httpCore->response_code); + } + + public function testForcePathStyleOKV4() + { + $bucket = Common::getPathStyleBucket(); + + $this->assertFalse(empty($bucket), "path style bucket is not set."); + + $config = array( + 'signatureVersion' => OssClient::OSS_SIGNATURE_VERSION_V4, + 'forcePathStyle' => true, + ); + + $pathStyleClient = Common::getOssClient($config); + + // bucket + $info = $pathStyleClient->getBucketInfo($bucket); + $this->assertEquals($bucket, $info->getName()); + + // object + $object = "upload-test-object-name.txt"; + $pathStyleClient->putObject($bucket, $object, 'hi oss'); + $res = $pathStyleClient->getObject($bucket, $object); + $this->assertEquals($res, 'hi oss'); + + //presign + $signUrl = $pathStyleClient->signUrl($bucket, $object, 3600); + + #print("signUrl" . $signUrl . "\n"); + + $httpCore = new RequestCore($signUrl); + $httpCore->set_body(""); + $httpCore->set_method("GET"); + $httpCore->connect_timeout = 10; + $httpCore->timeout = 10; + $httpCore->add_header("Content-Type", ""); + $httpCore->send_request(); + $this->assertEquals(200, $httpCore->response_code); + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientImageTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientImageTest.php new file mode 100644 index 0000000..a43584e --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientImageTest.php @@ -0,0 +1,149 @@ +client = $this->ossClient; + $this->bucketName = $this->bucket; + $this->local_file = "example.jpg"; + $this->object = "oss-example.jpg"; + $this->download_file = "image.jpg"; + + Common::waitMetaSync(); + $this->client->uploadFile($this->bucketName, $this->object, $this->local_file); + } + + protected function tearDown(): void + { + parent::tearDown(); + unlink($this->download_file); + } + + public function testImageResize() + { + $options = array( + OssClient::OSS_FILE_DOWNLOAD => $this->download_file, + OssClient::OSS_PROCESS => "image/resize,m_fixed,h_100,w_100",); + $this->check($options, 100, 100, 3267, 'jpg'); + } + + public function testImageCrop() + { + $options = array( + OssClient::OSS_FILE_DOWNLOAD => $this->download_file, + OssClient::OSS_PROCESS => "image/crop,w_100,h_100,x_100,y_100,r_1",); + $this->check($options, 100, 100, 1969, 'jpg'); + } + + public function testImageRotate() + { + $options = array( + OssClient::OSS_FILE_DOWNLOAD => $this->download_file, + OssClient::OSS_PROCESS => "image/rotate,90",); + $this->check($options, 267, 400, 20998, 'jpg'); + } + + public function testImageSharpen() + { + $options = array( + OssClient::OSS_FILE_DOWNLOAD => $this->download_file, + OssClient::OSS_PROCESS => "image/sharpen,100",); + $this->check($options, 400, 267, 23015, 'jpg'); + } + + public function testImageWatermark() + { + $options = array( + OssClient::OSS_FILE_DOWNLOAD => $this->download_file, + OssClient::OSS_PROCESS => "image/watermark,text_SGVsbG8g5Zu-54mH5pyN5YqhIQ",); + $this->check($options, 400, 267, 26369, 'jpg'); + } + + public function testImageFormat() + { + $options = array( + OssClient::OSS_FILE_DOWNLOAD => $this->download_file, + OssClient::OSS_PROCESS => "image/format,png",); + $this->check($options, 400, 267, 160733, 'png'); + } + + public function testImageTofile() + { + $options = array( + OssClient::OSS_FILE_DOWNLOAD => $this->download_file, + OssClient::OSS_PROCESS => "image/resize,m_fixed,w_100,h_100",); + $this->check($options, 100, 100, 3267, 'jpg'); + } + + public function testProcesObject() + { + $object = 'process-object.jpg'; + $process = 'image/resize,m_fixed,w_100,h_100' . + '|sys/saveas' . + ',o_' . $this->base64url_encode($object) . + ',b_' . $this->base64url_encode($this->bucketName); + $result = $this->client->processObject($this->bucketName, $this->object, $process); + $this->assertTrue(stripos($result, '"object": "process-object.jpg",') > 0); + $this->assertTrue(stripos($result, '"status": "OK"') > 0); + + + $options = array( + OssClient::OSS_FILE_DOWNLOAD => $this->download_file, + ); + $this->client->getObject($this->bucketName, $object, $options); + $array = getimagesize($this->download_file); + $this->assertEquals(100, $array[0]); + $this->assertEquals(100, $array[1]); + $this->assertEquals(2, $array[2]); + + //without bucket + $object = 'process-object-1.jpg'; + $process = 'image/watermark,text_SGVsbG8g5Zu-54mH5pyN5YqhIQ' . + '|sys/saveas' . + ',o_' . $this->base64url_encode($object); + $result = $this->client->processObject($this->bucketName, $this->object, $process); + $this->assertTrue(stripos($result, '"object": "process-object-1.jpg",') > 0); + $this->assertTrue(stripos($result, '"status": "OK"') > 0); + + + $options = array( + OssClient::OSS_FILE_DOWNLOAD => $this->download_file, + ); + $this->client->getObject($this->bucketName, $object, $options); + $array = getimagesize($this->download_file); + $this->assertEquals(400, $array[0]); + $this->assertEquals(267, $array[1]); + $this->assertEquals(2, $array[2]); + } + + private function check($options, $width, $height, $size, $type) + { + $this->client->getObject($this->bucketName, $this->object, $options); + $array = getimagesize($this->download_file); + $this->assertEquals($width, $array[0]); + $this->assertEquals($height, $array[1]); + $this->assertEquals($type === 'jpg' ? 2 : 3, $array[2]);//2 <=> jpg + } + + private function base64url_encode($data) + { + return rtrim(strtr(base64_encode($data), '+/', '-_'), '='); + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientListObjectsTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientListObjectsTest.php new file mode 100644 index 0000000..8ee47a2 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientListObjectsTest.php @@ -0,0 +1,184 @@ +ossClient->listObjects($this->bucket); + $objectList = $listObjectInfo->getObjectList(); + $prefixList = $listObjectInfo->getPrefixList(); + $this->assertNotNull($objectList); + $this->assertNotNull($prefixList); + $this->assertTrue(is_array($objectList)); + $this->assertTrue(is_array($prefixList)); + $this->assertEquals((2), count($objectList)); + $this->assertEquals(4, count($prefixList)); + + $this->assertEquals('file++00', $objectList[0]->getKey()); + $this->assertEquals('file++01', $objectList[1]->getKey()); + + $this->assertEquals('folder/', $prefixList[0]->getPrefix()); + $this->assertEquals('sub++/', $prefixList[1]->getPrefix()); + $this->assertEquals('test/', $prefixList[2]->getPrefix()); + $this->assertEquals('work/', $prefixList[3]->getPrefix()); + + } catch (OssException $e) { + $this->assertTrue(false); + } + } + + public function testListObjectsWithPrefix() + { + /** + * List the files in your bucket. + */ + $prefix = 'folder/'; + $delimiter = ''; + $next_marker = ''; + $maxkeys = 1000; + $options = array( + 'delimiter' => $delimiter, + 'prefix' => $prefix, + 'max-keys' => $maxkeys, + 'marker' => $next_marker, + ); + + try { + $listObjectInfo = $this->ossClient->listObjects($this->bucket, $options); + $objectList = $listObjectInfo->getObjectList(); + $prefixList = $listObjectInfo->getPrefixList(); + $this->assertNotNull($objectList); + $this->assertNotNull($prefixList); + $this->assertTrue(is_array($objectList)); + $this->assertTrue(is_array($prefixList)); + $this->assertEquals(12, count($objectList)); + $this->assertEquals(0, count($prefixList)); + + $this->assertEquals('folder/00', $objectList[0]->getKey()); + $this->assertEquals('folder/01', $objectList[1]->getKey()); + $this->assertEquals('folder/11', $objectList[11]->getKey()); + + } catch (OssException $e) { + $this->assertTrue(false); + } + } + + public function testListObjectsWithMaxKeysAndMarker() + { + $count = 0; + $nextMarker = ''; + + while (true) { + try { + $options = array( + 'delimiter' => '', + 'marker' => $nextMarker, + 'max-keys' => 2, + ); + $listObjectInfo = $this->ossClient->listObjects($this->bucket, $options); + } catch (OssException $e) { + $this->assertTrue(false); + } + $nextMarker = $listObjectInfo->getNextMarker(); + $listObject = $listObjectInfo->getObjectList(); + $count += count($listObject); + $this->assertEquals(2, count($listObject)); + if ($listObjectInfo->getIsTruncated() !== "true") { + break; + } + } + $this->assertEquals(12 + 8 + 5 + 3 + 2, $count); + } + + public function testListObjectsWithMarker() + { + $count = 0; + $nextMarker = 'h'; + + while (true) { + try { + $options = array( + 'delimiter' => '', + 'marker' => $nextMarker, + 'max-keys' => 1, + ); + $listObjectInfo = $this->ossClient->listObjects($this->bucket, $options); + } catch (OssException $e) { + $this->assertTrue(false); + } + $nextMarker = $listObjectInfo->getNextMarker(); + $listObject = $listObjectInfo->getObjectList(); + $count += count($listObject); + $this->assertEquals(1, count($listObject)); + if ($listObjectInfo->getIsTruncated() !== "true") { + break; + } + } + $this->assertEquals(8 + 5 + 3, $count); + + + $nextMarker = 'h'; + + try { + $options = array( + 'delimiter' => '', + 'marker' => $nextMarker, + 'max-keys' => 5, + ); + $listObjectInfo = $this->ossClient->listObjects($this->bucket, $options); + } catch (OssException $e) { + $this->assertTrue(false); + } + $nextMarker = $listObjectInfo->getNextMarker(); + $listObject = $listObjectInfo->getObjectList(); + $this->assertEquals('test/01', $nextMarker); + $this->assertEquals(5, count($listObject)); + $this->assertEquals("true", $listObjectInfo->getIsTruncated()); + } + + protected function setUp(): void + { + parent::setUp(); + //folder + for ($i = 0; $i < 12; $i++) { + $key = 'folder/'. sprintf("%02d",$i); + $this->ossClient->putObject($this->bucket, $key, "content"); + } + //test + for ($i = 0; $i < 8; $i++) { + $key = 'test/'. sprintf("%02d",$i); + $this->ossClient->putObject($this->bucket, $key, "content"); + } + //work + for ($i = 0; $i < 5; $i++) { + $key = 'work/'. sprintf("%02d",$i); + $this->ossClient->putObject($this->bucket, $key, "content"); + } + //sub++ + for ($i = 0; $i < 3; $i++) { + $key = 'sub++/'. sprintf("%02d",$i); + $this->ossClient->putObject($this->bucket, $key, "content"); + } + + //file++ + for ($i = 0; $i < 2; $i++) { + $key = 'file++'. sprintf("%02d",$i); + $this->ossClient->putObject($this->bucket, $key, "content"); + } + + } + + protected function tearDown(): void + { + parent::tearDown(); + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientListObjectsV2Test.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientListObjectsV2Test.php new file mode 100644 index 0000000..c913283 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientListObjectsV2Test.php @@ -0,0 +1,175 @@ +ossClient->putObject($this->bucket, $key, "content"); + } + //test + for ($i = 0; $i < 8; $i++) { + $key = 'test/'. sprintf("%02d",$i); + $this->ossClient->putObject($this->bucket, $key, "content"); + } + //work + for ($i = 0; $i < 5; $i++) { + $key = 'work/'. sprintf("%02d",$i); + $this->ossClient->putObject($this->bucket, $key, "content"); + } + //sub++ + for ($i = 0; $i < 3; $i++) { + $key = 'sub++/'. sprintf("%02d",$i); + $this->ossClient->putObject($this->bucket, $key, "content"); + } + + //file++ + for ($i = 0; $i < 2; $i++) { + $key = 'file++'. sprintf("%02d",$i); + $this->ossClient->putObject($this->bucket, $key, "content"); + } + + } + + protected function tearDown(): void + { + parent::tearDown(); + } + public function testListObjectsDefault() + { + try { + $listObjectInfo = $this->ossClient->listObjectsV2($this->bucket); + $objectList = $listObjectInfo->getObjectList(); + $prefixList = $listObjectInfo->getPrefixList(); + $this->assertNotNull($objectList); + $this->assertNotNull($prefixList); + $this->assertTrue(is_array($objectList)); + $this->assertTrue(is_array($prefixList)); + $this->assertEquals((2), count($objectList)); + $this->assertEquals(4, count($prefixList)); + + $this->assertEquals('file++00', $objectList[0]->getKey()); + $this->assertEquals('file++01', $objectList[1]->getKey()); + + $this->assertEquals('folder/', $prefixList[0]->getPrefix()); + $this->assertEquals('sub++/', $prefixList[1]->getPrefix()); + $this->assertEquals('test/', $prefixList[2]->getPrefix()); + $this->assertEquals('work/', $prefixList[3]->getPrefix()); + + } catch (OssException $e) { + $this->assertTrue(false); + } + } + + + public function testListObjectsWithPrefix() + { + /** + * List the files in your bucket. + */ + $prefix = 'folder/'; + $delimiter = ''; + $maxkeys = 1000; + $options = array( + 'delimiter' => $delimiter, + 'prefix' => $prefix, + 'max-keys' => $maxkeys, + ); + + try { + $listObjectInfo = $this->ossClient->listObjectsV2($this->bucket, $options); + $objectList = $listObjectInfo->getObjectList(); + $prefixList = $listObjectInfo->getPrefixList(); + $this->assertNotNull($objectList); + $this->assertNotNull($prefixList); + $this->assertTrue(is_array($objectList)); + $this->assertTrue(is_array($prefixList)); + $this->assertEquals(12, count($objectList)); + $this->assertEquals(0, count($prefixList)); + + $this->assertEquals('folder/00', $objectList[0]->getKey()); + $this->assertEquals('folder/01', $objectList[1]->getKey()); + $this->assertEquals('folder/11', $objectList[11]->getKey()); + + } catch (OssException $e) { + $this->assertTrue(false); + } + } + + + public function testListObjectsWithMaxKeysAndMarker() + { + $count = 0; + $options = array( + 'delimiter' => '', + 'max-keys' => 2, + ); + + while (true) { + try { + + $listObjectInfo = $this->ossClient->listObjectsV2($this->bucket, $options); + } catch (OssException $e) { + $this->assertTrue(false); + } + $options[OssClient::OSS_CONTINUATION_TOKEN] = $listObjectInfo->getNextContinuationToken(); + $listObject = $listObjectInfo->getObjectList(); + $count += count($listObject); + $this->assertEquals(2, count($listObject)); + if ($listObjectInfo->getIsTruncated() !== "true") { + break; + } + } + $this->assertEquals(12 + 8 + 5 + 3 + 2, $count); + } + + + public function testListObjectsWithStartAfter() + { + $count = 0; + $options = array( + 'delimiter' => '', + 'start-after' => 'folder/11', + 'max-keys' => 1, + ); + while (true) { + try { + $listObjectInfo = $this->ossClient->listObjectsV2($this->bucket, $options); + } catch (OssException $e) { + $this->assertTrue(false); + } + $options[OssClient::OSS_CONTINUATION_TOKEN] = $listObjectInfo->getNextContinuationToken(); + $listObject = $listObjectInfo->getObjectList(); + $count += count($listObject); + $this->assertEquals(1, count($listObject)); + if ($listObjectInfo->getIsTruncated() !== "true") { + break; + } + } + $this->assertEquals(8 + 5 + 3, $count); + $options2 = array( + 'delimiter' => '', + 'start-after' => 'folder/11', + 'max-keys' => 5, + ); + try { + $listObjectInfo = $this->ossClient->listObjectsV2($this->bucket, $options2); + } catch (OssException $e) { + $this->assertTrue(false); + } + $listObject = $listObjectInfo->getObjectList(); + $this->assertEquals(5, count($listObject)); + $this->assertEquals("true", $listObjectInfo->getIsTruncated()); + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientMultipartUploadTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientMultipartUploadTest.php new file mode 100644 index 0000000..3cd6a1e --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientMultipartUploadTest.php @@ -0,0 +1,476 @@ +ossClient->uploadDir($this->bucket, "", "abc/ds/s/s/notexitst"); + $this->assertFalse(true); + } catch (OssException $e) { + $this->assertEquals("parameter error: abc/ds/s/s/notexitst is not a directory, please check it", $e->getMessage()); + } + + } + + public function testMultipartUploadBigFile() + { + $bigFileName = __DIR__ . DIRECTORY_SEPARATOR . "/bigfile.tmp"; + $localFilename = __DIR__ . DIRECTORY_SEPARATOR . "/localfile.tmp"; + OssUtil::generateFile($bigFileName, 6 * 1024 * 1024); + $object = 'mpu/multipart-bigfile-test.tmp'; + try { + $this->ossClient->multiuploadFile($this->bucket, $object, $bigFileName, array(OssClient::OSS_PART_SIZE => 1)); + $options = array(OssClient::OSS_FILE_DOWNLOAD => $localFilename); + $this->ossClient->getObject($this->bucket, $object, $options); + $this->assertEquals(md5_file($bigFileName), md5_file($localFilename)); + } catch (OssException $e) { + var_dump($e->getMessage()); + $this->assertFalse(true); + } + unlink($bigFileName); + unlink($localFilename); + } + + public function testMultipartUploadBigFileWithMD5Check() + { + $bigFileName = __DIR__ . DIRECTORY_SEPARATOR . "/bigfile.tmp"; + $localFilename = __DIR__ . DIRECTORY_SEPARATOR . "/localfile.tmp"; + OssUtil::generateFile($bigFileName, 6 * 1024 * 1024); + $object = 'mpu/multipart-bigfile-test.tmp'; + $options = array( + OssClient::OSS_CHECK_MD5 => true, + OssClient::OSS_PART_SIZE => 1, + ); + try { + $this->ossClient->multiuploadFile($this->bucket, $object, $bigFileName, $options); + $options = array(OssClient::OSS_FILE_DOWNLOAD => $localFilename); + $this->ossClient->getObject($this->bucket, $object, $options); + $this->assertEquals(md5_file($bigFileName), md5_file($localFilename)); + } catch (OssException $e) { + var_dump($e->getMessage()); + $this->assertFalse(true); + } + unlink($bigFileName); + unlink($localFilename); + } + + public function testCopyPart() + { + $object = "mpu/multipart-test.txt"; + $copiedObject = "mpu/multipart-test.txt.copied"; + $this->ossClient->putObject($this->bucket, $copiedObject, file_get_contents(__FILE__)); + try { + $upload_id = $this->ossClient->initiateMultipartUpload($this->bucket, $object); + } catch (OssException $e) { + $this->assertFalse(true); + } + + $copyId = 1; + $eTag = $this->ossClient->uploadPartCopy($this->bucket, $copiedObject, $this->bucket, $object, $copyId, $upload_id); + $upload_parts[] = array( + 'PartNumber' => $copyId, + 'ETag' => $eTag, + ); + + try { + $listPartsInfo = $this->ossClient->listParts($this->bucket, $object, $upload_id); + $this->assertNotNull($listPartsInfo); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $this->ossClient->completeMultipartUpload($this->bucket, $object, $upload_id, $upload_parts); + } catch (OssException $e) { + var_dump($e->getMessage()); + $this->assertTrue(false); + } + + $this->assertEquals($this->ossClient->getObject($this->bucket, $object), file_get_contents(__FILE__)); + $this->assertEquals($this->ossClient->getObject($this->bucket, $copiedObject), file_get_contents(__FILE__)); + } + + public function testCopyPartWithRange() + { + $object = "mpu/multipart-test.txt"; + $copiedObject = "mpu/multipart-test.txt.range.copied"; + $this->ossClient->putObject($this->bucket, $copiedObject, file_get_contents(__FILE__)); + try { + $upload_id = $this->ossClient->initiateMultipartUpload($this->bucket, $object); + } catch (OssException $e) { + $this->assertFalse(true); + } + /* + * step 2. uploadPartCopy + */ + $copyId = 1; + $options = array( + 'start' => 0, + 'end' => 3, + ); + $eTag = $this->ossClient->uploadPartCopy($this->bucket, $copiedObject, $this->bucket, $object, $copyId, $upload_id, $options); + $upload_parts[] = array( + 'PartNumber' => $copyId, + 'ETag' => $eTag, + ); + + try { + $listPartsInfo = $this->ossClient->listParts($this->bucket, $object, $upload_id); + $this->assertNotNull($listPartsInfo); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $this->ossClient->completeMultipartUpload($this->bucket, $object, $upload_id, $upload_parts); + } catch (OssException $e) { + var_dump($e->getMessage()); + $this->assertTrue(false); + } + + $this->assertEquals($this->ossClient->getObject($this->bucket, $copiedObject), file_get_contents(__FILE__)); + $this->assertEquals($this->ossClient->getObject($this->bucket, $object), 'ossClient->initiateMultipartUpload($this->bucket, $object); + } catch (OssException $e) { + $this->assertFalse(true); + } + $part_size = 10 * 1024 * 1024; + $upload_file = __FILE__; + $upload_filesize = sprintf('%u',filesize($upload_file)); + $pieces = $this->ossClient->generateMultiuploadParts($upload_filesize, $part_size); + $response_upload_part = array(); + $upload_position = 0; + $is_check_md5 = true; + foreach ($pieces as $i => $piece) { + $from_pos = $upload_position + (integer)$piece[OssClient::OSS_SEEK_TO]; + $to_pos = (integer)$piece[OssClient::OSS_LENGTH] + $from_pos - 1; + $up_options = array( + OssClient::OSS_FILE_UPLOAD => $upload_file, + OssClient::OSS_PART_NUM => ($i + 1), + OssClient::OSS_SEEK_TO => $from_pos, + OssClient::OSS_LENGTH => $to_pos - $from_pos + 1, + OssClient::OSS_CHECK_MD5 => $is_check_md5, + ); + if ($is_check_md5) { + $content_md5 = OssUtil::getMd5SumForFile($upload_file, $from_pos, $to_pos); + $up_options[OssClient::OSS_CONTENT_MD5] = $content_md5; + } + //2. 将每一分片上传到OSS + try { + $response_upload_part[] = $this->ossClient->uploadPart($this->bucket, $object, $upload_id, $up_options); + } catch (OssException $e) { + $this->assertFalse(true); + } + } + $upload_parts = array(); + foreach ($response_upload_part as $i => $eTag) { + $upload_parts[] = array( + 'PartNumber' => ($i + 1), + 'ETag' => $eTag, + ); + } + + try { + $listPartsInfo = $this->ossClient->listParts($this->bucket, $object, $upload_id, array('max-parts' => 100)); + $this->assertNotNull($listPartsInfo); + } catch (OssException $e) { + $this->assertTrue(false); + } + $this->assertEquals(1, count($listPartsInfo->getListPart())); + + $numOfMultipartUpload1 = 0; + $options = null; + try { + $listMultipartUploadInfo = $listMultipartUploadInfo = $this->ossClient->listMultipartUploads($this->bucket, $options); + $this->assertNotNull($listMultipartUploadInfo); + $numOfMultipartUpload1 = count($listMultipartUploadInfo->getUploads()); + } catch (OssException $e) { + $this->assertFalse(true); + } + + try { + $this->ossClient->abortMultipartUpload($this->bucket, $object, $upload_id); + } catch (OssException $e) { + $this->assertTrue(false); + } + + $numOfMultipartUpload2 = 0; + try { + $listMultipartUploadInfo = $listMultipartUploadInfo = $this->ossClient->listMultipartUploads($this->bucket, array('max-uploads' => 1000)); + $this->assertNotNull($listMultipartUploadInfo); + $numOfMultipartUpload2 = count($listMultipartUploadInfo->getUploads()); + } catch (OssException $e) { + $this->assertFalse(true); + } + $this->assertEquals($numOfMultipartUpload1 - 1, $numOfMultipartUpload2); + } + + public function testPutObjectByRawApis() + { + $object = "mpu/multipart-test.txt"; + try { + $upload_id = $this->ossClient->initiateMultipartUpload($this->bucket, $object); + } catch (OssException $e) { + $this->assertFalse(true); + } + $part_size = 10 * 1024 * 1024; + $upload_file = __FILE__; + $upload_filesize = sprintf('%u',filesize($upload_file)); + $pieces = $this->ossClient->generateMultiuploadParts($upload_filesize, $part_size); + $response_upload_part = array(); + $upload_position = 0; + $is_check_md5 = true; + foreach ($pieces as $i => $piece) { + $from_pos = $upload_position + (integer)$piece[OssClient::OSS_SEEK_TO]; + $to_pos = (integer)$piece[OssClient::OSS_LENGTH] + $from_pos - 1; + $up_options = array( + OssClient::OSS_FILE_UPLOAD => $upload_file, + OssClient::OSS_PART_NUM => ($i + 1), + OssClient::OSS_SEEK_TO => $from_pos, + OssClient::OSS_LENGTH => $to_pos - $from_pos + 1, + OssClient::OSS_CHECK_MD5 => $is_check_md5, + ); + if ($is_check_md5) { + $content_md5 = OssUtil::getMd5SumForFile($upload_file, $from_pos, $to_pos); + $up_options[OssClient::OSS_CONTENT_MD5] = $content_md5; + } + //2. 将每一分片上传到OSS + try { + $response_upload_part[] = $this->ossClient->uploadPart($this->bucket, $object, $upload_id, $up_options); + } catch (OssException $e) { + $this->assertFalse(true); + } + } + $upload_parts = array(); + foreach ($response_upload_part as $i => $eTag) { + $upload_parts[] = array( + 'PartNumber' => ($i + 1), + 'ETag' => $eTag, + ); + } + + try { + $listPartsInfo = $this->ossClient->listParts($this->bucket, $object, $upload_id); + $this->assertNotNull($listPartsInfo); + } catch (OssException $e) { + $this->assertTrue(false); + } + + /** + * step 3. + */ + try { + $this->ossClient->completeMultipartUpload($this->bucket, $object, $upload_id, $upload_parts); + } catch (OssException $e) { + $this->assertTrue(false); + } + } + + function testPutObjectsByDir() + { + $localDirectory = dirname(__FILE__); + $prefix = "samples/codes"; + try { + $this->ossClient->uploadDir($this->bucket, $prefix, $localDirectory); + } catch (OssException $e) { + var_dump($e->getMessage()); + $this->assertFalse(true); + + } + $this->assertTrue($this->ossClient->doesObjectExist($this->bucket, 'samples/codes/' . "OssClientMultipartUploadTest.php")); + } + + public function testPutObjectByMultipartUpload() + { + $object = "mpu/multipart-test.txt"; + $file = __FILE__; + $options = array(); + + try { + $this->ossClient->multiuploadFile($this->bucket, $object, $file, $options); + $this->assertFalse(false); + } catch (OssException $e) { + $this->assertFalse(true); + } + } + + public function testPutObjectByMultipartUploadWithMD5Check() + { + $object = "mpu/multipart-test.txt"; + $file = __FILE__; + $options = array(OssClient::OSS_CHECK_MD5 => true); + + try { + $this->ossClient->multiuploadFile($this->bucket, $object, $file, $options); + $this->assertFalse(false); + } catch (OssException $e) { + $this->assertFalse(true); + } + } + + public function testPutObjectByMultipartUploadWithOSS_LENGTH() + { + $object = "mpu/multipart-test-length.txt"; + $file = __FILE__; + + try { + $upload_id = $this->ossClient->initiateMultipartUpload($this->bucket, $object); + $options = array(OssClient::OSS_LENGTH => 4, OssClient::OSS_UPLOAD_ID => $upload_id); + $this->ossClient->multiuploadFile($this->bucket, $object, $file, $options); + $this->assertEquals($this->ossClient->getObject($this->bucket, $object), 'assertFalse(true); + } + } + + public function testPutObjectByMultipartUploadWithOSS_CONTENT_LENGTH() + { + $object = "mpu/multipart-test-content-length.txt"; + $file = __FILE__; + + try { + $upload_id = $this->ossClient->initiateMultipartUpload($this->bucket, $object); + $options = array(OssClient::OSS_CONTENT_LENGTH => 4, OssClient::OSS_UPLOAD_ID => $upload_id); + $this->ossClient->multiuploadFile($this->bucket, $object, $file, $options); + $this->assertEquals($this->ossClient->getObject($this->bucket, $object), 'assertFalse(true); + } + } + + public function testPutObjectByMultipartUploadWithException() + { + $object = "mpu/multipart-test-exception.txt"; + $file = ""; + + try { + $this->ossClient->multiuploadFile($this->bucket, $object, $file); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + if (strpos($e, "parameter invalid, file is empty") == false) + { + $this->assertTrue(true); + } + } + } + + public function testListMultipartUploads() + { + $options = null; + try { + $listMultipartUploadInfo = $this->ossClient->listMultipartUploads($this->bucket, $options); + $this->assertNotNull($listMultipartUploadInfo); + } catch (OssException $e) { + $this->assertFalse(true); + } + } + + public function testCompleteMultipartUploadWithException() + { + $object = "mpu/multipart-test-complete.txt"; + $uploadId = "uploadId"; + try { + $listMultipartUploadInfo = $this->ossClient->completeMultipartUpload($this->bucket, $object, $uploadId, null); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertEquals('NoSuchUpload', $e->getErrorCode()); + } + } + + public function testCompleteMultipartUploadWithEmptyArray(){ + $object = 'multipart-test-complete.txt'; + try { + $uploadId = $this->ossClient->initiateMultipartUpload($this->bucket, $object); + $listMultipartUploadInfo = $this->ossClient->completeMultipartUpload($this->bucket, $object, $uploadId, array()); + $this->assertNotNull($listMultipartUploadInfo); + } catch (OssException $e) { + $this->assertFalse(true); + } + + } + + + public function testCompleteMultipartUploadWithNull(){ + $object = "mpu/multipart-test.txt"; + try { + $upload_id = $this->ossClient->initiateMultipartUpload($this->bucket, $object); + } catch (OssException $e) { + $this->assertFalse(true); + } + + $part_size = 5 * 1024 * 1024; + $upload_file = __FILE__; + $upload_filesize = sprintf('%u',filesize($upload_file)); + $pieces = $this->ossClient->generateMultiuploadParts($upload_filesize, $part_size); + $response_upload_part = array(); + $upload_position = 0; + $is_check_md5 = true; + foreach ($pieces as $i => $piece) { + $from_pos = $upload_position + (integer)$piece[OssClient::OSS_SEEK_TO]; + $to_pos = (integer)$piece[OssClient::OSS_LENGTH] + $from_pos - 1; + $up_options = array( + OssClient::OSS_FILE_UPLOAD => $upload_file, + OssClient::OSS_PART_NUM => ($i + 1), + OssClient::OSS_SEEK_TO => $from_pos, + OssClient::OSS_LENGTH => $to_pos - $from_pos + 1, + OssClient::OSS_CHECK_MD5 => $is_check_md5, + ); + if ($is_check_md5) { + $content_md5 = OssUtil::getMd5SumForFile($upload_file, $from_pos, $to_pos); + $up_options[OssClient::OSS_CONTENT_MD5] = $content_md5; + } + try { + $response_upload_part[] = $this->ossClient->uploadPart($this->bucket, $object, $upload_id, $up_options); + } catch (OssException $e) { + $this->assertFalse(true); + } + } + $upload_parts = array(); + foreach ($response_upload_part as $i => $eTag) { + $upload_parts[] = array( + 'PartNumber' => ($i + 1), + 'ETag' => $eTag, + ); + } + + try { + $listPartsInfo = $this->ossClient->listParts($this->bucket, $object, $upload_id); + $this->assertNotNull($listPartsInfo); + } catch (OssException $e) { + $this->assertTrue(false); + } + + $options['headers'] = array( + 'x-oss-forbid-overwrite' => 'false', + 'x-oss-complete-all'=> 'yes' + ); + + try { + $result = $this->ossClient->completeMultipartUpload($this->bucket, $object, $upload_id, null,$options); + $this->assertNotNull($result); + } catch (OssException $e) { + $this->assertTrue(false); + } + + } + + + +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientObjectRequestPaymentTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientObjectRequestPaymentTest.php new file mode 100644 index 0000000..9f645d3 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientObjectRequestPaymentTest.php @@ -0,0 +1,472 @@ +payerClient->listObjects($this->bucket); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertEquals('AccessDenied', $e->getErrorCode()); + } + + try { + $this->payerClient->createObjectDir($this->bucket, 'folder/'); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertEquals('AccessDenied', $e->getErrorCode()); + } + + try { + $this->payerClient->putObject($this->bucket, 'object', 'content'); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertEquals('AccessDenied', $e->getErrorCode()); + } + + try { + $this->payerClient->putSymlink($this->bucket, 'symlink', 'default-object'); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertEquals('AccessDenied', $e->getErrorCode()); + } + + try { + $this->payerClient->getSymlink($this->bucket, 'default-symlink'); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertEquals('AccessDenied', $e->getErrorCode()); + } + + try { + $this->payerClient->uploadFile($this->bucket, 'file-object', __FILE__); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertEquals('AccessDenied', $e->getErrorCode()); + } + + try { + $this->payerClient->appendObject($this->bucket, 'append-object', 'content', 0); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertEquals('AccessDenied', $e->getErrorCode()); + } + + try { + $this->payerClient->appendObject($this->bucket, 'append-file', __FILE__, 0); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertEquals('AccessDenied', $e->getErrorCode()); + } + + try { + $this->payerClient->copyObject($this->bucket, 'default-object', $this->bucket, 'copy-object'); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertEquals('AccessDenied', $e->getErrorCode()); + } + + try { + $this->payerClient->getObjectMeta($this->bucket, 'default-object'); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + } + + try { + $this->payerClient->getSimplifiedObjectMeta($this->bucket, 'default-object'); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + } + + try { + $this->payerClient->deleteObject($this->bucket, 'default-object'); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertEquals('AccessDenied', $e->getErrorCode()); + } + + try { + $this->payerClient->getObject($this->bucket, 'default-object'); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertEquals('AccessDenied', $e->getErrorCode()); + } + + try { + $this->payerClient->doesObjectExist($this->bucket, 'default-object'); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + } + + try { + $this->payerClient->restoreObject($this->bucket, 'default-ia-object'); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertEquals('AccessDenied', $e->getErrorCode()); + } + + try { + $config = new TaggingConfig(); + $config->addTag(new Tag("key1", "value1")); + $this->payerClient->putObjectTagging($this->bucket, 'default-object', $config); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertEquals('AccessDenied', $e->getErrorCode()); + } + + try { + $this->payerClient->getObjectTagging($this->bucket, 'default-object'); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertEquals('AccessDenied', $e->getErrorCode()); + } + + try { + $this->payerClient->deleteObjectTagging($this->bucket, 'default-object'); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertEquals('AccessDenied', $e->getErrorCode()); + } + + try { + $this->payerClient->initiateMultipartUpload($this->bucket, 'mup-object'); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertEquals('AccessDenied', $e->getErrorCode()); + } + + $uploadId= $this->ossClient->initiateMultipartUpload($this->bucket, 'mup-object'); + + try { + $this->payerClient->listParts($this->bucket, 'mup-object', $uploadId); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertEquals('AccessDenied', $e->getErrorCode()); + } + + try { + $this->payerClient->abortMultipartUpload($this->bucket, 'mup-object', $uploadId); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertEquals('AccessDenied', $e->getErrorCode()); + } + + try { + $this->payerClient->listMultipartUploads($this->bucket); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertEquals('AccessDenied', $e->getErrorCode()); + } + + try { + $this->payerClient->multiuploadFile($this->bucket, 'mup-file', __FILE__); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertEquals('AccessDenied', $e->getErrorCode()); + } + } + + public function testObjectOperationsWithRequester() + { + $options = array( + OssClient::OSS_HEADERS => array( + OssClient::OSS_REQUEST_PAYER => 'requester', + )); + + try { + $this->payerClient->listObjects($this->bucket, $options); + $this->assertTrue(true); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $this->payerClient->createObjectDir($this->bucket, 'folder/', $options); + $this->assertTrue(true); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $this->payerClient->putObject($this->bucket, 'object', 'content', $options); + $this->assertTrue(true); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $this->payerClient->putSymlink($this->bucket, 'symlink', 'default-object', $options); + $this->assertTrue(true); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $this->payerClient->getSymlink($this->bucket, 'default-symlink', $options); + $this->assertTrue(true); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $this->payerClient->uploadFile($this->bucket, 'file-object', __FILE__, $options); + $this->assertTrue(true); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $this->payerClient->appendObject($this->bucket, 'append-object', 'content', 0, $options); + $this->assertTrue(true); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $this->payerClient->appendObject($this->bucket, 'append-file', __FILE__, 0, $options); + $this->assertTrue(true); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $this->payerClient->copyObject($this->bucket, 'default-object', $this->bucket, 'copy-object', $options); + $this->assertTrue(true); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $this->payerClient->getObjectMeta($this->bucket, 'default-object', $options); + $this->assertTrue(true); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $this->payerClient->getSimplifiedObjectMeta($this->bucket, 'default-object', $options); + $this->assertTrue(true); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $this->payerClient->getObject($this->bucket, 'default-object', $options); + $this->assertTrue(true); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $this->payerClient->putObject($this->bucket, 'test-object', 'content', $options); + $this->assertTrue(true); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $this->payerClient->deleteObject($this->bucket, 'test-object', $options); + $this->assertTrue(true); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $this->payerClient->doesObjectExist($this->bucket, 'default-object', $options); + $this->assertTrue(true); + } catch (OssException $e) { + $this->assertTrue(false); + } + + $ia_options = array( + OssClient::OSS_HEADERS => array( + 'x-oss-storage-class' => 'Archive', + )); + $this->ossClient->putObject($this->bucket, 'default-Archive-object', 'content', $ia_options); + try { + $this->payerClient->restoreObject($this->bucket, 'default-Archive-object', $options); + $this->assertTrue(true); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $config = new TaggingConfig(); + $config->addTag(new Tag("key1", "value1")); + $this->payerClient->putObjectTagging($this->bucket, 'default-object', $config, $options); + $this->assertTrue(true); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $this->payerClient->getObjectTagging($this->bucket, 'default-object', $options); + $this->assertTrue(true); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $this->payerClient->deleteObjectTagging($this->bucket, 'default-object', $options); + $this->assertTrue(true); + } catch (OssException $e) { + $this->assertTrue(false); + } + } + + public function testMultipartOperationsWithRequester() + { + $options = array( + OssClient::OSS_HEADERS => array( + OssClient::OSS_REQUEST_PAYER => 'requester', + )); + + $object = "mpu/multipart-test.txt"; + /** + * step 1. 初始化一个分块上传事件, 也就是初始化上传Multipart, 获取upload id + */ + try { + $upload_id = $this->payerClient->initiateMultipartUpload($this->bucket, $object, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /* + * step 2. 上传分片 + */ + $part_size = 1 * 1024 * 1024; + $upload_file = __FILE__; + $upload_filesize = sprintf('%u',filesize($upload_file)); + $pieces = $this->payerClient->generateMultiuploadParts($upload_filesize, $part_size); + $response_upload_part = array(); + $upload_position = 0; + $is_check_md5 = false; + foreach ($pieces as $i => $piece) { + $from_pos = $upload_position + (integer)$piece[OssClient::OSS_SEEK_TO]; + $to_pos = (integer)$piece[OssClient::OSS_LENGTH] + $from_pos - 1; + $up_options = array( + OssClient::OSS_FILE_UPLOAD => $upload_file, + OssClient::OSS_PART_NUM => ($i + 1), + OssClient::OSS_SEEK_TO => $from_pos, + OssClient::OSS_LENGTH => $to_pos - $from_pos + 1, + OssClient::OSS_CHECK_MD5 => $is_check_md5, + OssClient::OSS_HEADERS => array( + OssClient::OSS_REQUEST_PAYER => 'requester', + ), + ); + + //2. 将每一分片上传到OSS + try { + $response_upload_part[] = $this->ossClient->uploadPart($this->bucket, $object, $upload_id, $up_options); + } catch (OssException $e) { + $this->assertFalse(true); + } + } + $upload_parts = array(); + foreach ($response_upload_part as $i => $eTag) { + $upload_parts[] = array( + 'PartNumber' => ($i + 1), + 'ETag' => $eTag, + ); + } + + try { + $listPartsInfo = $this->payerClient->listParts($this->bucket, $object, $upload_id, $options); + $this->assertNotNull($listPartsInfo); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $uploads = $this->payerClient->listMultipartUploads($this->bucket, $options); + $this->assertNotNull($uploads); + } catch (OssException $e) { + $this->assertTrue(false); + } + + /** + * step 3. + */ + try { + $this->payerClient->completeMultipartUpload($this->bucket, $object, $upload_id, $upload_parts, $options); + } catch (OssException $e) { + $this->assertTrue(false); + } + } + + public function testMiscOperationsWithRequester() + { + //use multipart + $options = array( + OssClient::OSS_PART_SIZE => 1, + OssClient::OSS_HEADERS => array( + OssClient::OSS_REQUEST_PAYER => 'requester', + )); + + $bigFileName = __DIR__ . DIRECTORY_SEPARATOR . "/bigfile.tmp"; + OssUtil::generateFile($bigFileName, 256 * 1024); + $object = 'mpu/multipart-bigfile-test.tmp'; + try { + $this->ossClient->multiuploadFile($this->bucket, $object, $bigFileName, $options); + $this->assertTrue(true); + } catch (OssException $e) { + $this->assertFalse(true); + } + + //use uploadfile + $options = array( + OssClient::OSS_PART_SIZE => 1024*1024, + OssClient::OSS_HEADERS => array( + OssClient::OSS_REQUEST_PAYER => 'requester', + )); + + try { + $this->ossClient->multiuploadFile($this->bucket, $object, $bigFileName, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + + unlink($bigFileName); + } + + protected function setUp(): void + { + parent::setUp(); + $this->payerClient = new OssClient( + Common::getPayerAccessKeyId(), + Common::getPayerAccessKeySecret(), + Common::getEndpoint(), false); + + $policy = '{"Version":"1","Statement":[{"Action":["oss:*"],"Effect": "Allow",'. + '"Principal":["' . Common::getPayerUid() . '"],'. + '"Resource": ["acs:oss:*:*:' . $this->bucket . '","acs:oss:*:*:' . $this->bucket . '/*"]}]}'; + + $this->ossClient->putBucketPolicy($this->bucket, $policy); + $this->ossClient->putBucketRequestPayment($this->bucket, 'Requester'); + $this->ossClient->putObject($this->bucket, "default-object", ""); + $this->ossClient->putSymlink($this->bucket, "default-symlink", "default-object"); + } + + protected function tearDown(): void + { + parent::tearDown(); + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientObjectTaggingTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientObjectTaggingTest.php new file mode 100644 index 0000000..401d1b7 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientObjectTaggingTest.php @@ -0,0 +1,160 @@ +ossClient->putObject($this->bucket, $object, $content); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $config = $this->ossClient->getObjectTagging($this->bucket, $object); + $this->assertEquals(0, count($config->getTags())); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $config = new TaggingConfig(); + $config->addTag(new Tag("key1", "value1")); + $config->addTag(new Tag("key2", "value2")); + $config->addTag(new Tag("key3", "value3")); + $this->ossClient->putObjectTagging($this->bucket, $object, $config); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $config2 = $this->ossClient->getObjectTagging($this->bucket, $object); + $this->assertEquals(3, count($config2->getTags())); + $this->assertEquals("key1", $config2->getTags()[0]->getKey()); + $this->assertEquals("value1", $config2->getTags()[0]->getValue()); + $this->assertEquals("key2", $config2->getTags()[1]->getKey()); + $this->assertEquals("value2", $config2->getTags()[1]->getValue()); + $this->assertEquals("key3", $config2->getTags()[2]->getKey()); + $this->assertEquals("value3", $config2->getTags()[2]->getValue()); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $this->ossClient->deleteObjectTagging($this->bucket, $object); + $config2 = $this->ossClient->getObjectTagging($this->bucket, $object); + $this->assertEquals(0, count($config2->getTags())); + } catch (OssException $e) { + $this->assertTrue(false); + } + } + + public function testPutObjectTaggingFromHeader() + { + $object = "object-tagging-header.txt"; + $content = "hello world"; + + try { + $options = array( + OssClient::OSS_HEADERS => array( + 'x-oss-tagging' => 'key1=value1&key2=value2&key3=value3', + )); + + $this->ossClient->putObject($this->bucket, $object, $content, $options); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + + $config2 = $this->ossClient->getObjectTagging($this->bucket, $object); + $this->assertEquals(3, count($config2->getTags())); + $this->assertEquals("key1", $config2->getTags()[0]->getKey()); + $this->assertEquals("value1", $config2->getTags()[0]->getValue()); + $this->assertEquals("key2", $config2->getTags()[1]->getKey()); + $this->assertEquals("value2", $config2->getTags()[1]->getValue()); + $this->assertEquals("key3", $config2->getTags()[2]->getKey()); + $this->assertEquals("value3", $config2->getTags()[2]->getValue()); + } catch (OssException $e) { + $this->assertTrue(false); + } + } + + public function testAppendObjectTaggingFromHeader() + { + $object = "append-object-tagging-header.txt"; + $content_array = array('Hello OSS', 'Hi OSS', 'OSS OK'); + + try { + $options = array( + OssClient::OSS_HEADERS => array( + 'x-oss-tagging' => 'key1=value1&key2=value2&key3=value3', + )); + + $position = $this->ossClient->appendObject($this->bucket, $object, $content_array[0], 0, $options); + $this->assertEquals($position, strlen($content_array[0])); + $position = $this->ossClient->appendObject($this->bucket, $object, $content_array[1], $position); + $this->assertEquals($position, strlen($content_array[0]) + strlen($content_array[1])); + $position = $this->ossClient->appendObject($this->bucket, $object, $content_array[2], $position, array(OssClient::OSS_LENGTH => strlen($content_array[2]))); + $this->assertEquals($position, strlen($content_array[0]) + strlen($content_array[1]) + strlen($content_array[2])); + + $config2 = $this->ossClient->getObjectTagging($this->bucket, $object); + $this->assertEquals(3, count($config2->getTags())); + $this->assertEquals("key1", $config2->getTags()[0]->getKey()); + $this->assertEquals("value1", $config2->getTags()[0]->getValue()); + $this->assertEquals("key2", $config2->getTags()[1]->getKey()); + $this->assertEquals("value2", $config2->getTags()[1]->getValue()); + $this->assertEquals("key3", $config2->getTags()[2]->getKey()); + $this->assertEquals("value3", $config2->getTags()[2]->getValue()); + + } catch (OssException $e) { + $this->assertFalse(true); + } + } + + public function testMultipartUploadTaggingFromHeader() + { + $file = __DIR__ . DIRECTORY_SEPARATOR . "/bigfile.tmp"; + OssUtil::generateFile($file, 110 * 1024); + + $object = "mpu-object-tagging-header.txt"; + $options = array( + OssClient::OSS_CHECK_MD5 => true, + OssClient::OSS_PART_SIZE => 1, + OssClient::OSS_HEADERS => array( + 'x-oss-tagging' => 'key1=value1&key2=value2&key3=value3', + ), + ); + try { + $this->ossClient->multiuploadFile($this->bucket, $object, $file, $options); + + $config2 = $this->ossClient->getObjectTagging($this->bucket, $object); + $this->assertEquals(3, count($config2->getTags())); + $this->assertEquals("key1", $config2->getTags()[0]->getKey()); + $this->assertEquals("value1", $config2->getTags()[0]->getValue()); + $this->assertEquals("key2", $config2->getTags()[1]->getKey()); + $this->assertEquals("value2", $config2->getTags()[1]->getValue()); + $this->assertEquals("key3", $config2->getTags()[2]->getKey()); + $this->assertEquals("value3", $config2->getTags()[2]->getValue()); + } catch (OssException $e) { + $this->assertFalse(true); + } + + unlink($file); + } + +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientObjectTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientObjectTest.php new file mode 100644 index 0000000..a573f15 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientObjectTest.php @@ -0,0 +1,938 @@ +ossClient->getObjectMeta($this->bucket, $object); + $this->assertEquals('200', $res['info']['http_code']); + $this->assertEquals('text/plain', $res['content-type']); + $this->assertEquals('Accept-Encoding', $res['vary']); + $this->assertTrue(isset($res['content-encoding'])); + } catch (OssException $e) { + $this->assertTrue(false); + } + + $options = array(OssClient::OSS_HEADERS => array(OssClient::OSS_ACCEPT_ENCODING => 'deflate, gzip')); + + try { + $res = $this->ossClient->getObjectMeta($this->bucket, $object, $options); + $this->assertEquals('200', $res['info']['http_code']); + $this->assertEquals('text/plain', $res['content-type']); + $this->assertEquals('Accept-Encoding', $res['vary']); + $this->assertEquals('gzip', $res['content-encoding']); + } catch (OssException $e) { + $this->assertTrue(false); + } + } + + public function testGetObjectWithAcceptEncoding() + { + $object = "oss-php-sdk-test/upload-test-object-name.txt"; + $options = array(OssClient::OSS_HEADERS => array(OssClient::OSS_ACCEPT_ENCODING => 'deflate, gzip')); + + try { + $res = $this->ossClient->getObject($this->bucket, $object, $options); + $this->assertEquals(file_get_contents(__FILE__), $res); + } catch (OssException $e) { + $this->assertTrue(false); + } + } + + public function testGetObjectWithHeader() + { + $object = "oss-php-sdk-test/upload-test-object-name.txt"; + try { + $res = $this->ossClient->getObject($this->bucket, $object, array(OssClient::OSS_LAST_MODIFIED => "xx")); + $this->assertEquals(file_get_contents(__FILE__), $res); + } catch (OssException $e) { + $this->assertEquals('"/ilegal.txt" object name is invalid', $e->getMessage()); + } + } + + public function testGetObjectWithIleggalEtag() + { + $object = "oss-php-sdk-test/upload-test-object-name.txt"; + try { + $res = $this->ossClient->getObject($this->bucket, $object, array(OssClient::OSS_ETAG => "xx")); + $this->assertEquals(file_get_contents(__FILE__), $res); + } catch (OssException $e) { + $this->assertEquals('"/ilegal.txt" object name is invalid', $e->getMessage()); + } + } + + public function testObject() + { + /** + * Upload the local variable to bucket + */ + $object = "oss-php-sdk-test/upload-test-object-name.txt"; + $content = file_get_contents(__FILE__); + $options = array( + OssClient::OSS_LENGTH => strlen($content), + OssClient::OSS_HEADERS => array( + 'Expires' => 'Fri, 28 Feb 2020 05:38:42 GMT', + 'Cache-Control' => 'no-cache', + 'Content-Disposition' => 'attachment;filename=oss_download.log', + 'Content-Language' => 'zh-CN', + 'x-oss-server-side-encryption' => 'AES256', + 'x-oss-meta-self-define-title' => 'user define meta info', + ), + ); + + try { + $this->ossClient->putObject($this->bucket, $object, $content, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + + try { + $this->ossClient->putObject($this->bucket, $object, $content, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + + try { + $result = $this->ossClient->deleteObjects($this->bucket, "stringtype", $options); + $this->assertEquals('stringtype', $result[0]); + } catch (OssException $e) { + $this->assertEquals('objects must be array', $e->getMessage()); + } + + try { + $result = $this->ossClient->deleteObjects($this->bucket, "stringtype", $options); + $this->assertFalse(true); + } catch (OssException $e) { + $this->assertEquals('objects must be array', $e->getMessage()); + } + + try { + $this->ossClient->uploadFile($this->bucket, $object, "notexist.txt", $options); + $this->assertFalse(true); + } catch (OssException $e) { + $this->assertEquals('notexist.txt file does not exist', $e->getMessage()); + } + + /** + * GetObject to the local variable and check for match + */ + try { + $content = $this->ossClient->getObject($this->bucket, $object); + $this->assertEquals($content, file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * GetObject first five bytes + */ + try { + $options = array(OssClient::OSS_RANGE => '0-4'); + $content = $this->ossClient->getObject($this->bucket, $object, $options); + $this->assertEquals($content, 'assertFalse(true); + } + + + /** + * Upload the local file to object + */ + try { + $this->ossClient->uploadFile($this->bucket, $object, __FILE__); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Download the file to the local variable and check for match. + */ + try { + $content = $this->ossClient->getObject($this->bucket, $object); + $this->assertEquals($content, file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Download the file to the local file + */ + $localfile = "upload-test-object-name.txt"; + $options = array( + OssClient::OSS_FILE_DOWNLOAD => $localfile, + ); + + try { + $this->ossClient->getObject($this->bucket, $object, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + $this->assertTrue(file_get_contents($localfile) === file_get_contents(__FILE__)); + if (file_exists($localfile)) { + unlink($localfile); + } + + /** + * Download the file to the local file. no such key + */ + $localfile = "upload-test-object-name-no-such-key.txt"; + $options = array( + OssClient::OSS_FILE_DOWNLOAD => $localfile, + ); + + try { + $this->ossClient->getObject($this->bucket, $object . "no-such-key", $options); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + $this->assertFalse(file_exists($localfile)); + if (strpos($e, "The specified key does not exist") == false) { + $this->assertTrue(true); + } + } + + /** + * Download the file to the content. no such key + */ + try { + $result = $this->ossClient->getObject($this->bucket, $object . "no-such-key"); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + if (strpos($e, "The specified key does not exist") == false) { + $this->assertTrue(true); + } + } + + /** + * Copy object + */ + $to_bucket = $this->bucket; + $to_object = $object . '.copy'; + $options = array(); + try { + $result = $this->ossClient->copyObject($this->bucket, $object, $to_bucket, $to_object, $options); + $this->assertFalse(empty($result)); + $this->assertEquals(strlen("2016-11-21T03:46:58.000Z"), strlen($result[0])); + $this->assertEquals(strlen("\"5B3C1A2E053D763E1B002CC607C5A0FE\""), strlen($result[1])); + } catch (OssException $e) { + $this->assertFalse(true); + var_dump($e->getMessage()); + + } + + /** + * Check if the replication is the same + */ + try { + $content = $this->ossClient->getObject($this->bucket, $to_object); + $this->assertEquals($content, file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * List the files in your bucket. + */ + $prefix = ''; + $delimiter = '/'; + $next_marker = ''; + $maxkeys = 1000; + $options = array( + 'delimiter' => $delimiter, + 'prefix' => $prefix, + 'max-keys' => $maxkeys, + 'marker' => $next_marker, + ); + + try { + $listObjectInfo = $this->ossClient->listObjects($this->bucket, $options); + $objectList = $listObjectInfo->getObjectList(); + $prefixList = $listObjectInfo->getPrefixList(); + $this->assertNotNull($objectList); + $this->assertNotNull($prefixList); + $this->assertTrue(is_array($objectList)); + $this->assertTrue(is_array($prefixList)); + + } catch (OssException $e) { + $this->assertTrue(false); + } + + /** + * Set the meta information for the file + */ + $from_bucket = $this->bucket; + $from_object = "oss-php-sdk-test/upload-test-object-name.txt"; + $to_bucket = $from_bucket; + $to_object = $from_object; + $copy_options = array( + OssClient::OSS_HEADERS => array( + 'Expires' => '2012-10-01 08:00:00', + 'Content-Disposition' => 'attachment; filename="xxxxxx"', + ), + ); + try { + $this->ossClient->copyObject($from_bucket, $from_object, $to_bucket, $to_object, $copy_options); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Get the meta information for the file + */ + $object = "oss-php-sdk-test/upload-test-object-name.txt"; + try { + $objectMeta = $this->ossClient->getObjectMeta($this->bucket, $object); + $this->assertEquals('attachment; filename="xxxxxx"', $objectMeta[strtolower('Content-Disposition')]); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Delete single file + */ + $object = "oss-php-sdk-test/upload-test-object-name.txt"; + + try { + $this->assertTrue($this->ossClient->doesObjectExist($this->bucket, $object)); + $this->ossClient->deleteObject($this->bucket, $object); + $this->assertFalse($this->ossClient->doesObjectExist($this->bucket, $object)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Delete multiple files + */ + $object1 = "oss-php-sdk-test/upload-test-object-name.txt"; + $object2 = "oss-php-sdk-test/upload-test-object-name.txt.copy"; + $list = array($object1, $object2); + try { + $this->assertTrue($this->ossClient->doesObjectExist($this->bucket, $object2)); + + $result = $this->ossClient->deleteObjects($this->bucket, $list); + $this->assertEquals($list[0], $result[0]); + $this->assertEquals($list[1], $result[1]); + + $result = $this->ossClient->deleteObjects($this->bucket, $list, array('quiet' => 'true')); + $this->assertEquals(array(), $result); + $this->assertFalse($this->ossClient->doesObjectExist($this->bucket, $object2)); + + $this->ossClient->putObject($this->bucket, $object, $content); + $this->assertTrue($this->ossClient->doesObjectExist($this->bucket, $object)); + $result = $this->ossClient->deleteObjects($this->bucket, $list, array('quiet' => true)); + $this->assertEquals(array(), $result); + $this->assertFalse($this->ossClient->doesObjectExist($this->bucket, $object)); + } catch (OssException $e) { + $this->assertFalse(true); + } + } + + public function testAppendObject() + { + $object = "oss-php-sdk-test/append-test-object-name.txt"; + $content_array = array('Hello OSS', 'Hi OSS', 'OSS OK'); + + /** + * Append the upload string + */ + try { + $position = $this->ossClient->appendObject($this->bucket, $object, $content_array[0], 0); + $this->assertEquals($position, strlen($content_array[0])); + $position = $this->ossClient->appendObject($this->bucket, $object, $content_array[1], $position); + $this->assertEquals($position, strlen($content_array[0]) + strlen($content_array[1])); + $position = $this->ossClient->appendObject($this->bucket, $object, $content_array[2], $position, array(OssClient::OSS_LENGTH => strlen($content_array[2]))); + $this->assertEquals($position, strlen($content_array[0]) + strlen($content_array[1]) + strlen($content_array[2])); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Check if the content is the same + */ + try { + $content = $this->ossClient->getObject($this->bucket, $object); + $this->assertEquals($content, implode($content_array)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + + /** + * Delete test object + */ + try { + $this->ossClient->deleteObject($this->bucket, $object); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Append the upload of invalid local files + */ + try { + $position = $this->ossClient->appendFile($this->bucket, $object, "invalid-file-path", 0); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + } + + /** + * Append the upload of local files + */ + try { + $position = $this->ossClient->appendFile($this->bucket, $object, __FILE__, 0); + $this->assertEquals($position, sprintf('%u', filesize(__FILE__))); + $position = $this->ossClient->appendFile($this->bucket, $object, __FILE__, $position); + $this->assertEquals($position, sprintf('%u', filesize(__FILE__)) * 2); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Check if the replication is the same + */ + try { + $content = $this->ossClient->getObject($this->bucket, $object); + $this->assertEquals($content, file_get_contents(__FILE__) . file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Delete test object + */ + try { + $this->ossClient->deleteObject($this->bucket, $object); + } catch (OssException $e) { + $this->assertFalse(true); + } + + + $options = array( + OssClient::OSS_HEADERS => array( + 'Expires' => '2012-10-01 08:00:00', + 'Content-Disposition' => 'attachment; filename="xxxxxx"', + ), + ); + + /** + * Append upload with option + */ + try { + $position = $this->ossClient->appendObject($this->bucket, $object, "Hello OSS, ", 0, $options); + $position = $this->ossClient->appendObject($this->bucket, $object, "Hi OSS.", $position); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Get the meta information for the file + */ + try { + $objectMeta = $this->ossClient->getObjectMeta($this->bucket, $object); + $this->assertEquals('attachment; filename="xxxxxx"', $objectMeta[strtolower('Content-Disposition')]); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Delete test object + */ + try { + $this->ossClient->deleteObject($this->bucket, $object); + } catch (OssException $e) { + $this->assertFalse(true); + } + } + + public function testPutIllelObject() + { + $object = "/ilegal.txt"; + try { + $this->ossClient->putObject($this->bucket, $object, "hi", null); + $this->assertFalse(true); + } catch (OssException $e) { + $this->assertEquals('"/ilegal.txt" object name is invalid', $e->getMessage()); + } + } + + public function testCheckMD5() + { + $object = "oss-php-sdk-test/upload-test-object-name.txt"; + $content = file_get_contents(__FILE__); + $options = array(OssClient::OSS_CHECK_MD5 => true); + + /** + * Upload data to start MD5 + */ + try { + $this->ossClient->putObject($this->bucket, $object, $content, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Check if the replication is the same + */ + try { + $content = $this->ossClient->getObject($this->bucket, $object); + $this->assertEquals($content, file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Upload file to start MD5 + */ + try { + $this->ossClient->uploadFile($this->bucket, $object, __FILE__, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Check if the replication is the same + */ + try { + $content = $this->ossClient->getObject($this->bucket, $object); + $this->assertEquals($content, file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Delete test object + */ + try { + $this->ossClient->deleteObject($this->bucket, $object); + } catch (OssException $e) { + $this->assertFalse(true); + } + + $object = "oss-php-sdk-test/append-test-object-name.txt"; + $content_array = array('Hello OSS', 'Hi OSS', 'OSS OK'); + $options = array(OssClient::OSS_CHECK_MD5 => true); + + /** + * Append the upload string + */ + try { + $position = $this->ossClient->appendObject($this->bucket, $object, $content_array[0], 0, $options); + $this->assertEquals($position, strlen($content_array[0])); + $position = $this->ossClient->appendObject($this->bucket, $object, $content_array[1], $position, $options); + $this->assertEquals($position, strlen($content_array[0]) + strlen($content_array[1])); + $position = $this->ossClient->appendObject($this->bucket, $object, $content_array[2], $position, $options); + $this->assertEquals($position, strlen($content_array[0]) + strlen($content_array[1]) + strlen($content_array[1])); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Check if the content is the same + */ + try { + $content = $this->ossClient->getObject($this->bucket, $object); + $this->assertEquals($content, implode($content_array)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Delete test object + */ + try { + $this->ossClient->deleteObject($this->bucket, $object); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Append upload of local files + */ + try { + $position = $this->ossClient->appendFile($this->bucket, $object, __FILE__, 0, $options); + $this->assertEquals($position, sprintf('%u', filesize(__FILE__))); + $position = $this->ossClient->appendFile($this->bucket, $object, __FILE__, $position, $options); + $this->assertEquals($position, sprintf('%u', filesize(__FILE__)) * 2); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Check if the replication is the same + */ + try { + $content = $this->ossClient->getObject($this->bucket, $object); + $this->assertEquals($content, file_get_contents(__FILE__) . file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * delete test object + */ + try { + $this->ossClient->deleteObject($this->bucket, $object); + } catch (OssException $e) { + $this->assertFalse(true); + } + } + + public function testWithInvalidBucketName() + { + try { + $this->ossClient->createBucket("abcefc/", "test-key"); + $this->assertFalse(true); + } catch (OssException $e) { + $this->assertEquals('"abcefc/"bucket name is invalid', $e->getMessage()); + } + } + + public function testGetSimplifiedObjectMeta() + { + $object = "oss-php-sdk-test/upload-test-object-name.txt"; + + try { + $objectMeta = $this->ossClient->getSimplifiedObjectMeta($this->bucket, $object); + $this->assertEquals(false, array_key_exists(strtolower('Content-Disposition'), $objectMeta)); + $this->assertEquals(strlen(file_get_contents(__FILE__)), $objectMeta[strtolower('Content-Length')]); + $this->assertEquals(true, array_key_exists(strtolower('ETag'), $objectMeta)); + $this->assertEquals(true, array_key_exists(strtolower('Last-Modified'), $objectMeta)); + } catch (OssException $e) { + $this->assertFalse(true); + } + } + + public function testUploadStream() + { + $object = "oss-php-sdk-test/put-from-stream.txt"; + $options = array(OssClient::OSS_CHECK_MD5 => true); + $handle = fopen(__FILE__, 'rb'); + /** + * Upload data to start MD5 + */ + try { + $this->ossClient->uploadStream($this->bucket, $object, $handle, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Check if the replication is the same + */ + try { + $content = $this->ossClient->getObject($this->bucket, $object); + $this->assertEquals($content, file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + $object = "oss-php-sdk-test/put-from-stream-without-md5.txt"; + $handle = fopen(__FILE__, 'rb'); + try { + $this->ossClient->uploadStream($this->bucket, $object, $handle); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Check if the replication is the same + */ + try { + $content = $this->ossClient->getObject($this->bucket, $object); + $this->assertEquals($content, file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + } + + public function testObjectKeyWithQuestionMark() + { + /** + * Upload the local variable to bucket + */ + $object = "oss-php-sdk-test/??/upload-test-object-name???123??123??.txt"; + $content = file_get_contents(__FILE__); + $options = array( + OssClient::OSS_LENGTH => strlen($content), + OssClient::OSS_HEADERS => array( + 'Expires' => 'Fri, 28 Feb 2020 05:38:42 GMT', + 'Cache-Control' => 'no-cache', + 'Content-Disposition' => 'attachment;filename=oss_download.log', + 'Content-Language' => 'zh-CN', + 'x-oss-server-side-encryption' => 'AES256', + 'x-oss-meta-self-define-title' => 'user define meta info', + ), + ); + + try { + $this->ossClient->putObject($this->bucket, $object, $content, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + + try { + $this->ossClient->putObject($this->bucket, $object, $content, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * GetObject to the local variable and check for match + */ + try { + $content = $this->ossClient->getObject($this->bucket, $object); + $this->assertEquals($content, file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * GetObject first five bytes + */ + try { + $options = array(OssClient::OSS_RANGE => '0-4'); + $content = $this->ossClient->getObject($this->bucket, $object, $options); + $this->assertEquals($content, 'assertFalse(true); + } + + + /** + * Upload the local file to object + */ + try { + $this->ossClient->uploadFile($this->bucket, $object, __FILE__); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Download the file to the local variable and check for match. + */ + try { + $content = $this->ossClient->getObject($this->bucket, $object); + $this->assertEquals($content, file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Copy object + */ + $to_bucket = $this->bucket; + $to_object = $object . '.copy'; + $options = array(); + try { + $result = $this->ossClient->copyObject($this->bucket, $object, $to_bucket, $to_object, $options); + $this->assertFalse(empty($result)); + $this->assertEquals(strlen("2016-11-21T03:46:58.000Z"), strlen($result[0])); + $this->assertEquals(strlen("\"5B3C1A2E053D763E1B002CC607C5A0FE\""), strlen($result[1])); + } catch (OssException $e) { + $this->assertFalse(true); + var_dump($e->getMessage()); + + } + + /** + * Check if the replication is the same + */ + try { + $content = $this->ossClient->getObject($this->bucket, $to_object); + $this->assertEquals($content, file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + + try { + $this->assertTrue($this->ossClient->doesObjectExist($this->bucket, $object)); + $this->ossClient->deleteObject($this->bucket, $object); + $this->assertFalse($this->ossClient->doesObjectExist($this->bucket, $object)); + } catch (OssException $e) { + $this->assertFalse(true); + } + } + + public function testObjectKeyWithNonUTF8Name() + { + $object = "中文测试.txt"; + $hexObject = bin2hex($object); + $gbkObject = iconv('UTF-8', 'GBK', $object); + $hexGbkObject = bin2hex($gbkObject); + $content = "hello world"; + + $this->assertEquals("e4b8ade69687e6b58be8af952e747874", $hexObject); + $this->assertEquals("d6d0cec4b2e2cad42e747874", $hexGbkObject); + + try { + $this->ossClient->putObject($this->bucket, $gbkObject, $content); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertEquals('InvalidArgument', $e->getErrorCode()); + $this->assertEquals('The characters encoding must be utf-8.', $e->getErrorMessage()); + } catch (\Exception $e) { + $this->assertTrue(false); + } + + //enable object encoding check + $config = array( + 'checkObjectEncoding' => true, + ); + $ossClient = Common::getOssClient($config); + try { + $ossClient->putObject($this->bucket, $gbkObject, $content); + $content1 = $this->ossClient->getObject($this->bucket, $object); + $content2 = $ossClient->getObject($this->bucket, $gbkObject); + $this->assertEquals($content, $content1); + $this->assertEquals($content, $content2); + } catch (\Exception $e) { + $this->assertTrue(false); + } + + // ascii + try { + $ossClient->putObject($this->bucket, '1234', 'ascii'); + $content1 = $this->ossClient->getObject($this->bucket, '1234'); + $content2 = $ossClient->getObject($this->bucket, '1234'); + $this->assertEquals('ascii', $content1); + $this->assertEquals('ascii', $content2); + } catch (\Exception $e) { + $this->assertTrue(false); + } + } + + public function testEncodeFilePath() + { + if (!OssUtil::isWin()) { + $this->assertTrue(true); + return; + } + + $fileFolder = __DIR__ . DIRECTORY_SEPARATOR . "中文目录"; + $filePath1 = $fileFolder . DIRECTORY_SEPARATOR . "中文文件名1.txt"; + $filePath2 = $fileFolder . DIRECTORY_SEPARATOR . "中文文件名2.txt"; + + $gbkfileFolder = iconv('UTF-8', 'GBK', $fileFolder); + $gbkfilePath1 = iconv('UTF-8', 'GBK', $filePath1); + $gbkfilePath2 = iconv('UTF-8', 'GBK', $filePath2); + + $hexfilePath1 = bin2hex($filePath1); + $hexGbkfilePath2 = bin2hex($gbkfilePath2); + + $content1 = ''; + $content2 = ''; + if (version_compare(phpversion(), '7.0.0', '<')) { + try { + mkdir($gbkfileFolder); + } catch (\Exception $e) { + } + OssUtil::generateFile($gbkfilePath1, 200 * 1024); + OssUtil::generateFile($gbkfilePath2, 202 * 1024); + $content1 = file_get_contents($gbkfilePath1); + $content2 = file_get_contents($gbkfilePath2); + } else { + try { + mkdir($fileFolder); + } catch (\Exception $e) { + } + OssUtil::generateFile($filePath1, 200 * 1024); + OssUtil::generateFile($filePath2, 202 * 1024); + $content1 = file_get_contents($filePath1); + $content2 = file_get_contents($filePath2); + } + + try { + + // upload file + $this->ossClient->uploadFile($this->bucket, '123', $filePath1); + $this->ossClient->uploadFile($this->bucket, '234', $gbkfilePath2); + + $res = $this->ossClient->getObject($this->bucket, '123'); + $this->assertEquals($content1, $res); + + $res = $this->ossClient->getObject($this->bucket, '234'); + $this->assertEquals($content2, $res); + + // append file + $position = $this->ossClient->appendFile($this->bucket, 'append-file', $filePath1, 0); + $position = $this->ossClient->appendFile($this->bucket, 'append-file', $gbkfilePath2, $position); + + $res = $this->ossClient->getObject($this->bucket, 'append-file'); + $this->assertEquals($content1.$content2, $res); + + // multi paet + $this->ossClient->multiuploadFile($this->bucket, 'multi-file-123', $filePath1, array(OssClient::OSS_PART_SIZE => 1)); + $this->ossClient->multiuploadFile($this->bucket, 'multi-file-234', $gbkfilePath2, array(OssClient::OSS_PART_SIZE => 1)); + $res = $this->ossClient->getObject($this->bucket, 'multi-file-123'); + $this->assertEquals($content1, $res); + + $res = $this->ossClient->getObject($this->bucket, 'multi-file-234'); + $this->assertEquals($content2, $res); + + // uploadDir + $this->ossClient->uploadDir($this->bucket, "dir", $fileFolder); + $options = array( + 'delimiter' => '', + 'prefix' => "dir", + ); + $listObjectInfo = $this->ossClient->listObjects($this->bucket, $options); + $objectList = $listObjectInfo->getObjectList(); + $this->assertEquals(2, count($objectList)); + $this->assertEquals('dir/中文文件名1.txt', $objectList[0]->getKey()); + $this->assertEquals('dir/中文文件名2.txt', $objectList[1]->getKey()); + + // uploadDir + if (version_compare(phpversion(), '7.0.0', '<')) { + $this->ossClient->uploadDir($this->bucket, "gbkdir", $gbkfileFolder); + $options = array( + 'delimiter' => '', + 'prefix' => "gbkdir", + ); + $listObjectInfo = $this->ossClient->listObjects($this->bucket, $options); + $objectList = $listObjectInfo->getObjectList(); + $this->assertEquals(2, count($objectList)); + $this->assertEquals('gbkdir/中文文件名1.txt', $objectList[0]->getKey()); + $this->assertEquals('gbkdir/中文文件名2.txt', $objectList[1]->getKey()); + } + + } catch (OssException $e) { + $this->assertFalse(true); + } + + try { + if (phpversion() < "7.0.0") { + unlink($gbkfilePath1); + unlink($gbkfilePath2); + rmdir($gbkfileFolder); + } else { + unlink($filePath1); + unlink($filePath2); + rmdir($fileFolder); + } + } catch (\Exception $e) { + } + } + + protected function setUp(): void + { + parent::setUp(); + $this->ossClient->putObject($this->bucket, 'oss-php-sdk-test/upload-test-object-name.txt', file_get_contents(__FILE__)); + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientObjectVersioningTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientObjectVersioningTest.php new file mode 100644 index 0000000..66f204a --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientObjectVersioningTest.php @@ -0,0 +1,610 @@ +ossClient->putObject($this->bucket, $object, $content1, array(OssClient::OSS_HEADERS => array('x-oss-object-acl' => 'public-read', 'x-oss-tagging' => 'key1=value1'))); + $ret2 = $this->ossClient->putObject($this->bucket, $object, $content2, array(OssClient::OSS_HEADERS => array('x-oss-object-acl' => 'private', 'x-oss-tagging' => 'key2=value2'))); + + $this->assertTrue(isset($ret1[OssClient::OSS_HEADER_VERSION_ID])); + $this->assertTrue(isset($ret2[OssClient::OSS_HEADER_VERSION_ID])); + + $versionId1 = $ret1[OssClient::OSS_HEADER_VERSION_ID]; + $versionId2 = $ret2[OssClient::OSS_HEADER_VERSION_ID]; + + //get object + $res = $this->ossClient->getObject($this->bucket, $object); + $res1 = $this->ossClient->getObject($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $versionId1)); + $res2 = $this->ossClient->getObject($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $versionId2)); + $this->assertEquals($content1, $res1); + $this->assertEquals($content2, $res2); + $this->assertEquals($content2, $res); + + //meta + $headers = $this->ossClient->getObjectMeta($this->bucket, $object); + $headers1 = $this->ossClient->getObjectMeta($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $versionId1)); + $headers2 = $this->ossClient->getObjectMeta($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $versionId2)); + + $this->assertTrue(isset($headers[OssClient::OSS_HEADER_VERSION_ID])); + $this->assertTrue(isset($headers1[OssClient::OSS_HEADER_VERSION_ID])); + $this->assertTrue(isset($headers2[OssClient::OSS_HEADER_VERSION_ID])); + $this->assertEquals($versionId1, $headers1[OssClient::OSS_HEADER_VERSION_ID]); + $this->assertEquals($versionId2, $headers2[OssClient::OSS_HEADER_VERSION_ID]); + $this->assertEquals($versionId2, $headers[OssClient::OSS_HEADER_VERSION_ID]); + + + $sheaders = $this->ossClient->getSimplifiedObjectMeta($this->bucket, $object); + $sheaders1 = $this->ossClient->getSimplifiedObjectMeta($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $versionId1)); + $sheaders2 = $this->ossClient->getSimplifiedObjectMeta($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $versionId2)); + + $this->assertTrue(isset($sheaders[OssClient::OSS_HEADER_VERSION_ID])); + $this->assertTrue(isset($sheaders1[OssClient::OSS_HEADER_VERSION_ID])); + $this->assertTrue(isset($sheaders2[OssClient::OSS_HEADER_VERSION_ID])); + $this->assertEquals($versionId1, $sheaders1[OssClient::OSS_HEADER_VERSION_ID]); + $this->assertEquals($versionId2, $sheaders2[OssClient::OSS_HEADER_VERSION_ID]); + $this->assertEquals($versionId2, $sheaders[OssClient::OSS_HEADER_VERSION_ID]); + + //acl + $acl = $this->ossClient->getObjectAcl($this->bucket, $object); + $acl1 = $this->ossClient->getObjectAcl($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $versionId1)); + $acl2 = $this->ossClient->getObjectAcl($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $versionId2)); + + $this->assertEquals('public-read', $acl1); + $this->assertEquals('private', $acl2); + $this->assertEquals('private', $acl); + + $this->ossClient->putObjectAcl($this->bucket, $object, 'public-read-write', array(OssClient::OSS_VERSION_ID => $versionId1)); + $acl = $this->ossClient->getObjectAcl($this->bucket, $object); + $acl1 = $this->ossClient->getObjectAcl($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $versionId1)); + $this->assertEquals('public-read-write', $acl1); + $this->assertEquals('private', $acl); + + //tagging + $tag = $this->ossClient->getObjectTagging($this->bucket, $object); + $tag1 = $this->ossClient->getObjectTagging($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $versionId1)); + $tag2 = $this->ossClient->getObjectTagging($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $versionId2)); + $this->assertEquals(1, count($tag1->getTags())); + $this->assertEquals("key1", $tag1->getTags()[0]->getKey()); + $this->assertEquals("value1", $tag1->getTags()[0]->getValue()); + $this->assertEquals(1, count($tag2->getTags())); + $this->assertEquals("key2", $tag2->getTags()[0]->getKey()); + $this->assertEquals("value2", $tag2->getTags()[0]->getValue()); + $this->assertEquals(1, count($tag->getTags())); + $this->assertEquals("key2", $tag->getTags()[0]->getKey()); + $this->assertEquals("value2", $tag->getTags()[0]->getValue()); + + $config = new TaggingConfig(); + $config->addTag(new Tag("key11", "value11")); + $this->ossClient->putObjectTagging($this->bucket, $object, $config, array(OssClient::OSS_VERSION_ID => $versionId1)); + $tag = $this->ossClient->getObjectTagging($this->bucket, $object); + $tag1 = $this->ossClient->getObjectTagging($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $versionId1)); + $this->assertEquals(1, count($tag1->getTags())); + $this->assertEquals("key11", $tag1->getTags()[0]->getKey()); + $this->assertEquals("value11", $tag1->getTags()[0]->getValue()); + $this->assertEquals(1, count($tag->getTags())); + $this->assertEquals("key2", $tag->getTags()[0]->getKey()); + $this->assertEquals("value2", $tag->getTags()[0]->getValue()); + + $this->ossClient->deleteObjectTagging($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $versionId1)); + $tag = $this->ossClient->getObjectTagging($this->bucket, $object); + $tag1 = $this->ossClient->getObjectTagging($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $versionId1)); + $this->assertEquals(0, count($tag1->getTags())); + $this->assertEquals(1, count($tag->getTags())); + $this->assertEquals("key2", $tag->getTags()[0]->getKey()); + $this->assertEquals("value2", $tag->getTags()[0]->getValue()); + + //delete + $dret = $this->ossClient->deleteObject($this->bucket, $object); + $this->assertTrue(isset($dret['x-oss-delete-marker'])); + $this->assertTrue(isset($dret['x-oss-version-id'])); + $this->assertEquals("true", $dret['x-oss-delete-marker']); + $this->assertFalse($this->ossClient->doesObjectExist($this->bucket, $object)); + $this->assertTrue($this->ossClient->doesObjectExist($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $versionId1))); + $this->assertTrue($this->ossClient->doesObjectExist($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $versionId2))); + + $dret1 = $this->ossClient->deleteObject($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $versionId1)); + $this->assertFalse(isset($dret1['x-oss-delete-marker'])); + $this->assertTrue(isset($dret1['x-oss-version-id'])); + $this->assertEquals($versionId1, $dret1['x-oss-version-id']); + $this->assertFalse($this->ossClient->doesObjectExist($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $versionId1))); + + + $dret_ = $this->ossClient->deleteObject($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $dret['x-oss-version-id'])); + $this->assertTrue(isset($dret_['x-oss-delete-marker'])); + $this->assertTrue(isset($dret_['x-oss-version-id'])); + $this->assertEquals($dret['x-oss-version-id'], $dret_['x-oss-version-id']); + $this->assertTrue($this->ossClient->doesObjectExist($this->bucket, $object)); + + } + + public function testObjectSymlink() + { + $object1 = 'object-target-1'; + $object2 = 'object-target-2'; + $symlink = 'object-symlink'; + $content1 = 'hello'; + $content2 = 'hello world'; + + + $ret1 = $this->ossClient->putObject($this->bucket, $object1, $content1); + $sym1 = $this->ossClient->putSymlink($this->bucket, $symlink, $object1); + + $ret2 = $this->ossClient->putObject($this->bucket, $object2, $content2); + $sym2 = $this->ossClient->putSymlink($this->bucket, $symlink, $object2); + + $this->assertTrue(isset($ret1[OssClient::OSS_HEADER_VERSION_ID])); + $this->assertTrue(isset($ret2[OssClient::OSS_HEADER_VERSION_ID])); + + $this->assertTrue(isset($sym1[OssClient::OSS_HEADER_VERSION_ID])); + $this->assertTrue(isset($sym2[OssClient::OSS_HEADER_VERSION_ID])); + + $versionId1 = $ret1[OssClient::OSS_HEADER_VERSION_ID]; + $versionId2 = $ret2[OssClient::OSS_HEADER_VERSION_ID]; + + $sym_versionId1 = $sym1[OssClient::OSS_HEADER_VERSION_ID]; + $sym_versionId2 = $sym2[OssClient::OSS_HEADER_VERSION_ID]; + + + $sym_ret = $this->ossClient->getSymlink($this->bucket, $symlink); + $sym_ret1 = $this->ossClient->getSymlink($this->bucket, $symlink, array(OssClient::OSS_VERSION_ID => $sym_versionId1)); + $sym_ret2 = $this->ossClient->getSymlink($this->bucket, $symlink, array(OssClient::OSS_VERSION_ID => $sym_versionId2)); + + $this->assertTrue(isset($sym_ret['x-oss-version-id'])); + $this->assertTrue(isset($sym_ret1['x-oss-version-id'])); + $this->assertTrue(isset($sym_ret2['x-oss-version-id'])); + + $this->assertEquals($sym_versionId1, $sym_ret1['x-oss-version-id']); + $this->assertEquals($sym_versionId2, $sym_ret2['x-oss-version-id']); + $this->assertEquals($sym_versionId2, $sym_ret['x-oss-version-id']); + + + $res = $this->ossClient->getObject($this->bucket, $symlink); + $res1 = $this->ossClient->getObject($this->bucket, $symlink, array(OssClient::OSS_VERSION_ID => $sym_versionId1)); + $res2 = $this->ossClient->getObject($this->bucket, $symlink, array(OssClient::OSS_VERSION_ID => $sym_versionId2)); + $this->assertEquals($content1, $res1); + $this->assertEquals($content2, $res2); + $this->assertEquals($content2, $res); + } + + public function testObjectCopy() + { + $object = 'copy-= +object'; + $content1 = 'hello'; + $content2 = 'hello world'; + $to_bucket = $this->bucket; + $to_object = $object . '.copy'; + $to_object1 = $object . '.copy1'; + $to_object2 = $object . '.copy2'; + + $ret1 = $this->ossClient->putObject($this->bucket, $object, $content1); + $ret2 = $this->ossClient->putObject($this->bucket, $object, $content2); + + $versionId1 = $ret1[OssClient::OSS_HEADER_VERSION_ID]; + $versionId2 = $ret2[OssClient::OSS_HEADER_VERSION_ID]; + + $cret = $this->ossClient->copyObject($this->bucket, $object, $to_bucket, $to_object); + $cret1 = $this->ossClient->copyObject($this->bucket, $object, $to_bucket, $to_object1, array(OssClient::OSS_VERSION_ID => $versionId1)); + $cret2 = $this->ossClient->copyObject($this->bucket, $object, $to_bucket, $to_object2, array(OssClient::OSS_VERSION_ID => $versionId2)); + $this->assertFalse(empty($cret1)); + $this->assertEquals(strlen("2016-11-21T03:46:58.000Z"), strlen($cret1[0])); + $this->assertEquals(trim($ret1['etag'], '"'), trim($cret1[1], '"')); + $this->assertTrue(isset($cret1['x-oss-version-id'])); + $this->assertEquals($versionId1, $cret1['x-oss-copy-source-version-id']); + + $this->assertFalse(empty($cret2)); + $this->assertEquals(strlen("2016-11-21T03:46:58.000Z"), strlen($cret2[0])); + $this->assertEquals(trim($ret2['etag'], '"'), trim($cret2[1], '"')); + $this->assertTrue(isset($cret2['x-oss-version-id'])); + $this->assertEquals($versionId2, $cret2['x-oss-copy-source-version-id']); + + $this->assertFalse(empty($cret)); + $this->assertEquals(strlen("2016-11-21T03:46:58.000Z"), strlen($cret[0])); + $this->assertEquals(trim($ret2['etag'], '"'), trim($cret[1], '"')); + $this->assertTrue(isset($cret2['x-oss-version-id'])); + $this->assertEquals($versionId2, $cret['x-oss-copy-source-version-id']); + + $res = $this->ossClient->getObject($this->bucket, $to_object); + $res1 = $this->ossClient->getObject($this->bucket, $to_object1); + $res2 = $this->ossClient->getObject($this->bucket, $to_object2); + $this->assertEquals($content1, $res1); + $this->assertEquals($content2, $res2); + $this->assertEquals($content2, $res); + } + + public function testObjectRestore() + { + $object = 'retore-object'; + $content1 = 'hello'; + $content2 = 'hello world'; + $ret1 = $this->ossClient->putObject($this->bucket, $object, $content1, array(OssClient::OSS_HEADERS => array('x-oss-storage-class' => 'Archive'))); + $ret2 = $this->ossClient->putObject($this->bucket, $object, $content2); + + $versionId1 = $ret1[OssClient::OSS_HEADER_VERSION_ID]; + $versionId2 = $ret2[OssClient::OSS_HEADER_VERSION_ID]; + + try{ + $this->ossClient->getObject($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $versionId1)); + $this->assertTrue(false); + }catch (OssException $e){ + $this->assertEquals('403', $e->getHTTPStatus()); + $this->assertEquals('InvalidObjectState', $e->getErrorCode()); + } + + try{ + $this->ossClient->restoreObject($this->bucket, $object); + $this->assertTrue(false); + }catch(OssException $e){ + $this->assertEquals('400', $e->getHTTPStatus()); + $this->assertEquals('OperationNotSupported', $e->getErrorCode()); + } + + $result = $this->ossClient->restoreObject($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $versionId1)); + common::waitMetaSync(); + $this->assertEquals('202', $result['info']['http_code']); + + try{ + $this->ossClient->restoreObject($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $versionId1)); + }catch(OssException $e){ + $this->assertEquals('409', $e->getHTTPStatus()); + $this->assertEquals('RestoreAlreadyInProgress', $e->getErrorCode()); + } + } + + public function testObjectMultiPart() + { + $object_src = 'multi-= +object.src'; + $content1 = 'hello'; + $content2 = 'hello world'; + $ret1 = $this->ossClient->putObject($this->bucket, $object_src, $content1); + $ret2 = $this->ossClient->putObject($this->bucket, $object_src, $content2); + + $this->assertTrue(isset($ret1[OssClient::OSS_HEADER_VERSION_ID])); + $this->assertTrue(isset($ret2[OssClient::OSS_HEADER_VERSION_ID])); + + $versionId1 = $ret1[OssClient::OSS_HEADER_VERSION_ID]; + $versionId2 = $ret2[OssClient::OSS_HEADER_VERSION_ID]; + + //object + $object = "multi-object"; + $upload_id = $this->ossClient->initiateMultipartUpload($this->bucket, $object); + $copyId = 1; + $eTag = $this->ossClient->uploadPartCopy($this->bucket, $object_src, $this->bucket, $object, $copyId, $upload_id); + $upload_parts[] = array( + 'PartNumber' => $copyId, + 'ETag' => $eTag, + ); + $ret = $this->ossClient->completeMultipartUpload($this->bucket, $object, $upload_id, $upload_parts); + + //object-1 + $object1 = "multi-object-1"; + $upload_id = $this->ossClient->initiateMultipartUpload($this->bucket, $object1); + $copyId = 1; + $eTag = $this->ossClient->uploadPartCopy($this->bucket, $object_src, $this->bucket, $object1, $copyId, $upload_id, array(OssClient::OSS_VERSION_ID => $versionId1)); + $upload_parts1[] = array( + 'PartNumber' => $copyId, + 'ETag' => $eTag, + ); + $ret1 = $this->ossClient->completeMultipartUpload($this->bucket, $object1, $upload_id, $upload_parts1); + + //object-2 + $object2 = "multi-object-2"; + $upload_id = $this->ossClient->initiateMultipartUpload($this->bucket, $object2); + $copyId = 1; + $eTag = $this->ossClient->uploadPartCopy($this->bucket, $object_src, $this->bucket, $object2, $copyId, $upload_id, array(OssClient::OSS_VERSION_ID => $versionId2)); + $upload_parts2[] = array( + 'PartNumber' => $copyId, + 'ETag' => $eTag, + ); + $ret2 = $this->ossClient->completeMultipartUpload($this->bucket, $object2, $upload_id, $upload_parts2); + + $res = $this->ossClient->getObject($this->bucket, $object); + $res1 = $this->ossClient->getObject($this->bucket, $object1); + $res2 = $this->ossClient->getObject($this->bucket, $object2); + + $this->assertEquals($content1, $res1); + $this->assertEquals($content2, $res2); + $this->assertEquals($content2, $res); + } + + public function testObjectMisc() + { + //use multipart + $options = array( + OssClient::OSS_PART_SIZE => 1, + ); + + $object = 'misc-object'; + + $smallFile1 = __DIR__ . DIRECTORY_SEPARATOR . "/smallfile1.tmp"; + $smallFile2 = __DIR__ . DIRECTORY_SEPARATOR . "/smallfile2.tmp"; + $bigFile1 = __DIR__ . DIRECTORY_SEPARATOR . "/bigfile1.tmp"; + $bigFile2 = __DIR__ . DIRECTORY_SEPARATOR . "/bigfile2.tmp"; + + OssUtil::generateFile($smallFile1, 5); + OssUtil::generateFile($smallFile2, 10); + OssUtil::generateFile($bigFile1, 128 * 1024); + OssUtil::generateFile($bigFile2, 256 * 1024); + + $sret1 = $this->ossClient->multiuploadFile($this->bucket, $object, $smallFile1, $options); + $sret2 = $this->ossClient->multiuploadFile($this->bucket, $object, $smallFile2, $options); + $bret1 = $this->ossClient->multiuploadFile($this->bucket, $object, $bigFile1, $options); + $bret2 = $this->ossClient->multiuploadFile($this->bucket, $object, $bigFile2, $options); + + + $res = $this->ossClient->getObject($this->bucket, $object); + $sres1 = $this->ossClient->getObject($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $sret1['x-oss-version-id'])); + $sres2 = $this->ossClient->getObject($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $sret2['x-oss-version-id'])); + $bres1 = $this->ossClient->getObject($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $bret1['x-oss-version-id'])); + $bres2 = $this->ossClient->getObject($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $bret2['x-oss-version-id'])); + + + $this->assertEquals(file_get_contents($smallFile1), $sres1); + $this->assertEquals(file_get_contents($smallFile2), $sres2); + $this->assertEquals(file_get_contents($bigFile1), $bres1); + $this->assertEquals(file_get_contents($bigFile2), $bres2); + $this->assertEquals(file_get_contents($bigFile2), $res); + + + unlink($smallFile1); + unlink($smallFile2); + unlink($bigFile1); + unlink($bigFile2); + } + + public function testListObjects() + { + //folder + for ($i = 0; $i < 12; $i++) { + $key = 'folder/'. sprintf("%02d",$i); + $this->ossClient->putObject($this->bucket, $key, "content"); + $this->ossClient->putObject($this->bucket, $key, "content"); + $this->ossClient->deleteObject($this->bucket, $key); + } + + //test + for ($i = 0; $i < 8; $i++) { + $key = 'test/'. sprintf("%02d",$i); + $this->ossClient->putObject($this->bucket, $key, "content"); + $this->ossClient->deleteObject($this->bucket, $key); + $this->ossClient->putObject($this->bucket, $key, "content"); + } + //work + for ($i = 0; $i < 5; $i++) { + $key = 'work/'. sprintf("%02d",$i); + $this->ossClient->putObject($this->bucket, $key, "content"); + } + //sub++ + for ($i = 0; $i < 3; $i++) { + $key = 'sub++/'. sprintf("%02d",$i); + $this->ossClient->putObject($this->bucket, $key, "content"); + $this->ossClient->putObject($this->bucket, $key, "content"); + $this->ossClient->putObject($this->bucket, $key, "content"); + } + //file++ + for ($i = 0; $i < 2; $i++) { + $key = 'file++'. sprintf("%02d",$i); + $this->ossClient->putObject($this->bucket, $key, "content"); + $this->ossClient->deleteObject($this->bucket, $key); + } + + //list default + $result = $this->ossClient->listObjectVersions($this->bucket); + $versionList = $result->getObjectVersionList(); + $deleteMarkerList = $result->getDeleteMarkerList(); + $prefixList = $result->getPrefixList(); + + $this->assertNotNull($versionList); + $this->assertNotNull($deleteMarkerList); + $this->assertNotNull($prefixList); + $this->assertTrue(is_array($versionList)); + $this->assertTrue(is_array($deleteMarkerList)); + $this->assertTrue(is_array($prefixList)); + $this->assertEquals(2, count($versionList)); + $this->assertEquals(2, count($deleteMarkerList)); + $this->assertEquals(4, count($prefixList)); + + $this->assertEquals('file++00', $versionList[0]->getKey()); + $this->assertEquals('false', $versionList[0]->getIsLatest()); + $this->assertEquals('file++01', $versionList[1]->getKey()); + $this->assertEquals('false', $versionList[1]->getIsLatest()); + + $this->assertEquals('file++00', $deleteMarkerList[0]->getKey()); + $this->assertEquals('true', $deleteMarkerList[0]->getIsLatest()); + $this->assertEquals('file++01', $deleteMarkerList[1]->getKey()); + $this->assertEquals('true', $deleteMarkerList[1]->getIsLatest()); + + + $this->assertEquals('folder/', $prefixList[0]->getPrefix()); + $this->assertEquals('sub++/', $prefixList[1]->getPrefix()); + $this->assertEquals('test/', $prefixList[2]->getPrefix()); + $this->assertEquals('work/', $prefixList[3]->getPrefix()); + + //list by prefix + $prefix = 'folder/'; + $delimiter = ''; + $next_marker = ''; + $maxkeys = 1000; + $options = array( + 'delimiter' => $delimiter, + 'prefix' => $prefix, + 'max-keys' => $maxkeys, + 'key-marker' => $next_marker, + ); + + $result = $this->ossClient->listObjectVersions($this->bucket, $options); + $versionList = $result->getObjectVersionList(); + $deleteMarkerList = $result->getDeleteMarkerList(); + $prefixList = $result->getPrefixList(); + + $this->assertEquals(24, count($versionList)); + $this->assertEquals(12, count($deleteMarkerList)); + $this->assertEquals(0, count($prefixList)); + + $this->assertEquals('folder/00', $versionList[0]->getKey()); + $this->assertEquals('folder/00', $versionList[1]->getKey()); + $this->assertEquals('folder/00', $deleteMarkerList[0]->getKey()); + $this->assertEquals('folder/01', $deleteMarkerList[1]->getKey()); + + + //max-key & key-marker & version-id-marker + $count = 0; + $markerCount = 0; + $nextMarker = ''; + $nextVersionIdMarker = ''; + + while (true) { + $options = array( + 'delimiter' => '', + 'key-marker' => $nextMarker, + 'max-keys' => 1, + 'version-id-marker' => $nextVersionIdMarker, + ); + $result = $this->ossClient->listObjectVersions($this->bucket, $options); + + $nextMarker = $result->getNextKeyMarker(); + $nextVersionIdMarker = $result->getNextVersionIdMarker(); + $count += count($result->getObjectVersionList()); + $markerCount += count($result->getDeleteMarkerList()); + $this->assertEquals(1, count($result->getObjectVersionList()) + count($result->getDeleteMarkerList())); + if ($result->getIsTruncated() !== "true") { + break; + } + } + $this->assertEquals(12*3 + 8*3 + 5 + 3*3 + 2*2, $count + $markerCount); + } + + public function testDeleteObjects() + { + //deletes + for ($i = 0; $i < 5; $i++) { + $key = 'deletes/'. sprintf("%02d",$i); + $this->ossClient->putObject($this->bucket, $key, "content"); + $this->ossClient->putObject($this->bucket, $key, "content"); + } + + $options = array( + 'delimiter' => '', + 'prefix' => 'deletes/', + 'max-keys' => 1000, + ); + $result = $this->ossClient->listObjects($this->bucket, $options); + $this->assertEquals(5, count($result->getObjectList())); + + //delete without version-id + $objects = array(); + for ($i = 0; $i < 5; $i++) { + $key = 'deletes/'. sprintf("%02d",$i); + $objects[] = new DeleteObjectInfo($key); + } + $dresult = $this->ossClient->deleteObjectVersions($this->bucket, $objects); + $this->assertEquals(5, count($dresult)); + $this->assertEquals('deletes/00', $dresult[0]->getKey()); + $this->assertEquals('true', $dresult[0]->getDeleteMarker()); + $this->assertEquals('', $dresult[0]->getVersionId()); + $this->assertFalse(empty($dresult[0]->getDeleteMarkerVersionId())); + + $result = $this->ossClient->listObjects($this->bucket, $options); + $this->assertEquals(0, count($result->getObjectList())); + + //delete by version-id + $vresult = $this->ossClient->listObjectVersions($this->bucket, $options); + $versions = $vresult->getObjectVersionList(); + $deleteMarkerList = $vresult->getDeleteMarkerList(); + $this->assertEquals(10, count($versions)); + $this->assertEquals(5, count($deleteMarkerList)); + + $objects = array(); + foreach ($versions as $obj) { + $objects[] = new DeleteObjectInfo($obj->getKey(), $obj->getVersionId()); + } + $dresult = $this->ossClient->deleteObjectVersions($this->bucket, $objects); + $this->assertEquals(10, count($dresult)); + $this->assertEquals('deletes/00', $dresult[0]->getKey()); + $this->assertEquals('', $dresult[0]->getDeleteMarker()); + $this->assertFalse(empty($dresult[0]->getVersionId())); + $this->assertTrue(empty($dresult[0]->getDeleteMarkerVersionId())); + $this->assertEquals('deletes/00', $dresult[1]->getKey()); + $this->assertEquals('', $dresult[1]->getDeleteMarker()); + $this->assertFalse(empty($dresult[1]->getVersionId())); + $this->assertTrue(empty($dresult[1]->getDeleteMarkerVersionId())); + + + $vresult = $this->ossClient->listObjectVersions($this->bucket, $options); + $versions = $vresult->getObjectVersionList(); + $deleteMarkerList = $vresult->getDeleteMarkerList(); + $this->assertEquals(0, count($versions)); + $this->assertEquals(5, count($deleteMarkerList)); + + $objects = array(); + foreach ($deleteMarkerList as $obj) { + $objects[] = new DeleteObjectInfo($obj->getKey(), $obj->getVersionId()); + } + $dresult = $this->ossClient->deleteObjectVersions($this->bucket, $objects); + $this->assertEquals(5, count($dresult)); + $this->assertEquals('deletes/00', $dresult[0]->getKey()); + $this->assertEquals('true', $dresult[0]->getDeleteMarker()); + $this->assertFalse(empty($dresult[1]->getVersionId())); + $this->assertFalse(empty($dresult[1]->getDeleteMarkerVersionId())); + + $vresult = $this->ossClient->listObjectVersions($this->bucket, $options); + $versions = $vresult->getObjectVersionList(); + $deleteMarkerList = $vresult->getDeleteMarkerList(); + $this->assertEquals(0, count($versions)); + $this->assertEquals(0, count($deleteMarkerList)); + } + + protected function setUp(): void + { + parent::setUp(); + + $this->ossClient->putBucketVersioning($this->bucket, "Enabled"); + + } + + protected function tearDown(): void + { + if (!$this->ossClient->doesBucketExist($this->bucket)) { + return; + } + + $this->ossClient->putBucketVersioning($this->bucket, "Suspended"); + + $result = $this->ossClient->listObjectVersions( + $this->bucket, array('max-keys' => 1000, 'delimiter' => '')); + + $versions = $result->getObjectVersionList(); + $deleteMarkers = $result->getDeleteMarkerList(); + + foreach ($versions as $obj) { + $options = array( + OssClient::OSS_VERSION_ID => $obj->getVersionId(), + ); + $this->ossClient->deleteObject($this->bucket, $obj->getKey(), $options); + } + + foreach ($deleteMarkers as $del) { + $options = array( + OssClient::OSS_VERSION_ID => $del->getVersionId(), + ); + $this->ossClient->deleteObject($this->bucket, $del->getKey(), $options); + } + + parent::tearDown(); + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientPresignTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientPresignTest.php new file mode 100644 index 0000000..14dc047 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientPresignTest.php @@ -0,0 +1,70 @@ + OssClient::OSS_SIGNATURE_VERSION_V1 + ); + $this->bucket = Common::getBucketName() . '-' . time(); + $this->ossClient = Common::getOssClient($config); + $this->ossClient->createBucket($this->bucket); + Common::waitMetaSync(); + + $object = "a.file"; + $this->ossClient->putObject($this->bucket, $object, "hi oss"); + $timeout = 3600; + $options = array( + "response-content-disposition" => "inline" + ); + try { + $signedUrl = $this->ossClient->signUrl($this->bucket, $object, $timeout, OssClient::OSS_HTTP_GET, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + $this->assertStringContainsString("response-content-disposition=inline", $signedUrl); + $options = array( + "response-content-disposition" => "attachment", + ); + + try { + $signedUrl = $this->ossClient->signUrl($this->bucket, $object, $timeout, OssClient::OSS_HTTP_GET, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + $this->assertStringContainsString("response-content-disposition=attachment", $signedUrl); + + $httpCore = new RequestCore($signedUrl); + $httpCore->set_body(""); + $httpCore->set_method("GET"); + $httpCore->connect_timeout = 10; + $httpCore->timeout = 10; + $httpCore->add_header("Content-Type", ""); + $httpCore->send_request(); + $this->assertEquals(200, $httpCore->response_code); + } + + protected function tearDown(): void + { + $this->ossClient->deleteObject($this->bucket, "a.file"); + parent::tearDown(); + } + + protected function setUp(): void + { + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientPresignV4Test.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientPresignV4Test.php new file mode 100644 index 0000000..28296bc --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientPresignV4Test.php @@ -0,0 +1,369 @@ +ossClient->putObject($this->bucket, $object, file_get_contents(__FILE__)); + $timeout = 3600; + try { + $signedUrl = $this->ossClient->signUrl($this->bucket, $object, $timeout); + } catch (OssException $e) { + $this->assertFalse(true); + } + + $request = new RequestCore($signedUrl); + $request->set_method('GET'); + $request->add_header('Content-Type', ''); + $request->send_request(); + $res = new ResponseCore($request->get_response_header(), $request->get_response_body(), $request->get_response_code()); + $this->assertEquals(file_get_contents(__FILE__), $res->body); + sleep(1); + + //testGetSignedUrlForPuttingObject + $object = "a.file"; + $timeout = 3600; + try { + $signedUrl = $this->ossClient->signUrl($this->bucket, $object, $timeout, "PUT"); + $content = file_get_contents(__FILE__); + $request = new RequestCore($signedUrl); + $request->set_method('PUT'); + $request->add_header('Content-Type', ''); + $request->add_header('Content-Length', strlen($content)); + $request->set_body($content); + $request->send_request(); + $res = new ResponseCore($request->get_response_header(), + $request->get_response_body(), $request->get_response_code()); + $this->assertTrue($res->isOK()); + } catch (OssException $e) { + $this->assertFalse(true); + } + sleep(1); + + // test Get SignedUrl For Putting Object From File + $file = __FILE__; + $object = "a.file"; + $timeout = 3600; + $options = array('Content-Type' => 'txt'); + try { + $signedUrl = $this->ossClient->signUrl($this->bucket, $object, $timeout, "PUT", $options); + $request = new RequestCore($signedUrl); + $request->set_method('PUT'); + $request->add_header('Content-Type', 'txt'); + $request->set_read_file($file); + $request->set_read_stream_size(sprintf('%u', filesize($file))); + $request->send_request(); + $res = new ResponseCore($request->get_response_header(), $request->get_response_body(), $request->get_response_code()); + $this->assertTrue($res->isOK()); + } catch (OssException $e) { + $this->assertFalse(true); + } + sleep(1); + // test SignedUrl With Exception + $object = "a.file"; + $timeout = 3600; + $options = array('Content-Type' => 'txt'); + try { + $signedUrl = $this->ossClient->signUrl($this->bucket, $object, $timeout, "POST", $options); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + if (strpos($e, "method is invalid") == false) { + $this->assertTrue(false); + } + } + + // test GetgenPreSignedUrl For GettingObject + $object = "a.file"; + $this->ossClient->putObject($this->bucket, $object, file_get_contents(__FILE__)); + $expires = time() + 3600; + try { + $signedUrl = $this->ossClient->generatePresignedUrl($this->bucket, $object, $expires); + } catch (OssException $e) { + $this->assertFalse(true); + } + + $request = new RequestCore($signedUrl); + $request->set_method('GET'); + $request->add_header('Content-Type', ''); + $request->send_request(); + $res = new ResponseCore($request->get_response_header(), $request->get_response_body(), $request->get_response_code()); + $this->assertEquals(file_get_contents(__FILE__), $res->body); + sleep(1); + // test Get genPreSignedUrl Vs SignedUrl + + $object = "object-vs.file"; + $signedUrl1 = '245'; + $signedUrl2 = '123'; + $expiration = 0; + + do { + usleep(500000); + $begin = time(); + $expiration = time() + 3600; + $signedUrl1 = $this->ossClient->generatePresignedUrl($this->bucket, $object, $expiration); + $signedUrl2 = $this->ossClient->signUrl($this->bucket, $object, 3600); + $end = time(); + } while ($begin != $end); + $this->assertEquals($signedUrl1, $signedUrl2); + $this->assertTrue(strpos($signedUrl1, 'x-oss-expires=') !== false); + + $object = "a.file"; + $options = array( + OssClient::OSS_HEADERS => array( + 'name' => 'aliyun', + 'email' => 'aliyun@aliyun.com', + 'book' => 'english', + ), + OssClient::OSS_ADDITIONAL_HEADERS => array("name", "email") + ); + $this->ossClient->putObject($this->bucket, $object, file_get_contents(__FILE__), $options); + $expires = time() + 3600; + try { + $signedUrl = $this->ossClient->generatePresignedUrl($this->bucket, $object, $expires, "GET", $options); + $request = new RequestCore($signedUrl); + $request->set_method('GET'); + $request->add_header('Content-Type', ''); + $request->add_header('name', 'aliyun'); + $request->add_header('email', 'aliyun@aliyun.com'); + $request->send_request(); + $res = new ResponseCore($request->get_response_header(), $request->get_response_body(), $request->get_response_code()); + $this->assertEquals(file_get_contents(__FILE__), $res->body); + sleep(1); + } catch (OssException $e) { + print_r($e->getMessage()); + $this->assertFalse(true); + } + + + try { + $signedUrl = $this->ossClient->generatePresignedUrl($this->bucket, $object, $expires); + } catch (OssException $e) { + $this->assertFalse(true); + } + + $request = new RequestCore($signedUrl); + $request->set_method('GET'); + $request->add_header('Content-Type', ''); + $request->send_request(); + $res = new ResponseCore($request->get_response_header(), $request->get_response_body(), $request->get_response_code()); + $this->assertEquals(file_get_contents(__FILE__), $res->body); + sleep(1); + + + } + + public function testObjectWithStsClientSignV4() + { + $object = "a.file"; + $this->stsOssClient->putObject($this->bucket, $object, file_get_contents(__FILE__)); + $timeout = 3600; + try { + $signedUrl = $this->stsOssClient->signUrl($this->bucket, $object, $timeout); + } catch (OssException $e) { + $this->assertFalse(true); + } + + $request = new RequestCore($signedUrl); + $request->set_method('GET'); + $request->add_header('Content-Type', ''); + $request->send_request(); + $res = new ResponseCore($request->get_response_header(), $request->get_response_body(), $request->get_response_code()); + $this->assertEquals(file_get_contents(__FILE__), $res->body); + sleep(1); + + //testGetSignedUrlForPuttingObject + $object = "a.file"; + $timeout = 3600; + try { + $signedUrl = $this->stsOssClient->signUrl($this->bucket, $object, $timeout, "PUT"); + $content = file_get_contents(__FILE__); + $request = new RequestCore($signedUrl); + $request->set_method('PUT'); + $request->add_header('Content-Type', ''); + $request->add_header('Content-Length', strlen($content)); + $request->set_body($content); + $request->send_request(); + $res = new ResponseCore($request->get_response_header(), + $request->get_response_body(), $request->get_response_code()); + $this->assertTrue($res->isOK()); + } catch (OssException $e) { + $this->assertFalse(true); + } + sleep(1); + + // test Get SignedUrl For Putting Object From File + $file = __FILE__; + $object = "a.file"; + $timeout = 3600; + $options = array('Content-Type' => 'txt'); + try { + $signedUrl = $this->stsOssClient->signUrl($this->bucket, $object, $timeout, "PUT", $options); + $request = new RequestCore($signedUrl); + $request->set_method('PUT'); + $request->add_header('Content-Type', 'txt'); + $request->set_read_file($file); + $request->set_read_stream_size(sprintf('%u', filesize($file))); + $request->send_request(); + $res = new ResponseCore($request->get_response_header(), $request->get_response_body(), $request->get_response_code()); + $this->assertTrue($res->isOK()); + } catch (OssException $e) { + $this->assertFalse(true); + } + sleep(1); + // test SignedUrl With Exception + $file = __FILE__; + $object = "a.file"; + $timeout = 3600; + $options = array('Content-Type' => 'txt'); + try { + $signedUrl = $this->stsOssClient->signUrl($this->bucket, $object, $timeout, "POST", $options); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + if (strpos($e, "method is invalid") == false) { + $this->assertTrue(false); + } + } + + // test GetgenPreSignedUrl For GettingObject + $object = "a.file"; + $this->stsOssClient->putObject($this->bucket, $object, file_get_contents(__FILE__)); + $expires = time() + 3600; + try { + $signedUrl = $this->stsOssClient->generatePresignedUrl($this->bucket, $object, $expires); + } catch (OssException $e) { + $this->assertFalse(true); + } + + try { + $request = new RequestCore($signedUrl); + $request->set_method('GET'); + $request->add_header('Content-Type', ''); + $request->send_request(); + $res = new ResponseCore($request->get_response_header(), $request->get_response_body(), $request->get_response_code()); + $this->assertEquals(file_get_contents(__FILE__), $res->body); + sleep(1); + } catch (OssException $e) { + $this->assertFalse(true); + } + + // test Get genPreSignedUrl Vs SignedUrl + + $object = "object-vs.file"; + + do { + usleep(500000); + $begin = time(); + $expiration = time() + 3600; + $signedUrl1 = $this->stsOssClient->generatePresignedUrl($this->bucket, $object, $expiration); + $signedUrl2 = $this->stsOssClient->signUrl($this->bucket, $object, 3600); + $end = time(); + } while ($begin != $end); + $this->assertEquals($signedUrl1, $signedUrl2); + $this->assertTrue(strpos($signedUrl1, 'x-oss-expires=') !== false); + + $object = "a.file"; + $options = array( + OssClient::OSS_HEADERS => array( + 'name' => 'aliyun', + 'email' => 'aliyun@aliyun.com', + 'book' => 'english', + ), + OssClient::OSS_ADDITIONAL_HEADERS => array("name", "email") + ); + $this->stsOssClient->putObject($this->bucket, $object, file_get_contents(__FILE__), $options); + $expires = time() + 3600; + try { + $signedUrl = $this->stsOssClient->generatePresignedUrl($this->bucket, $object, $expires, "GET", $options); + $request = new RequestCore($signedUrl); + $request->set_method('GET'); + $request->add_header('Content-Type', ''); + $request->add_header('name', 'aliyun'); + $request->add_header('email', 'aliyun@aliyun.com'); + $request->send_request(); + $res = new ResponseCore($request->get_response_header(), $request->get_response_body(), $request->get_response_code()); + $this->assertEquals(file_get_contents(__FILE__), $res->body); + sleep(1); + } catch (OssException $e) { + print_r($e->getMessage()); + $this->assertFalse(true); + } + } + + public function testObjectWithSignV4AndResponseQuery() + { + $config = array( + 'signatureVersion' => OssClient::OSS_SIGNATURE_VERSION_V4 + ); + $this->bucket = Common::getBucketName() . '-' . time(); + $this->ossClient = Common::getOssClient($config); + $this->ossClient->createBucket($this->bucket); + Common::waitMetaSync(); + + $object = "a.file"; + $this->ossClient->putObject($this->bucket, $object, "hi oss"); + $timeout = 3600; + $options = array( + "response-content-disposition" => "inline" + ); + try { + $signedUrl = $this->ossClient->signUrl($this->bucket, $object, $timeout, OssClient::OSS_HTTP_GET, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + $this->assertStringContainsString("response-content-disposition=inline", $signedUrl); + $options = array( + "response-content-disposition" => "attachment" + ); + + try { + $signedUrl = $this->ossClient->signUrl($this->bucket, $object, $timeout, OssClient::OSS_HTTP_GET, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + $this->assertStringContainsString("response-content-disposition=attachment", $signedUrl); + + $httpCore = new RequestCore($signedUrl); + $httpCore->set_body(""); + $httpCore->set_method("GET"); + $httpCore->connect_timeout = 10; + $httpCore->timeout = 10; + $httpCore->add_header("Content-Type", ""); + $httpCore->send_request(); + $this->assertEquals(200, $httpCore->response_code); + } + + protected function tearDown(): void + { + $this->ossClient->deleteObject($this->bucket, "a.file"); + parent::tearDown(); + } + + protected function setUp(): void + { + $config = array( + 'signatureVersion' => OssClient::OSS_SIGNATURE_VERSION_V4 + ); + $this->bucket = Common::getBucketName() . '-' . time(); + $this->ossClient = Common::getOssClient($config); + $this->ossClient->createBucket($this->bucket); + Common::waitMetaSync(); + $this->stsOssClient = Common::getStsOssClient($config); + Common::waitMetaSync(); + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientRestoreObjectTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientRestoreObjectTest.php new file mode 100644 index 0000000..9aa0b9b --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientRestoreObjectTest.php @@ -0,0 +1,174 @@ +ossClient->putObject($this->iaBucket, $object,'testcontent'); + try{ + $this->ossClient->restoreObject($this->iaBucket, $object); + $this->assertTrue(false); + }catch (OssException $e){ + $this->assertEquals('400', $e->getHTTPStatus()); + $this->assertEquals('OperationNotSupported', $e->getErrorCode()); + } + } + + public function testNullObjectRestoreObject() + { + $object = 'null-object'; + + try{ + $this->ossClient->restoreObject($this->bucket, $object); + $this->assertTrue(false); + }catch (OssException $e){ + $this->assertEquals('404', $e->getHTTPStatus()); + } + } + + public function testArchiveRestoreObject() + { + $object = 'storage-object'; + + $this->ossClient->putObject($this->archiveBucket, $object,'testcontent'); + try{ + $this->ossClient->getObject($this->archiveBucket, $object); + $this->assertTrue(false); + }catch (OssException $e){ + $this->assertEquals('403', $e->getHTTPStatus()); + $this->assertEquals('InvalidObjectState', $e->getErrorCode()); + } + $result = $this->ossClient->restoreObject($this->archiveBucket, $object); + common::waitMetaSync(); + $this->assertEquals('202', $result['info']['http_code']); + + try{ + $this->ossClient->restoreObject($this->archiveBucket, $object); + }catch(OssException $e){ + $this->assertEquals('409', $e->getHTTPStatus()); + $this->assertEquals('RestoreAlreadyInProgress', $e->getErrorCode()); + } + } + + public function testColdArchiveRestoreObject() + { + $client = new OssClient( + getenv('OSS_ACCESS_KEY_ID'), + getenv('OSS_ACCESS_KEY_SECRET'), + 'oss-ap-southeast-1.aliyuncs.com', false); + + $bucket = $this->bucket . 'cold-archive'; + $object = 'storage-object'; + + //create bucket + $options = array( + OssClient::OSS_STORAGE => OssClient::OSS_STORAGE_COLDARCHIVE + ); + $client->createBucket($bucket, OssClient::OSS_ACL_TYPE_PRIVATE, $options); + + //test with days + $client->putObject($bucket, $object,'testcontent'); + + try{ + $client->getObject($bucket, $object); + $this->assertTrue(false); + }catch (OssException $e){ + $this->assertEquals('403', $e->getHTTPStatus()); + $this->assertEquals('InvalidObjectState', $e->getErrorCode()); + } + + $config = new RestoreConfig(5); + $resoptions = array( + OssClient::OSS_RESTORE_CONFIG => $config + ); + try{ + $client->restoreObject($bucket, $object, $resoptions); + }catch(OssException $e){ + $this->assertTrue(false); + } + + try{ + $client->restoreObject($bucket, $object, $resoptions); + }catch(OssException $e){ + $this->assertEquals('409', $e->getHTTPStatus()); + $this->assertEquals('RestoreAlreadyInProgress', $e->getErrorCode()); + } + + //test with days & tier + $client->putObject($bucket, $object,'testcontent'); + + try{ + $client->getObject($bucket, $object); + $this->assertTrue(false); + }catch (OssException $e){ + $this->assertEquals('403', $e->getHTTPStatus()); + $this->assertEquals('InvalidObjectState', $e->getErrorCode()); + } + + $config = new RestoreConfig(5, "Expedited"); + $resoptions = array( + OssClient::OSS_RESTORE_CONFIG => $config + ); + try{ + $client->restoreObject($bucket, $object, $resoptions); + }catch(OssException $e){ + $this->assertTrue(false); + } + + try{ + $client->restoreObject($bucket, $object, $resoptions); + }catch(OssException $e){ + $this->assertEquals('409', $e->getHTTPStatus()); + $this->assertEquals('RestoreAlreadyInProgress', $e->getErrorCode()); + } + + $client->deleteObject($bucket, $object); + $client->deleteBucket($bucket); + } + + + protected function setUp(): void + { + parent::setUp(); + + $this->iaBucket = 'ia-' . $this->bucket; + $this->archiveBucket = 'archive-' . $this->bucket; + $options = array( + OssClient::OSS_STORAGE => OssClient::OSS_STORAGE_IA + ); + + $this->ossClient->createBucket($this->iaBucket, OssClient::OSS_ACL_TYPE_PRIVATE, $options); + + $options = array( + OssClient::OSS_STORAGE => OssClient::OSS_STORAGE_ARCHIVE + ); + + $this->ossClient->createBucket($this->archiveBucket, OssClient::OSS_ACL_TYPE_PRIVATE, $options); + } + + protected function tearDown(): void + { + parent::tearDown(); + + $object = 'storage-object'; + + $this->ossClient->deleteObject($this->iaBucket, $object); + $this->ossClient->deleteObject($this->archiveBucket, $object); + $this->ossClient->deleteBucket($this->iaBucket); + $this->ossClient->deleteBucket($this->archiveBucket); + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientSignatureTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientSignatureTest.php new file mode 100644 index 0000000..63e8bf3 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientSignatureTest.php @@ -0,0 +1,267 @@ +ossClient->putObject($this->bucket, $object, file_get_contents(__FILE__)); + $timeout = 3600; + try { + $signedUrl = $this->ossClient->signUrl($this->bucket, $object, $timeout); + } catch (OssException $e) { + $this->assertFalse(true); + } + + $request = new RequestCore($signedUrl); + $request->set_method('GET'); + $request->add_header('Content-Type', ''); + $request->send_request(); + $res = new ResponseCore($request->get_response_header(), $request->get_response_body(), $request->get_response_code()); + $this->assertEquals(file_get_contents(__FILE__), $res->body); + } + + public function testGetSignedUrlForPuttingObject() + { + $object = "a.file"; + $timeout = 3600; + try { + $signedUrl = $this->ossClient->signUrl($this->bucket, $object, $timeout, "PUT"); + $content = file_get_contents(__FILE__); + $request = new RequestCore($signedUrl); + $request->set_method('PUT'); + $request->add_header('Content-Type', ''); + $request->add_header('Content-Length', strlen($content)); + $request->set_body($content); + $request->send_request(); + $res = new ResponseCore($request->get_response_header(), + $request->get_response_body(), $request->get_response_code()); + $this->assertTrue($res->isOK()); + } catch (OssException $e) { + $this->assertFalse(true); + } + } + + public function testGetSignedUrlForPuttingObjectFromFile() + { + $file = __FILE__; + $object = "a.file"; + $timeout = 3600; + $options = array('Content-Type' => 'txt'); + try { + $signedUrl = $this->ossClient->signUrl($this->bucket, $object, $timeout, "PUT", $options); + $request = new RequestCore($signedUrl); + $request->set_method('PUT'); + $request->add_header('Content-Type', 'txt'); + $request->set_read_file($file); + $request->set_read_stream_size(sprintf('%u',filesize($file))); + $request->send_request(); + $res = new ResponseCore($request->get_response_header(), + $request->get_response_body(), $request->get_response_code()); + $this->assertTrue($res->isOK()); + } catch (OssException $e) { + $this->assertFalse(true); + } + + } + + public function testSignedUrlWithException() + { + $file = __FILE__; + $object = "a.file"; + $timeout = 3600; + $options = array('Content-Type' => 'txt'); + try { + $signedUrl = $this->ossClient->signUrl($this->bucket, $object, $timeout, "POST", $options); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + if (strpos($e, "method is invalid") == false) + { + $this->assertTrue(false); + } + } + + $object = "?a.file"; + $timeout = 3600; + $options = array('Content-Type' => 'txt'); + try { + $signedUrl = $this->ossClient->signUrl($this->bucket, $object, $timeout, "PUT", $options); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + if (strpos($e, "object name cannot start with `?`") == false) + { + $this->assertTrue(false); + } + } + + // Set StrictObjectName false + $object = "?a.file"; + $timeout = 3600; + $options = array('Content-Type' => 'txt'); + $config = array( + 'strictObjectName' => false + ); + $ossClient = Common::getOssClient($config); + try { + $signedUrl = $ossClient->signUrl($this->bucket, $object, $timeout, "PUT", $options); + $this->assertTrue(true); + } catch (OssException $e) { + print_r($e->getMessage()); + $this->assertFalse(true); + } + + // V4 + $object = "?a.file"; + $timeout = 3600; + $options = array('Content-Type' => 'txt'); + $config = array( + 'signatureVersion' => OssClient::OSS_SIGNATURE_VERSION_V4 + ); + $ossClient = Common::getOssClient($config); + try { + $signedUrl = $ossClient->signUrl($this->bucket, $object, $timeout, "PUT", $options); + $this->assertTrue(true); + } catch (OssException $e) { + print_r($e->getMessage()); + $this->assertFalse(true); + } + } + + function testGetgenPreSignedUrlForGettingObject() + { + $object = "a.file"; + $this->ossClient->putObject($this->bucket, $object, file_get_contents(__FILE__)); + $expires = time() + 3600; + try { + $signedUrl = $this->ossClient->generatePresignedUrl($this->bucket, $object, $expires); + } catch (OssException $e) { + $this->assertFalse(true); + } + + $request = new RequestCore($signedUrl); + $request->set_method('GET'); + $request->add_header('Content-Type', ''); + $request->send_request(); + $res = new ResponseCore($request->get_response_header(), $request->get_response_body(), $request->get_response_code()); + $this->assertEquals(file_get_contents(__FILE__), $res->body); + } + + function testGetgenPreSignedUrlVsSignedUrl() + { + $object = "object-vs.file"; + $signedUrl1 = '245'; + $signedUrl2 = '123'; + $expiration = 0; + + do { + usleep(500000); + $begin = time(); + $expiration = time() + 3600; + $signedUrl1 = $this->ossClient->generatePresignedUrl($this->bucket, $object, $expiration); + $signedUrl2 = $this->ossClient->signUrl($this->bucket, $object, 3600); + $end = time(); + } while ($begin != $end); + $this->assertEquals($signedUrl1, $signedUrl2); + $this->assertTrue(strpos($signedUrl1, 'Expires='.$expiration) !== false); + } + + public function testPutObjectWithQueryCallback() + { + $object = "a.file"; + $timeout = 3600; + $url = '{"callbackUrl":"http://aliyun.com", "callbackBody":"bucket=${bucket}&object=${object}"}'; + $var = + '{ + "x:var1":"value1", + "x:var2":"value2" + }'; + try { + $options[OssClient::OSS_QUERY_STRING] = array( + 'callback'=>base64_encode($url), + 'callback-var'=>base64_encode($var) + ); + $signedUrl = $this->ossClient->signUrl($this->bucket, $object, $timeout, "PUT", $options); + $content = file_get_contents(__FILE__); + $request = new RequestCore($signedUrl); + $request->set_method('PUT'); + $request->add_header('Content-Type', ''); + $request->add_header('Content-Length', strlen($content)); + $request->set_body($content); + $request->send_request(); + $res = new ResponseCore($request->get_response_header(), + $request->get_response_body(), $request->get_response_code()); + $this->assertEquals($res->status, 203); + } catch (OssException $e) { + $this->assertFalse(true); + } + + try { + $options = array(OssClient::OSS_CALLBACK => $url, + OssClient::OSS_CALLBACK_VAR => $var + ); + $signedUrl = $this->ossClient->signUrl($this->bucket, $object, $timeout, "PUT", $options); + $content = file_get_contents(__FILE__); + $request = new RequestCore($signedUrl); + $request->set_method('PUT'); + $request->add_header('Content-Type', ''); + $request->add_header(OssClient::OSS_CALLBACK, base64_encode($url)); + $request->add_header(OssClient::OSS_CALLBACK_VAR , base64_encode($var)); + $request->add_header('Content-Length', strlen($content)); + $request->set_body($content); + $request->send_request(); + $res = new ResponseCore($request->get_response_header(), + $request->get_response_body(), $request->get_response_code()); + $this->assertEquals($res->status, 203); + } catch (OssException $e) { + $this->assertFalse(true); + } + } + + + protected function tearDown(): void + { + $this->ossClient->deleteObject($this->bucket, "a.file"); + parent::tearDown(); + } + + protected function setUp(): void + { + parent::setUp(); + /** + * 上传本地变量到bucket + */ + $object = "a.file"; + $content = file_get_contents(__FILE__); + $options = array( + OssClient::OSS_LENGTH => strlen($content), + OssClient::OSS_HEADERS => array( + 'Expires' => 'Fri, 28 Feb 2020 05:38:42 GMT', + 'Cache-Control' => 'no-cache', + 'Content-Disposition' => 'attachment;filename=oss_download.log', + 'Content-Encoding' => 'utf-8', + 'Content-Language' => 'zh-CN', + 'x-oss-server-side-encryption' => 'AES256', + 'x-oss-meta-self-define-title' => 'user define meta info', + ), + ); + + try { + $this->ossClient->putObject($this->bucket, $object, $content, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientSignatureV4Test.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientSignatureV4Test.php new file mode 100644 index 0000000..ed26374 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientSignatureV4Test.php @@ -0,0 +1,1409 @@ +ossClient->putObject($this->bucket, $object, file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertTrue(false); + } + + // test GetObjectMeta + try { + $res = $this->ossClient->getObjectMeta($this->bucket, $object); + $this->assertEquals('200', $res['info']['http_code']); + $this->assertEquals('text/plain', $res['content-type']); + $this->assertEquals('Accept-Encoding', $res['vary']); + $this->assertFalse(isset($res['Content-Encoding'])); + } catch (OssException $e) { + $this->assertTrue(false); + } + + $options = array(OssClient::OSS_HEADERS => array(OssClient::OSS_ACCEPT_ENCODING => 'deflate, gzip')); + try { + $res = $this->ossClient->getObjectMeta($this->bucket, $object, $options); + $this->assertEquals('200', $res['info']['http_code']); + $this->assertEquals('text/plain', $res['content-type']); + $this->assertEquals('Accept-Encoding', $res['vary']); + $this->assertFalse(isset($res['content-length'])); + $this->assertEquals('gzip', $res['content-encoding']); + } catch (OssException $e) { + $this->assertTrue(false); + } + + $options = array(OssClient::OSS_HEADERS => array(OssClient::OSS_ACCEPT_ENCODING => 'deflate, gzip')); + try { + $res = $this->ossClient->getObject($this->bucket, $object, $options); + $this->assertEquals(file_get_contents(__FILE__), $res); + } catch (OssException $e) { + $this->assertTrue(false); + } + try { + $res = $this->ossClient->getObject($this->bucket, $object, array(OssClient::OSS_LAST_MODIFIED => "xx")); + $this->assertEquals(file_get_contents(__FILE__), $res); + } catch (OssException $e) { + $this->assertEquals('"/ilegal.txt" object name is invalid', $e->getMessage()); + } + + try { + $res = $this->ossClient->getObject($this->bucket, $object, array(OssClient::OSS_ETAG => "xx")); + $this->assertEquals(file_get_contents(__FILE__), $res); + } catch (OssException $e) { + $this->assertEquals('"/ilegal.txt" object name is invalid', $e->getMessage()); + } + + $content = file_get_contents(__FILE__); + $options = array( + OssClient::OSS_LENGTH => strlen($content), + OssClient::OSS_HEADERS => array( + 'Expires' => 'Fri, 28 Feb 2020 05:38:42 GMT', + 'Cache-Control' => 'no-cache', + 'Content-Disposition' => 'attachment;filename=oss_download.log', + 'Content-Language' => 'zh-CN', + 'x-oss-server-side-encryption' => 'AES256', + 'x-oss-meta-self-define-title' => 'user define meta info', + ), + ); + + try { + $this->ossClient->putObject($this->bucket, $object, $content, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + + try { + $result = $this->ossClient->deleteObjects($this->bucket, "stringtype", $options); + $this->assertEquals('stringtype', $result[0]); + } catch (OssException $e) { + $this->assertEquals('objects must be array', $e->getMessage()); + } + + try { + $this->ossClient->uploadFile($this->bucket, $object, "notexist.txt", $options); + $this->assertFalse(true); + } catch (OssException $e) { + $this->assertEquals('notexist.txt file does not exist', $e->getMessage()); + } + + $content = file_get_contents(__FILE__); + $options = array( + OssClient::OSS_LENGTH => strlen($content), + OssClient::OSS_HEADERS => array( + 'Expires' => 'Fri, 28 Feb 2020 05:38:42 GMT', + 'Cache-Control' => 'no-cache', + 'Content-Disposition' => 'attachment;filename=oss_download.log', + 'Content-Language' => 'zh-CN', + 'x-oss-server-side-encryption' => 'AES256', + 'x-oss-meta-self-define-title' => 'user define meta info', + ), + ); + + try { + $this->ossClient->putObject($this->bucket, $object, $content, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * GetObject to the local variable and check for match + */ + try { + $content = $this->ossClient->getObject($this->bucket, $object); + $this->assertEquals($content, file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * GetObject first five bytes + */ + try { + $options = array(OssClient::OSS_RANGE => '0-4'); + $content = $this->ossClient->getObject($this->bucket, $object, $options); + $this->assertEquals($content, 'assertFalse(true); + } + + /** + * Upload the local file to object + */ + try { + $this->ossClient->uploadFile($this->bucket, $object, __FILE__); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Download the file to the local variable and check for match. + */ + try { + $content = $this->ossClient->getObject($this->bucket, $object); + $this->assertEquals($content, file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Download the file to the local file + */ + $localfile = "upload-test-object-name.txt"; + $options = array( + OssClient::OSS_FILE_DOWNLOAD => $localfile, + ); + + try { + $this->ossClient->getObject($this->bucket, $object, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + $this->assertTrue(file_get_contents($localfile) === file_get_contents(__FILE__)); + if (file_exists($localfile)) { + unlink($localfile); + } + + /** + * Download the file to the local file. no such key + */ + $localfile = "upload-test-object-name-no-such-key.txt"; + $options = array( + OssClient::OSS_FILE_DOWNLOAD => $localfile, + ); + + try { + $this->ossClient->getObject($this->bucket, $object . "no-such-key", $options); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + $this->assertFalse(file_exists($localfile)); + if (strpos($e, "The specified key does not exist") == false) { + $this->assertTrue(true); + } + } + + /** + * Download the file to the content. no such key + */ + try { + $result = $this->ossClient->getObject($this->bucket, $object . "no-such-key"); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + if (strpos($e, "The specified key does not exist") == false) { + $this->assertTrue(true); + } + } + + /** + * Copy object + */ + $to_bucket = $this->bucket; + $to_object = $object . '.copy'; + $options = array(); + try { + $result = $this->ossClient->copyObject($this->bucket, $object, $to_bucket, $to_object, $options); + $this->assertFalse(empty($result)); + $this->assertEquals(strlen("2016-11-21T03:46:58.000Z"), strlen($result[0])); + $this->assertEquals(strlen("\"5B3C1A2E053D763E1B002CC607C5A0FE\""), strlen($result[1])); + } catch (OssException $e) { + $this->assertFalse(true); + var_dump($e->getMessage()); + + } + + /** + * Check if the replication is the same + */ + try { + $content = $this->ossClient->getObject($this->bucket, $to_object); + $this->assertEquals($content, file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * List the files in your bucket. + */ + $prefix = ''; + $delimiter = '/'; + $next_marker = ''; + $maxkeys = 1000; + $options = array( + 'delimiter' => $delimiter, + 'prefix' => $prefix, + 'max-keys' => $maxkeys, + 'marker' => $next_marker, + ); + + try { + $listObjectInfo = $this->ossClient->listObjects($this->bucket, $options); + $objectList = $listObjectInfo->getObjectList(); + $prefixList = $listObjectInfo->getPrefixList(); + $this->assertNotNull($objectList); + $this->assertNotNull($prefixList); + $this->assertTrue(is_array($objectList)); + $this->assertTrue(is_array($prefixList)); + + } catch (OssException $e) { + $this->assertTrue(false); + } + + /** + * Set the meta information for the file + */ + $from_bucket = $this->bucket; + $from_object = "oss-php-sdk-test/upload-test-object-name.txt"; + $to_bucket = $from_bucket; + $to_object = $from_object; + $copy_options = array( + OssClient::OSS_HEADERS => array( + 'Expires' => '2012-10-01 08:00:00', + 'Content-Disposition' => 'attachment; filename="xxxxxx"', + ), + ); + try { + $this->ossClient->copyObject($from_bucket, $from_object, $to_bucket, $to_object, $copy_options); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Get the meta information for the file + */ + $object = "oss-php-sdk-test/upload-test-object-name.txt"; + try { + $objectMeta = $this->ossClient->getObjectMeta($this->bucket, $object); + $this->assertEquals('attachment; filename="xxxxxx"', $objectMeta[strtolower('Content-Disposition')]); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Delete single file + */ + $object = "oss-php-sdk-test/upload-test-object-name.txt"; + + try { + $this->assertTrue($this->ossClient->doesObjectExist($this->bucket, $object)); + $this->ossClient->deleteObject($this->bucket, $object); + $this->assertFalse($this->ossClient->doesObjectExist($this->bucket, $object)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Delete multiple files + */ + $object1 = "oss-php-sdk-test/upload-test-object-name.txt"; + $object2 = "oss-php-sdk-test/upload-test-object-name.txt.copy"; + $list = array($object1, $object2); + try { + $this->assertTrue($this->ossClient->doesObjectExist($this->bucket, $object2)); + + $result = $this->ossClient->deleteObjects($this->bucket, $list); + $this->assertEquals($list[0], $result[0]); + $this->assertEquals($list[1], $result[1]); + + $result = $this->ossClient->deleteObjects($this->bucket, $list, array('quiet' => 'true')); + $this->assertEquals(array(), $result); + $this->assertFalse($this->ossClient->doesObjectExist($this->bucket, $object2)); + + $this->ossClient->putObject($this->bucket, $object, $content); + $this->assertTrue($this->ossClient->doesObjectExist($this->bucket, $object)); + $result = $this->ossClient->deleteObjects($this->bucket, $list, array('quiet' => true)); + $this->assertEquals(array(), $result); + $this->assertFalse($this->ossClient->doesObjectExist($this->bucket, $object)); + } catch (OssException $e) { + + $this->assertFalse(true); + } + + $content_array = array('Hello OSS', 'Hi OSS', 'OSS OK'); + + /** + * Append the upload string + */ + try { + $position = $this->ossClient->appendObject($this->bucket, $object, $content_array[0], 0); + $this->assertEquals($position, strlen($content_array[0])); + $position = $this->ossClient->appendObject($this->bucket, $object, $content_array[1], $position); + $this->assertEquals($position, strlen($content_array[0]) + strlen($content_array[1])); + $position = $this->ossClient->appendObject($this->bucket, $object, $content_array[2], $position, array(OssClient::OSS_LENGTH => strlen($content_array[2]))); + $this->assertEquals($position, strlen($content_array[0]) + strlen($content_array[1]) + strlen($content_array[2])); + } catch (OssException $e) { + print_r($e->getMessage()); + $this->assertFalse(true); + } + + /** + * Check if the content is the same + */ + try { + $content = $this->ossClient->getObject($this->bucket, $object); + $this->assertEquals($content, implode($content_array)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + + /** + * Delete test object + */ + try { + $this->ossClient->deleteObject($this->bucket, $object); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Append the upload of invalid local files + */ + try { + $position = $this->ossClient->appendFile($this->bucket, $object, "invalid-file-path", 0); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + } + + /** + * Append the upload of local files + */ + try { + $position = $this->ossClient->appendFile($this->bucket, $object, __FILE__, 0); + $this->assertEquals($position, sprintf('%u', filesize(__FILE__))); + $position = $this->ossClient->appendFile($this->bucket, $object, __FILE__, $position); + $this->assertEquals($position, sprintf('%u', filesize(__FILE__)) * 2); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Check if the replication is the same + */ + try { + $content = $this->ossClient->getObject($this->bucket, $object); + $this->assertEquals($content, file_get_contents(__FILE__) . file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Delete test object + */ + try { + $this->ossClient->deleteObject($this->bucket, $object); + } catch (OssException $e) { + $this->assertFalse(true); + } + + + $options = array( + OssClient::OSS_HEADERS => array( + 'Expires' => '2012-10-01 08:00:00', + 'Content-Disposition' => 'attachment; filename="xxxxxx"', + ), + ); + + /** + * Append upload with option + */ + try { + $position = $this->ossClient->appendObject($this->bucket, $object, "Hello OSS, ", 0, $options); + $position = $this->ossClient->appendObject($this->bucket, $object, "Hi OSS.", $position); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Get the meta information for the file + */ + try { + $objectMeta = $this->ossClient->getObjectMeta($this->bucket, $object); + $this->assertEquals('attachment; filename="xxxxxx"', $objectMeta[strtolower('Content-Disposition')]); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Delete test object + */ + try { + $this->ossClient->deleteObject($this->bucket, $object); + } catch (OssException $e) { + $this->assertFalse(true); + } + + $options = array(OssClient::OSS_CHECK_MD5 => true); + + $content = file_get_contents(__FILE__); + /** + * Upload data to start MD5 + */ + try { + $this->ossClient->putObject($this->bucket, $object, $content, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Check if the replication is the same + */ + try { + $content = $this->ossClient->getObject($this->bucket, $object); + $this->assertEquals($content, file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Upload file to start MD5 + */ + try { + $this->ossClient->uploadFile($this->bucket, $object, __FILE__, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Check if the replication is the same + */ + try { + $content = $this->ossClient->getObject($this->bucket, $object); + $this->assertEquals($content, file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Delete test object + */ + try { + $this->ossClient->deleteObject($this->bucket, $object); + } catch (OssException $e) { + $this->assertFalse(true); + } + + $object = "oss-php-sdk-test/append-test-object-name.txt"; + $content_array = array('Hello OSS', 'Hi OSS', 'OSS OK'); + $options = array(OssClient::OSS_CHECK_MD5 => true); + + /** + * Append the upload string + */ + try { + $position = $this->ossClient->appendObject($this->bucket, $object, $content_array[0], 0, $options); + $this->assertEquals($position, strlen($content_array[0])); + $position = $this->ossClient->appendObject($this->bucket, $object, $content_array[1], $position, $options); + $this->assertEquals($position, strlen($content_array[0]) + strlen($content_array[1])); + $position = $this->ossClient->appendObject($this->bucket, $object, $content_array[2], $position, $options); + $this->assertEquals($position, strlen($content_array[0]) + strlen($content_array[1]) + strlen($content_array[1])); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Check if the content is the same + */ + try { + $content = $this->ossClient->getObject($this->bucket, $object); + $this->assertEquals($content, implode($content_array)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Delete test object + */ + try { + $this->ossClient->deleteObject($this->bucket, $object); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Append upload of local files + */ + try { + $position = $this->ossClient->appendFile($this->bucket, $object, __FILE__, 0, $options); + $this->assertEquals($position, sprintf('%u', filesize(__FILE__))); + $position = $this->ossClient->appendFile($this->bucket, $object, __FILE__, $position, $options); + $this->assertEquals($position, (sprintf('%u', filesize(__FILE__)) * 2)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Check if the replication is the same + */ + try { + $content = $this->ossClient->getObject($this->bucket, $object); + $this->assertEquals($content, file_get_contents(__FILE__) . file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * delete test object + */ + try { + $this->ossClient->deleteObject($this->bucket, $object); + } catch (OssException $e) { + $this->assertFalse(true); + } + + $options = array( + OssClient::OSS_HEADERS => array( + "Content-Type" => "application/octet-stream", + "name" => "aliyun", + "email" => "aliyun@aliyun.com", + ), + OssClient::OSS_ADDITIONAL_HEADERS => array('name', 'email') + ); + try { + $this->ossClient->uploadFile($this->bucket, $object, __FILE__, $options); + } catch (OssException $e) { + print_r($e->getMessage()); + $this->assertFalse(true); + } + + try { + $content = $this->ossClient->getObject($this->bucket, $object, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * delete test object + */ + try { + $this->ossClient->deleteObject($this->bucket, $object, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + + + } + + public function testObjectKeyWithQuestionMark() + { + /** + * Upload the local variable to bucket + */ + $object = "oss-php-sdk-test/??/upload-test-object-name???123??123??.txt"; + $content = file_get_contents(__FILE__); + $options = array( + OssClient::OSS_LENGTH => strlen($content), + OssClient::OSS_HEADERS => array( + 'Expires' => 'Fri, 28 Feb 2020 05:38:42 GMT', + 'Cache-Control' => 'no-cache', + 'Content-Disposition' => 'attachment;filename=oss_download.log', + 'Content-Language' => 'zh-CN', + 'x-oss-server-side-encryption' => 'AES256', + 'x-oss-meta-self-define-title' => 'user define meta info', + ), + ); + + try { + $this->ossClient->putObject($this->bucket, $object, $content, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + + try { + $this->ossClient->putObject($this->bucket, $object, $content, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * GetObject to the local variable and check for match + */ + try { + $content = $this->ossClient->getObject($this->bucket, $object); + $this->assertEquals($content, file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * GetObject first five bytes + */ + try { + $options = array(OssClient::OSS_RANGE => '0-4'); + $content = $this->ossClient->getObject($this->bucket, $object, $options); + $this->assertEquals($content, 'assertFalse(true); + } + + + /** + * Upload the local file to object + */ + try { + $this->ossClient->uploadFile($this->bucket, $object, __FILE__); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Download the file to the local variable and check for match. + */ + try { + $content = $this->ossClient->getObject($this->bucket, $object); + $this->assertEquals($content, file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Copy object + */ + $to_bucket = $this->bucket; + $to_object = $object . '.copy'; + $options = array(); + try { + $result = $this->ossClient->copyObject($this->bucket, $object, $to_bucket, $to_object, $options); + $this->assertFalse(empty($result)); + $this->assertEquals(strlen("2016-11-21T03:46:58.000Z"), strlen($result[0])); + $this->assertEquals(strlen("\"5B3C1A2E053D763E1B002CC607C5A0FE\""), strlen($result[1])); + } catch (OssException $e) { + $this->assertFalse(true); + var_dump($e->getMessage()); + + } + + /** + * Check if the replication is the same + */ + try { + $content = $this->ossClient->getObject($this->bucket, $to_object); + $this->assertEquals($content, file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + + try { + $this->assertTrue($this->ossClient->doesObjectExist($this->bucket, $object)); + $this->ossClient->deleteObject($this->bucket, $object); + $this->assertFalse($this->ossClient->doesObjectExist($this->bucket, $object)); + } catch (OssException $e) { + $this->assertFalse(true); + } + } + + public function testBaseInterfaceForBucekt() + { + $this->ossClient->createBucket($this->bucket, OssClient::OSS_ACL_TYPE_PUBLIC_READ_WRITE); + + $bucketListInfo = $this->ossClient->listBuckets(); + $this->assertNotNull($bucketListInfo); + + $bucketList = $bucketListInfo->getBucketList(); + $this->assertTrue(is_array($bucketList)); + $this->assertGreaterThan(0, count($bucketList)); + + $this->ossClient->putBucketAcl($this->bucket, OssClient::OSS_ACL_TYPE_PUBLIC_READ_WRITE); + Common::waitMetaSync(); + $this->assertEquals($this->ossClient->getBucketAcl($this->bucket), OssClient::OSS_ACL_TYPE_PUBLIC_READ_WRITE); + + $this->assertTrue($this->ossClient->doesBucketExist($this->bucket)); + $this->assertFalse($this->ossClient->doesBucketExist($this->bucket . '-notexist')); + + $this->assertNotNull($this->ossClient->getBucketLocation($this->bucket)); + + $res = $this->ossClient->getBucketMeta($this->bucket); + $this->assertEquals('200', $res['info']['http_code']); + $this->assertNotNull($res['x-oss-bucket-region']); + } + + public function testBaseInterfaceForObjectWithSts() + { + + $object = "oss-php-sdk-test/upload-test-object-name.txt"; + try { + $this->stsOssClient->putObject($this->bucket, $object, file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertTrue(false); + } + + // test GetObjectMeta + try { + $res = $this->stsOssClient->getObjectMeta($this->bucket, $object); + $this->assertEquals('200', $res['info']['http_code']); + $this->assertEquals('text/plain', $res['content-type']); + $this->assertEquals('Accept-Encoding', $res['vary']); + $this->assertTrue(isset($res['content-encoding'])); + } catch (OssException $e) { + $this->assertTrue(false); + } + + $options = array(OssClient::OSS_HEADERS => array(OssClient::OSS_ACCEPT_ENCODING => 'deflate, gzip')); + try { + $res = $this->stsOssClient->getObjectMeta($this->bucket, $object, $options); + $this->assertEquals('200', $res['info']['http_code']); + $this->assertEquals('text/plain', $res['content-type']); + $this->assertEquals('Accept-Encoding', $res['vary']); + $this->assertEquals('gzip', $res['content-encoding']); + } catch (OssException $e) { + $this->assertTrue(false); + } + + $options = array(OssClient::OSS_HEADERS => array(OssClient::OSS_ACCEPT_ENCODING => 'deflate, gzip')); + try { + $res = $this->stsOssClient->getObject($this->bucket, $object, $options); + $this->assertEquals(file_get_contents(__FILE__), $res); + } catch (OssException $e) { + $this->assertTrue(false); + } + try { + $res = $this->stsOssClient->getObject($this->bucket, $object, array(OssClient::OSS_LAST_MODIFIED => "xx")); + $this->assertEquals(file_get_contents(__FILE__), $res); + } catch (OssException $e) { + $this->assertEquals('"/ilegal.txt" object name is invalid', $e->getMessage()); + } + + try { + $res = $this->stsOssClient->getObject($this->bucket, $object, array(OssClient::OSS_ETAG => "xx")); + $this->assertEquals(file_get_contents(__FILE__), $res); + } catch (OssException $e) { + $this->assertEquals('"/ilegal.txt" object name is invalid', $e->getMessage()); + } + + $content = file_get_contents(__FILE__); + $options = array( + OssClient::OSS_LENGTH => strlen($content), + OssClient::OSS_HEADERS => array( + 'Expires' => 'Fri, 28 Feb 2020 05:38:42 GMT', + 'Cache-Control' => 'no-cache', + 'Content-Disposition' => 'attachment;filename=oss_download.log', + 'Content-Language' => 'zh-CN', + 'x-oss-server-side-encryption' => 'AES256', + 'x-oss-meta-self-define-title' => 'user define meta info', + ), + ); + + try { + $this->stsOssClient->putObject($this->bucket, $object, $content, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + + try { + $this->stsOssClient->putObject($this->bucket, $object, $content, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + + try { + $result = $this->stsOssClient->deleteObjects($this->bucket, "stringtype", $options); + $this->assertEquals('stringtype', $result[0]); + } catch (OssException $e) { + $this->assertEquals('objects must be array', $e->getMessage()); + } + + try { + $result = $this->stsOssClient->deleteObjects($this->bucket, "stringtype", $options); + $this->assertFalse(true); + } catch (OssException $e) { + $this->assertEquals('objects must be array', $e->getMessage()); + } + + try { + $this->stsOssClient->uploadFile($this->bucket, $object, "notexist.txt", $options); + $this->assertFalse(true); + } catch (OssException $e) { + $this->assertEquals('notexist.txt file does not exist', $e->getMessage()); + } + + $content = file_get_contents(__FILE__); + $options = array( + OssClient::OSS_LENGTH => strlen($content), + OssClient::OSS_HEADERS => array( + 'Expires' => 'Fri, 28 Feb 2020 05:38:42 GMT', + 'Cache-Control' => 'no-cache', + 'Content-Disposition' => 'attachment;filename=oss_download.log', + 'Content-Language' => 'zh-CN', + 'x-oss-server-side-encryption' => 'AES256', + 'x-oss-meta-self-define-title' => 'user define meta info', + ), + ); + + try { + $this->stsOssClient->putObject($this->bucket, $object, $content, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + + try { + $this->stsOssClient->putObject($this->bucket, $object, $content, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + /** + * GetObject to the local variable and check for match + */ + try { + $content = $this->stsOssClient->getObject($this->bucket, $object); + $this->assertEquals($content, file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * GetObject first five bytes + */ + try { + $options = array(OssClient::OSS_RANGE => '0-4'); + $content = $this->stsOssClient->getObject($this->bucket, $object, $options); + $this->assertEquals($content, 'assertFalse(true); + } + + + /** + * Upload the local file to object + */ + try { + $this->stsOssClient->uploadFile($this->bucket, $object, __FILE__); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Download the file to the local variable and check for match. + */ + try { + $content = $this->stsOssClient->getObject($this->bucket, $object); + $this->assertEquals($content, file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Download the file to the local file + */ + $localfile = "upload-test-object-name.txt"; + $options = array( + OssClient::OSS_FILE_DOWNLOAD => $localfile, + ); + + try { + $this->stsOssClient->getObject($this->bucket, $object, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + $this->assertTrue(file_get_contents($localfile) === file_get_contents(__FILE__)); + if (file_exists($localfile)) { + unlink($localfile); + } + + /** + * Download the file to the local file. no such key + */ + $localfile = "upload-test-object-name-no-such-key.txt"; + $options = array( + OssClient::OSS_FILE_DOWNLOAD => $localfile, + ); + + try { + $this->stsOssClient->getObject($this->bucket, $object . "no-such-key", $options); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + $this->assertFalse(file_exists($localfile)); + if (strpos($e, "The specified key does not exist") == false) { + $this->assertTrue(true); + } + } + + /** + * Download the file to the content. no such key + */ + try { + $result = $this->stsOssClient->getObject($this->bucket, $object . "no-such-key"); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + if (strpos($e, "The specified key does not exist") == false) { + $this->assertTrue(true); + } + } + + /** + * Copy object + */ + $to_bucket = $this->bucket; + $to_object = $object . '.copy'; + $options = array(); + try { + $result = $this->stsOssClient->copyObject($this->bucket, $object, $to_bucket, $to_object, $options); + $this->assertFalse(empty($result)); + $this->assertEquals(strlen("2016-11-21T03:46:58.000Z"), strlen($result[0])); + $this->assertEquals(strlen("\"5B3C1A2E053D763E1B002CC607C5A0FE\""), strlen($result[1])); + } catch (OssException $e) { + $this->assertFalse(true); + var_dump($e->getMessage()); + + } + + /** + * Check if the replication is the same + */ + try { + $content = $this->stsOssClient->getObject($this->bucket, $to_object); + $this->assertEquals($content, file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * List the files in your bucket. + */ + $prefix = ''; + $delimiter = '/'; + $next_marker = ''; + $maxkeys = 1000; + $options = array( + 'delimiter' => $delimiter, + 'prefix' => $prefix, + 'max-keys' => $maxkeys, + 'marker' => $next_marker, + ); + + try { + $listObjectInfo = $this->stsOssClient->listObjects($this->bucket, $options); + $objectList = $listObjectInfo->getObjectList(); + $prefixList = $listObjectInfo->getPrefixList(); + $this->assertNotNull($objectList); + $this->assertNotNull($prefixList); + $this->assertTrue(is_array($objectList)); + $this->assertTrue(is_array($prefixList)); + + } catch (OssException $e) { + $this->assertTrue(false); + } + + /** + * Set the meta information for the file + */ + $from_bucket = $this->bucket; + $from_object = "oss-php-sdk-test/upload-test-object-name.txt"; + $to_bucket = $from_bucket; + $to_object = $from_object; + $copy_options = array( + OssClient::OSS_HEADERS => array( + 'Expires' => '2012-10-01 08:00:00', + 'Content-Disposition' => 'attachment; filename="xxxxxx"', + ), + ); + try { + $this->stsOssClient->copyObject($from_bucket, $from_object, $to_bucket, $to_object, $copy_options); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Get the meta information for the file + */ + $object = "oss-php-sdk-test/upload-test-object-name.txt"; + try { + $objectMeta = $this->stsOssClient->getObjectMeta($this->bucket, $object); + $this->assertEquals('attachment; filename="xxxxxx"', $objectMeta[strtolower('Content-Disposition')]); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Delete single file + */ + $object = "oss-php-sdk-test/upload-test-object-name.txt"; + + try { + $this->assertTrue($this->stsOssClient->doesObjectExist($this->bucket, $object)); + $this->stsOssClient->deleteObject($this->bucket, $object); + $this->assertFalse($this->stsOssClient->doesObjectExist($this->bucket, $object)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Delete multiple files + */ + $object1 = "oss-php-sdk-test/upload-test-object-name.txt"; + $object2 = "oss-php-sdk-test/upload-test-object-name.txt.copy"; + $list = array($object1, $object2); + try { + $this->assertTrue($this->stsOssClient->doesObjectExist($this->bucket, $object2)); + + $result = $this->stsOssClient->deleteObjects($this->bucket, $list); + $this->assertEquals($list[0], $result[0]); + $this->assertEquals($list[1], $result[1]); + + $result = $this->stsOssClient->deleteObjects($this->bucket, $list, array('quiet' => 'true')); + $this->assertEquals(array(), $result); + $this->assertFalse($this->stsOssClient->doesObjectExist($this->bucket, $object2)); + + $this->stsOssClient->putObject($this->bucket, $object, $content); + $this->assertTrue($this->stsOssClient->doesObjectExist($this->bucket, $object)); + $result = $this->stsOssClient->deleteObjects($this->bucket, $list, array('quiet' => true)); + $this->assertEquals(array(), $result); + $this->assertFalse($this->stsOssClient->doesObjectExist($this->bucket, $object)); + } catch (OssException $e) { + + $this->assertFalse(true); + } + + $content_array = array('Hello OSS', 'Hi OSS', 'OSS OK'); + + /** + * Append the upload string + */ + try { + $position = $this->stsOssClient->appendObject($this->bucket, $object, $content_array[0], 0); + $this->assertEquals($position, strlen($content_array[0])); + $position = $this->stsOssClient->appendObject($this->bucket, $object, $content_array[1], $position); + $this->assertEquals($position, strlen($content_array[0]) + strlen($content_array[1])); + $position = $this->stsOssClient->appendObject($this->bucket, $object, $content_array[2], $position, array(OssClient::OSS_LENGTH => strlen($content_array[2]))); + $this->assertEquals($position, strlen($content_array[0]) + strlen($content_array[1]) + strlen($content_array[2])); + } catch (OssException $e) { + print_r($e->getMessage()); + $this->assertFalse(true); + } + + /** + * Check if the content is the same + */ + try { + $content = $this->stsOssClient->getObject($this->bucket, $object); + $this->assertEquals($content, implode($content_array)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + + /** + * Delete test object + */ + try { + $this->stsOssClient->deleteObject($this->bucket, $object); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Append the upload of invalid local files + */ + try { + $position = $this->stsOssClient->appendFile($this->bucket, $object, "invalid-file-path", 0); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + } + + /** + * Append the upload of local files + */ + try { + $position = $this->stsOssClient->appendFile($this->bucket, $object, __FILE__, 0); + $this->assertEquals($position, sprintf('%u', filesize(__FILE__))); + $position = $this->stsOssClient->appendFile($this->bucket, $object, __FILE__, $position); + $this->assertEquals($position, sprintf('%u', filesize(__FILE__)) * 2); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Check if the replication is the same + */ + try { + $content = $this->stsOssClient->getObject($this->bucket, $object); + $this->assertEquals($content, file_get_contents(__FILE__) . file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Delete test object + */ + try { + $this->stsOssClient->deleteObject($this->bucket, $object); + } catch (OssException $e) { + $this->assertFalse(true); + } + + + $options = array( + OssClient::OSS_HEADERS => array( + 'Expires' => '2012-10-01 08:00:00', + 'Content-Disposition' => 'attachment; filename="xxxxxx"', + ), + ); + + /** + * Append upload with option + */ + try { + $position = $this->stsOssClient->appendObject($this->bucket, $object, "Hello OSS, ", 0, $options); + $position = $this->stsOssClient->appendObject($this->bucket, $object, "Hi OSS.", $position); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Get the meta information for the file + */ + try { + $objectMeta = $this->stsOssClient->getObjectMeta($this->bucket, $object); + $this->assertEquals('attachment; filename="xxxxxx"', $objectMeta[strtolower('Content-Disposition')]); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Delete test object + */ + try { + $this->stsOssClient->deleteObject($this->bucket, $object); + } catch (OssException $e) { + $this->assertFalse(true); + } + + $options = array(OssClient::OSS_CHECK_MD5 => true); + + $content = file_get_contents(__FILE__); + /** + * Upload data to start MD5 + */ + try { + $this->stsOssClient->putObject($this->bucket, $object, $content, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Check if the replication is the same + */ + try { + $content = $this->stsOssClient->getObject($this->bucket, $object); + $this->assertEquals($content, file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Upload file to start MD5 + */ + try { + $this->stsOssClient->uploadFile($this->bucket, $object, __FILE__, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Check if the replication is the same + */ + try { + $content = $this->stsOssClient->getObject($this->bucket, $object); + $this->assertEquals($content, file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Delete test object + */ + try { + $this->stsOssClient->deleteObject($this->bucket, $object); + } catch (OssException $e) { + $this->assertFalse(true); + } + + $object = "oss-php-sdk-test/append-test-object-name.txt"; + $content_array = array('Hello OSS', 'Hi OSS', 'OSS OK'); + $options = array(OssClient::OSS_CHECK_MD5 => true); + + /** + * Append the upload string + */ + try { + $position = $this->stsOssClient->appendObject($this->bucket, $object, $content_array[0], 0, $options); + $this->assertEquals($position, strlen($content_array[0])); + $position = $this->stsOssClient->appendObject($this->bucket, $object, $content_array[1], $position, $options); + $this->assertEquals($position, strlen($content_array[0]) + strlen($content_array[1])); + $position = $this->stsOssClient->appendObject($this->bucket, $object, $content_array[2], $position, $options); + $this->assertEquals($position, strlen($content_array[0]) + strlen($content_array[1]) + strlen($content_array[1])); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Check if the content is the same + */ + try { + $content = $this->stsOssClient->getObject($this->bucket, $object); + $this->assertEquals($content, implode($content_array)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Delete test object + */ + try { + $this->stsOssClient->deleteObject($this->bucket, $object); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Append upload of local files + */ + try { + $position = $this->stsOssClient->appendFile($this->bucket, $object, __FILE__, 0, $options); + $this->assertEquals($position, sprintf('%u', filesize(__FILE__))); + $position = $this->stsOssClient->appendFile($this->bucket, $object, __FILE__, $position, $options); + $this->assertEquals($position, sprintf('%u', filesize(__FILE__)) * 2); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Check if the replication is the same + */ + try { + $content = $this->stsOssClient->getObject($this->bucket, $object); + $this->assertEquals($content, file_get_contents(__FILE__) . file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * delete test object + */ + try { + $this->stsOssClient->deleteObject($this->bucket, $object); + } catch (OssException $e) { + $this->assertFalse(true); + } + + $options = array( + OssClient::OSS_HEADERS => array( + "Content-Type" => "application/octet-stream", + "name" => "aliyun", + "email" => "aliyun@aliyun.com", + ), + OssClient::OSS_ADDITIONAL_HEADERS => array('name', 'email') + ); + try { + $this->stsOssClient->uploadFile($this->bucket, $object, __FILE__, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + + try { + $content = $this->stsOssClient->getObject($this->bucket, $object, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * delete test object + */ + try { + $this->stsOssClient->deleteObject($this->bucket, $object, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + + } + + public function testBaseInterfaceForBucektWithSts() + { + $options = array( + OssClient::OSS_HEADERS => array( + "Content-Type" => "application/octet-stream", + "name" => "aliyun", + "email" => "aliyun@aliyun.com", + ), + OssClient::OSS_ADDITIONAL_HEADERS => array('name', 'email') + ); + $this->stsOssClient->createBucket($this->bucket, OssClient::OSS_ACL_TYPE_PUBLIC_READ_WRITE, $options); + + $bucketListInfo = $this->stsOssClient->listBuckets($options); + $this->assertNotNull($bucketListInfo); + + $bucketList = $bucketListInfo->getBucketList(); + $this->assertTrue(is_array($bucketList)); + $this->assertGreaterThan(0, count($bucketList)); + + $this->stsOssClient->putBucketAcl($this->bucket, OssClient::OSS_ACL_TYPE_PUBLIC_READ_WRITE, $options); + Common::waitMetaSync(); + $this->assertEquals($this->stsOssClient->getBucketAcl($this->bucket), OssClient::OSS_ACL_TYPE_PUBLIC_READ_WRITE); + + $this->assertTrue($this->stsOssClient->doesBucketExist($this->bucket)); + $this->assertFalse($this->stsOssClient->doesBucketExist($this->bucket . '-notexist')); + + $this->assertNotNull($this->stsOssClient->getBucketLocation($this->bucket)); + + $res = $this->stsOssClient->getBucketMeta($this->bucket, $options); + $this->assertEquals('200', $res['info']['http_code']); + $this->assertNotNull($res['x-oss-bucket-region']); + } + + protected function setUp(): void + { + $config = array( + 'signatureVersion' => OssClient::OSS_SIGNATURE_VERSION_V4 + ); + $this->bucket = Common::getBucketName() . '-' . time(); + $this->ossClient = Common::getOssClient($config); + $this->ossClient->createBucket($this->bucket); + Common::waitMetaSync(); + $this->stsOssClient = Common::getStsOssClient($config); + Common::waitMetaSync(); + } + + protected function tearDown(): void + { + if (!$this->ossClient->doesBucketExist($this->bucket)) { + return; + } + + $objects = $this->ossClient->listObjects( + $this->bucket, array('max-keys' => 1000, 'delimiter' => ''))->getObjectList(); + $keys = array(); + foreach ($objects as $obj) { + $keys[] = $obj->getKey(); + } + if (count($keys) > 0) { + $this->ossClient->deleteObjects($this->bucket, $keys); + } + $uploads = $this->ossClient->listMultipartUploads($this->bucket)->getUploads(); + foreach ($uploads as $up) { + $this->ossClient->abortMultipartUpload($this->bucket, $up->getKey(), $up->getUploadId()); + } + + $this->ossClient->deleteBucket($this->bucket); + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientTest.php new file mode 100644 index 0000000..58b864d --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientTest.php @@ -0,0 +1,521 @@ +credentials = new TestEmptyIdCredentials(); + } else if ($flag == 1) { + $this->credentials = new TestEmptySecretCredentials(); + } else { + $this->credentials = null; + } + } + + /** + * @return Credentials + */ + public function getCredentials() + { + return $this->credentials; + } +} + +class OssClientTest extends TestOssClientBase +{ + public function testConstrunct() + { + try { + $ossClient = new OssClient('id', 'key', 'http://oss-cn-hangzhou.aliyuncs.com'); + $this->assertFalse($ossClient->isUseSSL()); + $ossClient->setUseSSL(true); + $this->assertTrue($ossClient->isUseSSL()); + $this->assertTrue(true); + $this->assertEquals(3, $ossClient->getMaxRetries()); + $ossClient->setMaxTries(4); + $this->assertEquals(4, $ossClient->getMaxRetries()); + $ossClient->setTimeout(10); + $ossClient->setConnectTimeout(20); + } catch (OssException $e) { + assertFalse(true); + } + } + + public function testConstrunct2() + { + try { + $ossClient = new OssClient('id', "", 'http://oss-cn-hangzhou.aliyuncs.com'); + $this->assertFalse(true); + } catch (OssException $e) { + $this->assertEquals("access key secret is empty", $e->getMessage()); + } + } + + public function testConstrunct3() + { + try { + $ossClient = new OssClient("", 'key', 'http://oss-cn-hangzhou.aliyuncs.com'); + $this->assertFalse(true); + } catch (OssException $e) { + $this->assertEquals("access key id is empty", $e->getMessage()); + } + } + + public function testConstrunct4() + { + try { + $ossClient = new OssClient('id', 'key', ""); + $this->assertFalse(true); + } catch (OssException $e) { + $this->assertEquals('endpoint is empty', $e->getMessage()); + } + } + + public function testConstrunct5() + { + try { + $ossClient = new OssClient('id', 'key', "123.123.123.1"); + $this->assertTrue(true); + } catch (OssException $e) { + $this->assertTrue(false); + } + } + + public function testConstrunct6() + { + try { + $ossClient = new OssClient('id', 'key', "https://123.123.123.1"); + $this->assertTrue($ossClient->isUseSSL()); + $this->assertTrue(true); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $ossClient = new OssClient('id', 'key', "https://123.123.123.1:3128"); + $this->assertTrue($ossClient->isUseSSL()); + $this->assertTrue(true); + } catch (OssException $e) { + $this->assertTrue(false); + } + } + + public function testConstrunct7() + { + try { + $ossClient = new OssClient('id', 'key', "http://123.123.123.1"); + $this->assertFalse($ossClient->isUseSSL()); + $this->assertTrue(true); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $ossClient = new OssClient('id', 'key', "http://123.123.123.1:3128"); + $this->assertFalse($ossClient->isUseSSL()); + $this->assertTrue(true); + } catch (OssException $e) { + $this->assertTrue(false); + } + } + + public function testConstrunct8() + { + try { + $ossClient = new OssClient('id', 'key', "http://123.123.123.1", true); + $ossClient->listBuckets(); + $this->assertFalse(true); + } catch (OssException $e) { + $this->assertFalse(false); + } + } + + public function testConstrunct9() + { + try { + $accessKeyId = ' ' . getenv('OSS_ACCESS_KEY_ID') . ' '; + $accessKeySecret = ' ' . getenv('OSS_ACCESS_KEY_SECRET') . ' '; + $endpoint = ' ' . Common::getEndpoint() . '/ '; + $ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint, false); + $ossClient->listBuckets(); + $this->assertTrue(true); + } catch (OssException $e) { + $this->assertFalse(true); + } + } + + public function testConstrunct10() + { + try { + $ossClient = new OssClient('id', 'key', "http://ABC-COM.TEST.123.cn", true); + $this->assertTrue(true); + } catch (OssException $e) { + $this->assertTrue(false); + } + } + + public function testConstrunct11() + { + try { + $ossClient = new OssClient('id', 'key', "oss-test.com\\aliyuncs.com"); + $this->assertFalse(true); + } catch (OssException $e) { + $this->assertEquals('endpoint is invalid:' . "oss-test.com\\aliyuncs.com", $e->getMessage()); + } + } + + public function testConstrunct12() + { + try { + $ossClient = new OssClient('id', 'key', "192.168.1.0:abc123"); + $this->assertFalse(true); + } catch (OssException $e) { + $this->assertEquals('endpoint is invalid:' . "192.168.1.0:abc123", $e->getMessage()); + } + } + + public function testSupportPutEmptyObject() + { + try { + $accessKeyId = ' ' . getenv('OSS_ACCESS_KEY_ID') . ' '; + $accessKeySecret = ' ' . getenv('OSS_ACCESS_KEY_SECRET') . ' '; + $endpoint = ' ' . Common::getEndpoint() . '/ '; + $bucket = $this->bucket; + $ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint, false); + $ossClient->putObject($bucket, 'test_emptybody', ''); + } catch (OssException $e) { + $this->assertFalse(true); + } + + //use invalid sts-token, should fail. + try { + $accessKeyId = ' ' . getenv('OSS_ACCESS_KEY_ID') . ' '; + $accessKeySecret = ' ' . getenv('OSS_ACCESS_KEY_SECRET') . ' '; + $endpoint = ' ' . Common::getEndpoint() . '/ '; + $bucket = $this->bucket; + $ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint, false, "invalid-sts-token"); + $ossClient->putObject($bucket, 'test_emptybody', ''); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertEquals('InvalidAccessKeyId', $e->getErrorCode()); + } + } + + public function testCreateObjectDir() + { + $accessKeyId = ' ' . getenv('OSS_ACCESS_KEY_ID') . ' '; + $accessKeySecret = ' ' . getenv('OSS_ACCESS_KEY_SECRET') . ' '; + $endpoint = ' ' . Common::getEndpoint() . '/ '; + $bucket = $this->bucket; + $ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint, false); + + try { + $object = 'test-dir'; + $ossClient->createObjectDir($bucket, $object); + $this->assertTrue(true); + } catch (OssException $e) { + $this->assertFalse(true); + } + + try { + $object = '0'; + $ossClient->createObjectDir($bucket, $object); + $ossClient->putObject($bucket, $object, ''); + $this->assertTrue(true); + } catch (OssException $e) { + var_dump($e); + $this->assertFalse(true); + } + } + + public function testGetBucketCors() + { + try { + $accessKeyId = ' ' . getenv('OSS_ACCESS_KEY_ID') . ' '; + $accessKeySecret = ' ' . getenv('OSS_ACCESS_KEY_SECRET') . ' '; + $endpoint = ' ' . Common::getEndpoint(). '/ '; + $bucket = Common::getBucketName(); + $ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint, false); + $ossClient->getBucketCors($bucket); + $this->assertTrue(true); + } catch (OssException $e) { + $this->assertFalse(true); + } + } + + public function testGetBucketCname() + { + try { + $accessKeyId = ' ' . getenv('OSS_ACCESS_KEY_ID') . ' '; + $accessKeySecret = ' ' . getenv('OSS_ACCESS_KEY_SECRET') . ' '; + $endpoint = ' ' . Common::getEndpoint() . '/ '; + $bucket = $this->bucket; + $ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint, false); + $ossClient->getBucketCname($bucket); + $this->assertTrue(true); + } catch (OssException $e) { + $this->assertFalse(true); + } + } + + public function testProxySupport() + { + $accessKeyId = ' ' . getenv('OSS_ACCESS_KEY_ID') . ' '; + $accessKeySecret = ' ' . getenv('OSS_ACCESS_KEY_SECRET') . ' '; + $endpoint = ' ' . Common::getEndpoint() . '/ '; + $bucket = Common::getBucketName() . '-proxy'; + $requestProxy = getenv('OSS_PROXY'); + $key = 'test-proxy-srv-object'; + $content = 'test-content'; + $proxys = parse_url($requestProxy); + + $ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint, false, null, $requestProxy); + + $result = $ossClient->createBucket($bucket); + $this->checkProxy($result, $proxys); + + $result = $ossClient->putObject($bucket, $key, $content); + $this->checkProxy($result, $proxys); + $result = $ossClient->getObject($bucket, $key); + $this->assertEquals($content, $result); + + // list object + $objectListInfo = $ossClient->listObjects($bucket); + $objectList = $objectListInfo->getObjectList(); + $this->assertNotNull($objectList); + $this->assertTrue(is_array($objectList)); + $objects = array(); + foreach ($objectList as $value) { + $objects[] = $value->getKey(); + } + $this->assertEquals(1, count($objects)); + $this->assertTrue(in_array($key, $objects)); + + $result = $ossClient->deleteObject($bucket, $key); + $this->checkProxy($result, $proxys); + + $result = $ossClient->deleteBucket($bucket); + $this->checkProxy($result, $proxys); + } + + private function checkProxy($result, $proxys) + { + $this->assertEquals($result['info']['primary_ip'], $proxys['host']); + $this->assertEquals($result['info']['primary_port'], $proxys['port']); + $this->assertTrue(array_key_exists('via', $result)); + } + + public function testIpEndpoint() + { + try { + $accessKeyId = 'sk' . getenv('OSS_ACCESS_KEY_ID') . ' '; + $accessKeySecret = ' ' . getenv('OSS_ACCESS_KEY_SECRET') . ' '; + $endpoint = '192.168.1.1'; + $bucket = Common::getBucketName(); + $ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint, false); + $object = "a.file"; + $timeout = 3600; + $options = array('Content-Type' => 'txt'); + $signedUrl = $ossClient->signUrl($bucket, $object, $timeout, "PUT", $options); + $this->assertTrue(strpos($signedUrl, '192.168.1.1/' . $bucket . '/a.file?') != false); + } catch (OssException $e) { + $this->assertFalse(true); + } + } + + public function testCnameEndpoint() + { + try { + $accessKeyId = 'sk' . getenv('OSS_ACCESS_KEY_ID') . ' '; + $accessKeySecret = ' ' . getenv('OSS_ACCESS_KEY_SECRET') . ' '; + $endpoint = 'cname.endpoint'; + $bucket = Common::getBucketName(); + $ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint, true); + $object = "a.file"; + $timeout = 3600; + $options = array('Content-Type' => 'txt'); + $signedUrl = $ossClient->signUrl($bucket, $object, $timeout, "PUT", $options); + $this->assertTrue(strpos($signedUrl, 'cname.endpoint/a.file?') != false); + } catch (OssException $e) { + $this->assertFalse(true); + } + } + + public function testStsToken() + { + try { + $accessKeyId = 'sk' . getenv('OSS_ACCESS_KEY_ID') . ' '; + $accessKeySecret = ' ' . getenv('OSS_ACCESS_KEY_SECRET') . ' '; + $endpoint = ' ' . Common::getEndpoint() . '/ '; + $bucket = Common::getBucketName(); + $ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint, false, "test-token"); + $object = "a.file"; + $timeout = 3600; + $options = array('Content-Type' => 'txt'); + $signedUrl = $ossClient->signUrl($bucket, $object, $timeout, "PUT", $options); + $this->assertTrue(strpos($signedUrl, 'security-token=test-token') != false); + } catch (OssException $e) { + $this->assertFalse(true); + } + } + + public function testEmptyCredentials() + { + // empty case, should throw exception + try { + $id = ''; + $secret = 'accessKey_secret'; + $provider = new StaticCredentialsProvider($id, $secret); + $config = array( + 'provider' => $provider, + 'endpoint' => 'http://oss-cn-hangzhou.aliyuncs.com' + ); + $ossClient = new OssClient($config); + $this->assertFalse(true); + } catch (OssException $e) { + $this->assertEquals('access key id is empty', $e->getMessage()); + } + + // empty case, should throw exception + try { + $id = 'id'; + $secret = ''; + $provider = new StaticCredentialsProvider($id, $secret); + $config = array( + 'provider' => $provider, + 'endpoint' => 'http://oss-cn-hangzhou.aliyuncs.com' + ); + $ossClient = new OssClient($config); + $this->assertFalse(true); + } catch (OssException $e) { + $this->assertEquals('access key secret is empty', $e->getMessage()); + } + + // empty case, should throw exception + try { + $provider = new TestCredentialsProvider(0); + $config = array( + 'provider' => $provider, + 'endpoint' => 'http://oss-cn-hangzhou.aliyuncs.com' + ); + $ossClient = new OssClient($config); + $ossClient->getBucketAcl("bucket"); + $this->assertFalse(true); + } catch (OssException $e) { + $this->assertEquals('credentials is empty.', $e->getMessage()); + } + + // empty case, should throw exception + try { + $provider = new TestCredentialsProvider(1); + $config = array( + 'provider' => $provider, + 'endpoint' => 'http://oss-cn-hangzhou.aliyuncs.com' + ); + $ossClient = new OssClient($config); + $ossClient->getBucketAcl("bucket"); + $this->assertFalse(true); + } catch (OssException $e) { + $this->assertEquals('access key secret is empty', $e->getMessage()); + } + + // empty case, should throw exception + try { + $provider = new TestCredentialsProvider(2); + $config = array( + 'provider' => $provider, + 'endpoint' => 'http://oss-cn-hangzhou.aliyuncs.com' + ); + $ossClient = new OssClient($config); + $ossClient->getBucketAcl("bucket"); + $this->assertFalse(true); + } catch (OssException $e) { + $this->assertEquals('access key id is empty', $e->getMessage()); + } + } + + public function testEnvironmentVariableCredentialsProvider() + { + try { + $provider = new EnvironmentVariableCredentialsProvider(); + $config = array( + 'provider' => $provider, + 'endpoint' => Common::getEndpoint(), + ); + $ossClient = new OssClient($config); + $ossClient->putObject($this->bucket, 'test_emptybody', ''); + $this->assertTrue(true); + } catch (OssException $e) { + printf($e->getMessage()); + $this->assertFalse(true); + } + + + try { + $ossClient->getObject($this->bucket, 'test_emptybody'); + $this->assertTrue(true); + } catch (OssException $e) { + printf($e->getMessage()); + $this->assertFalse(true); + } + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssExceptionTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssExceptionTest.php new file mode 100644 index 0000000..91de9bb --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssExceptionTest.php @@ -0,0 +1,19 @@ +assertTrue(false); + } catch (OssException $e) { + $this->assertNotNull($e); + $this->assertEquals($e->getMessage(), "ERR"); + } + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssTrafficLimitTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssTrafficLimitTest.php new file mode 100644 index 0000000..5aeb0ea --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssTrafficLimitTest.php @@ -0,0 +1,96 @@ + array( + OssClient::OSS_TRAFFIC_LIMIT => 819200, + )); + + try { + $result = $this->ossClient->putObject($this->bucket, 'default-object', 'content', $options); + $this->assertTrue(true); + $this->assertTrue(isset($result["x-oss-qos-delay-time"])); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $result = $this->ossClient->appendObject($this->bucket, 'append-object', 'content', 0, $options); + $this->assertTrue(true); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $result = $this->ossClient->copyObject($this->bucket, 'default-object', $this->bucket, 'copy-object', $options); + $this->assertTrue(true); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $result = $this->ossClient->getObject($this->bucket, 'default-object', $options); + $this->assertTrue(true); + } catch (OssException $e) { + $this->assertTrue(false); + } + } + + function testTrafficLimitInQuery() + { + $options = array( + OssClient::OSS_TRAFFIC_LIMIT => 819200, + ); + + $object = "get.file"; + $content = 'hello world'; + $this->ossClient->putObject($this->bucket, $object, $content); + $timeout = 3600; + try { + $signedUrl = $this->ossClient->signUrl($this->bucket, $object, $timeout, "GET", $options); + $this->assertTrue(stripos($signedUrl, 'x-oss-traffic-limit=819200') > 0); + } catch (OssException $e) { + $this->assertFalse(true); + } + + $request = new RequestCore($signedUrl); + $request->set_method('GET'); + $request->add_header('Content-Type', ''); + $request->send_request(); + $res = new ResponseCore($request->get_response_header(), $request->get_response_body(), $request->get_response_code()); + $this->assertEquals($content, $res->body); + + + $object = "put.file"; + $timeout = 3600; + try { + $signedUrl = $this->ossClient->signUrl($this->bucket, $object, $timeout, "PUT", $options); + $this->assertTrue(stripos($signedUrl, 'x-oss-traffic-limit=819200') > 0); + + $request = new RequestCore($signedUrl); + $request->set_method('PUT'); + $request->add_header('Content-Type', ''); + $request->add_header('Content-Length', strlen($content)); + $request->set_body($content); + $request->send_request(); + $res = new ResponseCore($request->get_response_header(), + $request->get_response_body(), $request->get_response_code()); + $this->assertTrue($res->isOK()); + } catch (OssException $e) { + $this->assertFalse(true); + } + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssUtilTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssUtilTest.php new file mode 100644 index 0000000..6d6196c --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssUtilTest.php @@ -0,0 +1,300 @@ +assertEquals(OssUtil::chkChinese("hello,world"), 0); + $str = '你好,这里是卖咖啡!'; + $strGBK = OssUtil::encodePath($str); + $this->assertEquals(OssUtil::chkChinese($str), 1); + $this->assertEquals(OssUtil::chkChinese($strGBK), 1); + } + + public function testIsGB2312() + { + $str = '你好,这里是卖咖啡!'; + $this->assertFalse(OssUtil::isGb2312($str)); + } + + public function testCheckChar() + { + $str = '你好,这里是卖咖啡!'; + $this->assertFalse(OssUtil::checkChar($str)); + $this->assertTrue(OssUtil::checkChar(iconv("UTF-8", "GB2312//IGNORE", $str))); + } + + public function testIsIpFormat() + { + $this->assertTrue(OssUtil::isIPFormat("10.101.160.147")); + $this->assertTrue(OssUtil::isIPFormat("12.12.12.34")); + $this->assertTrue(OssUtil::isIPFormat("12.12.12.12")); + $this->assertTrue(OssUtil::isIPFormat("255.255.255.255")); + $this->assertTrue(OssUtil::isIPFormat("0.1.1.1")); + $this->assertFalse(OssUtil::isIPFormat("0.1.1.x")); + $this->assertFalse(OssUtil::isIPFormat("0.1.1.256")); + $this->assertFalse(OssUtil::isIPFormat("256.1.1.1")); + $this->assertFalse(OssUtil::isIPFormat("0.1.1.0.1")); + $this->assertTrue(OssUtil::isIPFormat("10.10.10.10:123")); + } + + public function testToQueryString() + { + $option = array("a" => "b"); + $this->assertEquals('a=b', OssUtil::toQueryString($option)); + } + + public function testSReplace() + { + $str = "<>&'\""; + $this->assertEquals("&lt;&gt;&'"", OssUtil::sReplace($str)); + } + + public function testCheckChinese() + { + $str = '你好,这里是卖咖啡!'; + $this->assertEquals(OssUtil::chkChinese($str), 1); + if (OssUtil::isWin()) { + $strGB = OssUtil::encodePath($str); + $this->assertEquals($str, iconv("GB2312", "UTF-8", $strGB)); + } + } + + public function testValidateOption() + { + $option = 'string'; + + try { + OssUtil::validateOptions($option); + $this->assertFalse(true); + } catch (OssException $e) { + $this->assertEquals("string:option must be array", $e->getMessage()); + } + + $option = null; + + try { + OssUtil::validateOptions($option); + $this->assertTrue(true); + } catch (OssException $e) { + $this->assertFalse(true); + } + + } + + public function testCreateDeleteObjectsXmlBody() + { + $xml = <<trueobj1 +BBBB; + $a = array('obj1'); + $this->assertEquals($xml, $this->cleanXml(OssUtil::createDeleteObjectsXmlBody($a, 'true'))); + } + + public function testCreateCompleteMultipartUploadXmlBody() + { + $xml = <<2xx +BBBB; + $a = array(array("PartNumber" => 2, "ETag" => "xx")); + $this->assertEquals($this->cleanXml(OssUtil::createCompleteMultipartUploadXmlBody($a)), $xml); + } + + public function testCreateBucketXmlBody() + { + $xml = <<Standard +BBBB; + $storageClass ="Standard"; + $this->assertEquals($this->cleanXml(OssUtil::createBucketXmlBody($storageClass)), $xml); + } + + public function testValidateBucket() + { + $this->assertTrue(OssUtil::validateBucket("xxx")); + $this->assertFalse(OssUtil::validateBucket("XXXqwe123")); + $this->assertFalse(OssUtil::validateBucket("XX")); + $this->assertFalse(OssUtil::validateBucket("/X")); + $this->assertFalse(OssUtil::validateBucket("")); + } + + public function testValidateObject() + { + $this->assertTrue(OssUtil::validateObject("xxx")); + $this->assertTrue(OssUtil::validateObject("xxx23")); + $this->assertTrue(OssUtil::validateObject("12321-xxx")); + $this->assertTrue(OssUtil::validateObject("x")); + $this->assertFalse(OssUtil::validateObject("/aa")); + $this->assertFalse(OssUtil::validateObject("\\aa")); + $this->assertFalse(OssUtil::validateObject("")); + } + + public function testStartWith() + { + $this->assertTrue(OssUtil::startsWith("xxab", "xx"), true); + } + + public function testReadDir() + { + $list = OssUtil::readDir(__DIR__, ".|..|.svn|.git", true); + $this->assertNotNull($list); + } + + //public function testIsWin() + //{ + // //$this->assertTrue(OssUtil::isWin()); + //} + + public function testGetMd5SumForFile() + { + $this->assertEquals(OssUtil::getMd5SumForFile(__FILE__, 0, sprintf('%u',filesize(__FILE__)) - 1), base64_encode(md5(file_get_contents(__FILE__), true))); + // false case + $this->assertEquals(OssUtil::getMd5SumForFile(__FILE__, 0, OssClient::OSS_MAX_PART_SIZE + 1), ""); + $this->assertEquals(OssUtil::getMd5SumForFile(__FILE__, 0, sprintf('%u',filesize(__FILE__)) + 1), ""); + + } + + public function testGenerateFile() + { + $path = __DIR__ . DIRECTORY_SEPARATOR . "generatedFile.txt"; + OssUtil::generateFile($path, 1024 * 1024); + $this->assertEquals(sprintf('%u',filesize($path)), 1024 * 1024); + unlink($path); + } + + public function testThrowOssExceptionWithMessageIfEmpty() + { + $null = null; + try { + OssUtil::throwOssExceptionWithMessageIfEmpty($null, "xx"); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertEquals('xx', $e->getMessage()); + } + } + + public function testThrowOssExceptionWithMessageIfEmpty2() + { + $null = ""; + try { + OssUtil::throwOssExceptionWithMessageIfEmpty($null, "xx"); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertEquals('xx', $e->getMessage()); + } + } + + public function testValidContent() + { + $null = ""; + try { + OssUtil::validateContent($null); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertEquals('http body content is invalid', $e->getMessage()); + } + + $notnull = "x"; + try { + OssUtil::validateContent($notnull); + $this->assertTrue(true); + } catch (OssException $e) { + $this->assertEquals('http body content is invalid', $e->getMessage()); + } + } + + public function testThrowOssExceptionWithMessageIfEmpty3() + { + $null = "xx"; + try { + OssUtil::throwOssExceptionWithMessageIfEmpty($null, "xx"); + $this->assertTrue(True); + } catch (OssException $e) { + $this->assertTrue(false); + } + } + + private function cleanXml($xml) + { + return str_replace("\n", "", str_replace("\r", "", $xml)); + } + + public function testGetHostPortFromEndpoint() + { + $str = OssUtil::getHostPortFromEndpoint('http://username:password@hostname:80/path?arg=value#anchor'); + $this->assertEquals('hostname:80', $str); + + $str = OssUtil::getHostPortFromEndpoint('hostname:80'); + $this->assertEquals('hostname:80', $str); + + $str = OssUtil::getHostPortFromEndpoint('www.hostname.com'); + $this->assertEquals('www.hostname.com', $str); + + $str = OssUtil::getHostPortFromEndpoint('http://www.hostname.com'); + $this->assertEquals('www.hostname.com', $str); + + $str = OssUtil::getHostPortFromEndpoint('https://www.hostname.com'); + $this->assertEquals('www.hostname.com', $str); + + $str = OssUtil::getHostPortFromEndpoint('192.168.1.10:8080'); + $this->assertEquals('192.168.1.10:8080', $str); + + $str = OssUtil::getHostPortFromEndpoint('file://username:password@hostname:80/path?arg=value#anchor'); + $this->assertEquals('hostname:80', $str); + + $str = OssUtil::getHostPortFromEndpoint('https://WWW.hostname.com-_www.test.com'); + $this->assertEquals('WWW.hostname.com-_www.test.com', $str); + + try { + $str = OssUtil::getHostPortFromEndpoint('http:///path?arg=value#anchor'); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + } + + try { + $str = OssUtil::getHostPortFromEndpoint('https://www.hostname.com\www.test.com'); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + } + + try { + $str = OssUtil::getHostPortFromEndpoint('www.hostname.com-_*www.test.com'); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + } + + try { + $str = OssUtil::getHostPortFromEndpoint('www.hostname.com:ab123'); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + } + + try { + $str = OssUtil::getHostPortFromEndpoint('www.hostname.com:'); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + } + } + + public function testDecodeKey() + { + try { + OssUtil::decodeKey("key", "unknown"); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + } + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/PutSetDeleteResultTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/PutSetDeleteResultTest.php new file mode 100644 index 0000000..c87955e --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/PutSetDeleteResultTest.php @@ -0,0 +1,66 @@ +assertFalse(true); + } catch (OssException $e) { + $this->assertEquals('raw response is null', $e->getMessage()); + } + } + + public function testOkResponse() + { + $header= array( + 'x-oss-request-id' => '582AA51E004C4550BD27E0E4', + 'etag' => '595FA1EA77945233921DF12427F9C7CE', + 'content-md5' => 'WV+h6neUUjOSHfEkJ/nHzg==', + 'info' => array( + 'http_code' => '200', + 'method' => 'PUT' + ), + ); + $response = new ResponseCore($header, "this is a mock body, just for test", 200); + $result = new PutSetDeleteResult($response); + $data = $result->getData(); + $this->assertTrue($result->isOK()); + $this->assertEquals("this is a mock body, just for test", $data['body']); + $this->assertEquals('582AA51E004C4550BD27E0E4', $data['x-oss-request-id']); + $this->assertEquals('595FA1EA77945233921DF12427F9C7CE', $data['etag']); + $this->assertEquals('WV+h6neUUjOSHfEkJ/nHzg==', $data['content-md5']); + $this->assertEquals('200', $data['info']['http_code']); + $this->assertEquals('PUT', $data['info']['method']); + } + + public function testFailResponse() + { + $response = new ResponseCore(array(), "", 301); + try { + new PutSetDeleteResult($response); + $this->assertFalse(true); + } catch (OssException $e) { + $this->assertFalse(false); + } + } + + protected function setUp(): void + { + + } + + protected function tearDown(): void + { + + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/RefererConfigTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/RefererConfigTest.php new file mode 100644 index 0000000..5112da8 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/RefererConfigTest.php @@ -0,0 +1,54 @@ + + +true + +http://www.aliyun.com +https://www.aliyun.com +http://www.*.com +https://www.?.aliyuncs.com + + +BBBB; + + private $validXml2 = << + +true + +http://www.aliyun.com + + +BBBB; + + public function testParseValidXml() + { + $refererConfig = new RefererConfig(); + $refererConfig->parseFromXml($this->validXml); + $this->assertEquals($this->cleanXml($this->validXml), $this->cleanXml($refererConfig->serializeToXml())); + } + + public function testParseValidXml2() + { + $refererConfig = new RefererConfig(); + $refererConfig->parseFromXml($this->validXml2); + $this->assertEquals(true, $refererConfig->isAllowEmptyReferer()); + $this->assertEquals(1, count($refererConfig->getRefererList())); + $this->assertEquals($this->cleanXml($this->validXml2), $this->cleanXml(strval($refererConfig))); + } + + private function cleanXml($xml) + { + return str_replace("\n", "", str_replace("\r", "", $xml)); + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/SignerTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/SignerTest.php new file mode 100644 index 0000000..f92bbd2 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/SignerTest.php @@ -0,0 +1,558 @@ +set_method("PUT"); + $bucket = "examplebucket"; + $object = "nelson"; + + $request->add_header("Content-MD5", "eB5eJF1ptWaXm4bijSPyxw=="); + $request->add_header("Content-Type", "text/html"); + $request->add_header("x-oss-meta-author", "alice"); + $request->add_header("x-oss-meta-magic", "abracadabra"); + $request->add_header("x-oss-date", "Wed, 28 Dec 2022 10:27:41 GMT"); + + $request->add_header("Date", "Wed, 28 Dec 2022 10:27:41 GMT"); + + $signer = new SignerV1(); + + $signingOpt = array( + 'bucket' => $bucket, + 'key' => $object, + ); + $signer->sign($request, $credentials, $signingOpt); + + $signToString = "PUT\neB5eJF1ptWaXm4bijSPyxw==\ntext/html\nWed, 28 Dec 2022 10:27:41 GMT\nx-oss-date:Wed, 28 Dec 2022 10:27:41 GMT\nx-oss-meta-author:alice\nx-oss-meta-magic:abracadabra\n/examplebucket/nelson"; + + $this->assertEquals($signToString, $signingOpt['string_to_sign']); + $this->assertEquals('OSS ak:kSHKmLxlyEAKtZPkJhG9bZb5k7M=', $request->request_headers['Authorization']); + + // case 2 + $request2 = new RequestCore("http://examplebucket.oss-cn-hangzhou.aliyuncs.com?acl"); + $request2->set_method("PUT"); + + $request2->add_header("Content-MD5", "eB5eJF1ptWaXm4bijSPyxw=="); + $request2->add_header("Content-Type", "text/html"); + $request2->add_header("x-oss-meta-author", "alice"); + $request2->add_header("x-oss-meta-magic", "abracadabra"); + $request2->add_header("x-oss-date", "Wed, 28 Dec 2022 10:27:41 GMT"); + + $request2->add_header("Date", "Wed, 28 Dec 2022 10:27:41 GMT"); + + $signer = new SignerV1(); + + $signingOpt2 = array( + 'bucket' => $bucket, + 'key' => $object, + ); + $signer->sign($request2, $credentials, $signingOpt2); + + $signToString = "PUT\neB5eJF1ptWaXm4bijSPyxw==\ntext/html\nWed, 28 Dec 2022 10:27:41 GMT\nx-oss-date:Wed, 28 Dec 2022 10:27:41 GMT\nx-oss-meta-author:alice\nx-oss-meta-magic:abracadabra\n/examplebucket/nelson?acl"; + + $this->assertEquals($signToString, $signingOpt2['string_to_sign']); + $this->assertEquals('OSS ak:/afkugFbmWDQ967j1vr6zygBLQk=', $request2->request_headers['Authorization']); + + // case 3 with non-signed query + $request3 = new RequestCore("http://examplebucket.oss-cn-hangzhou.aliyuncs.com?acl&non-signed-key=value"); + $request3->set_method("PUT"); + + $request3->add_header("Content-MD5", "eB5eJF1ptWaXm4bijSPyxw=="); + $request3->add_header("Content-Type", "text/html"); + $request3->add_header("x-oss-meta-author", "alice"); + $request3->add_header("x-oss-meta-magic", "abracadabra"); + $request3->add_header("x-oss-date", "Wed, 28 Dec 2022 10:27:41 GMT"); + + $request3->add_header("Date", "Wed, 28 Dec 2022 10:27:41 GMT"); + + $signingOpt3 = array( + 'bucket' => $bucket, + 'key' => $object, + ); + $signer->sign($request3, $credentials, $signingOpt3); + + $signToString = "PUT\neB5eJF1ptWaXm4bijSPyxw==\ntext/html\nWed, 28 Dec 2022 10:27:41 GMT\nx-oss-date:Wed, 28 Dec 2022 10:27:41 GMT\nx-oss-meta-author:alice\nx-oss-meta-magic:abracadabra\n/examplebucket/nelson?acl"; + + $this->assertEquals($signToString, $signingOpt3['string_to_sign']); + $this->assertEquals('OSS ak:/afkugFbmWDQ967j1vr6zygBLQk=', $request3->request_headers['Authorization']); + } + + public function testSignerV1HeaderWithToken() + { + // case 1 + $credentials = new Credentials("ak", "sk", "token"); + $request = new RequestCore("http://examplebucket.oss-cn-hangzhou.aliyuncs.com"); + $request->set_method("PUT"); + $bucket = "examplebucket"; + $object = "nelson"; + + $request->add_header("Content-MD5", "eB5eJF1ptWaXm4bijSPyxw=="); + $request->add_header("Content-Type", "text/html"); + $request->add_header("x-oss-meta-author", "alice"); + $request->add_header("x-oss-meta-magic", "abracadabra"); + $request->add_header("x-oss-date", "Wed, 28 Dec 2022 10:27:41 GMT"); + + $request->add_header("Date", "Wed, 28 Dec 2022 10:27:41 GMT"); + + $signer = new SignerV1(); + + $signingOpt = array( + 'bucket' => $bucket, + 'key' => $object, + ); + $signer->sign($request, $credentials, $signingOpt); + + $signToString = "PUT\neB5eJF1ptWaXm4bijSPyxw==\ntext/html\nWed, 28 Dec 2022 10:27:41 GMT\nx-oss-date:Wed, 28 Dec 2022 10:27:41 GMT\nx-oss-meta-author:alice\nx-oss-meta-magic:abracadabra\nx-oss-security-token:token\n/examplebucket/nelson"; + + $this->assertEquals($signToString, $signingOpt['string_to_sign']); + $this->assertEquals('OSS ak:H3PAlN3Vucn74tPVEqaQC4AnLwQ=', $request->request_headers['Authorization']); + $this->assertEquals('token', $request->request_headers['x-oss-security-token']); + + // case 2 + $request2 = new RequestCore("http://examplebucket.oss-cn-hangzhou.aliyuncs.com?acl"); + $request2->set_method("PUT"); + + $request2->add_header("Content-MD5", "eB5eJF1ptWaXm4bijSPyxw=="); + $request2->add_header("Content-Type", "text/html"); + $request2->add_header("x-oss-meta-author", "alice"); + $request2->add_header("x-oss-meta-magic", "abracadabra"); + $request2->add_header("x-oss-date", "Wed, 28 Dec 2022 10:27:41 GMT"); + + $request2->add_header("Date", "Wed, 28 Dec 2022 10:27:41 GMT"); + + $signer = new SignerV1(); + + $signingOpt2 = array( + 'bucket' => $bucket, + 'key' => $object, + ); + $signer->sign($request2, $credentials, $signingOpt2); + + $signToString = "PUT\neB5eJF1ptWaXm4bijSPyxw==\ntext/html\nWed, 28 Dec 2022 10:27:41 GMT\nx-oss-date:Wed, 28 Dec 2022 10:27:41 GMT\nx-oss-meta-author:alice\nx-oss-meta-magic:abracadabra\nx-oss-security-token:token\n/examplebucket/nelson?acl"; + + $this->assertEquals($signToString, $signingOpt2['string_to_sign']); + $this->assertEquals("OSS ak:yeceHMAsgusDPCR979RJcLtd7RI=", $request2->request_headers['Authorization']); + + // case 3 with non-signed query + $request3 = new RequestCore("http://examplebucket.oss-cn-hangzhou.aliyuncs.com?acl&non-signed-key=value"); + $request3->set_method("PUT"); + + $request3->add_header("Content-MD5", "eB5eJF1ptWaXm4bijSPyxw=="); + $request3->add_header("Content-Type", "text/html"); + $request3->add_header("x-oss-meta-author", "alice"); + $request3->add_header("x-oss-meta-magic", "abracadabra"); + $request3->add_header("x-oss-date", "Wed, 28 Dec 2022 10:27:41 GMT"); + + $request3->add_header("Date", "Wed, 28 Dec 2022 10:27:41 GMT"); + + $signingOpt3 = array( + 'bucket' => $bucket, + 'key' => $object, + ); + $signer->sign($request3, $credentials, $signingOpt3); + + $signToString = "PUT\neB5eJF1ptWaXm4bijSPyxw==\ntext/html\nWed, 28 Dec 2022 10:27:41 GMT\nx-oss-date:Wed, 28 Dec 2022 10:27:41 GMT\nx-oss-meta-author:alice\nx-oss-meta-magic:abracadabra\nx-oss-security-token:token\n/examplebucket/nelson?acl"; + + $this->assertEquals($signToString, $signingOpt3['string_to_sign']); + $this->assertEquals('OSS ak:yeceHMAsgusDPCR979RJcLtd7RI=', $request2->request_headers['Authorization']); + } + + public function testSignerV1Presign() + { + $credentials = new Credentials("ak", "sk"); + $request = new RequestCore("http://bucket.oss-cn-hangzhou.aliyuncs.com/key?versionId=versionId"); + $request->set_method("GET"); + $bucket = "bucket"; + $object = "key"; + + $signer = new SignerV1(); + + $signingOpt = array( + 'bucket' => $bucket, + 'key' => $object, + 'expiration' => 1699807420, + ); + $signer->presign($request, $credentials, $signingOpt); + + $parsed_url = parse_url($request->request_url); + $queryString = isset($parsed_url['query']) ? $parsed_url['query'] : ''; + $query = array(); + parse_str($queryString, $query); + + $this->assertEquals('1699807420', $query['Expires']); + $this->assertEquals('ak', $query['OSSAccessKeyId']); + $this->assertEquals('dcLTea+Yh9ApirQ8o8dOPqtvJXQ=', $query['Signature']); + $this->assertEquals('versionId', $query['versionId']); + $this->assertEquals('/key', $parsed_url['path']); + } + + public function testSignerV1PresignWithToken() + { + $credentials = new Credentials("ak", "sk", "token"); + $request = new RequestCore("http://bucket.oss-cn-hangzhou.aliyuncs.com/key%2B123?versionId=versionId"); + $request->set_method("GET"); + $bucket = "bucket"; + $object = "key+123"; + + $signer = new SignerV1(); + + $signingOpt = array( + 'bucket' => $bucket, + 'key' => $object, + 'expiration' => 1699808204, + ); + $signer->presign($request, $credentials, $signingOpt); + + $parsed_url = parse_url($request->request_url); + $queryString = isset($parsed_url['query']) ? $parsed_url['query'] : ''; + $query = array(); + parse_str($queryString, $query); + + $this->assertEquals('1699808204', $query['Expires']); + $this->assertEquals('ak', $query['OSSAccessKeyId']); + $this->assertEquals('jzKYRrM5y6Br0dRFPaTGOsbrDhY=', $query['Signature']); + $this->assertEquals('versionId', $query['versionId']); + $this->assertEquals('token', $query['security-token']); + $this->assertEquals('/key%2B123', $parsed_url['path']); + } + + public function testSignerV4Header() + { + // case 1 + $credentials = new Credentials("ak", "sk"); + $request = new RequestCore("http://bucket.oss-cn-hangzhou.aliyuncs.com/1234%2B-/123/1.txt"); + $request->set_method("PUT"); + $bucket = "bucket"; + $object = "1234+-/123/1.txt"; + + $request->add_header("x-oss-head1", "value"); + $request->add_header("abc", "value"); + $request->add_header("ZAbc", "value"); + $request->add_header("XYZ", "value"); + $request->add_header("content-type", "text/plain"); + $request->add_header("x-oss-content-sha256", "UNSIGNED-PAYLOAD"); + + $request->add_header("Date", gmdate('D, d M Y H:i:s \G\M\T', 1702743657)); + + $signer = new SignerV4(); + + $query = array(); + $query["param1"] = "value1"; + $query["+param1"] = "value3"; + $query["|param1"] = "value4"; + $query["+param2"] = ""; + $query["|param2"] = ""; + $query["param2"] = ""; + + $parsed_url = parse_url($request->request_url); + $parsed_url['query'] = OssUtil::toQueryString($query);; + $request->request_url = OssUtil::unparseUrl($parsed_url); + + $signingOpt = array( + 'bucket' => $bucket, + 'key' => $object, + 'region' => 'cn-hangzhou', + 'product' => 'oss', + ); + $signer->sign($request, $credentials, $signingOpt); + + $authPat = "OSS4-HMAC-SHA256 Credential=ak/20231216/cn-hangzhou/oss/aliyun_v4_request,Signature=e21d18daa82167720f9b1047ae7e7f1ce7cb77a31e8203a7d5f4624fa0284afe"; + $this->assertEquals($authPat, $request->request_headers['Authorization']); + } + + public function testSignerV4HeaderWithToken() + { + // case 1 + $credentials = new Credentials("ak", "sk", "token"); + $request = new RequestCore("http://bucket.oss-cn-hangzhou.aliyuncs.com/1234%2B-/123/1.txt"); + $request->set_method("PUT"); + $bucket = "bucket"; + $object = "1234+-/123/1.txt"; + + $request->add_header("x-oss-head1", "value"); + $request->add_header("abc", "value"); + $request->add_header("ZAbc", "value"); + $request->add_header("XYZ", "value"); + $request->add_header("content-type", "text/plain"); + $request->add_header("x-oss-content-sha256", "UNSIGNED-PAYLOAD"); + + $request->add_header("Date", gmdate('D, d M Y H:i:s \G\M\T', 1702784856)); + + $signer = new SignerV4(); + + $query = array(); + $query["param1"] = "value1"; + $query["+param1"] = "value3"; + $query["|param1"] = "value4"; + $query["+param2"] = ""; + $query["|param2"] = ""; + $query["param2"] = ""; + + $parsed_url = parse_url($request->request_url); + $parsed_url['query'] = OssUtil::toQueryString($query);; + $request->request_url = OssUtil::unparseUrl($parsed_url); + + $signingOpt = array( + 'bucket' => $bucket, + 'key' => $object, + 'region' => 'cn-hangzhou', + 'product' => 'oss', + ); + $signer->sign($request, $credentials, $signingOpt); + + $authPat = "OSS4-HMAC-SHA256 Credential=ak/20231217/cn-hangzhou/oss/aliyun_v4_request,Signature=b94a3f999cf85bcdc00d332fbd3734ba03e48382c36fa4d5af5df817395bd9ea"; + $this->assertEquals($authPat, $request->request_headers['Authorization']); + } + + public function testSignerV4AdditionalHeaders() + { + // case 1 + $credentials = new Credentials("ak", "sk"); + $request = new RequestCore("http://bucket.oss-cn-hangzhou.aliyuncs.com/1234%2B-/123/1.txt"); + $request->set_method("PUT"); + $bucket = "bucket"; + $object = "1234+-/123/1.txt"; + + $request->add_header("x-oss-head1", "value"); + $request->add_header("abc", "value"); + $request->add_header("ZAbc", "value"); + $request->add_header("XYZ", "value"); + $request->add_header("content-type", "text/plain"); + $request->add_header("x-oss-content-sha256", "UNSIGNED-PAYLOAD"); + + $request->add_header("Date", gmdate('D, d M Y H:i:s \G\M\T', 1702747512)); + + $signer = new SignerV4(); + + $query = array(); + $query["param1"] = "value1"; + $query["+param1"] = "value3"; + $query["|param1"] = "value4"; + $query["+param2"] = ""; + $query["|param2"] = ""; + $query["param2"] = ""; + + $parsed_url = parse_url($request->request_url); + $parsed_url['query'] = OssUtil::toQueryString($query);; + $request->request_url = OssUtil::unparseUrl($parsed_url); + + $signingOpt = array( + 'bucket' => $bucket, + 'key' => $object, + 'region' => 'cn-hangzhou', + 'product' => 'oss', + 'additionalHeaders' => array("ZAbc", "abc") + ); + $signer->sign($request, $credentials, $signingOpt); + + $authPat = "OSS4-HMAC-SHA256 Credential=ak/20231216/cn-hangzhou/oss/aliyun_v4_request,AdditionalHeaders=abc;zabc,Signature=4a4183c187c07c8947db7620deb0a6b38d9fbdd34187b6dbaccb316fa251212f"; + $this->assertEquals($authPat, $request->request_headers['Authorization']); + + // case 1 + $credentials = new Credentials("ak", "sk"); + $request = new RequestCore("http://bucket.oss-cn-hangzhou.aliyuncs.com/1234%2B-/123/1.txt"); + $request->set_method("PUT"); + $bucket = "bucket"; + $object = "1234+-/123/1.txt"; + + $request->add_header("x-oss-head1", "value"); + $request->add_header("abc", "value"); + $request->add_header("ZAbc", "value"); + $request->add_header("XYZ", "value"); + $request->add_header("content-type", "text/plain"); + $request->add_header("x-oss-content-sha256", "UNSIGNED-PAYLOAD"); + + $request->add_header("Date", gmdate('D, d M Y H:i:s \G\M\T', 1702747512)); + + $signer = new SignerV4(); + + $query = array(); + $query["param1"] = "value1"; + $query["+param1"] = "value3"; + $query["|param1"] = "value4"; + $query["+param2"] = ""; + $query["|param2"] = ""; + $query["param2"] = ""; + + $parsed_url = parse_url($request->request_url); + $parsed_url['query'] = OssUtil::toQueryString($query);; + $request->request_url = OssUtil::unparseUrl($parsed_url); + + $signingOpt = array( + 'bucket' => $bucket, + 'key' => $object, + 'region' => 'cn-hangzhou', + 'product' => 'oss', + 'additionalHeaders' => array("x-oss-no-exist", "ZAbc", "x-oss-head1", "abc") + ); + $signer->sign($request, $credentials, $signingOpt); + + $authPat = "OSS4-HMAC-SHA256 Credential=ak/20231216/cn-hangzhou/oss/aliyun_v4_request,AdditionalHeaders=abc;zabc,Signature=4a4183c187c07c8947db7620deb0a6b38d9fbdd34187b6dbaccb316fa251212f"; + $this->assertEquals($authPat, $request->request_headers['Authorization']); + } + + public function testSignerV4Presign() + { + // case 1 + $credentials = new Credentials("ak", "sk"); + $request = new RequestCore("http://bucket.oss-cn-hangzhou.aliyuncs.com/1234%2B-/123/1.txt"); + $request->set_method("PUT"); + $bucket = "bucket"; + $object = "1234+-/123/1.txt"; + + $request->add_header("x-oss-head1", "value"); + $request->add_header("abc", "value"); + $request->add_header("ZAbc", "value"); + $request->add_header("XYZ", "value"); + $request->add_header("content-type", "application/octet-stream"); + $request->add_header("Date", gmdate('D, d M Y H:i:s \G\M\T', 1702781677)); + + $signer = new SignerV4(); + + $query = array(); + $query["param1"] = "value1"; + $query["+param1"] = "value3"; + $query["|param1"] = "value4"; + $query["+param2"] = ""; + $query["|param2"] = ""; + $query["param2"] = ""; + + $parsed_url = parse_url($request->request_url); + $parsed_url['query'] = OssUtil::toQueryString($query);; + $request->request_url = OssUtil::unparseUrl($parsed_url); + + $signingOpt = array( + 'bucket' => $bucket, + 'key' => $object, + 'region' => 'cn-hangzhou', + 'product' => 'oss', + 'expiration' => 1702782276, + ); + $signer->presign($request, $credentials, $signingOpt); + $parsed_url = parse_url($request->request_url); + $queryString = isset($parsed_url['query']) ? $parsed_url['query'] : ''; + $query = array(); + parse_str($queryString, $query); + $this->assertEquals('OSS4-HMAC-SHA256', $query['x-oss-signature-version']); + $this->assertEquals('OSS4-HMAC-SHA256', $query['x-oss-signature-version']); + $this->assertEquals('599', $query['x-oss-expires']); + $this->assertEquals('ak/20231217/cn-hangzhou/oss/aliyun_v4_request', $query['x-oss-credential']); + $this->assertEquals('a39966c61718be0d5b14e668088b3fa07601033f6518ac7b523100014269c0fe', $query['x-oss-signature']); + $this->assertFalse(isset($query['x-oss-additional-headers'])); + } + + public function testSignerV4PresignWithToken() + { + // case 1 + $credentials = new Credentials("ak", "sk", "token"); + $request = new RequestCore("http://bucket.oss-cn-hangzhou.aliyuncs.com/1234%2B-/123/1.txt"); + $request->set_method("PUT"); + $bucket = "bucket"; + $object = "1234+-/123/1.txt"; + + $request->add_header("x-oss-head1", "value"); + $request->add_header("abc", "value"); + $request->add_header("ZAbc", "value"); + $request->add_header("XYZ", "value"); + $request->add_header("content-type", "application/octet-stream"); + $request->add_header("Date", gmdate('D, d M Y H:i:s \G\M\T', 1702785388)); + + $signer = new SignerV4(); + + $query = array(); + $query["param1"] = "value1"; + $query["+param1"] = "value3"; + $query["|param1"] = "value4"; + $query["+param2"] = ""; + $query["|param2"] = ""; + $query["param2"] = ""; + + $parsed_url = parse_url($request->request_url); + $parsed_url['query'] = OssUtil::toQueryString($query);; + $request->request_url = OssUtil::unparseUrl($parsed_url); + + $signingOpt = array( + 'bucket' => $bucket, + 'key' => $object, + 'region' => 'cn-hangzhou', + 'product' => 'oss', + 'expiration' => 1702785987, + ); + $signer->presign($request, $credentials, $signingOpt); + $parsed_url = parse_url($request->request_url); + $queryString = isset($parsed_url['query']) ? $parsed_url['query'] : ''; + $query = array(); + parse_str($queryString, $query); + $this->assertEquals('OSS4-HMAC-SHA256', $query['x-oss-signature-version']); + $this->assertEquals('599', $query['x-oss-expires']); + $this->assertEquals('ak/20231217/cn-hangzhou/oss/aliyun_v4_request', $query['x-oss-credential']); + $this->assertEquals('3817ac9d206cd6dfc90f1c09c00be45005602e55898f26f5ddb06d7892e1f8b5', $query['x-oss-signature']); + $this->assertFalse(isset($query['x-oss-additional-headers'])); + //print($request->request_url); + } + + public function testSignerV4PresignWithAdditionalHeaders() + { + // case 1 + $credentials = new Credentials("ak", "sk"); + $request = new RequestCore("http://bucket.oss-cn-hangzhou.aliyuncs.com/1234%2B-/123/1.txt"); + $request->set_method("PUT"); + $bucket = "bucket"; + $object = "1234+-/123/1.txt"; + + $request->add_header("x-oss-head1", "value"); + $request->add_header("abc", "value"); + $request->add_header("ZAbc", "value"); + $request->add_header("XYZ", "value"); + $request->add_header("content-type", "application/octet-stream"); + $request->add_header("Date", gmdate('D, d M Y H:i:s \G\M\T', 1702783809)); + + $signer = new SignerV4(); + + $query = array(); + $query["param1"] = "value1"; + $query["+param1"] = "value3"; + $query["|param1"] = "value4"; + $query["+param2"] = ""; + $query["|param2"] = ""; + $query["param2"] = ""; + + $parsed_url = parse_url($request->request_url); + $parsed_url['query'] = OssUtil::toQueryString($query);; + $request->request_url = OssUtil::unparseUrl($parsed_url); + + $signingOpt = array( + 'bucket' => $bucket, + 'key' => $object, + 'region' => 'cn-hangzhou', + 'product' => 'oss', + 'expiration' => 1702784408, + 'additionalHeaders' => array("ZAbc", "abc") + ); + $signer->presign($request, $credentials, $signingOpt); + $parsed_url = parse_url($request->request_url); + $queryString = isset($parsed_url['query']) ? $parsed_url['query'] : ''; + $query = array(); + parse_str($queryString, $query); + $this->assertEquals('OSS4-HMAC-SHA256', $query['x-oss-signature-version']); + $this->assertEquals('20231217T033009Z', $query['x-oss-date']); + $this->assertEquals('599', $query['x-oss-expires']); + $this->assertEquals('ak/20231217/cn-hangzhou/oss/aliyun_v4_request', $query['x-oss-credential']); + $this->assertEquals('6bd984bfe531afb6db1f7550983a741b103a8c58e5e14f83ea474c2322dfa2b7', $query['x-oss-signature']); + $this->assertEquals('abc;zabc', $query['x-oss-additional-headers']); + } +} + + diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/StorageCapacityConfigTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/StorageCapacityConfigTest.php new file mode 100644 index 0000000..58aa791 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/StorageCapacityConfigTest.php @@ -0,0 +1,58 @@ + + +10 + +BBBB; + +private $validXml_20 = << + +20 + +BBBB; + + public function testConstruct() + { + $config = new StorageCapacityConfig(10); + $this->assertEquals($config->getStorageCapacity(), 10); + $this->assertEquals($this->cleanXml($this->validXml_10), $this->cleanXml($config->serializeToXml())); + } + + public function testSetStorageCapacity() + { + $config = new StorageCapacityConfig(2); + $config->setStorageCapacity(20); + $this->assertEquals($this->cleanXml($this->validXml_20), $this->cleanXml($config->serializeToXml())); + $this->assertEquals($this->cleanXml($this->validXml_20), $this->cleanXml($config->__toString())); + } + + public function testParseFromXml() + { + try { + $config = new StorageCapacityConfig(10); + $config->parseFromXml('invaide xml'); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + if (strpos($e, "Not implemented.") == false) + { + $this->assertTrue(false); + } + } + } + + private function cleanXml($xml) + { + return str_replace("\n", "", str_replace("\r", "", $xml)); + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/StorageCapacityTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/StorageCapacityTest.php new file mode 100644 index 0000000..8d2a9df --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/StorageCapacityTest.php @@ -0,0 +1,63 @@ + + + 1 + +BBBB; + + private $validXml = << + + 1 + +BBBB; + + public function testParseInValidXml() + { + $response = new ResponseCore(array(), $this->inValidXml, 300); + try { + new GetStorageCapacityResult($response); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + } + } + + public function testParseEmptyXml() + { + $response = new ResponseCore(array(), "", 300); + try { + new GetStorageCapacityResult($response); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + } + } + + public function testParseValidXml() + { + $response = new ResponseCore(array(), $this->validXml, 200); + $result = new GetStorageCapacityResult($response); + $this->assertEquals($result->getData(), 1); + } + + public function testSerializeToXml() + { + $xml = "\n1\n"; + + $storageCapacityConfig = new StorageCapacityConfig(1); + $content = $storageCapacityConfig->serializeToXml(); + $this->assertEquals($content, $xml); + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/StsBase.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/StsBase.php new file mode 100644 index 0000000..5b1f1d2 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/StsBase.php @@ -0,0 +1,33 @@ +$name = $value; + } + + public function __construct() + { + $this->Timestamp = gmdate('Y-m-d\TH:i:s\Z'); + $this->SignatureNonce = time().rand(10000,99999); + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/StsClient.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/StsClient.php new file mode 100644 index 0000000..0aae601 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/StsClient.php @@ -0,0 +1,108 @@ +generateSignedURL($params); + + $response = $this->sendRequest($request_url, $format); + + $result= $this->parseResponse($response, $format); + + return $result; + } + + private function sendRequest($url, $format) + { + $curl_handle = curl_init(); + + curl_setopt($curl_handle, CURLOPT_URL, $url); + curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($curl_handle, CURLOPT_CUSTOMREQUEST, "GET"); + curl_setopt($curl_handle, CURLOPT_SSL_VERIFYPEER, false); + curl_setopt($curl_handle, CURLOPT_SSL_VERIFYHOST,false); + curl_setopt($curl_handle, CURLOPT_HEADER, true); + + $response = curl_exec($curl_handle); + $headerSize = curl_getinfo($curl_handle, CURLINFO_HEADER_SIZE); + $response = substr($response, $headerSize); + + if (curl_getinfo($curl_handle, CURLINFO_HTTP_CODE) != '200') { + $errors = $this->parseResponse($response, $format); + throw new OssException($errors->Code); + } + + curl_close($curl_handle); + + return $response; + } + + private function parseResponse($body, $format) + { + if ("JSON" == $format) { + $respObject = json_decode($body); + } elseif ("XML" == $format) { + $respObject = @simplexml_load_string($body); + } elseif ("RAW" == $format) { + $respObject = $body; + } + return $respObject; + } + + private function generateSignedURL($arr) + { + $request_url = 'https://sts.aliyuncs.com/?'; + + foreach ($arr as $key=>$item) { + if (is_null($item)) unset($arr[$key]); + } + + $Signature = $this->computeSignature($arr, $this->AccessSecret); + ksort($arr); + foreach ($arr as $key => $value) { + $request_url .= $key."=".urlencode($value)."&"; + } + $request_url .="Signature=".urlencode($Signature); + + return $request_url; + } + + private function computeSignature($parameters, $accessKeySecret) + { + ksort($parameters); + $canonicalizedQueryString = ''; + foreach ($parameters as $key => $value) { + $canonicalizedQueryString .= '&' . $this->percentEncode($key). '=' . $this->percentEncode($value); + } + $stringToSign = 'GET&%2F&' . $this->percentencode(substr($canonicalizedQueryString, 1)); + $signature = $this->signString($stringToSign, $accessKeySecret."&"); + + return $signature; + } + + private function signString($source, $accessSecret) + { + return base64_encode(hash_hmac('sha1', $source, $accessSecret, true)); + } + + private function percentEncode($str) + { + $res = urlencode($str); + $res = preg_replace('/\+/', '%20', $res); + $res = preg_replace('/\*/', '%2A', $res); + $res = preg_replace('/%7E/', '~', $res); + return $res; + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/SymlinkTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/SymlinkTest.php new file mode 100644 index 0000000..c436391 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/SymlinkTest.php @@ -0,0 +1,77 @@ +bucket; + $symlink = 'test-link'; + $special_object = 'exist_object^$#!~'; + $object = 'exist_object'; + + $this->ossClient ->putObject($bucket, $object, 'test_content'); + $this->ossClient->putSymlink($bucket, $symlink, $object); + $result = $this->ossClient->getObject($bucket, $symlink); + $this->assertEquals('test_content', $result); + + $this->ossClient ->putObject($bucket, $special_object, 'test_content'); + $this->ossClient->putSymlink($bucket, $symlink, $special_object); + $result = $this->ossClient->getObject($bucket, $symlink); + $this->assertEquals('test_content', $result); + } + + public function testGetSymlink() + { + $bucket = $this->bucket; + $symlink = 'test-link'; + $object = 'exist_object^$#!~'; + + $this->ossClient ->putObject($bucket, $object, 'test_content'); + $this->ossClient->putSymlink($bucket, $symlink, $object); + + $result = $this->ossClient->getSymlink($bucket, $symlink); + $this->assertEquals($result[OssClient::OSS_SYMLINK_TARGET], $object); + $this->assertEquals('200', $result[OssClient::OSS_INFO][OssClient::OSS_HTTP_CODE]); + $this->assertTrue(isset($result[OssClient::OSS_ETAG])); + $this->assertTrue(isset($result[OssClient::OSS_REQUEST_ID])); + } + + public function testPutNullSymlink() + { + $bucket = $this->bucket; + $symlink = 'null-link'; + $object_not_exist = 'not_exist_object+$#!b不'; + $this->ossClient->putSymlink($bucket, $symlink, $object_not_exist); + + try{ + $this->ossClient->getObject($bucket, $symlink); + $this->assertTrue(false); + }catch (OssException $e){ + $this->assertEquals('The symlink target object does not exist', $e->getErrorMessage()); + } + } + + public function testGetNullSymlink() + { + $bucket = $this->bucket; + $symlink = 'null-link-new'; + + try{ + $result = $this->ossClient->getSymlink($bucket, $symlink); + $this->assertTrue(false); + }catch (OssException $e){ + $this->assertEquals('The specified key does not exist.', $e->getErrorMessage()); + } + } +} + + diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/TestOssClientBase.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/TestOssClientBase.php new file mode 100644 index 0000000..b204871 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/TestOssClientBase.php @@ -0,0 +1,51 @@ +bucket = Common::getBucketName() .'-'. time(); + $this->ossClient = Common::getOssClient(); + $this->ossClient->createBucket($this->bucket); + Common::waitMetaSync(); + } + + protected function tearDown(): void + { + if (!$this->ossClient->doesBucketExist($this->bucket)) { + return; + } + + $objects = $this->ossClient->listObjects( + $this->bucket, array('max-keys' => 1000, 'delimiter' => ''))->getObjectList(); + $keys = array(); + foreach ($objects as $obj) { + $keys[] = $obj->getKey(); + } + if (count($keys) > 0) { + $this->ossClient->deleteObjects($this->bucket, $keys); + } + $uploads = $this->ossClient->listMultipartUploads($this->bucket)->getUploads(); + foreach ($uploads as $up) { + $this->ossClient->abortMultipartUpload($this->bucket, $up->getKey(), $up->getUploadId()); + } + + $this->ossClient->deleteBucket($this->bucket); + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/TransferAccelerationConfigTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/TransferAccelerationConfigTest.php new file mode 100644 index 0000000..19f9805 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/TransferAccelerationConfigTest.php @@ -0,0 +1,56 @@ + + +true + +BBBB; + private $validXml1 = << + +false + +BBBB; + + private $invalidXml1 = << + + +BBBB; + + public function testParseValidXml() + { + $transferConfig = new TransferAccelerationConfig(); + $transferConfig->parseFromXml($this->validXml); + $this->assertEquals($this->cleanXml($this->validXml), $this->cleanXml(strval($transferConfig))); + $this->assertEquals(true,$transferConfig->getEnabled()); + } + + public function testValidXml1() + { + $transferConfig = new TransferAccelerationConfig(); + $transferConfig->parseFromXml($this->validXml1); + $this->assertEquals($this->cleanXml($this->validXml1), $this->cleanXml(strval($transferConfig))); + $this->assertEquals(false,$transferConfig->getEnabled()); + } + + public function testInvalidXml1() + { + $transferConfig = new TransferAccelerationConfig(); + $transferConfig->parseFromXml($this->invalidXml1); + $this->assertEquals(false,$transferConfig->getEnabled()); + } + + private function cleanXml($xml) + { + return str_replace("\n", "", str_replace("\r", "", $xml)); + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/UploadPartResultTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/UploadPartResultTest.php new file mode 100644 index 0000000..df4ad94 --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/UploadPartResultTest.php @@ -0,0 +1,33 @@ + '7265F4D211B56873A381D321F586E4A9'); + private $invalidHeader = array(); + + public function testParseValidHeader() + { + $response = new ResponseCore($this->validHeader, "", 200); + $result = new UploadPartResult($response); + $eTag = $result->getData(); + $this->assertEquals('7265F4D211B56873A381D321F586E4A9', $eTag); + } + + public function testParseInvalidHeader() + { + $response = new ResponseCore($this->invalidHeader, "", 200); + try { + new UploadPartResult($response); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertEquals('cannot get ETag', $e->getMessage()); + } + } +} diff --git a/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/WebsiteConfigTest.php b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/WebsiteConfigTest.php new file mode 100644 index 0000000..d04b42c --- /dev/null +++ b/vendor/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/WebsiteConfigTest.php @@ -0,0 +1,56 @@ + + + +index.html + + +errorDocument.html + + +BBBB; + + private $nullXml = << +BBBB; + private $nullXml2 = << +BBBB; + + public function testParseValidXml() + { + $websiteConfig = new WebsiteConfig("index"); + $websiteConfig->parseFromXml($this->validXml); + $this->assertEquals($this->cleanXml($this->validXml), $this->cleanXml($websiteConfig->serializeToXml())); + } + + public function testParsenullXml() + { + $websiteConfig = new WebsiteConfig(); + $websiteConfig->parseFromXml($this->nullXml); + $this->assertTrue($this->cleanXml($this->nullXml) === $this->cleanXml($websiteConfig->serializeToXml()) || + $this->cleanXml($this->nullXml2) === $this->cleanXml($websiteConfig->serializeToXml())); + } + + public function testWebsiteConstruct() + { + $websiteConfig = new WebsiteConfig("index.html", "errorDocument.html"); + $this->assertEquals('index.html', $websiteConfig->getIndexDocument()); + $this->assertEquals('errorDocument.html', $websiteConfig->getErrorDocument()); + $this->assertEquals($this->cleanXml($this->validXml), $this->cleanXml($websiteConfig->serializeToXml())); + } + + private function cleanXml($xml) + { + return str_replace("\n", "", str_replace("\r", "", $xml)); + } +} diff --git a/vendor/vendor/autoload.php b/vendor/vendor/autoload.php new file mode 100644 index 0000000..6f3cc6f --- /dev/null +++ b/vendor/vendor/autoload.php @@ -0,0 +1,22 @@ + + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Composer\Autoload; + +/** + * ClassLoader implements a PSR-0, PSR-4 and classmap class loader. + * + * $loader = new \Composer\Autoload\ClassLoader(); + * + * // register classes with namespaces + * $loader->add('Symfony\Component', __DIR__.'/component'); + * $loader->add('Symfony', __DIR__.'/framework'); + * + * // activate the autoloader + * $loader->register(); + * + * // to enable searching the include path (eg. for PEAR packages) + * $loader->setUseIncludePath(true); + * + * In this example, if you try to use a class in the Symfony\Component + * namespace or one of its children (Symfony\Component\Console for instance), + * the autoloader will first look for the class under the component/ + * directory, and it will then fallback to the framework/ directory if not + * found before giving up. + * + * This class is loosely based on the Symfony UniversalClassLoader. + * + * @author Fabien Potencier + * @author Jordi Boggiano + * @see https://www.php-fig.org/psr/psr-0/ + * @see https://www.php-fig.org/psr/psr-4/ + */ +class ClassLoader +{ + /** @var \Closure(string):void */ + private static $includeFile; + + /** @var string|null */ + private $vendorDir; + + // PSR-4 + /** + * @var array> + */ + private $prefixLengthsPsr4 = array(); + /** + * @var array> + */ + private $prefixDirsPsr4 = array(); + /** + * @var list + */ + private $fallbackDirsPsr4 = array(); + + // PSR-0 + /** + * List of PSR-0 prefixes + * + * Structured as array('F (first letter)' => array('Foo\Bar (full prefix)' => array('path', 'path2'))) + * + * @var array>> + */ + private $prefixesPsr0 = array(); + /** + * @var list + */ + private $fallbackDirsPsr0 = array(); + + /** @var bool */ + private $useIncludePath = false; + + /** + * @var array + */ + private $classMap = array(); + + /** @var bool */ + private $classMapAuthoritative = false; + + /** + * @var array + */ + private $missingClasses = array(); + + /** @var string|null */ + private $apcuPrefix; + + /** + * @var array + */ + private static $registeredLoaders = array(); + + /** + * @param string|null $vendorDir + */ + public function __construct($vendorDir = null) + { + $this->vendorDir = $vendorDir; + self::initializeIncludeClosure(); + } + + /** + * @return array> + */ + public function getPrefixes() + { + if (!empty($this->prefixesPsr0)) { + return call_user_func_array('array_merge', array_values($this->prefixesPsr0)); + } + + return array(); + } + + /** + * @return array> + */ + public function getPrefixesPsr4() + { + return $this->prefixDirsPsr4; + } + + /** + * @return list + */ + public function getFallbackDirs() + { + return $this->fallbackDirsPsr0; + } + + /** + * @return list + */ + public function getFallbackDirsPsr4() + { + return $this->fallbackDirsPsr4; + } + + /** + * @return array Array of classname => path + */ + public function getClassMap() + { + return $this->classMap; + } + + /** + * @param array $classMap Class to filename map + * + * @return void + */ + public function addClassMap(array $classMap) + { + if ($this->classMap) { + $this->classMap = array_merge($this->classMap, $classMap); + } else { + $this->classMap = $classMap; + } + } + + /** + * Registers a set of PSR-0 directories for a given prefix, either + * appending or prepending to the ones previously set for this prefix. + * + * @param string $prefix The prefix + * @param list|string $paths The PSR-0 root directories + * @param bool $prepend Whether to prepend the directories + * + * @return void + */ + public function add($prefix, $paths, $prepend = false) + { + $paths = (array) $paths; + if (!$prefix) { + if ($prepend) { + $this->fallbackDirsPsr0 = array_merge( + $paths, + $this->fallbackDirsPsr0 + ); + } else { + $this->fallbackDirsPsr0 = array_merge( + $this->fallbackDirsPsr0, + $paths + ); + } + + return; + } + + $first = $prefix[0]; + if (!isset($this->prefixesPsr0[$first][$prefix])) { + $this->prefixesPsr0[$first][$prefix] = $paths; + + return; + } + if ($prepend) { + $this->prefixesPsr0[$first][$prefix] = array_merge( + $paths, + $this->prefixesPsr0[$first][$prefix] + ); + } else { + $this->prefixesPsr0[$first][$prefix] = array_merge( + $this->prefixesPsr0[$first][$prefix], + $paths + ); + } + } + + /** + * Registers a set of PSR-4 directories for a given namespace, either + * appending or prepending to the ones previously set for this namespace. + * + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param list|string $paths The PSR-4 base directories + * @param bool $prepend Whether to prepend the directories + * + * @throws \InvalidArgumentException + * + * @return void + */ + public function addPsr4($prefix, $paths, $prepend = false) + { + $paths = (array) $paths; + if (!$prefix) { + // Register directories for the root namespace. + if ($prepend) { + $this->fallbackDirsPsr4 = array_merge( + $paths, + $this->fallbackDirsPsr4 + ); + } else { + $this->fallbackDirsPsr4 = array_merge( + $this->fallbackDirsPsr4, + $paths + ); + } + } elseif (!isset($this->prefixDirsPsr4[$prefix])) { + // Register directories for a new namespace. + $length = strlen($prefix); + if ('\\' !== $prefix[$length - 1]) { + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); + } + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; + $this->prefixDirsPsr4[$prefix] = $paths; + } elseif ($prepend) { + // Prepend directories for an already registered namespace. + $this->prefixDirsPsr4[$prefix] = array_merge( + $paths, + $this->prefixDirsPsr4[$prefix] + ); + } else { + // Append directories for an already registered namespace. + $this->prefixDirsPsr4[$prefix] = array_merge( + $this->prefixDirsPsr4[$prefix], + $paths + ); + } + } + + /** + * Registers a set of PSR-0 directories for a given prefix, + * replacing any others previously set for this prefix. + * + * @param string $prefix The prefix + * @param list|string $paths The PSR-0 base directories + * + * @return void + */ + public function set($prefix, $paths) + { + if (!$prefix) { + $this->fallbackDirsPsr0 = (array) $paths; + } else { + $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; + } + } + + /** + * Registers a set of PSR-4 directories for a given namespace, + * replacing any others previously set for this namespace. + * + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param list|string $paths The PSR-4 base directories + * + * @throws \InvalidArgumentException + * + * @return void + */ + public function setPsr4($prefix, $paths) + { + if (!$prefix) { + $this->fallbackDirsPsr4 = (array) $paths; + } else { + $length = strlen($prefix); + if ('\\' !== $prefix[$length - 1]) { + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); + } + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; + $this->prefixDirsPsr4[$prefix] = (array) $paths; + } + } + + /** + * Turns on searching the include path for class files. + * + * @param bool $useIncludePath + * + * @return void + */ + public function setUseIncludePath($useIncludePath) + { + $this->useIncludePath = $useIncludePath; + } + + /** + * Can be used to check if the autoloader uses the include path to check + * for classes. + * + * @return bool + */ + public function getUseIncludePath() + { + return $this->useIncludePath; + } + + /** + * Turns off searching the prefix and fallback directories for classes + * that have not been registered with the class map. + * + * @param bool $classMapAuthoritative + * + * @return void + */ + public function setClassMapAuthoritative($classMapAuthoritative) + { + $this->classMapAuthoritative = $classMapAuthoritative; + } + + /** + * Should class lookup fail if not found in the current class map? + * + * @return bool + */ + public function isClassMapAuthoritative() + { + return $this->classMapAuthoritative; + } + + /** + * APCu prefix to use to cache found/not-found classes, if the extension is enabled. + * + * @param string|null $apcuPrefix + * + * @return void + */ + public function setApcuPrefix($apcuPrefix) + { + $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null; + } + + /** + * The APCu prefix in use, or null if APCu caching is not enabled. + * + * @return string|null + */ + public function getApcuPrefix() + { + return $this->apcuPrefix; + } + + /** + * Registers this instance as an autoloader. + * + * @param bool $prepend Whether to prepend the autoloader or not + * + * @return void + */ + public function register($prepend = false) + { + spl_autoload_register(array($this, 'loadClass'), true, $prepend); + + if (null === $this->vendorDir) { + return; + } + + if ($prepend) { + self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders; + } else { + unset(self::$registeredLoaders[$this->vendorDir]); + self::$registeredLoaders[$this->vendorDir] = $this; + } + } + + /** + * Unregisters this instance as an autoloader. + * + * @return void + */ + public function unregister() + { + spl_autoload_unregister(array($this, 'loadClass')); + + if (null !== $this->vendorDir) { + unset(self::$registeredLoaders[$this->vendorDir]); + } + } + + /** + * Loads the given class or interface. + * + * @param string $class The name of the class + * @return true|null True if loaded, null otherwise + */ + public function loadClass($class) + { + if ($file = $this->findFile($class)) { + $includeFile = self::$includeFile; + $includeFile($file); + + return true; + } + + return null; + } + + /** + * Finds the path to the file where the class is defined. + * + * @param string $class The name of the class + * + * @return string|false The path if found, false otherwise + */ + public function findFile($class) + { + // class map lookup + if (isset($this->classMap[$class])) { + return $this->classMap[$class]; + } + if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) { + return false; + } + if (null !== $this->apcuPrefix) { + $file = apcu_fetch($this->apcuPrefix.$class, $hit); + if ($hit) { + return $file; + } + } + + $file = $this->findFileWithExtension($class, '.php'); + + // Search for Hack files if we are running on HHVM + if (false === $file && defined('HHVM_VERSION')) { + $file = $this->findFileWithExtension($class, '.hh'); + } + + if (null !== $this->apcuPrefix) { + apcu_add($this->apcuPrefix.$class, $file); + } + + if (false === $file) { + // Remember that this class does not exist. + $this->missingClasses[$class] = true; + } + + return $file; + } + + /** + * Returns the currently registered loaders keyed by their corresponding vendor directories. + * + * @return array + */ + public static function getRegisteredLoaders() + { + return self::$registeredLoaders; + } + + /** + * @param string $class + * @param string $ext + * @return string|false + */ + private function findFileWithExtension($class, $ext) + { + // PSR-4 lookup + $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; + + $first = $class[0]; + if (isset($this->prefixLengthsPsr4[$first])) { + $subPath = $class; + while (false !== $lastPos = strrpos($subPath, '\\')) { + $subPath = substr($subPath, 0, $lastPos); + $search = $subPath . '\\'; + if (isset($this->prefixDirsPsr4[$search])) { + $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1); + foreach ($this->prefixDirsPsr4[$search] as $dir) { + if (file_exists($file = $dir . $pathEnd)) { + return $file; + } + } + } + } + } + + // PSR-4 fallback dirs + foreach ($this->fallbackDirsPsr4 as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { + return $file; + } + } + + // PSR-0 lookup + if (false !== $pos = strrpos($class, '\\')) { + // namespaced class name + $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1) + . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); + } else { + // PEAR-like class name + $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; + } + + if (isset($this->prefixesPsr0[$first])) { + foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { + if (0 === strpos($class, $prefix)) { + foreach ($dirs as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + return $file; + } + } + } + } + } + + // PSR-0 fallback dirs + foreach ($this->fallbackDirsPsr0 as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + return $file; + } + } + + // PSR-0 include paths. + if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { + return $file; + } + + return false; + } + + /** + * @return void + */ + private static function initializeIncludeClosure() + { + if (self::$includeFile !== null) { + return; + } + + /** + * Scope isolated include. + * + * Prevents access to $this/self from included files. + * + * @param string $file + * @return void + */ + self::$includeFile = \Closure::bind(static function($file) { + include $file; + }, null, null); + } +} diff --git a/vendor/vendor/composer/InstalledVersions.php b/vendor/vendor/composer/InstalledVersions.php new file mode 100644 index 0000000..2052022 --- /dev/null +++ b/vendor/vendor/composer/InstalledVersions.php @@ -0,0 +1,396 @@ + + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Composer; + +use Composer\Autoload\ClassLoader; +use Composer\Semver\VersionParser; + +/** + * This class is copied in every Composer installed project and available to all + * + * See also https://getcomposer.org/doc/07-runtime.md#installed-versions + * + * To require its presence, you can require `composer-runtime-api ^2.0` + * + * @final + */ +class InstalledVersions +{ + /** + * @var string|null if set (by reflection by Composer), this should be set to the path where this class is being copied to + * @internal + */ + private static $selfDir = null; + + /** + * @var mixed[]|null + * @psalm-var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array}|array{}|null + */ + private static $installed; + + /** + * @var bool + */ + private static $installedIsLocalDir; + + /** + * @var bool|null + */ + private static $canGetVendors; + + /** + * @var array[] + * @psalm-var array}> + */ + private static $installedByVendor = array(); + + /** + * Returns a list of all package names which are present, either by being installed, replaced or provided + * + * @return string[] + * @psalm-return list + */ + public static function getInstalledPackages() + { + $packages = array(); + foreach (self::getInstalled() as $installed) { + $packages[] = array_keys($installed['versions']); + } + + if (1 === \count($packages)) { + return $packages[0]; + } + + return array_keys(array_flip(\call_user_func_array('array_merge', $packages))); + } + + /** + * Returns a list of all package names with a specific type e.g. 'library' + * + * @param string $type + * @return string[] + * @psalm-return list + */ + public static function getInstalledPackagesByType($type) + { + $packagesByType = array(); + + foreach (self::getInstalled() as $installed) { + foreach ($installed['versions'] as $name => $package) { + if (isset($package['type']) && $package['type'] === $type) { + $packagesByType[] = $name; + } + } + } + + return $packagesByType; + } + + /** + * Checks whether the given package is installed + * + * This also returns true if the package name is provided or replaced by another package + * + * @param string $packageName + * @param bool $includeDevRequirements + * @return bool + */ + public static function isInstalled($packageName, $includeDevRequirements = true) + { + foreach (self::getInstalled() as $installed) { + if (isset($installed['versions'][$packageName])) { + return $includeDevRequirements || !isset($installed['versions'][$packageName]['dev_requirement']) || $installed['versions'][$packageName]['dev_requirement'] === false; + } + } + + return false; + } + + /** + * Checks whether the given package satisfies a version constraint + * + * e.g. If you want to know whether version 2.3+ of package foo/bar is installed, you would call: + * + * Composer\InstalledVersions::satisfies(new VersionParser, 'foo/bar', '^2.3') + * + * @param VersionParser $parser Install composer/semver to have access to this class and functionality + * @param string $packageName + * @param string|null $constraint A version constraint to check for, if you pass one you have to make sure composer/semver is required by your package + * @return bool + */ + public static function satisfies(VersionParser $parser, $packageName, $constraint) + { + $constraint = $parser->parseConstraints((string) $constraint); + $provided = $parser->parseConstraints(self::getVersionRanges($packageName)); + + return $provided->matches($constraint); + } + + /** + * Returns a version constraint representing all the range(s) which are installed for a given package + * + * It is easier to use this via isInstalled() with the $constraint argument if you need to check + * whether a given version of a package is installed, and not just whether it exists + * + * @param string $packageName + * @return string Version constraint usable with composer/semver + */ + public static function getVersionRanges($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + $ranges = array(); + if (isset($installed['versions'][$packageName]['pretty_version'])) { + $ranges[] = $installed['versions'][$packageName]['pretty_version']; + } + if (array_key_exists('aliases', $installed['versions'][$packageName])) { + $ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']); + } + if (array_key_exists('replaced', $installed['versions'][$packageName])) { + $ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']); + } + if (array_key_exists('provided', $installed['versions'][$packageName])) { + $ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']); + } + + return implode(' || ', $ranges); + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @param string $packageName + * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present + */ + public static function getVersion($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + if (!isset($installed['versions'][$packageName]['version'])) { + return null; + } + + return $installed['versions'][$packageName]['version']; + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @param string $packageName + * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present + */ + public static function getPrettyVersion($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + if (!isset($installed['versions'][$packageName]['pretty_version'])) { + return null; + } + + return $installed['versions'][$packageName]['pretty_version']; + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @param string $packageName + * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as reference + */ + public static function getReference($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + if (!isset($installed['versions'][$packageName]['reference'])) { + return null; + } + + return $installed['versions'][$packageName]['reference']; + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @param string $packageName + * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as install path. Packages of type metapackages also have a null install path. + */ + public static function getInstallPath($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + return isset($installed['versions'][$packageName]['install_path']) ? $installed['versions'][$packageName]['install_path'] : null; + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @return array + * @psalm-return array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool} + */ + public static function getRootPackage() + { + $installed = self::getInstalled(); + + return $installed[0]['root']; + } + + /** + * Returns the raw installed.php data for custom implementations + * + * @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect. + * @return array[] + * @psalm-return array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} + */ + public static function getRawData() + { + @trigger_error('getRawData only returns the first dataset loaded, which may not be what you expect. Use getAllRawData() instead which returns all datasets for all autoloaders present in the process.', E_USER_DEPRECATED); + + if (null === self::$installed) { + // only require the installed.php file if this file is loaded from its dumped location, + // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 + if (substr(__DIR__, -8, 1) !== 'C') { + self::$installed = include __DIR__ . '/installed.php'; + } else { + self::$installed = array(); + } + } + + return self::$installed; + } + + /** + * Returns the raw data of all installed.php which are currently loaded for custom implementations + * + * @return array[] + * @psalm-return list}> + */ + public static function getAllRawData() + { + return self::getInstalled(); + } + + /** + * Lets you reload the static array from another file + * + * This is only useful for complex integrations in which a project needs to use + * this class but then also needs to execute another project's autoloader in process, + * and wants to ensure both projects have access to their version of installed.php. + * + * A typical case would be PHPUnit, where it would need to make sure it reads all + * the data it needs from this class, then call reload() with + * `require $CWD/vendor/composer/installed.php` (or similar) as input to make sure + * the project in which it runs can then also use this class safely, without + * interference between PHPUnit's dependencies and the project's dependencies. + * + * @param array[] $data A vendor/composer/installed.php data set + * @return void + * + * @psalm-param array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} $data + */ + public static function reload($data) + { + self::$installed = $data; + self::$installedByVendor = array(); + + // when using reload, we disable the duplicate protection to ensure that self::$installed data is + // always returned, but we cannot know whether it comes from the installed.php in __DIR__ or not, + // so we have to assume it does not, and that may result in duplicate data being returned when listing + // all installed packages for example + self::$installedIsLocalDir = false; + } + + /** + * @return string + */ + private static function getSelfDir() + { + if (self::$selfDir === null) { + self::$selfDir = strtr(__DIR__, '\\', '/'); + } + + return self::$selfDir; + } + + /** + * @return array[] + * @psalm-return list}> + */ + private static function getInstalled() + { + if (null === self::$canGetVendors) { + self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders'); + } + + $installed = array(); + $copiedLocalDir = false; + + if (self::$canGetVendors) { + $selfDir = self::getSelfDir(); + foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) { + $vendorDir = strtr($vendorDir, '\\', '/'); + if (isset(self::$installedByVendor[$vendorDir])) { + $installed[] = self::$installedByVendor[$vendorDir]; + } elseif (is_file($vendorDir.'/composer/installed.php')) { + /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} $required */ + $required = require $vendorDir.'/composer/installed.php'; + self::$installedByVendor[$vendorDir] = $required; + $installed[] = $required; + if (self::$installed === null && $vendorDir.'/composer' === $selfDir) { + self::$installed = $required; + self::$installedIsLocalDir = true; + } + } + if (self::$installedIsLocalDir && $vendorDir.'/composer' === $selfDir) { + $copiedLocalDir = true; + } + } + } + + if (null === self::$installed) { + // only require the installed.php file if this file is loaded from its dumped location, + // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 + if (substr(__DIR__, -8, 1) !== 'C') { + /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} $required */ + $required = require __DIR__ . '/installed.php'; + self::$installed = $required; + } else { + self::$installed = array(); + } + } + + if (self::$installed !== array() && !$copiedLocalDir) { + $installed[] = self::$installed; + } + + return $installed; + } +} diff --git a/vendor/vendor/composer/LICENSE b/vendor/vendor/composer/LICENSE new file mode 100644 index 0000000..f27399a --- /dev/null +++ b/vendor/vendor/composer/LICENSE @@ -0,0 +1,21 @@ + +Copyright (c) Nils Adermann, Jordi Boggiano + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + diff --git a/vendor/vendor/composer/autoload_classmap.php b/vendor/vendor/composer/autoload_classmap.php new file mode 100644 index 0000000..016c54b --- /dev/null +++ b/vendor/vendor/composer/autoload_classmap.php @@ -0,0 +1,16 @@ + $vendorDir . '/symfony/polyfill-php80/Resources/stubs/Attribute.php', + 'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php', + 'JsonException' => $vendorDir . '/symfony/polyfill-php73/Resources/stubs/JsonException.php', + 'PhpToken' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/PhpToken.php', + 'Stringable' => $vendorDir . '/myclabs/php-enum/stubs/Stringable.php', + 'UnhandledMatchError' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/UnhandledMatchError.php', + 'ValueError' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/ValueError.php', +); diff --git a/vendor/vendor/composer/autoload_files.php b/vendor/vendor/composer/autoload_files.php new file mode 100644 index 0000000..2617134 --- /dev/null +++ b/vendor/vendor/composer/autoload_files.php @@ -0,0 +1,23 @@ + $vendorDir . '/symfony/deprecation-contracts/function.php', + '7b11c4dc42b3b3023073cb14e519683c' => $vendorDir . '/ralouphie/getallheaders/src/getallheaders.php', + '37a3dc5111fe8f707ab4c132ef1dbc62' => $vendorDir . '/guzzlehttp/guzzle/src/functions_include.php', + 'd767e4fc2dc52fe66584ab8c6684783e' => $vendorDir . '/adbario/php-dot-notation/src/helpers.php', + 'a4a119a56e50fbb293281d9a48007e0e' => $vendorDir . '/symfony/polyfill-php80/bootstrap.php', + '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => $vendorDir . '/symfony/polyfill-mbstring/bootstrap.php', + '0d59ee240a4cd96ddbb4ff164fccea4d' => $vendorDir . '/symfony/polyfill-php73/bootstrap.php', + '2cffec82183ee1cea088009cef9a6fc3' => $vendorDir . '/ezyang/htmlpurifier/library/HTMLPurifier.composer.php', + '9b552a3cc426e3287cc811caefa3cf53' => $vendorDir . '/topthink/think-helper/src/helper.php', + 'f7e3d8cd19cf23ce3883a6a51d791b77' => $vendorDir . '/fastadminnet/fastadmin-addons/src/common.php', + 'f0e7e63bbb278a92db02393536748c5f' => $vendorDir . '/overtrue/wechat/src/Kernel/Support/Helpers.php', + '6747f579ad6817f318cc3a7e7a0abb93' => $vendorDir . '/overtrue/wechat/src/Kernel/Helpers.php', + '1cfd2761b63b0a29ed23657ea394cb2d' => $vendorDir . '/topthink/think-captcha/src/helper.php', + 'cc56288302d9df745d97c934d6a6e5f0' => $vendorDir . '/topthink/think-queue/src/common.php', +); diff --git a/vendor/vendor/composer/autoload_namespaces.php b/vendor/vendor/composer/autoload_namespaces.php new file mode 100644 index 0000000..be11dd8 --- /dev/null +++ b/vendor/vendor/composer/autoload_namespaces.php @@ -0,0 +1,11 @@ + array($vendorDir . '/pimple/pimple/src'), + 'HTMLPurifier' => array($vendorDir . '/ezyang/htmlpurifier/library'), +); diff --git a/vendor/vendor/composer/autoload_psr4.php b/vendor/vendor/composer/autoload_psr4.php new file mode 100644 index 0000000..8872fc3 --- /dev/null +++ b/vendor/vendor/composer/autoload_psr4.php @@ -0,0 +1,61 @@ + array($vendorDir . '/topthink/think-helper/src'), + 'think\\composer\\' => array($vendorDir . '/topthink/think-installer/src'), + 'think\\captcha\\' => array($vendorDir . '/topthink/think-captcha/src'), + 'think\\' => array($vendorDir . '/topthink/think-queue/src', $vendorDir . '/fastadminnet/fastadmin-addons/src', $baseDir . '/thinkphp/library/think'), + 'addons\\' => array($baseDir . '/addons'), + 'ZipStream\\' => array($vendorDir . '/maennchen/zipstream-php/src'), + 'Tx\\' => array($vendorDir . '/fastadminnet/fastadmin-mailer/src'), + 'Symfony\\Polyfill\\Php80\\' => array($vendorDir . '/symfony/polyfill-php80'), + 'Symfony\\Polyfill\\Php73\\' => array($vendorDir . '/symfony/polyfill-php73'), + 'Symfony\\Polyfill\\Mbstring\\' => array($vendorDir . '/symfony/polyfill-mbstring'), + 'Symfony\\Contracts\\Service\\' => array($vendorDir . '/symfony/service-contracts'), + 'Symfony\\Contracts\\EventDispatcher\\' => array($vendorDir . '/symfony/event-dispatcher-contracts'), + 'Symfony\\Contracts\\Cache\\' => array($vendorDir . '/symfony/cache-contracts'), + 'Symfony\\Component\\VarExporter\\' => array($vendorDir . '/symfony/var-exporter'), + 'Symfony\\Component\\HttpFoundation\\' => array($vendorDir . '/symfony/http-foundation'), + 'Symfony\\Component\\Finder\\' => array($vendorDir . '/symfony/finder'), + 'Symfony\\Component\\EventDispatcher\\' => array($vendorDir . '/symfony/event-dispatcher'), + 'Symfony\\Component\\Cache\\' => array($vendorDir . '/symfony/cache'), + 'Symfony\\Bridge\\PsrHttpMessage\\' => array($vendorDir . '/symfony/psr-http-message-bridge'), + 'Psr\\SimpleCache\\' => array($vendorDir . '/psr/simple-cache/src'), + 'Psr\\Log\\' => array($vendorDir . '/psr/log/Psr/Log'), + 'Psr\\Http\\Message\\' => array($vendorDir . '/psr/http-factory/src', $vendorDir . '/psr/http-message/src'), + 'Psr\\Http\\Client\\' => array($vendorDir . '/psr/http-client/src'), + 'Psr\\EventDispatcher\\' => array($vendorDir . '/psr/event-dispatcher/src'), + 'Psr\\Container\\' => array($vendorDir . '/psr/container/src'), + 'Psr\\Cache\\' => array($vendorDir . '/psr/cache/src'), + 'PhpZip\\' => array($vendorDir . '/nelexa/zip/src'), + 'PhpOffice\\PhpSpreadsheet\\' => array($vendorDir . '/phpoffice/phpspreadsheet/src/PhpSpreadsheet'), + 'Overtrue\\Socialite\\' => array($vendorDir . '/overtrue/socialite/src'), + 'Overtrue\\Pinyin\\' => array($vendorDir . '/overtrue/pinyin/src'), + 'OneSm\\' => array($vendorDir . '/lizhichao/one-sm/src'), + 'OSS\\' => array($vendorDir . '/aliyuncs/oss-sdk-php/src/OSS'), + 'MyCLabs\\Enum\\' => array($vendorDir . '/myclabs/php-enum/src'), + 'Monolog\\' => array($vendorDir . '/monolog/monolog/src/Monolog'), + 'Matrix\\' => array($vendorDir . '/markbaker/matrix/classes/src'), + 'GuzzleHttp\\Psr7\\' => array($vendorDir . '/guzzlehttp/psr7/src'), + 'GuzzleHttp\\Promise\\' => array($vendorDir . '/guzzlehttp/promises/src'), + 'GuzzleHttp\\' => array($vendorDir . '/guzzlehttp/guzzle/src'), + 'EasyWeChat\\' => array($vendorDir . '/overtrue/wechat/src'), + 'EasyWeChatComposer\\' => array($vendorDir . '/easywechat-composer/easywechat-composer/src'), + 'Darabonba\\OpenApi\\' => array($vendorDir . '/alibabacloud/darabonba-openapi/src'), + 'Darabonba\\GatewaySpi\\' => array($vendorDir . '/alibabacloud/gateway-spi/src'), + 'Composer\\Pcre\\' => array($vendorDir . '/composer/pcre/src'), + 'Complex\\' => array($vendorDir . '/markbaker/complex/classes/src'), + 'AlibabaCloud\\Tea\\XML\\' => array($vendorDir . '/alibabacloud/tea-xml/src'), + 'AlibabaCloud\\Tea\\Utils\\' => array($vendorDir . '/alibabacloud/tea-utils/src'), + 'AlibabaCloud\\Tea\\' => array($vendorDir . '/alibabacloud/tea/src'), + 'AlibabaCloud\\SDK\\Dypnsapi\\V20170525\\' => array($vendorDir . '/alibabacloud/dypnsapi-20170525/src'), + 'AlibabaCloud\\OpenApiUtil\\' => array($vendorDir . '/alibabacloud/openapi-util/src'), + 'AlibabaCloud\\Endpoint\\' => array($vendorDir . '/alibabacloud/endpoint-util/src'), + 'AlibabaCloud\\Credentials\\' => array($vendorDir . '/alibabacloud/credentials/src'), + 'Adbar\\' => array($vendorDir . '/adbario/php-dot-notation/src'), +); diff --git a/vendor/vendor/composer/autoload_real.php b/vendor/vendor/composer/autoload_real.php new file mode 100644 index 0000000..6d7f80e --- /dev/null +++ b/vendor/vendor/composer/autoload_real.php @@ -0,0 +1,50 @@ +register(true); + + $filesToLoad = \Composer\Autoload\ComposerStaticInitf3106b6ef3260b6914241eab0bed11c1::$files; + $requireFile = \Closure::bind(static function ($fileIdentifier, $file) { + if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { + $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true; + + require $file; + } + }, null, null); + foreach ($filesToLoad as $fileIdentifier => $file) { + $requireFile($fileIdentifier, $file); + } + + return $loader; + } +} diff --git a/vendor/vendor/composer/autoload_static.php b/vendor/vendor/composer/autoload_static.php new file mode 100644 index 0000000..a1bbc67 --- /dev/null +++ b/vendor/vendor/composer/autoload_static.php @@ -0,0 +1,371 @@ + __DIR__ . '/..' . '/symfony/deprecation-contracts/function.php', + '7b11c4dc42b3b3023073cb14e519683c' => __DIR__ . '/..' . '/ralouphie/getallheaders/src/getallheaders.php', + '37a3dc5111fe8f707ab4c132ef1dbc62' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/functions_include.php', + 'd767e4fc2dc52fe66584ab8c6684783e' => __DIR__ . '/..' . '/adbario/php-dot-notation/src/helpers.php', + 'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php', + '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php', + '0d59ee240a4cd96ddbb4ff164fccea4d' => __DIR__ . '/..' . '/symfony/polyfill-php73/bootstrap.php', + '2cffec82183ee1cea088009cef9a6fc3' => __DIR__ . '/..' . '/ezyang/htmlpurifier/library/HTMLPurifier.composer.php', + '9b552a3cc426e3287cc811caefa3cf53' => __DIR__ . '/..' . '/topthink/think-helper/src/helper.php', + 'f7e3d8cd19cf23ce3883a6a51d791b77' => __DIR__ . '/..' . '/fastadminnet/fastadmin-addons/src/common.php', + 'f0e7e63bbb278a92db02393536748c5f' => __DIR__ . '/..' . '/overtrue/wechat/src/Kernel/Support/Helpers.php', + '6747f579ad6817f318cc3a7e7a0abb93' => __DIR__ . '/..' . '/overtrue/wechat/src/Kernel/Helpers.php', + '1cfd2761b63b0a29ed23657ea394cb2d' => __DIR__ . '/..' . '/topthink/think-captcha/src/helper.php', + 'cc56288302d9df745d97c934d6a6e5f0' => __DIR__ . '/..' . '/topthink/think-queue/src/common.php', + ); + + public static $prefixLengthsPsr4 = array ( + 't' => + array ( + 'think\\helper\\' => 13, + 'think\\composer\\' => 15, + 'think\\captcha\\' => 14, + 'think\\' => 6, + ), + 'a' => + array ( + 'addons\\' => 7, + ), + 'Z' => + array ( + 'ZipStream\\' => 10, + ), + 'T' => + array ( + 'Tx\\' => 3, + ), + 'S' => + array ( + 'Symfony\\Polyfill\\Php80\\' => 23, + 'Symfony\\Polyfill\\Php73\\' => 23, + 'Symfony\\Polyfill\\Mbstring\\' => 26, + 'Symfony\\Contracts\\Service\\' => 26, + 'Symfony\\Contracts\\EventDispatcher\\' => 34, + 'Symfony\\Contracts\\Cache\\' => 24, + 'Symfony\\Component\\VarExporter\\' => 30, + 'Symfony\\Component\\HttpFoundation\\' => 33, + 'Symfony\\Component\\Finder\\' => 25, + 'Symfony\\Component\\EventDispatcher\\' => 34, + 'Symfony\\Component\\Cache\\' => 24, + 'Symfony\\Bridge\\PsrHttpMessage\\' => 30, + ), + 'P' => + array ( + 'Psr\\SimpleCache\\' => 16, + 'Psr\\Log\\' => 8, + 'Psr\\Http\\Message\\' => 17, + 'Psr\\Http\\Client\\' => 16, + 'Psr\\EventDispatcher\\' => 20, + 'Psr\\Container\\' => 14, + 'Psr\\Cache\\' => 10, + 'PhpZip\\' => 7, + 'PhpOffice\\PhpSpreadsheet\\' => 25, + ), + 'O' => + array ( + 'Overtrue\\Socialite\\' => 19, + 'Overtrue\\Pinyin\\' => 16, + 'OneSm\\' => 6, + 'OSS\\' => 4, + ), + 'M' => + array ( + 'MyCLabs\\Enum\\' => 13, + 'Monolog\\' => 8, + 'Matrix\\' => 7, + ), + 'G' => + array ( + 'GuzzleHttp\\Psr7\\' => 16, + 'GuzzleHttp\\Promise\\' => 19, + 'GuzzleHttp\\' => 11, + ), + 'E' => + array ( + 'EasyWeChat\\' => 11, + 'EasyWeChatComposer\\' => 19, + ), + 'D' => + array ( + 'Darabonba\\OpenApi\\' => 18, + 'Darabonba\\GatewaySpi\\' => 21, + ), + 'C' => + array ( + 'Composer\\Pcre\\' => 14, + 'Complex\\' => 8, + ), + 'A' => + array ( + 'AlibabaCloud\\Tea\\XML\\' => 21, + 'AlibabaCloud\\Tea\\Utils\\' => 23, + 'AlibabaCloud\\Tea\\' => 17, + 'AlibabaCloud\\SDK\\Dypnsapi\\V20170525\\' => 36, + 'AlibabaCloud\\OpenApiUtil\\' => 25, + 'AlibabaCloud\\Endpoint\\' => 22, + 'AlibabaCloud\\Credentials\\' => 25, + 'Adbar\\' => 6, + ), + ); + + public static $prefixDirsPsr4 = array ( + 'think\\helper\\' => + array ( + 0 => __DIR__ . '/..' . '/topthink/think-helper/src', + ), + 'think\\composer\\' => + array ( + 0 => __DIR__ . '/..' . '/topthink/think-installer/src', + ), + 'think\\captcha\\' => + array ( + 0 => __DIR__ . '/..' . '/topthink/think-captcha/src', + ), + 'think\\' => + array ( + 0 => __DIR__ . '/..' . '/topthink/think-queue/src', + 1 => __DIR__ . '/..' . '/fastadminnet/fastadmin-addons/src', + 2 => __DIR__ . '/../..' . '/thinkphp/library/think', + ), + 'addons\\' => + array ( + 0 => __DIR__ . '/../..' . '/addons', + ), + 'ZipStream\\' => + array ( + 0 => __DIR__ . '/..' . '/maennchen/zipstream-php/src', + ), + 'Tx\\' => + array ( + 0 => __DIR__ . '/..' . '/fastadminnet/fastadmin-mailer/src', + ), + 'Symfony\\Polyfill\\Php80\\' => + array ( + 0 => __DIR__ . '/..' . '/symfony/polyfill-php80', + ), + 'Symfony\\Polyfill\\Php73\\' => + array ( + 0 => __DIR__ . '/..' . '/symfony/polyfill-php73', + ), + 'Symfony\\Polyfill\\Mbstring\\' => + array ( + 0 => __DIR__ . '/..' . '/symfony/polyfill-mbstring', + ), + 'Symfony\\Contracts\\Service\\' => + array ( + 0 => __DIR__ . '/..' . '/symfony/service-contracts', + ), + 'Symfony\\Contracts\\EventDispatcher\\' => + array ( + 0 => __DIR__ . '/..' . '/symfony/event-dispatcher-contracts', + ), + 'Symfony\\Contracts\\Cache\\' => + array ( + 0 => __DIR__ . '/..' . '/symfony/cache-contracts', + ), + 'Symfony\\Component\\VarExporter\\' => + array ( + 0 => __DIR__ . '/..' . '/symfony/var-exporter', + ), + 'Symfony\\Component\\HttpFoundation\\' => + array ( + 0 => __DIR__ . '/..' . '/symfony/http-foundation', + ), + 'Symfony\\Component\\Finder\\' => + array ( + 0 => __DIR__ . '/..' . '/symfony/finder', + ), + 'Symfony\\Component\\EventDispatcher\\' => + array ( + 0 => __DIR__ . '/..' . '/symfony/event-dispatcher', + ), + 'Symfony\\Component\\Cache\\' => + array ( + 0 => __DIR__ . '/..' . '/symfony/cache', + ), + 'Symfony\\Bridge\\PsrHttpMessage\\' => + array ( + 0 => __DIR__ . '/..' . '/symfony/psr-http-message-bridge', + ), + 'Psr\\SimpleCache\\' => + array ( + 0 => __DIR__ . '/..' . '/psr/simple-cache/src', + ), + 'Psr\\Log\\' => + array ( + 0 => __DIR__ . '/..' . '/psr/log/Psr/Log', + ), + 'Psr\\Http\\Message\\' => + array ( + 0 => __DIR__ . '/..' . '/psr/http-factory/src', + 1 => __DIR__ . '/..' . '/psr/http-message/src', + ), + 'Psr\\Http\\Client\\' => + array ( + 0 => __DIR__ . '/..' . '/psr/http-client/src', + ), + 'Psr\\EventDispatcher\\' => + array ( + 0 => __DIR__ . '/..' . '/psr/event-dispatcher/src', + ), + 'Psr\\Container\\' => + array ( + 0 => __DIR__ . '/..' . '/psr/container/src', + ), + 'Psr\\Cache\\' => + array ( + 0 => __DIR__ . '/..' . '/psr/cache/src', + ), + 'PhpZip\\' => + array ( + 0 => __DIR__ . '/..' . '/nelexa/zip/src', + ), + 'PhpOffice\\PhpSpreadsheet\\' => + array ( + 0 => __DIR__ . '/..' . '/phpoffice/phpspreadsheet/src/PhpSpreadsheet', + ), + 'Overtrue\\Socialite\\' => + array ( + 0 => __DIR__ . '/..' . '/overtrue/socialite/src', + ), + 'Overtrue\\Pinyin\\' => + array ( + 0 => __DIR__ . '/..' . '/overtrue/pinyin/src', + ), + 'OneSm\\' => + array ( + 0 => __DIR__ . '/..' . '/lizhichao/one-sm/src', + ), + 'OSS\\' => + array ( + 0 => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS', + ), + 'MyCLabs\\Enum\\' => + array ( + 0 => __DIR__ . '/..' . '/myclabs/php-enum/src', + ), + 'Monolog\\' => + array ( + 0 => __DIR__ . '/..' . '/monolog/monolog/src/Monolog', + ), + 'Matrix\\' => + array ( + 0 => __DIR__ . '/..' . '/markbaker/matrix/classes/src', + ), + 'GuzzleHttp\\Psr7\\' => + array ( + 0 => __DIR__ . '/..' . '/guzzlehttp/psr7/src', + ), + 'GuzzleHttp\\Promise\\' => + array ( + 0 => __DIR__ . '/..' . '/guzzlehttp/promises/src', + ), + 'GuzzleHttp\\' => + array ( + 0 => __DIR__ . '/..' . '/guzzlehttp/guzzle/src', + ), + 'EasyWeChat\\' => + array ( + 0 => __DIR__ . '/..' . '/overtrue/wechat/src', + ), + 'EasyWeChatComposer\\' => + array ( + 0 => __DIR__ . '/..' . '/easywechat-composer/easywechat-composer/src', + ), + 'Darabonba\\OpenApi\\' => + array ( + 0 => __DIR__ . '/..' . '/alibabacloud/darabonba-openapi/src', + ), + 'Darabonba\\GatewaySpi\\' => + array ( + 0 => __DIR__ . '/..' . '/alibabacloud/gateway-spi/src', + ), + 'Composer\\Pcre\\' => + array ( + 0 => __DIR__ . '/..' . '/composer/pcre/src', + ), + 'Complex\\' => + array ( + 0 => __DIR__ . '/..' . '/markbaker/complex/classes/src', + ), + 'AlibabaCloud\\Tea\\XML\\' => + array ( + 0 => __DIR__ . '/..' . '/alibabacloud/tea-xml/src', + ), + 'AlibabaCloud\\Tea\\Utils\\' => + array ( + 0 => __DIR__ . '/..' . '/alibabacloud/tea-utils/src', + ), + 'AlibabaCloud\\Tea\\' => + array ( + 0 => __DIR__ . '/..' . '/alibabacloud/tea/src', + ), + 'AlibabaCloud\\SDK\\Dypnsapi\\V20170525\\' => + array ( + 0 => __DIR__ . '/..' . '/alibabacloud/dypnsapi-20170525/src', + ), + 'AlibabaCloud\\OpenApiUtil\\' => + array ( + 0 => __DIR__ . '/..' . '/alibabacloud/openapi-util/src', + ), + 'AlibabaCloud\\Endpoint\\' => + array ( + 0 => __DIR__ . '/..' . '/alibabacloud/endpoint-util/src', + ), + 'AlibabaCloud\\Credentials\\' => + array ( + 0 => __DIR__ . '/..' . '/alibabacloud/credentials/src', + ), + 'Adbar\\' => + array ( + 0 => __DIR__ . '/..' . '/adbario/php-dot-notation/src', + ), + ); + + public static $prefixesPsr0 = array ( + 'P' => + array ( + 'Pimple' => + array ( + 0 => __DIR__ . '/..' . '/pimple/pimple/src', + ), + ), + 'H' => + array ( + 'HTMLPurifier' => + array ( + 0 => __DIR__ . '/..' . '/ezyang/htmlpurifier/library', + ), + ), + ); + + public static $classMap = array ( + 'Attribute' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/Attribute.php', + 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php', + 'JsonException' => __DIR__ . '/..' . '/symfony/polyfill-php73/Resources/stubs/JsonException.php', + 'PhpToken' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/PhpToken.php', + 'Stringable' => __DIR__ . '/..' . '/myclabs/php-enum/stubs/Stringable.php', + 'UnhandledMatchError' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/UnhandledMatchError.php', + 'ValueError' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/ValueError.php', + ); + + public static function getInitializer(ClassLoader $loader) + { + return \Closure::bind(function () use ($loader) { + $loader->prefixLengthsPsr4 = ComposerStaticInitf3106b6ef3260b6914241eab0bed11c1::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInitf3106b6ef3260b6914241eab0bed11c1::$prefixDirsPsr4; + $loader->prefixesPsr0 = ComposerStaticInitf3106b6ef3260b6914241eab0bed11c1::$prefixesPsr0; + $loader->classMap = ComposerStaticInitf3106b6ef3260b6914241eab0bed11c1::$classMap; + + }, null, ClassLoader::class); + } +} diff --git a/vendor/vendor/composer/installed.json b/vendor/vendor/composer/installed.json new file mode 100644 index 0000000..67b80c2 --- /dev/null +++ b/vendor/vendor/composer/installed.json @@ -0,0 +1,3924 @@ +{ + "packages": [ + { + "name": "adbario/php-dot-notation", + "version": "2.5.0", + "version_normalized": "2.5.0.0", + "source": { + "type": "git", + "url": "https://github.com/adbario/php-dot-notation.git", + "reference": "081e2cca50c84bfeeea2e3ef9b2c8d206d80ccae" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/adbario/php-dot-notation/zipball/081e2cca50c84bfeeea2e3ef9b2c8d206d80ccae", + "reference": "081e2cca50c84bfeeea2e3ef9b2c8d206d80ccae", + "shasum": "" + }, + "require": { + "ext-json": "*", + "php": "^5.5 || ^7.0 || ^8.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.8|^5.7|^6.6|^7.5|^8.5|^9.5", + "squizlabs/php_codesniffer": "^3.6" + }, + "time": "2022-10-14T20:31:46+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "files": [ + "src/helpers.php" + ], + "psr-4": { + "Adbar\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Riku Särkinen", + "email": "riku@adbar.io" + } + ], + "description": "PHP dot notation access to arrays", + "homepage": "https://github.com/adbario/php-dot-notation", + "keywords": [ + "ArrayAccess", + "dotnotation" + ], + "support": { + "issues": "https://github.com/adbario/php-dot-notation/issues", + "source": "https://github.com/adbario/php-dot-notation/tree/2.5.0" + }, + "install-path": "../adbario/php-dot-notation" + }, + { + "name": "alibabacloud/credentials", + "version": "1.2.3", + "version_normalized": "1.2.3.0", + "source": { + "type": "git", + "url": "https://github.com/aliyun/credentials-php.git", + "reference": "f6d1986e7b7be8da781d0b99f24c92d9860ba0c1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/aliyun/credentials-php/zipball/f6d1986e7b7be8da781d0b99f24c92d9860ba0c1", + "reference": "f6d1986e7b7be8da781d0b99f24c92d9860ba0c1", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "adbario/php-dot-notation": "^2.2", + "alibabacloud/tea": "^3.0", + "ext-curl": "*", + "ext-json": "*", + "ext-libxml": "*", + "ext-mbstring": "*", + "ext-openssl": "*", + "ext-simplexml": "*", + "ext-xmlwriter": "*", + "guzzlehttp/guzzle": "^6.3|^7.0", + "php": ">=5.6" + }, + "require-dev": { + "composer/composer": "^1.8", + "drupal/coder": "^8.3", + "ext-dom": "*", + "ext-pcre": "*", + "ext-sockets": "*", + "ext-spl": "*", + "mikey179/vfsstream": "^1.6", + "monolog/monolog": "^1.24", + "phpunit/phpunit": "^5.7|^6.6|^9.3", + "psr/cache": "^1.0", + "symfony/dotenv": "^3.4", + "symfony/var-dumper": "^3.4" + }, + "suggest": { + "ext-sockets": "To use client-side monitoring" + }, + "time": "2025-04-18T09:09:46+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "AlibabaCloud\\Credentials\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Alibaba Cloud SDK", + "email": "sdk-team@alibabacloud.com", + "homepage": "http://www.alibabacloud.com" + } + ], + "description": "Alibaba Cloud Credentials for PHP", + "homepage": "https://www.alibabacloud.com/", + "keywords": [ + "alibaba", + "alibabacloud", + "aliyun", + "client", + "cloud", + "credentials", + "library", + "sdk", + "tool" + ], + "support": { + "issues": "https://github.com/aliyun/credentials-php/issues", + "source": "https://github.com/aliyun/credentials-php" + }, + "install-path": "../alibabacloud/credentials" + }, + { + "name": "alibabacloud/darabonba-openapi", + "version": "0.2.15", + "version_normalized": "0.2.15.0", + "source": { + "type": "git", + "url": "https://github.com/alibabacloud-sdk-php/darabonba-openapi.git", + "reference": "de1a60831d74b0ddf78c16f6d31be57d95b7d49e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/alibabacloud-sdk-php/darabonba-openapi/zipball/de1a60831d74b0ddf78c16f6d31be57d95b7d49e", + "reference": "de1a60831d74b0ddf78c16f6d31be57d95b7d49e", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "alibabacloud/credentials": "^1.2.2", + "alibabacloud/gateway-spi": "^1", + "alibabacloud/openapi-util": "^0.1.10|^0.2.1", + "alibabacloud/tea-utils": "^0.2.21", + "alibabacloud/tea-xml": "^0.2", + "php": ">5.5" + }, + "time": "2025-04-15T11:59:13+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "Darabonba\\OpenApi\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Alibaba Cloud SDK", + "email": "sdk-team@alibabacloud.com" + } + ], + "description": "Alibaba Cloud OpenApi Client", + "support": { + "issues": "https://github.com/alibabacloud-sdk-php/darabonba-openapi/issues", + "source": "https://github.com/alibabacloud-sdk-php/darabonba-openapi/tree/0.2.15" + }, + "install-path": "../alibabacloud/darabonba-openapi" + }, + { + "name": "alibabacloud/dypnsapi-20170525", + "version": "1.1.3", + "version_normalized": "1.1.3.0", + "source": { + "type": "git", + "url": "https://github.com/alibabacloud-sdk-php/dypnsapi-20170525.git", + "reference": "dec5e2a15a4cacfa98f3c26e477d90bf750c0f0e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/alibabacloud-sdk-php/dypnsapi-20170525/zipball/dec5e2a15a4cacfa98f3c26e477d90bf750c0f0e", + "reference": "dec5e2a15a4cacfa98f3c26e477d90bf750c0f0e", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "alibabacloud/darabonba-openapi": "^0.2.13", + "alibabacloud/endpoint-util": "^0.1.0", + "alibabacloud/openapi-util": "^0.1.10|^0.2.1", + "alibabacloud/tea-utils": "^0.2.21", + "php": ">5.5" + }, + "time": "2024-10-24T09:40:08+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "AlibabaCloud\\SDK\\Dypnsapi\\V20170525\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Alibaba Cloud SDK", + "email": "sdk-team@alibabacloud.com" + } + ], + "description": "Alibaba Cloud Dypnsapi (20170525) SDK Library for PHP", + "support": { + "source": "https://github.com/alibabacloud-sdk-php/dypnsapi-20170525/tree/1.1.3" + }, + "install-path": "../alibabacloud/dypnsapi-20170525" + }, + { + "name": "alibabacloud/endpoint-util", + "version": "0.1.1", + "version_normalized": "0.1.1.0", + "source": { + "type": "git", + "url": "https://github.com/alibabacloud-sdk-php/endpoint-util.git", + "reference": "f3fe88a25d8df4faa3b0ae14ff202a9cc094e6c5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/alibabacloud-sdk-php/endpoint-util/zipball/f3fe88a25d8df4faa3b0ae14ff202a9cc094e6c5", + "reference": "f3fe88a25d8df4faa3b0ae14ff202a9cc094e6c5", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "php": ">5.5" + }, + "require-dev": { + "phpunit/phpunit": "^4.8.35|^5.4.3" + }, + "time": "2020-06-04T10:57:15+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "AlibabaCloud\\Endpoint\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Alibaba Cloud SDK", + "email": "sdk-team@alibabacloud.com" + } + ], + "description": "Alibaba Cloud Endpoint Library for PHP", + "support": { + "source": "https://github.com/alibabacloud-sdk-php/endpoint-util/tree/0.1.1" + }, + "install-path": "../alibabacloud/endpoint-util" + }, + { + "name": "alibabacloud/gateway-spi", + "version": "1.0.0", + "version_normalized": "1.0.0.0", + "source": { + "type": "git", + "url": "https://github.com/alibabacloud-sdk-php/alibabacloud-gateway-spi.git", + "reference": "7440f77750c329d8ab252db1d1d967314ccd1fcb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/alibabacloud-sdk-php/alibabacloud-gateway-spi/zipball/7440f77750c329d8ab252db1d1d967314ccd1fcb", + "reference": "7440f77750c329d8ab252db1d1d967314ccd1fcb", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "alibabacloud/credentials": "^1.1", + "php": ">5.5" + }, + "time": "2022-07-14T05:31:35+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "Darabonba\\GatewaySpi\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Alibaba Cloud SDK", + "email": "sdk-team@alibabacloud.com" + } + ], + "description": "Alibaba Cloud Gateway SPI Client", + "support": { + "source": "https://github.com/alibabacloud-sdk-php/alibabacloud-gateway-spi/tree/1.0.0" + }, + "install-path": "../alibabacloud/gateway-spi" + }, + { + "name": "alibabacloud/openapi-util", + "version": "0.2.1", + "version_normalized": "0.2.1.0", + "source": { + "type": "git", + "url": "https://github.com/alibabacloud-sdk-php/openapi-util.git", + "reference": "f31f7bcd835e08ca24b6b8ba33637eb4eceb093a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/alibabacloud-sdk-php/openapi-util/zipball/f31f7bcd835e08ca24b6b8ba33637eb4eceb093a", + "reference": "f31f7bcd835e08ca24b6b8ba33637eb4eceb093a", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "alibabacloud/tea": "^3.1", + "alibabacloud/tea-utils": "^0.2", + "lizhichao/one-sm": "^1.5", + "php": ">5.5" + }, + "require-dev": { + "phpunit/phpunit": "*" + }, + "time": "2023-01-10T09:10:10+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "AlibabaCloud\\OpenApiUtil\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Alibaba Cloud SDK", + "email": "sdk-team@alibabacloud.com" + } + ], + "description": "Alibaba Cloud OpenApi Util", + "support": { + "issues": "https://github.com/alibabacloud-sdk-php/openapi-util/issues", + "source": "https://github.com/alibabacloud-sdk-php/openapi-util/tree/0.2.1" + }, + "install-path": "../alibabacloud/openapi-util" + }, + { + "name": "alibabacloud/tea", + "version": "3.2.1", + "version_normalized": "3.2.1.0", + "source": { + "type": "git", + "url": "https://github.com/aliyun/tea-php.git", + "reference": "1619cb96c158384f72b873e1f85de8b299c9c367" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/aliyun/tea-php/zipball/1619cb96c158384f72b873e1f85de8b299c9c367", + "reference": "1619cb96c158384f72b873e1f85de8b299c9c367", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "adbario/php-dot-notation": "^2.4", + "ext-curl": "*", + "ext-json": "*", + "ext-libxml": "*", + "ext-mbstring": "*", + "ext-openssl": "*", + "ext-simplexml": "*", + "ext-xmlwriter": "*", + "guzzlehttp/guzzle": "^6.3|^7.0", + "php": ">=5.5" + }, + "require-dev": { + "phpunit/phpunit": "*", + "symfony/dotenv": "^3.4", + "symfony/var-dumper": "^3.4" + }, + "suggest": { + "ext-sockets": "To use client-side monitoring" + }, + "time": "2023-05-16T06:43:41+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "AlibabaCloud\\Tea\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Alibaba Cloud SDK", + "email": "sdk-team@alibabacloud.com", + "homepage": "http://www.alibabacloud.com" + } + ], + "description": "Client of Tea for PHP", + "homepage": "https://www.alibabacloud.com/", + "keywords": [ + "alibabacloud", + "client", + "cloud", + "tea" + ], + "support": { + "issues": "https://github.com/aliyun/tea-php/issues", + "source": "https://github.com/aliyun/tea-php" + }, + "install-path": "../alibabacloud/tea" + }, + { + "name": "alibabacloud/tea-utils", + "version": "0.2.21", + "version_normalized": "0.2.21.0", + "source": { + "type": "git", + "url": "https://github.com/alibabacloud-sdk-php/tea-utils.git", + "reference": "5039e45714c6456186d267f5d81a4b260a652495" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/alibabacloud-sdk-php/tea-utils/zipball/5039e45714c6456186d267f5d81a4b260a652495", + "reference": "5039e45714c6456186d267f5d81a4b260a652495", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "alibabacloud/tea": "^3.1", + "php": ">5.5" + }, + "time": "2024-07-05T06:05:54+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "AlibabaCloud\\Tea\\Utils\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Alibaba Cloud SDK", + "email": "sdk-team@alibabacloud.com" + } + ], + "description": "Alibaba Cloud Tea Utils for PHP", + "support": { + "issues": "https://github.com/aliyun/tea-util/issues", + "source": "https://github.com/aliyun/tea-util" + }, + "install-path": "../alibabacloud/tea-utils" + }, + { + "name": "alibabacloud/tea-xml", + "version": "0.2.4", + "version_normalized": "0.2.4.0", + "source": { + "type": "git", + "url": "https://github.com/alibabacloud-sdk-php/tea-xml.git", + "reference": "3e0c000bf536224eebbac913c371bef174c0a16a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/alibabacloud-sdk-php/tea-xml/zipball/3e0c000bf536224eebbac913c371bef174c0a16a", + "reference": "3e0c000bf536224eebbac913c371bef174c0a16a", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "php": ">5.5" + }, + "require-dev": { + "phpunit/phpunit": "*", + "symfony/var-dumper": "*" + }, + "time": "2022-08-02T04:12:58+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "AlibabaCloud\\Tea\\XML\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Alibaba Cloud SDK", + "email": "sdk-team@alibabacloud.com" + } + ], + "description": "Alibaba Cloud Tea XML Library for PHP", + "support": { + "source": "https://github.com/alibabacloud-sdk-php/tea-xml/tree/0.2.4" + }, + "install-path": "../alibabacloud/tea-xml" + }, + { + "name": "aliyuncs/oss-sdk-php", + "version": "v2.7.2", + "version_normalized": "2.7.2.0", + "source": { + "type": "git", + "url": "https://github.com/aliyun/aliyun-oss-php-sdk.git", + "reference": "483dd0b8bff5d47f0e4ffc99f6077a295c5ccbb5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/aliyun/aliyun-oss-php-sdk/zipball/483dd0b8bff5d47f0e4ffc99f6077a295c5ccbb5", + "reference": "483dd0b8bff5d47f0e4ffc99f6077a295c5ccbb5", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "php": ">=5.3" + }, + "require-dev": { + "php-coveralls/php-coveralls": "*", + "phpunit/phpunit": "*" + }, + "time": "2024-10-28T10:41:12+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "OSS\\": "src/OSS" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Aliyuncs", + "homepage": "http://www.aliyun.com" + } + ], + "description": "Aliyun OSS SDK for PHP", + "homepage": "http://www.aliyun.com/product/oss/", + "support": { + "issues": "https://github.com/aliyun/aliyun-oss-php-sdk/issues", + "source": "https://github.com/aliyun/aliyun-oss-php-sdk/tree/v2.7.2" + }, + "install-path": "../aliyuncs/oss-sdk-php" + }, + { + "name": "composer/pcre", + "version": "3.3.2", + "version_normalized": "3.3.2.0", + "source": { + "type": "git", + "url": "https://github.com/composer/pcre.git", + "reference": "b2bed4734f0cc156ee1fe9c0da2550420d99a21e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/pcre/zipball/b2bed4734f0cc156ee1fe9c0da2550420d99a21e", + "reference": "b2bed4734f0cc156ee1fe9c0da2550420d99a21e", + "shasum": "" + }, + "require": { + "php": "^7.4 || ^8.0" + }, + "conflict": { + "phpstan/phpstan": "<1.11.10" + }, + "require-dev": { + "phpstan/phpstan": "^1.12 || ^2", + "phpstan/phpstan-strict-rules": "^1 || ^2", + "phpunit/phpunit": "^8 || ^9" + }, + "time": "2024-11-12T16:29:46+00:00", + "type": "library", + "extra": { + "phpstan": { + "includes": [ + "extension.neon" + ] + }, + "branch-alias": { + "dev-main": "3.x-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Composer\\Pcre\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" + } + ], + "description": "PCRE wrapping library that offers type-safe preg_* replacements.", + "keywords": [ + "PCRE", + "preg", + "regex", + "regular expression" + ], + "support": { + "issues": "https://github.com/composer/pcre/issues", + "source": "https://github.com/composer/pcre/tree/3.3.2" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "install-path": "./pcre" + }, + { + "name": "easywechat-composer/easywechat-composer", + "version": "1.4.1", + "version_normalized": "1.4.1.0", + "source": { + "type": "git", + "url": "https://github.com/mingyoung/easywechat-composer.git", + "reference": "3fc6a7ab6d3853c0f4e2922539b56cc37ef361cd" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/mingyoung/easywechat-composer/zipball/3fc6a7ab6d3853c0f4e2922539b56cc37ef361cd", + "reference": "3fc6a7ab6d3853c0f4e2922539b56cc37ef361cd", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^1.0 || ^2.0", + "php": ">=7.0" + }, + "require-dev": { + "composer/composer": "^1.0 || ^2.0", + "phpunit/phpunit": "^6.5 || ^7.0" + }, + "time": "2021-07-05T04:03:22+00:00", + "type": "composer-plugin", + "extra": { + "class": "EasyWeChatComposer\\Plugin" + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "EasyWeChatComposer\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "张铭阳", + "email": "mingyoungcheung@gmail.com" + } + ], + "description": "The composer plugin for EasyWeChat", + "support": { + "issues": "https://github.com/mingyoung/easywechat-composer/issues", + "source": "https://github.com/mingyoung/easywechat-composer/tree/1.4.1" + }, + "install-path": "../easywechat-composer/easywechat-composer" + }, + { + "name": "ezyang/htmlpurifier", + "version": "v4.18.0", + "version_normalized": "4.18.0.0", + "source": { + "type": "git", + "url": "https://github.com/ezyang/htmlpurifier.git", + "reference": "cb56001e54359df7ae76dc522d08845dc741621b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ezyang/htmlpurifier/zipball/cb56001e54359df7ae76dc522d08845dc741621b", + "reference": "cb56001e54359df7ae76dc522d08845dc741621b", + "shasum": "" + }, + "require": { + "php": "~5.6.0 || ~7.0.0 || ~7.1.0 || ~7.2.0 || ~7.3.0 || ~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0" + }, + "require-dev": { + "cerdic/css-tidy": "^1.7 || ^2.0", + "simpletest/simpletest": "dev-master" + }, + "suggest": { + "cerdic/css-tidy": "If you want to use the filter 'Filter.ExtractStyleBlocks'.", + "ext-bcmath": "Used for unit conversion and imagecrash protection", + "ext-iconv": "Converts text to and from non-UTF-8 encodings", + "ext-tidy": "Used for pretty-printing HTML" + }, + "time": "2024-11-01T03:51:45+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "files": [ + "library/HTMLPurifier.composer.php" + ], + "psr-0": { + "HTMLPurifier": "library/" + }, + "exclude-from-classmap": [ + "/library/HTMLPurifier/Language/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-2.1-or-later" + ], + "authors": [ + { + "name": "Edward Z. Yang", + "email": "admin@htmlpurifier.org", + "homepage": "http://ezyang.com" + } + ], + "description": "Standards compliant HTML filter written in PHP", + "homepage": "http://htmlpurifier.org/", + "keywords": [ + "html" + ], + "support": { + "issues": "https://github.com/ezyang/htmlpurifier/issues", + "source": "https://github.com/ezyang/htmlpurifier/tree/v4.18.0" + }, + "install-path": "../ezyang/htmlpurifier" + }, + { + "name": "fastadminnet/fastadmin-addons", + "version": "1.4.1", + "version_normalized": "1.4.1.0", + "source": { + "type": "git", + "url": "https://github.com/fastadminnet/fastadmin-addons.git", + "reference": "f98418b69fbdd07569ee97d9fd4a83dfd7fdc770" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/fastadminnet/fastadmin-addons/zipball/f98418b69fbdd07569ee97d9fd4a83dfd7fdc770", + "reference": "f98418b69fbdd07569ee97d9fd4a83dfd7fdc770", + "shasum": "" + }, + "require": { + "nelexa/zip": "^3.3 || ^4.0", + "php": ">=7.0.0" + }, + "time": "2025-03-29T13:58:15+00:00", + "type": "library", + "extra": { + "think-config": { + "addons": "src/config.php" + } + }, + "installation-source": "dist", + "autoload": { + "files": [ + "src/common.php" + ], + "psr-4": { + "think\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Karson", + "email": "karson@fastadmin.net" + }, + { + "name": "xiaobo.sun", + "email": "xiaobo.sun@qq.com" + } + ], + "description": "addons package for fastadmin", + "homepage": "https://github.com/fastadminnet/fastadmin-addons", + "support": { + "issues": "https://github.com/fastadminnet/fastadmin-addons/issues", + "source": "https://github.com/fastadminnet/fastadmin-addons/tree/v1.4.1" + }, + "install-path": "../fastadminnet/fastadmin-addons" + }, + { + "name": "fastadminnet/fastadmin-mailer", + "version": "v2.1.0", + "version_normalized": "2.1.0.0", + "source": { + "type": "git", + "url": "https://github.com/fastadminnet/fastadmin-mailer.git", + "reference": "99b7369406d52c35cf4c9c38b0322b6846ca227a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/fastadminnet/fastadmin-mailer/zipball/99b7369406d52c35cf4c9c38b0322b6846ca227a", + "reference": "99b7369406d52c35cf4c9c38b0322b6846ca227a", + "shasum": "" + }, + "require": { + "php": ">=5.3.2", + "psr/log": "~1.0" + }, + "require-dev": { + "monolog/monolog": "~1.13", + "phpunit/phpunit": "~5.0" + }, + "time": "2025-03-30T03:39:53+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "Tx\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Cloud", + "email": "cloud@txthinking.com", + "homepage": "http://www.txthinking.com", + "role": "Thinker" + }, + { + "name": "Matt Sowers", + "email": "msowers@erblearn.org" + } + ], + "description": "A very lightweight PHP SMTP mail sender", + "homepage": "https://github.com/fastadminnet/fastadmin-mailer", + "keywords": [ + "mail", + "smtp" + ], + "support": { + "source": "https://github.com/fastadminnet/fastadmin-mailer/tree/v2.1.0" + }, + "install-path": "../fastadminnet/fastadmin-mailer" + }, + { + "name": "guzzlehttp/guzzle", + "version": "7.9.2", + "version_normalized": "7.9.2.0", + "source": { + "type": "git", + "url": "https://github.com/guzzle/guzzle.git", + "reference": "d281ed313b989f213357e3be1a179f02196ac99b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/d281ed313b989f213357e3be1a179f02196ac99b", + "reference": "d281ed313b989f213357e3be1a179f02196ac99b", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "ext-json": "*", + "guzzlehttp/promises": "^1.5.3 || ^2.0.3", + "guzzlehttp/psr7": "^2.7.0", + "php": "^7.2.5 || ^8.0", + "psr/http-client": "^1.0", + "symfony/deprecation-contracts": "^2.2 || ^3.0" + }, + "provide": { + "psr/http-client-implementation": "1.0" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.8.2", + "ext-curl": "*", + "guzzle/client-integration-tests": "3.0.2", + "php-http/message-factory": "^1.1", + "phpunit/phpunit": "^8.5.39 || ^9.6.20", + "psr/log": "^1.1 || ^2.0 || ^3.0" + }, + "suggest": { + "ext-curl": "Required for CURL handler support", + "ext-intl": "Required for Internationalized Domain Name (IDN) support", + "psr/log": "Required for using the Log middleware" + }, + "time": "2024-07-24T11:22:20+00:00", + "type": "library", + "extra": { + "bamarni-bin": { + "bin-links": true, + "forward-command": false + } + }, + "installation-source": "dist", + "autoload": { + "files": [ + "src/functions_include.php" + ], + "psr-4": { + "GuzzleHttp\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" + }, + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "Jeremy Lindblom", + "email": "jeremeamia@gmail.com", + "homepage": "https://github.com/jeremeamia" + }, + { + "name": "George Mponos", + "email": "gmponos@gmail.com", + "homepage": "https://github.com/gmponos" + }, + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com", + "homepage": "https://github.com/Nyholm" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://github.com/sagikazarmark" + }, + { + "name": "Tobias Schultze", + "email": "webmaster@tubo-world.de", + "homepage": "https://github.com/Tobion" + } + ], + "description": "Guzzle is a PHP HTTP client library", + "keywords": [ + "client", + "curl", + "framework", + "http", + "http client", + "psr-18", + "psr-7", + "rest", + "web service" + ], + "support": { + "issues": "https://github.com/guzzle/guzzle/issues", + "source": "https://github.com/guzzle/guzzle/tree/7.9.2" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://github.com/Nyholm", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/guzzle", + "type": "tidelift" + } + ], + "install-path": "../guzzlehttp/guzzle" + }, + { + "name": "guzzlehttp/promises", + "version": "2.2.0", + "version_normalized": "2.2.0.0", + "source": { + "type": "git", + "url": "https://github.com/guzzle/promises.git", + "reference": "7c69f28996b0a6920945dd20b3857e499d9ca96c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/promises/zipball/7c69f28996b0a6920945dd20b3857e499d9ca96c", + "reference": "7c69f28996b0a6920945dd20b3857e499d9ca96c", + "shasum": "" + }, + "require": { + "php": "^7.2.5 || ^8.0" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.8.2", + "phpunit/phpunit": "^8.5.39 || ^9.6.20" + }, + "time": "2025-03-27T13:27:01+00:00", + "type": "library", + "extra": { + "bamarni-bin": { + "bin-links": true, + "forward-command": false + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "GuzzleHttp\\Promise\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" + }, + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com", + "homepage": "https://github.com/Nyholm" + }, + { + "name": "Tobias Schultze", + "email": "webmaster@tubo-world.de", + "homepage": "https://github.com/Tobion" + } + ], + "description": "Guzzle promises library", + "keywords": [ + "promise" + ], + "support": { + "issues": "https://github.com/guzzle/promises/issues", + "source": "https://github.com/guzzle/promises/tree/2.2.0" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://github.com/Nyholm", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/promises", + "type": "tidelift" + } + ], + "install-path": "../guzzlehttp/promises" + }, + { + "name": "guzzlehttp/psr7", + "version": "2.7.1", + "version_normalized": "2.7.1.0", + "source": { + "type": "git", + "url": "https://github.com/guzzle/psr7.git", + "reference": "c2270caaabe631b3b44c85f99e5a04bbb8060d16" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/c2270caaabe631b3b44c85f99e5a04bbb8060d16", + "reference": "c2270caaabe631b3b44c85f99e5a04bbb8060d16", + "shasum": "" + }, + "require": { + "php": "^7.2.5 || ^8.0", + "psr/http-factory": "^1.0", + "psr/http-message": "^1.1 || ^2.0", + "ralouphie/getallheaders": "^3.0" + }, + "provide": { + "psr/http-factory-implementation": "1.0", + "psr/http-message-implementation": "1.0" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.8.2", + "http-interop/http-factory-tests": "0.9.0", + "phpunit/phpunit": "^8.5.39 || ^9.6.20" + }, + "suggest": { + "laminas/laminas-httphandlerrunner": "Emit PSR-7 responses" + }, + "time": "2025-03-27T12:30:47+00:00", + "type": "library", + "extra": { + "bamarni-bin": { + "bin-links": true, + "forward-command": false + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "GuzzleHttp\\Psr7\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" + }, + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "George Mponos", + "email": "gmponos@gmail.com", + "homepage": "https://github.com/gmponos" + }, + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com", + "homepage": "https://github.com/Nyholm" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://github.com/sagikazarmark" + }, + { + "name": "Tobias Schultze", + "email": "webmaster@tubo-world.de", + "homepage": "https://github.com/Tobion" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://sagikazarmark.hu" + } + ], + "description": "PSR-7 message implementation that also provides common utility methods", + "keywords": [ + "http", + "message", + "psr-7", + "request", + "response", + "stream", + "uri", + "url" + ], + "support": { + "issues": "https://github.com/guzzle/psr7/issues", + "source": "https://github.com/guzzle/psr7/tree/2.7.1" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://github.com/Nyholm", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/psr7", + "type": "tidelift" + } + ], + "install-path": "../guzzlehttp/psr7" + }, + { + "name": "lizhichao/one-sm", + "version": "1.10", + "version_normalized": "1.10.0.0", + "source": { + "type": "git", + "url": "https://github.com/lizhichao/sm.git", + "reference": "687a012a44a5bfd4d9143a0234e1060543be455a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/lizhichao/sm/zipball/687a012a44a5bfd4d9143a0234e1060543be455a", + "reference": "687a012a44a5bfd4d9143a0234e1060543be455a", + "shasum": "" + }, + "require": { + "php": ">=5.6" + }, + "time": "2021-05-26T06:19:22+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "OneSm\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "tanszhe", + "email": "1018595261@qq.com" + } + ], + "description": "国密sm3", + "keywords": [ + "php", + "sm3" + ], + "support": { + "issues": "https://github.com/lizhichao/sm/issues", + "source": "https://github.com/lizhichao/sm/tree/1.10" + }, + "funding": [ + { + "url": "https://www.vicsdf.com/img/w.jpg", + "type": "custom" + }, + { + "url": "https://www.vicsdf.com/img/z.jpg", + "type": "custom" + } + ], + "install-path": "../lizhichao/one-sm" + }, + { + "name": "maennchen/zipstream-php", + "version": "2.2.6", + "version_normalized": "2.2.6.0", + "source": { + "type": "git", + "url": "https://github.com/maennchen/ZipStream-PHP.git", + "reference": "30ad6f93cf3efe4192bc7a4c9cad11ff8f4f237f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/maennchen/ZipStream-PHP/zipball/30ad6f93cf3efe4192bc7a4c9cad11ff8f4f237f", + "reference": "30ad6f93cf3efe4192bc7a4c9cad11ff8f4f237f", + "shasum": "" + }, + "require": { + "myclabs/php-enum": "^1.5", + "php": "^7.4 || ^8.0", + "psr/http-message": "^1.0", + "symfony/polyfill-mbstring": "^1.0" + }, + "require-dev": { + "ext-zip": "*", + "friendsofphp/php-cs-fixer": "^3.9", + "guzzlehttp/guzzle": "^6.5.3 || ^7.2.0", + "mikey179/vfsstream": "^1.6", + "php-coveralls/php-coveralls": "^2.4", + "phpunit/phpunit": "^8.5.8 || ^9.4.2", + "vimeo/psalm": "^4.1" + }, + "time": "2022-11-25T18:57:19+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "ZipStream\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Paul Duncan", + "email": "pabs@pablotron.org" + }, + { + "name": "Jonatan Männchen", + "email": "jonatan@maennchen.ch" + }, + { + "name": "Jesse Donat", + "email": "donatj@gmail.com" + }, + { + "name": "András Kolesár", + "email": "kolesar@kolesar.hu" + } + ], + "description": "ZipStream is a library for dynamically streaming dynamic zip files from PHP without writing to the disk at all on the server.", + "keywords": [ + "stream", + "zip" + ], + "support": { + "issues": "https://github.com/maennchen/ZipStream-PHP/issues", + "source": "https://github.com/maennchen/ZipStream-PHP/tree/2.2.6" + }, + "funding": [ + { + "url": "https://github.com/maennchen", + "type": "github" + }, + { + "url": "https://opencollective.com/zipstream", + "type": "open_collective" + } + ], + "install-path": "../maennchen/zipstream-php" + }, + { + "name": "markbaker/complex", + "version": "3.0.2", + "version_normalized": "3.0.2.0", + "source": { + "type": "git", + "url": "https://github.com/MarkBaker/PHPComplex.git", + "reference": "95c56caa1cf5c766ad6d65b6344b807c1e8405b9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/MarkBaker/PHPComplex/zipball/95c56caa1cf5c766ad6d65b6344b807c1e8405b9", + "reference": "95c56caa1cf5c766ad6d65b6344b807c1e8405b9", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "dev-master", + "phpcompatibility/php-compatibility": "^9.3", + "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0", + "squizlabs/php_codesniffer": "^3.7" + }, + "time": "2022-12-06T16:21:08+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "Complex\\": "classes/src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mark Baker", + "email": "mark@lange.demon.co.uk" + } + ], + "description": "PHP Class for working with complex numbers", + "homepage": "https://github.com/MarkBaker/PHPComplex", + "keywords": [ + "complex", + "mathematics" + ], + "support": { + "issues": "https://github.com/MarkBaker/PHPComplex/issues", + "source": "https://github.com/MarkBaker/PHPComplex/tree/3.0.2" + }, + "install-path": "../markbaker/complex" + }, + { + "name": "markbaker/matrix", + "version": "3.0.1", + "version_normalized": "3.0.1.0", + "source": { + "type": "git", + "url": "https://github.com/MarkBaker/PHPMatrix.git", + "reference": "728434227fe21be27ff6d86621a1b13107a2562c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/MarkBaker/PHPMatrix/zipball/728434227fe21be27ff6d86621a1b13107a2562c", + "reference": "728434227fe21be27ff6d86621a1b13107a2562c", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "dev-master", + "phpcompatibility/php-compatibility": "^9.3", + "phpdocumentor/phpdocumentor": "2.*", + "phploc/phploc": "^4.0", + "phpmd/phpmd": "2.*", + "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0", + "sebastian/phpcpd": "^4.0", + "squizlabs/php_codesniffer": "^3.7" + }, + "time": "2022-12-02T22:17:43+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "Matrix\\": "classes/src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mark Baker", + "email": "mark@demon-angel.eu" + } + ], + "description": "PHP Class for working with matrices", + "homepage": "https://github.com/MarkBaker/PHPMatrix", + "keywords": [ + "mathematics", + "matrix", + "vector" + ], + "support": { + "issues": "https://github.com/MarkBaker/PHPMatrix/issues", + "source": "https://github.com/MarkBaker/PHPMatrix/tree/3.0.1" + }, + "install-path": "../markbaker/matrix" + }, + { + "name": "monolog/monolog", + "version": "2.10.0", + "version_normalized": "2.10.0.0", + "source": { + "type": "git", + "url": "https://github.com/Seldaek/monolog.git", + "reference": "5cf826f2991858b54d5c3809bee745560a1042a7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Seldaek/monolog/zipball/5cf826f2991858b54d5c3809bee745560a1042a7", + "reference": "5cf826f2991858b54d5c3809bee745560a1042a7", + "shasum": "" + }, + "require": { + "php": ">=7.2", + "psr/log": "^1.0.1 || ^2.0 || ^3.0" + }, + "provide": { + "psr/log-implementation": "1.0.0 || 2.0.0 || 3.0.0" + }, + "require-dev": { + "aws/aws-sdk-php": "^2.4.9 || ^3.0", + "doctrine/couchdb": "~1.0@dev", + "elasticsearch/elasticsearch": "^7 || ^8", + "ext-json": "*", + "graylog2/gelf-php": "^1.4.2 || ^2@dev", + "guzzlehttp/guzzle": "^7.4", + "guzzlehttp/psr7": "^2.2", + "mongodb/mongodb": "^1.8", + "php-amqplib/php-amqplib": "~2.4 || ^3", + "phpspec/prophecy": "^1.15", + "phpstan/phpstan": "^1.10", + "phpunit/phpunit": "^8.5.38 || ^9.6.19", + "predis/predis": "^1.1 || ^2.0", + "rollbar/rollbar": "^1.3 || ^2 || ^3", + "ruflin/elastica": "^7", + "swiftmailer/swiftmailer": "^5.3|^6.0", + "symfony/mailer": "^5.4 || ^6", + "symfony/mime": "^5.4 || ^6" + }, + "suggest": { + "aws/aws-sdk-php": "Allow sending log messages to AWS services like DynamoDB", + "doctrine/couchdb": "Allow sending log messages to a CouchDB server", + "elasticsearch/elasticsearch": "Allow sending log messages to an Elasticsearch server via official client", + "ext-amqp": "Allow sending log messages to an AMQP server (1.0+ required)", + "ext-curl": "Required to send log messages using the IFTTTHandler, the LogglyHandler, the SendGridHandler, the SlackWebhookHandler or the TelegramBotHandler", + "ext-mbstring": "Allow to work properly with unicode symbols", + "ext-mongodb": "Allow sending log messages to a MongoDB server (via driver)", + "ext-openssl": "Required to send log messages using SSL", + "ext-sockets": "Allow sending log messages to a Syslog server (via UDP driver)", + "graylog2/gelf-php": "Allow sending log messages to a GrayLog2 server", + "mongodb/mongodb": "Allow sending log messages to a MongoDB server (via library)", + "php-amqplib/php-amqplib": "Allow sending log messages to an AMQP server using php-amqplib", + "rollbar/rollbar": "Allow sending log messages to Rollbar", + "ruflin/elastica": "Allow sending log messages to an Elastic Search server" + }, + "time": "2024-11-12T12:43:37+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "2.x-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Monolog\\": "src/Monolog" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "https://seld.be" + } + ], + "description": "Sends your logs to files, sockets, inboxes, databases and various web services", + "homepage": "https://github.com/Seldaek/monolog", + "keywords": [ + "log", + "logging", + "psr-3" + ], + "support": { + "issues": "https://github.com/Seldaek/monolog/issues", + "source": "https://github.com/Seldaek/monolog/tree/2.10.0" + }, + "funding": [ + { + "url": "https://github.com/Seldaek", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/monolog/monolog", + "type": "tidelift" + } + ], + "install-path": "../monolog/monolog" + }, + { + "name": "myclabs/php-enum", + "version": "1.8.5", + "version_normalized": "1.8.5.0", + "source": { + "type": "git", + "url": "https://github.com/myclabs/php-enum.git", + "reference": "e7be26966b7398204a234f8673fdad5ac6277802" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/myclabs/php-enum/zipball/e7be26966b7398204a234f8673fdad5ac6277802", + "reference": "e7be26966b7398204a234f8673fdad5ac6277802", + "shasum": "" + }, + "require": { + "ext-json": "*", + "php": "^7.3 || ^8.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.5", + "squizlabs/php_codesniffer": "1.*", + "vimeo/psalm": "^4.6.2 || ^5.2" + }, + "time": "2025-01-14T11:49:03+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "MyCLabs\\Enum\\": "src/" + }, + "classmap": [ + "stubs/Stringable.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP Enum contributors", + "homepage": "https://github.com/myclabs/php-enum/graphs/contributors" + } + ], + "description": "PHP Enum implementation", + "homepage": "https://github.com/myclabs/php-enum", + "keywords": [ + "enum" + ], + "support": { + "issues": "https://github.com/myclabs/php-enum/issues", + "source": "https://github.com/myclabs/php-enum/tree/1.8.5" + }, + "funding": [ + { + "url": "https://github.com/mnapoli", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/myclabs/php-enum", + "type": "tidelift" + } + ], + "install-path": "../myclabs/php-enum" + }, + { + "name": "nelexa/zip", + "version": "4.0.2", + "version_normalized": "4.0.2.0", + "source": { + "type": "git", + "url": "https://github.com/Ne-Lexa/php-zip.git", + "reference": "88a1b6549be813278ff2dd3b6b2ac188827634a7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Ne-Lexa/php-zip/zipball/88a1b6549be813278ff2dd3b6b2ac188827634a7", + "reference": "88a1b6549be813278ff2dd3b6b2ac188827634a7", + "shasum": "" + }, + "require": { + "ext-zlib": "*", + "php": "^7.4 || ^8.0", + "psr/http-message": "*", + "symfony/finder": "*" + }, + "require-dev": { + "ext-bz2": "*", + "ext-dom": "*", + "ext-fileinfo": "*", + "ext-iconv": "*", + "ext-openssl": "*", + "ext-xml": "*", + "friendsofphp/php-cs-fixer": "^3.4.0", + "guzzlehttp/psr7": "^1.6", + "phpunit/phpunit": "^9", + "symfony/http-foundation": "*", + "symfony/var-dumper": "*", + "vimeo/psalm": "^4.6" + }, + "suggest": { + "ext-bz2": "Needed to support BZIP2 compression", + "ext-fileinfo": "Needed to get mime-type file", + "ext-iconv": "Needed to support convert zip entry name to requested character encoding", + "ext-openssl": "Needed to support encrypt zip entries or use ext-mcrypt" + }, + "time": "2022-06-17T11:17:46+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "PhpZip\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ne-Lexa", + "email": "alexey@nelexa.ru", + "role": "Developer" + } + ], + "description": "PhpZip is a php-library for extended work with ZIP-archives. Open, create, update, delete, extract and get info tool. Supports appending to existing ZIP files, WinZip AES encryption, Traditional PKWARE Encryption, BZIP2 compression, external file attributes and ZIP64 extensions. Alternative ZipArchive. It does not require php-zip extension.", + "homepage": "https://github.com/Ne-Lexa/php-zip", + "keywords": [ + "archive", + "extract", + "unzip", + "winzip", + "zip", + "ziparchive" + ], + "support": { + "issues": "https://github.com/Ne-Lexa/php-zip/issues", + "source": "https://github.com/Ne-Lexa/php-zip/tree/4.0.2" + }, + "install-path": "../nelexa/zip" + }, + { + "name": "overtrue/pinyin", + "version": "3.0.6", + "version_normalized": "3.0.6.0", + "source": { + "type": "git", + "url": "https://github.com/overtrue/pinyin.git", + "reference": "3b781d267197b74752daa32814d3a2cf5d140779" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/overtrue/pinyin/zipball/3b781d267197b74752daa32814d3a2cf5d140779", + "reference": "3b781d267197b74752daa32814d3a2cf5d140779", + "shasum": "" + }, + "require": { + "php": ">=5.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.8" + }, + "time": "2017-07-10T07:20:01+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "Overtrue\\Pinyin\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Carlos", + "homepage": "http://github.com/overtrue" + } + ], + "description": "Chinese to pinyin translator.", + "homepage": "https://github.com/overtrue/pinyin", + "keywords": [ + "Chinese", + "Pinyin", + "cn2pinyin" + ], + "support": { + "issues": "https://github.com/overtrue/pinyin/issues", + "source": "https://github.com/overtrue/pinyin/tree/master" + }, + "install-path": "../overtrue/pinyin" + }, + { + "name": "overtrue/socialite", + "version": "2.0.24", + "version_normalized": "2.0.24.0", + "source": { + "type": "git", + "url": "https://github.com/overtrue/socialite.git", + "reference": "ee7e7b000ec7d64f2b8aba1f6a2eec5cdf3f8bec" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/overtrue/socialite/zipball/ee7e7b000ec7d64f2b8aba1f6a2eec5cdf3f8bec", + "reference": "ee7e7b000ec7d64f2b8aba1f6a2eec5cdf3f8bec", + "shasum": "" + }, + "require": { + "ext-json": "*", + "guzzlehttp/guzzle": "^5.0|^6.0|^7.0", + "php": ">=5.6", + "symfony/http-foundation": "^2.7|^3.0|^4.0|^5.0" + }, + "require-dev": { + "mockery/mockery": "~1.2", + "phpunit/phpunit": "^6.0|^7.0|^8.0|^9.0" + }, + "time": "2021-05-13T16:04:48+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "Overtrue\\Socialite\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "overtrue", + "email": "anzhengchao@gmail.com" + } + ], + "description": "A collection of OAuth 2 packages that extracts from laravel/socialite.", + "keywords": [ + "login", + "oauth", + "qq", + "social", + "wechat", + "weibo" + ], + "support": { + "issues": "https://github.com/overtrue/socialite/issues", + "source": "https://github.com/overtrue/socialite/tree/2.0.24" + }, + "funding": [ + { + "url": "https://www.patreon.com/overtrue", + "type": "patreon" + } + ], + "install-path": "../overtrue/socialite" + }, + { + "name": "overtrue/wechat", + "version": "4.9.0", + "version_normalized": "4.9.0.0", + "source": { + "type": "git", + "url": "https://github.com/w7corp/easywechat.git", + "reference": "92791f5d957269c633b9aa175f842f6006f945b1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/w7corp/easywechat/zipball/92791f5d957269c633b9aa175f842f6006f945b1", + "reference": "92791f5d957269c633b9aa175f842f6006f945b1", + "shasum": "" + }, + "require": { + "easywechat-composer/easywechat-composer": "^1.1", + "ext-fileinfo": "*", + "ext-openssl": "*", + "ext-simplexml": "*", + "guzzlehttp/guzzle": "^6.2 || ^7.0", + "monolog/monolog": "^1.22 || ^2.0", + "overtrue/socialite": "~2.0", + "php": ">=7.2", + "pimple/pimple": "^3.0", + "psr/simple-cache": "^1.0", + "symfony/cache": "^3.3 || ^4.3 || ^5.0", + "symfony/event-dispatcher": "^4.3 || ^5.0", + "symfony/http-foundation": "^2.7 || ^3.0 || ^4.0 || ^5.0", + "symfony/psr-http-message-bridge": "^0.3 || ^1.0 || ^2.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^2.15", + "mikey179/vfsstream": "^1.6", + "mockery/mockery": "^1.2.3", + "phpstan/phpstan": "^0.12.0", + "phpunit/phpunit": "^7.5" + }, + "time": "2023-04-28T03:30:34+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "files": [ + "src/Kernel/Support/Helpers.php", + "src/Kernel/Helpers.php" + ], + "psr-4": { + "EasyWeChat\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "overtrue", + "email": "anzhengchao@gmail.com" + } + ], + "description": "微信SDK", + "keywords": [ + "easywechat", + "sdk", + "wechat", + "weixin", + "weixin-sdk" + ], + "support": { + "issues": "https://github.com/w7corp/easywechat/issues", + "source": "https://github.com/w7corp/easywechat/tree/4.9.0" + }, + "funding": [ + { + "url": "https://github.com/overtrue", + "type": "github" + } + ], + "abandoned": "w7corp/easywechat", + "install-path": "../overtrue/wechat" + }, + { + "name": "phpoffice/phpspreadsheet", + "version": "1.29.10", + "version_normalized": "1.29.10.0", + "source": { + "type": "git", + "url": "https://github.com/PHPOffice/PhpSpreadsheet.git", + "reference": "c80041b1628c4f18030407134fe88303661d4e4e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPOffice/PhpSpreadsheet/zipball/c80041b1628c4f18030407134fe88303661d4e4e", + "reference": "c80041b1628c4f18030407134fe88303661d4e4e", + "shasum": "" + }, + "require": { + "composer/pcre": "^1||^2||^3", + "ext-ctype": "*", + "ext-dom": "*", + "ext-fileinfo": "*", + "ext-gd": "*", + "ext-iconv": "*", + "ext-libxml": "*", + "ext-mbstring": "*", + "ext-simplexml": "*", + "ext-xml": "*", + "ext-xmlreader": "*", + "ext-xmlwriter": "*", + "ext-zip": "*", + "ext-zlib": "*", + "ezyang/htmlpurifier": "^4.15", + "maennchen/zipstream-php": "^2.1 || ^3.0", + "markbaker/complex": "^3.0", + "markbaker/matrix": "^3.0", + "php": "^7.4 || ^8.0", + "psr/http-client": "^1.0", + "psr/http-factory": "^1.0", + "psr/simple-cache": "^1.0 || ^2.0 || ^3.0" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "dev-main", + "dompdf/dompdf": "^1.0 || ^2.0 || ^3.0", + "friendsofphp/php-cs-fixer": "^3.2", + "mitoteam/jpgraph": "^10.3", + "mpdf/mpdf": "^8.1.1", + "phpcompatibility/php-compatibility": "^9.3", + "phpstan/phpstan": "^1.1", + "phpstan/phpstan-phpunit": "^1.0", + "phpunit/phpunit": "^8.5 || ^9.0", + "squizlabs/php_codesniffer": "^3.7", + "tecnickcom/tcpdf": "^6.5" + }, + "suggest": { + "dompdf/dompdf": "Option for rendering PDF with PDF Writer", + "ext-intl": "PHP Internationalization Functions", + "mitoteam/jpgraph": "Option for rendering charts, or including charts with PDF or HTML Writers", + "mpdf/mpdf": "Option for rendering PDF with PDF Writer", + "tecnickcom/tcpdf": "Option for rendering PDF with PDF Writer" + }, + "time": "2025-02-08T02:56:14+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "PhpOffice\\PhpSpreadsheet\\": "src/PhpSpreadsheet" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Maarten Balliauw", + "homepage": "https://blog.maartenballiauw.be" + }, + { + "name": "Mark Baker", + "homepage": "https://markbakeruk.net" + }, + { + "name": "Franck Lefevre", + "homepage": "https://rootslabs.net" + }, + { + "name": "Erik Tilt" + }, + { + "name": "Adrien Crivelli" + } + ], + "description": "PHPSpreadsheet - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine", + "homepage": "https://github.com/PHPOffice/PhpSpreadsheet", + "keywords": [ + "OpenXML", + "excel", + "gnumeric", + "ods", + "php", + "spreadsheet", + "xls", + "xlsx" + ], + "support": { + "issues": "https://github.com/PHPOffice/PhpSpreadsheet/issues", + "source": "https://github.com/PHPOffice/PhpSpreadsheet/tree/1.29.10" + }, + "install-path": "../phpoffice/phpspreadsheet" + }, + { + "name": "pimple/pimple", + "version": "v3.5.0", + "version_normalized": "3.5.0.0", + "source": { + "type": "git", + "url": "https://github.com/silexphp/Pimple.git", + "reference": "a94b3a4db7fb774b3d78dad2315ddc07629e1bed" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/silexphp/Pimple/zipball/a94b3a4db7fb774b3d78dad2315ddc07629e1bed", + "reference": "a94b3a4db7fb774b3d78dad2315ddc07629e1bed", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "psr/container": "^1.1 || ^2.0" + }, + "require-dev": { + "symfony/phpunit-bridge": "^5.4@dev" + }, + "time": "2021-10-28T11:13:42+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.4.x-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-0": { + "Pimple": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + } + ], + "description": "Pimple, a simple Dependency Injection Container", + "homepage": "https://pimple.symfony.com", + "keywords": [ + "container", + "dependency injection" + ], + "support": { + "source": "https://github.com/silexphp/Pimple/tree/v3.5.0" + }, + "install-path": "../pimple/pimple" + }, + { + "name": "psr/cache", + "version": "1.0.1", + "version_normalized": "1.0.1.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/cache.git", + "reference": "d11b50ad223250cf17b86e38383413f5a6764bf8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/cache/zipball/d11b50ad223250cf17b86e38383413f5a6764bf8", + "reference": "d11b50ad223250cf17b86e38383413f5a6764bf8", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "time": "2016-08-06T20:24:11+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Psr\\Cache\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for caching libraries", + "keywords": [ + "cache", + "psr", + "psr-6" + ], + "support": { + "source": "https://github.com/php-fig/cache/tree/master" + }, + "install-path": "../psr/cache" + }, + { + "name": "psr/container", + "version": "2.0.2", + "version_normalized": "2.0.2.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/container.git", + "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/container/zipball/c71ecc56dfe541dbd90c5360474fbc405f8d5963", + "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963", + "shasum": "" + }, + "require": { + "php": ">=7.4.0" + }, + "time": "2021-11-05T16:47:00+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Psr\\Container\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common Container Interface (PHP FIG PSR-11)", + "homepage": "https://github.com/php-fig/container", + "keywords": [ + "PSR-11", + "container", + "container-interface", + "container-interop", + "psr" + ], + "support": { + "issues": "https://github.com/php-fig/container/issues", + "source": "https://github.com/php-fig/container/tree/2.0.2" + }, + "install-path": "../psr/container" + }, + { + "name": "psr/event-dispatcher", + "version": "1.0.0", + "version_normalized": "1.0.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/event-dispatcher.git", + "reference": "dbefd12671e8a14ec7f180cab83036ed26714bb0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/event-dispatcher/zipball/dbefd12671e8a14ec7f180cab83036ed26714bb0", + "reference": "dbefd12671e8a14ec7f180cab83036ed26714bb0", + "shasum": "" + }, + "require": { + "php": ">=7.2.0" + }, + "time": "2019-01-08T18:20:26+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Psr\\EventDispatcher\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Standard interfaces for event handling.", + "keywords": [ + "events", + "psr", + "psr-14" + ], + "support": { + "issues": "https://github.com/php-fig/event-dispatcher/issues", + "source": "https://github.com/php-fig/event-dispatcher/tree/1.0.0" + }, + "install-path": "../psr/event-dispatcher" + }, + { + "name": "psr/http-client", + "version": "1.0.3", + "version_normalized": "1.0.3.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-client.git", + "reference": "bb5906edc1c324c9a05aa0873d40117941e5fa90" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-client/zipball/bb5906edc1c324c9a05aa0873d40117941e5fa90", + "reference": "bb5906edc1c324c9a05aa0873d40117941e5fa90", + "shasum": "" + }, + "require": { + "php": "^7.0 || ^8.0", + "psr/http-message": "^1.0 || ^2.0" + }, + "time": "2023-09-23T14:17:50+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Psr\\Http\\Client\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP clients", + "homepage": "https://github.com/php-fig/http-client", + "keywords": [ + "http", + "http-client", + "psr", + "psr-18" + ], + "support": { + "source": "https://github.com/php-fig/http-client" + }, + "install-path": "../psr/http-client" + }, + { + "name": "psr/http-factory", + "version": "1.0.2", + "version_normalized": "1.0.2.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-factory.git", + "reference": "e616d01114759c4c489f93b099585439f795fe35" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-factory/zipball/e616d01114759c4c489f93b099585439f795fe35", + "reference": "e616d01114759c4c489f93b099585439f795fe35", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "php": ">=7.0.0", + "psr/http-message": "^1.0 || ^2.0" + }, + "time": "2023-04-10T20:10:41+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interfaces for PSR-7 HTTP message factories", + "keywords": [ + "factory", + "http", + "message", + "psr", + "psr-17", + "psr-7", + "request", + "response" + ], + "support": { + "source": "https://github.com/php-fig/http-factory/tree/1.0.2" + }, + "install-path": "../psr/http-factory" + }, + { + "name": "psr/http-message", + "version": "1.1", + "version_normalized": "1.1.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-message.git", + "reference": "cb6ce4845ce34a8ad9e68117c10ee90a29919eba" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-message/zipball/cb6ce4845ce34a8ad9e68117c10ee90a29919eba", + "reference": "cb6ce4845ce34a8ad9e68117c10ee90a29919eba", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "time": "2023-04-04T09:50:52+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1.x-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP messages", + "homepage": "https://github.com/php-fig/http-message", + "keywords": [ + "http", + "http-message", + "psr", + "psr-7", + "request", + "response" + ], + "support": { + "source": "https://github.com/php-fig/http-message/tree/1.1" + }, + "install-path": "../psr/http-message" + }, + { + "name": "psr/log", + "version": "1.1.4", + "version_normalized": "1.1.4.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "d49695b909c3b7628b6289db5479a1c204601f11" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/d49695b909c3b7628b6289db5479a1c204601f11", + "reference": "d49695b909c3b7628b6289db5479a1c204601f11", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "time": "2021-05-03T11:20:27+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1.x-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Psr\\Log\\": "Psr/Log/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "homepage": "https://github.com/php-fig/log", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "support": { + "source": "https://github.com/php-fig/log/tree/1.1.4" + }, + "install-path": "../psr/log" + }, + { + "name": "psr/simple-cache", + "version": "1.0.1", + "version_normalized": "1.0.1.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/simple-cache.git", + "reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/simple-cache/zipball/408d5eafb83c57f6365a3ca330ff23aa4a5fa39b", + "reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "time": "2017-10-23T01:57:42+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Psr\\SimpleCache\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interfaces for simple caching", + "keywords": [ + "cache", + "caching", + "psr", + "psr-16", + "simple-cache" + ], + "support": { + "source": "https://github.com/php-fig/simple-cache/tree/master" + }, + "install-path": "../psr/simple-cache" + }, + { + "name": "ralouphie/getallheaders", + "version": "3.0.3", + "version_normalized": "3.0.3.0", + "source": { + "type": "git", + "url": "https://github.com/ralouphie/getallheaders.git", + "reference": "120b605dfeb996808c31b6477290a714d356e822" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822", + "reference": "120b605dfeb996808c31b6477290a714d356e822", + "shasum": "" + }, + "require": { + "php": ">=5.6" + }, + "require-dev": { + "php-coveralls/php-coveralls": "^2.1", + "phpunit/phpunit": "^5 || ^6.5" + }, + "time": "2019-03-08T08:55:37+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "files": [ + "src/getallheaders.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ralph Khattar", + "email": "ralph.khattar@gmail.com" + } + ], + "description": "A polyfill for getallheaders.", + "support": { + "issues": "https://github.com/ralouphie/getallheaders/issues", + "source": "https://github.com/ralouphie/getallheaders/tree/develop" + }, + "install-path": "../ralouphie/getallheaders" + }, + { + "name": "symfony/cache", + "version": "v5.4.46", + "version_normalized": "5.4.46.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/cache.git", + "reference": "0fe08ee32cec2748fbfea10c52d3ee02049e0f6b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/cache/zipball/0fe08ee32cec2748fbfea10c52d3ee02049e0f6b", + "reference": "0fe08ee32cec2748fbfea10c52d3ee02049e0f6b", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "psr/cache": "^1.0|^2.0", + "psr/log": "^1.1|^2|^3", + "symfony/cache-contracts": "^1.1.7|^2", + "symfony/deprecation-contracts": "^2.1|^3", + "symfony/polyfill-php73": "^1.9", + "symfony/polyfill-php80": "^1.16", + "symfony/service-contracts": "^1.1|^2|^3", + "symfony/var-exporter": "^4.4|^5.0|^6.0" + }, + "conflict": { + "doctrine/dbal": "<2.13.1", + "symfony/dependency-injection": "<4.4", + "symfony/http-kernel": "<4.4", + "symfony/var-dumper": "<4.4" + }, + "provide": { + "psr/cache-implementation": "1.0|2.0", + "psr/simple-cache-implementation": "1.0|2.0", + "symfony/cache-implementation": "1.0|2.0" + }, + "require-dev": { + "cache/integration-tests": "dev-master", + "doctrine/cache": "^1.6|^2.0", + "doctrine/dbal": "^2.13.1|^3|^4", + "predis/predis": "^1.1|^2.0", + "psr/simple-cache": "^1.0|^2.0", + "symfony/config": "^4.4|^5.0|^6.0", + "symfony/dependency-injection": "^4.4|^5.0|^6.0", + "symfony/filesystem": "^4.4|^5.0|^6.0", + "symfony/http-kernel": "^4.4|^5.0|^6.0", + "symfony/messenger": "^4.4|^5.0|^6.0", + "symfony/var-dumper": "^4.4|^5.0|^6.0" + }, + "time": "2024-11-04T11:43:55+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "Symfony\\Component\\Cache\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides extended PSR-6, PSR-16 (and tags) implementations", + "homepage": "https://symfony.com", + "keywords": [ + "caching", + "psr6" + ], + "support": { + "source": "https://github.com/symfony/cache/tree/v5.4.46" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "install-path": "../symfony/cache" + }, + { + "name": "symfony/cache-contracts", + "version": "v2.5.4", + "version_normalized": "2.5.4.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/cache-contracts.git", + "reference": "517c3a3619dadfa6952c4651767fcadffb4df65e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/cache-contracts/zipball/517c3a3619dadfa6952c4651767fcadffb4df65e", + "reference": "517c3a3619dadfa6952c4651767fcadffb4df65e", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "psr/cache": "^1.0|^2.0|^3.0" + }, + "suggest": { + "symfony/cache-implementation": "" + }, + "time": "2024-09-25T14:11:13+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "2.5-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Symfony\\Contracts\\Cache\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Generic abstractions related to caching", + "homepage": "https://symfony.com", + "keywords": [ + "abstractions", + "contracts", + "decoupling", + "interfaces", + "interoperability", + "standards" + ], + "support": { + "source": "https://github.com/symfony/cache-contracts/tree/v2.5.4" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "install-path": "../symfony/cache-contracts" + }, + { + "name": "symfony/deprecation-contracts", + "version": "v2.5.4", + "version_normalized": "2.5.4.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/deprecation-contracts.git", + "reference": "605389f2a7e5625f273b53960dc46aeaf9c62918" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/605389f2a7e5625f273b53960dc46aeaf9c62918", + "reference": "605389f2a7e5625f273b53960dc46aeaf9c62918", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "time": "2024-09-25T14:11:13+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "2.5-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + }, + "installation-source": "dist", + "autoload": { + "files": [ + "function.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "A generic function and convention to trigger deprecation notices", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/deprecation-contracts/tree/v2.5.4" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "install-path": "../symfony/deprecation-contracts" + }, + { + "name": "symfony/event-dispatcher", + "version": "v5.4.45", + "version_normalized": "5.4.45.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/event-dispatcher.git", + "reference": "72982eb416f61003e9bb6e91f8b3213600dcf9e9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/72982eb416f61003e9bb6e91f8b3213600dcf9e9", + "reference": "72982eb416f61003e9bb6e91f8b3213600dcf9e9", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/deprecation-contracts": "^2.1|^3", + "symfony/event-dispatcher-contracts": "^2|^3", + "symfony/polyfill-php80": "^1.16" + }, + "conflict": { + "symfony/dependency-injection": "<4.4" + }, + "provide": { + "psr/event-dispatcher-implementation": "1.0", + "symfony/event-dispatcher-implementation": "2.0" + }, + "require-dev": { + "psr/log": "^1|^2|^3", + "symfony/config": "^4.4|^5.0|^6.0", + "symfony/dependency-injection": "^4.4|^5.0|^6.0", + "symfony/error-handler": "^4.4|^5.0|^6.0", + "symfony/expression-language": "^4.4|^5.0|^6.0", + "symfony/http-foundation": "^4.4|^5.0|^6.0", + "symfony/service-contracts": "^1.1|^2|^3", + "symfony/stopwatch": "^4.4|^5.0|^6.0" + }, + "suggest": { + "symfony/dependency-injection": "", + "symfony/http-kernel": "" + }, + "time": "2024-09-25T14:11:13+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "Symfony\\Component\\EventDispatcher\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides tools that allow your application components to communicate with each other by dispatching events and listening to them", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/event-dispatcher/tree/v5.4.45" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "install-path": "../symfony/event-dispatcher" + }, + { + "name": "symfony/event-dispatcher-contracts", + "version": "v2.5.4", + "version_normalized": "2.5.4.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/event-dispatcher-contracts.git", + "reference": "e0fe3d79b516eb75126ac6fa4cbf19b79b08c99f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/e0fe3d79b516eb75126ac6fa4cbf19b79b08c99f", + "reference": "e0fe3d79b516eb75126ac6fa4cbf19b79b08c99f", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "psr/event-dispatcher": "^1" + }, + "suggest": { + "symfony/event-dispatcher-implementation": "" + }, + "time": "2024-09-25T14:11:13+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "2.5-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Symfony\\Contracts\\EventDispatcher\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Generic abstractions related to dispatching event", + "homepage": "https://symfony.com", + "keywords": [ + "abstractions", + "contracts", + "decoupling", + "interfaces", + "interoperability", + "standards" + ], + "support": { + "source": "https://github.com/symfony/event-dispatcher-contracts/tree/v2.5.4" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "install-path": "../symfony/event-dispatcher-contracts" + }, + { + "name": "symfony/finder", + "version": "v5.4.45", + "version_normalized": "5.4.45.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/finder.git", + "reference": "63741784cd7b9967975eec610b256eed3ede022b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/finder/zipball/63741784cd7b9967975eec610b256eed3ede022b", + "reference": "63741784cd7b9967975eec610b256eed3ede022b", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/deprecation-contracts": "^2.1|^3", + "symfony/polyfill-php80": "^1.16" + }, + "time": "2024-09-28T13:32:08+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "Symfony\\Component\\Finder\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Finds files and directories via an intuitive fluent interface", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/finder/tree/v5.4.45" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "install-path": "../symfony/finder" + }, + { + "name": "symfony/http-foundation", + "version": "v5.4.48", + "version_normalized": "5.4.48.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/http-foundation.git", + "reference": "3f38b8af283b830e1363acd79e5bc3412d055341" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/http-foundation/zipball/3f38b8af283b830e1363acd79e5bc3412d055341", + "reference": "3f38b8af283b830e1363acd79e5bc3412d055341", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/deprecation-contracts": "^2.1|^3", + "symfony/polyfill-mbstring": "~1.1", + "symfony/polyfill-php80": "^1.16" + }, + "require-dev": { + "predis/predis": "^1.0|^2.0", + "symfony/cache": "^4.4|^5.0|^6.0", + "symfony/dependency-injection": "^5.4|^6.0", + "symfony/expression-language": "^4.4|^5.0|^6.0", + "symfony/http-kernel": "^5.4.12|^6.0.12|^6.1.4", + "symfony/mime": "^4.4|^5.0|^6.0", + "symfony/rate-limiter": "^5.2|^6.0" + }, + "suggest": { + "symfony/mime": "To use the file extension guesser" + }, + "time": "2024-11-13T18:58:02+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "Symfony\\Component\\HttpFoundation\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Defines an object-oriented layer for the HTTP specification", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/http-foundation/tree/v5.4.48" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "install-path": "../symfony/http-foundation" + }, + { + "name": "symfony/polyfill-mbstring", + "version": "v1.31.0", + "version_normalized": "1.31.0.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-mbstring.git", + "reference": "85181ba99b2345b0ef10ce42ecac37612d9fd341" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/85181ba99b2345b0ef10ce42ecac37612d9fd341", + "reference": "85181ba99b2345b0ef10ce42ecac37612d9fd341", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "php": ">=7.2" + }, + "provide": { + "ext-mbstring": "*" + }, + "suggest": { + "ext-mbstring": "For best performance" + }, + "time": "2024-09-09T11:45:10+00:00", + "type": "library", + "extra": { + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "installation-source": "dist", + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Mbstring\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for the Mbstring extension", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "mbstring", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.31.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "install-path": "../symfony/polyfill-mbstring" + }, + { + "name": "symfony/polyfill-php73", + "version": "v1.32.0", + "version_normalized": "1.32.0.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php73.git", + "reference": "0f68c03565dcaaf25a890667542e8bd75fe7e5bb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/0f68c03565dcaaf25a890667542e8bd75fe7e5bb", + "reference": "0f68c03565dcaaf25a890667542e8bd75fe7e5bb", + "shasum": "" + }, + "require": { + "php": ">=7.2" + }, + "time": "2024-09-09T11:45:10+00:00", + "type": "library", + "extra": { + "thanks": { + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" + } + }, + "installation-source": "dist", + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Php73\\": "" + }, + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php73/tree/v1.32.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "install-path": "../symfony/polyfill-php73" + }, + { + "name": "symfony/polyfill-php80", + "version": "v1.32.0", + "version_normalized": "1.32.0.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php80.git", + "reference": "0cc9dd0f17f61d8131e7df6b84bd344899fe2608" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/0cc9dd0f17f61d8131e7df6b84bd344899fe2608", + "reference": "0cc9dd0f17f61d8131e7df6b84bd344899fe2608", + "shasum": "" + }, + "require": { + "php": ">=7.2" + }, + "time": "2025-01-02T08:10:11+00:00", + "type": "library", + "extra": { + "thanks": { + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" + } + }, + "installation-source": "dist", + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Php80\\": "" + }, + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ion Bazan", + "email": "ion.bazan@gmail.com" + }, + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php80/tree/v1.32.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "install-path": "../symfony/polyfill-php80" + }, + { + "name": "symfony/psr-http-message-bridge", + "version": "v2.3.1", + "version_normalized": "2.3.1.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/psr-http-message-bridge.git", + "reference": "581ca6067eb62640de5ff08ee1ba6850a0ee472e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/psr-http-message-bridge/zipball/581ca6067eb62640de5ff08ee1ba6850a0ee472e", + "reference": "581ca6067eb62640de5ff08ee1ba6850a0ee472e", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "psr/http-message": "^1.0 || ^2.0", + "symfony/deprecation-contracts": "^2.5 || ^3.0", + "symfony/http-foundation": "^5.4 || ^6.0" + }, + "require-dev": { + "nyholm/psr7": "^1.1", + "psr/log": "^1.1 || ^2 || ^3", + "symfony/browser-kit": "^5.4 || ^6.0", + "symfony/config": "^5.4 || ^6.0", + "symfony/event-dispatcher": "^5.4 || ^6.0", + "symfony/framework-bundle": "^5.4 || ^6.0", + "symfony/http-kernel": "^5.4 || ^6.0", + "symfony/phpunit-bridge": "^6.2" + }, + "suggest": { + "nyholm/psr7": "For a super lightweight PSR-7/17 implementation" + }, + "time": "2023-07-26T11:53:26+00:00", + "type": "symfony-bridge", + "extra": { + "branch-alias": { + "dev-main": "2.3-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Symfony\\Bridge\\PsrHttpMessage\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "PSR HTTP message bridge", + "homepage": "http://symfony.com", + "keywords": [ + "http", + "http-message", + "psr-17", + "psr-7" + ], + "support": { + "issues": "https://github.com/symfony/psr-http-message-bridge/issues", + "source": "https://github.com/symfony/psr-http-message-bridge/tree/v2.3.1" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "install-path": "../symfony/psr-http-message-bridge" + }, + { + "name": "symfony/service-contracts", + "version": "v1.1.2", + "version_normalized": "1.1.2.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/service-contracts.git", + "reference": "191afdcb5804db960d26d8566b7e9a2843cab3a0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/191afdcb5804db960d26d8566b7e9a2843cab3a0", + "reference": "191afdcb5804db960d26d8566b7e9a2843cab3a0", + "shasum": "" + }, + "require": { + "php": "^7.1.3" + }, + "suggest": { + "psr/container": "", + "symfony/service-implementation": "" + }, + "time": "2019-05-28T07:50:59+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Symfony\\Contracts\\Service\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Generic abstractions related to writing services", + "homepage": "https://symfony.com", + "keywords": [ + "abstractions", + "contracts", + "decoupling", + "interfaces", + "interoperability", + "standards" + ], + "support": { + "source": "https://github.com/symfony/service-contracts/tree/v1.1.2" + }, + "install-path": "../symfony/service-contracts" + }, + { + "name": "symfony/var-exporter", + "version": "v5.4.45", + "version_normalized": "5.4.45.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/var-exporter.git", + "reference": "862700068db0ddfd8c5b850671e029a90246ec75" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/var-exporter/zipball/862700068db0ddfd8c5b850671e029a90246ec75", + "reference": "862700068db0ddfd8c5b850671e029a90246ec75", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/polyfill-php80": "^1.16" + }, + "require-dev": { + "symfony/var-dumper": "^4.4.9|^5.0.9|^6.0" + }, + "time": "2024-09-25T14:11:13+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "Symfony\\Component\\VarExporter\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Allows exporting any serializable PHP data structure to plain PHP code", + "homepage": "https://symfony.com", + "keywords": [ + "clone", + "construct", + "export", + "hydrate", + "instantiate", + "serialize" + ], + "support": { + "source": "https://github.com/symfony/var-exporter/tree/v5.4.45" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "install-path": "../symfony/var-exporter" + }, + { + "name": "topthink/framework", + "version": "dev-master", + "version_normalized": "dev-master", + "source": { + "type": "git", + "url": "https://gitee.com/fastadminnet/framework.git", + "reference": "e95df87aa1a37e83d7c5fb29722cc70967feb54b" + }, + "require": { + "php": ">=7.1.0", + "topthink/think-installer": "~1.0" + }, + "require-dev": { + "johnkary/phpunit-speedtrap": "^1.0", + "mikey179/vfsstream": "~1.6", + "phpdocumentor/reflection-docblock": "^2.0", + "phploc/phploc": "2.*", + "phpunit/phpunit": "4.8.*", + "sebastian/phpcpd": "2.*" + }, + "time": "2025-03-12T07:32:08+00:00", + "default-branch": true, + "type": "think-framework", + "installation-source": "source", + "autoload": { + "psr-4": { + "think\\": "library/think" + } + }, + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "liu21st", + "email": "liu21st@gmail.com" + } + ], + "description": "the new thinkphp framework", + "homepage": "http://thinkphp.cn/", + "keywords": [ + "ORM", + "framework", + "thinkphp" + ], + "install-path": "../../thinkphp" + }, + { + "name": "topthink/think-captcha", + "version": "v1.0.9", + "version_normalized": "1.0.9.0", + "source": { + "type": "git", + "url": "https://gitee.com/fastadminnet/think-captcha.git", + "reference": "9be9dd7e61c7fa3c478c4b92910d7230b94d0d23" + }, + "require": { + "topthink/framework": "~5.0.0 || dev-master", + "topthink/think-installer": ">=1.0.10" + }, + "time": "2023-07-16T09:41:14+00:00", + "type": "library", + "installation-source": "source", + "autoload": { + "psr-4": { + "think\\captcha\\": "src/" + }, + "files": [ + "src/helper.php" + ] + }, + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "yunwuxin", + "email": "448901948@qq.com" + } + ], + "description": "captcha package for thinkphp5", + "install-path": "../topthink/think-captcha" + }, + { + "name": "topthink/think-helper", + "version": "v1.0.7", + "version_normalized": "1.0.7.0", + "source": { + "type": "git", + "url": "https://github.com/top-think/think-helper.git", + "reference": "5f92178606c8ce131d36b37a57c58eb71e55f019" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/top-think/think-helper/zipball/5f92178606c8ce131d36b37a57c58eb71e55f019", + "reference": "5f92178606c8ce131d36b37a57c58eb71e55f019", + "shasum": "" + }, + "time": "2018-10-05T00:43:21+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "files": [ + "src/helper.php" + ], + "psr-4": { + "think\\helper\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "yunwuxin", + "email": "448901948@qq.com" + } + ], + "description": "The ThinkPHP5 Helper Package", + "support": { + "issues": "https://github.com/top-think/think-helper/issues", + "source": "https://github.com/top-think/think-helper/tree/master" + }, + "install-path": "../topthink/think-helper" + }, + { + "name": "topthink/think-installer", + "version": "v1.0.14", + "version_normalized": "1.0.14.0", + "source": { + "type": "git", + "url": "https://github.com/top-think/think-installer.git", + "reference": "eae1740ac264a55c06134b6685dfb9f837d004d1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/top-think/think-installer/zipball/eae1740ac264a55c06134b6685dfb9f837d004d1", + "reference": "eae1740ac264a55c06134b6685dfb9f837d004d1", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^1.0||^2.0" + }, + "require-dev": { + "composer/composer": "^1.0||^2.0" + }, + "time": "2021-03-25T08:34:02+00:00", + "type": "composer-plugin", + "extra": { + "class": "think\\composer\\Plugin" + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "think\\composer\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "yunwuxin", + "email": "448901948@qq.com" + } + ], + "support": { + "issues": "https://github.com/top-think/think-installer/issues", + "source": "https://github.com/top-think/think-installer/tree/v1.0.14" + }, + "install-path": "../topthink/think-installer" + }, + { + "name": "topthink/think-queue", + "version": "v1.1.6", + "version_normalized": "1.1.6.0", + "source": { + "type": "git", + "url": "https://github.com/top-think/think-queue.git", + "reference": "250650eb0e8ea5af4cfdc7ae46f3f4e0a24ac245" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/top-think/think-queue/zipball/250650eb0e8ea5af4cfdc7ae46f3f4e0a24ac245", + "reference": "250650eb0e8ea5af4cfdc7ae46f3f4e0a24ac245", + "shasum": "" + }, + "require": { + "topthink/think-helper": ">=1.0.4", + "topthink/think-installer": ">=1.0.10" + }, + "require-dev": { + "topthink/framework": "~5.0.0" + }, + "time": "2018-10-15T10:16:55+00:00", + "type": "think-extend", + "extra": { + "think-config": { + "queue": "src/config.php" + } + }, + "installation-source": "dist", + "autoload": { + "files": [ + "src/common.php" + ], + "psr-4": { + "think\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "yunwuxin", + "email": "448901948@qq.com" + } + ], + "description": "The ThinkPHP5 Queue Package", + "support": { + "issues": "https://github.com/top-think/think-queue/issues", + "source": "https://github.com/top-think/think-queue/tree/master" + }, + "install-path": "../topthink/think-queue" + } + ], + "dev": true, + "dev-package-names": [] +} diff --git a/vendor/vendor/composer/installed.php b/vendor/vendor/composer/installed.php new file mode 100644 index 0000000..5988428 --- /dev/null +++ b/vendor/vendor/composer/installed.php @@ -0,0 +1,601 @@ + array( + 'name' => 'fastadminnet/fastadmin', + 'pretty_version' => '1.0.0+no-version-set', + 'version' => '1.0.0.0', + 'reference' => null, + 'type' => 'project', + 'install_path' => __DIR__ . '/../../', + 'aliases' => array(), + 'dev' => true, + ), + 'versions' => array( + 'adbario/php-dot-notation' => array( + 'pretty_version' => '2.5.0', + 'version' => '2.5.0.0', + 'reference' => '081e2cca50c84bfeeea2e3ef9b2c8d206d80ccae', + 'type' => 'library', + 'install_path' => __DIR__ . '/../adbario/php-dot-notation', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'alibabacloud/credentials' => array( + 'pretty_version' => '1.2.3', + 'version' => '1.2.3.0', + 'reference' => 'f6d1986e7b7be8da781d0b99f24c92d9860ba0c1', + 'type' => 'library', + 'install_path' => __DIR__ . '/../alibabacloud/credentials', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'alibabacloud/darabonba-openapi' => array( + 'pretty_version' => '0.2.15', + 'version' => '0.2.15.0', + 'reference' => 'de1a60831d74b0ddf78c16f6d31be57d95b7d49e', + 'type' => 'library', + 'install_path' => __DIR__ . '/../alibabacloud/darabonba-openapi', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'alibabacloud/dypnsapi-20170525' => array( + 'pretty_version' => '1.1.3', + 'version' => '1.1.3.0', + 'reference' => 'dec5e2a15a4cacfa98f3c26e477d90bf750c0f0e', + 'type' => 'library', + 'install_path' => __DIR__ . '/../alibabacloud/dypnsapi-20170525', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'alibabacloud/endpoint-util' => array( + 'pretty_version' => '0.1.1', + 'version' => '0.1.1.0', + 'reference' => 'f3fe88a25d8df4faa3b0ae14ff202a9cc094e6c5', + 'type' => 'library', + 'install_path' => __DIR__ . '/../alibabacloud/endpoint-util', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'alibabacloud/gateway-spi' => array( + 'pretty_version' => '1.0.0', + 'version' => '1.0.0.0', + 'reference' => '7440f77750c329d8ab252db1d1d967314ccd1fcb', + 'type' => 'library', + 'install_path' => __DIR__ . '/../alibabacloud/gateway-spi', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'alibabacloud/openapi-util' => array( + 'pretty_version' => '0.2.1', + 'version' => '0.2.1.0', + 'reference' => 'f31f7bcd835e08ca24b6b8ba33637eb4eceb093a', + 'type' => 'library', + 'install_path' => __DIR__ . '/../alibabacloud/openapi-util', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'alibabacloud/tea' => array( + 'pretty_version' => '3.2.1', + 'version' => '3.2.1.0', + 'reference' => '1619cb96c158384f72b873e1f85de8b299c9c367', + 'type' => 'library', + 'install_path' => __DIR__ . '/../alibabacloud/tea', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'alibabacloud/tea-utils' => array( + 'pretty_version' => '0.2.21', + 'version' => '0.2.21.0', + 'reference' => '5039e45714c6456186d267f5d81a4b260a652495', + 'type' => 'library', + 'install_path' => __DIR__ . '/../alibabacloud/tea-utils', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'alibabacloud/tea-xml' => array( + 'pretty_version' => '0.2.4', + 'version' => '0.2.4.0', + 'reference' => '3e0c000bf536224eebbac913c371bef174c0a16a', + 'type' => 'library', + 'install_path' => __DIR__ . '/../alibabacloud/tea-xml', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'aliyuncs/oss-sdk-php' => array( + 'pretty_version' => 'v2.7.2', + 'version' => '2.7.2.0', + 'reference' => '483dd0b8bff5d47f0e4ffc99f6077a295c5ccbb5', + 'type' => 'library', + 'install_path' => __DIR__ . '/../aliyuncs/oss-sdk-php', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'composer/pcre' => array( + 'pretty_version' => '3.3.2', + 'version' => '3.3.2.0', + 'reference' => 'b2bed4734f0cc156ee1fe9c0da2550420d99a21e', + 'type' => 'library', + 'install_path' => __DIR__ . '/./pcre', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'easywechat-composer/easywechat-composer' => array( + 'pretty_version' => '1.4.1', + 'version' => '1.4.1.0', + 'reference' => '3fc6a7ab6d3853c0f4e2922539b56cc37ef361cd', + 'type' => 'composer-plugin', + 'install_path' => __DIR__ . '/../easywechat-composer/easywechat-composer', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'ezyang/htmlpurifier' => array( + 'pretty_version' => 'v4.18.0', + 'version' => '4.18.0.0', + 'reference' => 'cb56001e54359df7ae76dc522d08845dc741621b', + 'type' => 'library', + 'install_path' => __DIR__ . '/../ezyang/htmlpurifier', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'fastadminnet/fastadmin' => array( + 'pretty_version' => '1.0.0+no-version-set', + 'version' => '1.0.0.0', + 'reference' => null, + 'type' => 'project', + 'install_path' => __DIR__ . '/../../', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'fastadminnet/fastadmin-addons' => array( + 'pretty_version' => '1.4.1', + 'version' => '1.4.1.0', + 'reference' => 'f98418b69fbdd07569ee97d9fd4a83dfd7fdc770', + 'type' => 'library', + 'install_path' => __DIR__ . '/../fastadminnet/fastadmin-addons', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'fastadminnet/fastadmin-mailer' => array( + 'pretty_version' => 'v2.1.0', + 'version' => '2.1.0.0', + 'reference' => '99b7369406d52c35cf4c9c38b0322b6846ca227a', + 'type' => 'library', + 'install_path' => __DIR__ . '/../fastadminnet/fastadmin-mailer', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'guzzlehttp/guzzle' => array( + 'pretty_version' => '7.9.2', + 'version' => '7.9.2.0', + 'reference' => 'd281ed313b989f213357e3be1a179f02196ac99b', + 'type' => 'library', + 'install_path' => __DIR__ . '/../guzzlehttp/guzzle', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'guzzlehttp/promises' => array( + 'pretty_version' => '2.2.0', + 'version' => '2.2.0.0', + 'reference' => '7c69f28996b0a6920945dd20b3857e499d9ca96c', + 'type' => 'library', + 'install_path' => __DIR__ . '/../guzzlehttp/promises', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'guzzlehttp/psr7' => array( + 'pretty_version' => '2.7.1', + 'version' => '2.7.1.0', + 'reference' => 'c2270caaabe631b3b44c85f99e5a04bbb8060d16', + 'type' => 'library', + 'install_path' => __DIR__ . '/../guzzlehttp/psr7', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'lizhichao/one-sm' => array( + 'pretty_version' => '1.10', + 'version' => '1.10.0.0', + 'reference' => '687a012a44a5bfd4d9143a0234e1060543be455a', + 'type' => 'library', + 'install_path' => __DIR__ . '/../lizhichao/one-sm', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'maennchen/zipstream-php' => array( + 'pretty_version' => '2.2.6', + 'version' => '2.2.6.0', + 'reference' => '30ad6f93cf3efe4192bc7a4c9cad11ff8f4f237f', + 'type' => 'library', + 'install_path' => __DIR__ . '/../maennchen/zipstream-php', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'markbaker/complex' => array( + 'pretty_version' => '3.0.2', + 'version' => '3.0.2.0', + 'reference' => '95c56caa1cf5c766ad6d65b6344b807c1e8405b9', + 'type' => 'library', + 'install_path' => __DIR__ . '/../markbaker/complex', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'markbaker/matrix' => array( + 'pretty_version' => '3.0.1', + 'version' => '3.0.1.0', + 'reference' => '728434227fe21be27ff6d86621a1b13107a2562c', + 'type' => 'library', + 'install_path' => __DIR__ . '/../markbaker/matrix', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'monolog/monolog' => array( + 'pretty_version' => '2.10.0', + 'version' => '2.10.0.0', + 'reference' => '5cf826f2991858b54d5c3809bee745560a1042a7', + 'type' => 'library', + 'install_path' => __DIR__ . '/../monolog/monolog', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'myclabs/php-enum' => array( + 'pretty_version' => '1.8.5', + 'version' => '1.8.5.0', + 'reference' => 'e7be26966b7398204a234f8673fdad5ac6277802', + 'type' => 'library', + 'install_path' => __DIR__ . '/../myclabs/php-enum', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'nelexa/zip' => array( + 'pretty_version' => '4.0.2', + 'version' => '4.0.2.0', + 'reference' => '88a1b6549be813278ff2dd3b6b2ac188827634a7', + 'type' => 'library', + 'install_path' => __DIR__ . '/../nelexa/zip', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'overtrue/pinyin' => array( + 'pretty_version' => '3.0.6', + 'version' => '3.0.6.0', + 'reference' => '3b781d267197b74752daa32814d3a2cf5d140779', + 'type' => 'library', + 'install_path' => __DIR__ . '/../overtrue/pinyin', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'overtrue/socialite' => array( + 'pretty_version' => '2.0.24', + 'version' => '2.0.24.0', + 'reference' => 'ee7e7b000ec7d64f2b8aba1f6a2eec5cdf3f8bec', + 'type' => 'library', + 'install_path' => __DIR__ . '/../overtrue/socialite', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'overtrue/wechat' => array( + 'pretty_version' => '4.9.0', + 'version' => '4.9.0.0', + 'reference' => '92791f5d957269c633b9aa175f842f6006f945b1', + 'type' => 'library', + 'install_path' => __DIR__ . '/../overtrue/wechat', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'phpoffice/phpspreadsheet' => array( + 'pretty_version' => '1.29.10', + 'version' => '1.29.10.0', + 'reference' => 'c80041b1628c4f18030407134fe88303661d4e4e', + 'type' => 'library', + 'install_path' => __DIR__ . '/../phpoffice/phpspreadsheet', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'pimple/pimple' => array( + 'pretty_version' => 'v3.5.0', + 'version' => '3.5.0.0', + 'reference' => 'a94b3a4db7fb774b3d78dad2315ddc07629e1bed', + 'type' => 'library', + 'install_path' => __DIR__ . '/../pimple/pimple', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'psr/cache' => array( + 'pretty_version' => '1.0.1', + 'version' => '1.0.1.0', + 'reference' => 'd11b50ad223250cf17b86e38383413f5a6764bf8', + 'type' => 'library', + 'install_path' => __DIR__ . '/../psr/cache', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'psr/cache-implementation' => array( + 'dev_requirement' => false, + 'provided' => array( + 0 => '1.0|2.0', + ), + ), + 'psr/container' => array( + 'pretty_version' => '2.0.2', + 'version' => '2.0.2.0', + 'reference' => 'c71ecc56dfe541dbd90c5360474fbc405f8d5963', + 'type' => 'library', + 'install_path' => __DIR__ . '/../psr/container', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'psr/event-dispatcher' => array( + 'pretty_version' => '1.0.0', + 'version' => '1.0.0.0', + 'reference' => 'dbefd12671e8a14ec7f180cab83036ed26714bb0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../psr/event-dispatcher', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'psr/event-dispatcher-implementation' => array( + 'dev_requirement' => false, + 'provided' => array( + 0 => '1.0', + ), + ), + 'psr/http-client' => array( + 'pretty_version' => '1.0.3', + 'version' => '1.0.3.0', + 'reference' => 'bb5906edc1c324c9a05aa0873d40117941e5fa90', + 'type' => 'library', + 'install_path' => __DIR__ . '/../psr/http-client', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'psr/http-client-implementation' => array( + 'dev_requirement' => false, + 'provided' => array( + 0 => '1.0', + ), + ), + 'psr/http-factory' => array( + 'pretty_version' => '1.0.2', + 'version' => '1.0.2.0', + 'reference' => 'e616d01114759c4c489f93b099585439f795fe35', + 'type' => 'library', + 'install_path' => __DIR__ . '/../psr/http-factory', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'psr/http-factory-implementation' => array( + 'dev_requirement' => false, + 'provided' => array( + 0 => '1.0', + ), + ), + 'psr/http-message' => array( + 'pretty_version' => '1.1', + 'version' => '1.1.0.0', + 'reference' => 'cb6ce4845ce34a8ad9e68117c10ee90a29919eba', + 'type' => 'library', + 'install_path' => __DIR__ . '/../psr/http-message', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'psr/http-message-implementation' => array( + 'dev_requirement' => false, + 'provided' => array( + 0 => '1.0', + ), + ), + 'psr/log' => array( + 'pretty_version' => '1.1.4', + 'version' => '1.1.4.0', + 'reference' => 'd49695b909c3b7628b6289db5479a1c204601f11', + 'type' => 'library', + 'install_path' => __DIR__ . '/../psr/log', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'psr/log-implementation' => array( + 'dev_requirement' => false, + 'provided' => array( + 0 => '1.0.0 || 2.0.0 || 3.0.0', + ), + ), + 'psr/simple-cache' => array( + 'pretty_version' => '1.0.1', + 'version' => '1.0.1.0', + 'reference' => '408d5eafb83c57f6365a3ca330ff23aa4a5fa39b', + 'type' => 'library', + 'install_path' => __DIR__ . '/../psr/simple-cache', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'psr/simple-cache-implementation' => array( + 'dev_requirement' => false, + 'provided' => array( + 0 => '1.0|2.0', + ), + ), + 'ralouphie/getallheaders' => array( + 'pretty_version' => '3.0.3', + 'version' => '3.0.3.0', + 'reference' => '120b605dfeb996808c31b6477290a714d356e822', + 'type' => 'library', + 'install_path' => __DIR__ . '/../ralouphie/getallheaders', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'symfony/cache' => array( + 'pretty_version' => 'v5.4.46', + 'version' => '5.4.46.0', + 'reference' => '0fe08ee32cec2748fbfea10c52d3ee02049e0f6b', + 'type' => 'library', + 'install_path' => __DIR__ . '/../symfony/cache', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'symfony/cache-contracts' => array( + 'pretty_version' => 'v2.5.4', + 'version' => '2.5.4.0', + 'reference' => '517c3a3619dadfa6952c4651767fcadffb4df65e', + 'type' => 'library', + 'install_path' => __DIR__ . '/../symfony/cache-contracts', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'symfony/cache-implementation' => array( + 'dev_requirement' => false, + 'provided' => array( + 0 => '1.0|2.0', + ), + ), + 'symfony/deprecation-contracts' => array( + 'pretty_version' => 'v2.5.4', + 'version' => '2.5.4.0', + 'reference' => '605389f2a7e5625f273b53960dc46aeaf9c62918', + 'type' => 'library', + 'install_path' => __DIR__ . '/../symfony/deprecation-contracts', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'symfony/event-dispatcher' => array( + 'pretty_version' => 'v5.4.45', + 'version' => '5.4.45.0', + 'reference' => '72982eb416f61003e9bb6e91f8b3213600dcf9e9', + 'type' => 'library', + 'install_path' => __DIR__ . '/../symfony/event-dispatcher', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'symfony/event-dispatcher-contracts' => array( + 'pretty_version' => 'v2.5.4', + 'version' => '2.5.4.0', + 'reference' => 'e0fe3d79b516eb75126ac6fa4cbf19b79b08c99f', + 'type' => 'library', + 'install_path' => __DIR__ . '/../symfony/event-dispatcher-contracts', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'symfony/event-dispatcher-implementation' => array( + 'dev_requirement' => false, + 'provided' => array( + 0 => '2.0', + ), + ), + 'symfony/finder' => array( + 'pretty_version' => 'v5.4.45', + 'version' => '5.4.45.0', + 'reference' => '63741784cd7b9967975eec610b256eed3ede022b', + 'type' => 'library', + 'install_path' => __DIR__ . '/../symfony/finder', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'symfony/http-foundation' => array( + 'pretty_version' => 'v5.4.48', + 'version' => '5.4.48.0', + 'reference' => '3f38b8af283b830e1363acd79e5bc3412d055341', + 'type' => 'library', + 'install_path' => __DIR__ . '/../symfony/http-foundation', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'symfony/polyfill-mbstring' => array( + 'pretty_version' => 'v1.31.0', + 'version' => '1.31.0.0', + 'reference' => '85181ba99b2345b0ef10ce42ecac37612d9fd341', + 'type' => 'library', + 'install_path' => __DIR__ . '/../symfony/polyfill-mbstring', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'symfony/polyfill-php73' => array( + 'pretty_version' => 'v1.32.0', + 'version' => '1.32.0.0', + 'reference' => '0f68c03565dcaaf25a890667542e8bd75fe7e5bb', + 'type' => 'library', + 'install_path' => __DIR__ . '/../symfony/polyfill-php73', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'symfony/polyfill-php80' => array( + 'pretty_version' => 'v1.32.0', + 'version' => '1.32.0.0', + 'reference' => '0cc9dd0f17f61d8131e7df6b84bd344899fe2608', + 'type' => 'library', + 'install_path' => __DIR__ . '/../symfony/polyfill-php80', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'symfony/psr-http-message-bridge' => array( + 'pretty_version' => 'v2.3.1', + 'version' => '2.3.1.0', + 'reference' => '581ca6067eb62640de5ff08ee1ba6850a0ee472e', + 'type' => 'symfony-bridge', + 'install_path' => __DIR__ . '/../symfony/psr-http-message-bridge', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'symfony/service-contracts' => array( + 'pretty_version' => 'v1.1.2', + 'version' => '1.1.2.0', + 'reference' => '191afdcb5804db960d26d8566b7e9a2843cab3a0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../symfony/service-contracts', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'symfony/var-exporter' => array( + 'pretty_version' => 'v5.4.45', + 'version' => '5.4.45.0', + 'reference' => '862700068db0ddfd8c5b850671e029a90246ec75', + 'type' => 'library', + 'install_path' => __DIR__ . '/../symfony/var-exporter', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'topthink/framework' => array( + 'pretty_version' => 'dev-master', + 'version' => 'dev-master', + 'reference' => 'e95df87aa1a37e83d7c5fb29722cc70967feb54b', + 'type' => 'think-framework', + 'install_path' => __DIR__ . '/../../thinkphp', + 'aliases' => array( + 0 => '9999999-dev', + ), + 'dev_requirement' => false, + ), + 'topthink/think-captcha' => array( + 'pretty_version' => 'v1.0.9', + 'version' => '1.0.9.0', + 'reference' => '9be9dd7e61c7fa3c478c4b92910d7230b94d0d23', + 'type' => 'library', + 'install_path' => __DIR__ . '/../topthink/think-captcha', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'topthink/think-helper' => array( + 'pretty_version' => 'v1.0.7', + 'version' => '1.0.7.0', + 'reference' => '5f92178606c8ce131d36b37a57c58eb71e55f019', + 'type' => 'library', + 'install_path' => __DIR__ . '/../topthink/think-helper', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'topthink/think-installer' => array( + 'pretty_version' => 'v1.0.14', + 'version' => '1.0.14.0', + 'reference' => 'eae1740ac264a55c06134b6685dfb9f837d004d1', + 'type' => 'composer-plugin', + 'install_path' => __DIR__ . '/../topthink/think-installer', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'topthink/think-queue' => array( + 'pretty_version' => 'v1.1.6', + 'version' => '1.1.6.0', + 'reference' => '250650eb0e8ea5af4cfdc7ae46f3f4e0a24ac245', + 'type' => 'think-extend', + 'install_path' => __DIR__ . '/../topthink/think-queue', + 'aliases' => array(), + 'dev_requirement' => false, + ), + ), +); diff --git a/vendor/vendor/composer/pcre/LICENSE b/vendor/vendor/composer/pcre/LICENSE new file mode 100644 index 0000000..c5a282f --- /dev/null +++ b/vendor/vendor/composer/pcre/LICENSE @@ -0,0 +1,19 @@ +Copyright (C) 2021 Composer + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/vendor/vendor/composer/pcre/README.md b/vendor/vendor/composer/pcre/README.md new file mode 100644 index 0000000..4906514 --- /dev/null +++ b/vendor/vendor/composer/pcre/README.md @@ -0,0 +1,189 @@ +composer/pcre +============= + +PCRE wrapping library that offers type-safe `preg_*` replacements. + +This library gives you a way to ensure `preg_*` functions do not fail silently, returning +unexpected `null`s that may not be handled. + +As of 3.0 this library enforces [`PREG_UNMATCHED_AS_NULL`](#preg_unmatched_as_null) usage +for all matching and replaceCallback functions, [read more below](#preg_unmatched_as_null) +to understand the implications. + +It thus makes it easier to work with static analysis tools like PHPStan or Psalm as it +simplifies and reduces the possible return values from all the `preg_*` functions which +are quite packed with edge cases. As of v2.2.0 / v3.2.0 the library also comes with a +[PHPStan extension](#phpstan-extension) for parsing regular expressions and giving you even better output types. + +This library is a thin wrapper around `preg_*` functions with [some limitations](#restrictions--limitations). +If you are looking for a richer API to handle regular expressions have a look at +[rawr/t-regx](https://packagist.org/packages/rawr/t-regx) instead. + +[![Continuous Integration](https://github.com/composer/pcre/workflows/Continuous%20Integration/badge.svg?branch=main)](https://github.com/composer/pcre/actions) + + +Installation +------------ + +Install the latest version with: + +```bash +$ composer require composer/pcre +``` + + +Requirements +------------ + +* PHP 7.4.0 is required for 3.x versions +* PHP 7.2.0 is required for 2.x versions +* PHP 5.3.2 is required for 1.x versions + + +Basic usage +----------- + +Instead of: + +```php +if (preg_match('{fo+}', $string, $matches)) { ... } +if (preg_match('{fo+}', $string, $matches, PREG_OFFSET_CAPTURE)) { ... } +if (preg_match_all('{fo+}', $string, $matches)) { ... } +$newString = preg_replace('{fo+}', 'bar', $string); +$newString = preg_replace_callback('{fo+}', function ($match) { return strtoupper($match[0]); }, $string); +$newString = preg_replace_callback_array(['{fo+}' => fn ($match) => strtoupper($match[0])], $string); +$filtered = preg_grep('{[a-z]}', $elements); +$array = preg_split('{[a-z]+}', $string); +``` + +You can now call these on the `Preg` class: + +```php +use Composer\Pcre\Preg; + +if (Preg::match('{fo+}', $string, $matches)) { ... } +if (Preg::matchWithOffsets('{fo+}', $string, $matches)) { ... } +if (Preg::matchAll('{fo+}', $string, $matches)) { ... } +$newString = Preg::replace('{fo+}', 'bar', $string); +$newString = Preg::replaceCallback('{fo+}', function ($match) { return strtoupper($match[0]); }, $string); +$newString = Preg::replaceCallbackArray(['{fo+}' => fn ($match) => strtoupper($match[0])], $string); +$filtered = Preg::grep('{[a-z]}', $elements); +$array = Preg::split('{[a-z]+}', $string); +``` + +The main difference is if anything fails to match/replace/.., it will throw a `Composer\Pcre\PcreException` +instead of returning `null` (or false in some cases), so you can now use the return values safely relying on +the fact that they can only be strings (for replace), ints (for match) or arrays (for grep/split). + +Additionally the `Preg` class provides match methods that return `bool` rather than `int`, for stricter type safety +when the number of pattern matches is not useful: + +```php +use Composer\Pcre\Preg; + +if (Preg::isMatch('{fo+}', $string, $matches)) // bool +if (Preg::isMatchAll('{fo+}', $string, $matches)) // bool +``` + +Finally the `Preg` class provides a few `*StrictGroups` method variants that ensure match groups +are always present and thus non-nullable, making it easier to write type-safe code: + +```php +use Composer\Pcre\Preg; + +// $matches is guaranteed to be an array of strings, if a subpattern does not match and produces a null it will throw +if (Preg::matchStrictGroups('{fo+}', $string, $matches)) +if (Preg::matchAllStrictGroups('{fo+}', $string, $matches)) +``` + +**Note:** This is generally safe to use as long as you do not have optional subpatterns (i.e. `(something)?` +or `(something)*` or branches with a `|` that result in some groups not being matched at all). +A subpattern that can match an empty string like `(.*)` is **not** optional, it will be present as an +empty string in the matches. A non-matching subpattern, even if optional like `(?:foo)?` will anyway not be present in +matches so it is also not a problem to use these with `*StrictGroups` methods. + +If you would prefer a slightly more verbose usage, replacing by-ref arguments by result objects, you can use the `Regex` class: + +```php +use Composer\Pcre\Regex; + +// this is useful when you are just interested in knowing if something matched +// as it returns a bool instead of int(1/0) for match +$bool = Regex::isMatch('{fo+}', $string); + +$result = Regex::match('{fo+}', $string); +if ($result->matched) { something($result->matches); } + +$result = Regex::matchWithOffsets('{fo+}', $string); +if ($result->matched) { something($result->matches); } + +$result = Regex::matchAll('{fo+}', $string); +if ($result->matched && $result->count > 3) { something($result->matches); } + +$newString = Regex::replace('{fo+}', 'bar', $string)->result; +$newString = Regex::replaceCallback('{fo+}', function ($match) { return strtoupper($match[0]); }, $string)->result; +$newString = Regex::replaceCallbackArray(['{fo+}' => fn ($match) => strtoupper($match[0])], $string)->result; +``` + +Note that `preg_grep` and `preg_split` are only callable via the `Preg` class as they do not have +complex return types warranting a specific result object. + +See the [MatchResult](src/MatchResult.php), [MatchWithOffsetsResult](src/MatchWithOffsetsResult.php), [MatchAllResult](src/MatchAllResult.php), +[MatchAllWithOffsetsResult](src/MatchAllWithOffsetsResult.php), and [ReplaceResult](src/ReplaceResult.php) class sources for more details. + +Restrictions / Limitations +-------------------------- + +Due to type safety requirements a few restrictions are in place. + +- matching using `PREG_OFFSET_CAPTURE` is made available via `matchWithOffsets` and `matchAllWithOffsets`. + You cannot pass the flag to `match`/`matchAll`. +- `Preg::split` will also reject `PREG_SPLIT_OFFSET_CAPTURE` and you should use `splitWithOffsets` + instead. +- `matchAll` rejects `PREG_SET_ORDER` as it also changes the shape of the returned matches. There + is no alternative provided as you can fairly easily code around it. +- `preg_filter` is not supported as it has a rather crazy API, most likely you should rather + use `Preg::grep` in combination with some loop and `Preg::replace`. +- `replace`, `replaceCallback` and `replaceCallbackArray` do not support an array `$subject`, + only simple strings. +- As of 2.0, the library always uses `PREG_UNMATCHED_AS_NULL` for matching, which offers [much + saner/more predictable results](#preg_unmatched_as_null). As of 3.0 the flag is also set for + `replaceCallback` and `replaceCallbackArray`. + +#### PREG_UNMATCHED_AS_NULL + +As of 2.0, this library always uses PREG_UNMATCHED_AS_NULL for all `match*` and `isMatch*` +functions. As of 3.0 it is also done for `replaceCallback` and `replaceCallbackArray`. + +This means your matches will always contain all matching groups, either as null if unmatched +or as string if it matched. + +The advantages in clarity and predictability are clearer if you compare the two outputs of +running this with and without PREG_UNMATCHED_AS_NULL in $flags: + +```php +preg_match('/(a)(b)*(c)(d)*/', 'ac', $matches, $flags); +``` + +| no flag | PREG_UNMATCHED_AS_NULL | +| --- | --- | +| array (size=4) | array (size=5) | +| 0 => string 'ac' (length=2) | 0 => string 'ac' (length=2) | +| 1 => string 'a' (length=1) | 1 => string 'a' (length=1) | +| 2 => string '' (length=0) | 2 => null | +| 3 => string 'c' (length=1) | 3 => string 'c' (length=1) | +| | 4 => null | +| group 2 (any unmatched group preceding one that matched) is set to `''`. You cannot tell if it matched an empty string or did not match at all | group 2 is `null` when unmatched and a string if it matched, easy to check for | +| group 4 (any optional group without a matching one following) is missing altogether. So you have to check with `isset()`, but really you want `isset($m[4]) && $m[4] !== ''` for safety unless you are very careful to check that a non-optional group follows it | group 4 is always set, and null in this case as there was no match, easy to check for with `$m[4] !== null` | + +PHPStan Extension +----------------- + +To use the PHPStan extension if you do not use `phpstan/extension-installer` you can include `vendor/composer/pcre/extension.neon` in your PHPStan config. + +The extension provides much better type information for $matches as well as regex validation where possible. + +License +------- + +composer/pcre is licensed under the MIT License, see the LICENSE file for details. diff --git a/vendor/vendor/composer/pcre/composer.json b/vendor/vendor/composer/pcre/composer.json new file mode 100644 index 0000000..d3a7e67 --- /dev/null +++ b/vendor/vendor/composer/pcre/composer.json @@ -0,0 +1,54 @@ +{ + "name": "composer/pcre", + "description": "PCRE wrapping library that offers type-safe preg_* replacements.", + "type": "library", + "license": "MIT", + "keywords": [ + "pcre", + "regex", + "preg", + "regular expression" + ], + "authors": [ + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" + } + ], + "require": { + "php": "^7.4 || ^8.0" + }, + "require-dev": { + "phpunit/phpunit": "^8 || ^9", + "phpstan/phpstan": "^1.12 || ^2", + "phpstan/phpstan-strict-rules": "^1 || ^2" + }, + "conflict": { + "phpstan/phpstan": "<1.11.10" + }, + "autoload": { + "psr-4": { + "Composer\\Pcre\\": "src" + } + }, + "autoload-dev": { + "psr-4": { + "Composer\\Pcre\\": "tests" + } + }, + "extra": { + "branch-alias": { + "dev-main": "3.x-dev" + }, + "phpstan": { + "includes": [ + "extension.neon" + ] + } + }, + "scripts": { + "test": "@php vendor/bin/phpunit", + "phpstan": "@php phpstan analyse" + } +} diff --git a/vendor/vendor/composer/pcre/extension.neon b/vendor/vendor/composer/pcre/extension.neon new file mode 100644 index 0000000..b9cea11 --- /dev/null +++ b/vendor/vendor/composer/pcre/extension.neon @@ -0,0 +1,22 @@ +# composer/pcre PHPStan extensions +# +# These can be reused by third party packages by including 'vendor/composer/pcre/extension.neon' +# in your phpstan config + +services: + - + class: Composer\Pcre\PHPStan\PregMatchParameterOutTypeExtension + tags: + - phpstan.staticMethodParameterOutTypeExtension + - + class: Composer\Pcre\PHPStan\PregMatchTypeSpecifyingExtension + tags: + - phpstan.typeSpecifier.staticMethodTypeSpecifyingExtension + - + class: Composer\Pcre\PHPStan\PregReplaceCallbackClosureTypeExtension + tags: + - phpstan.staticMethodParameterClosureTypeExtension + +rules: + - Composer\Pcre\PHPStan\UnsafeStrictGroupsCallRule + - Composer\Pcre\PHPStan\InvalidRegexPatternRule diff --git a/vendor/vendor/composer/pcre/src/MatchAllResult.php b/vendor/vendor/composer/pcre/src/MatchAllResult.php new file mode 100644 index 0000000..b22b52d --- /dev/null +++ b/vendor/vendor/composer/pcre/src/MatchAllResult.php @@ -0,0 +1,46 @@ + + * + * For the full copyright and license information, please view + * the LICENSE file that was distributed with this source code. + */ + +namespace Composer\Pcre; + +final class MatchAllResult +{ + /** + * An array of match group => list of matched strings + * + * @readonly + * @var array> + */ + public $matches; + + /** + * @readonly + * @var 0|positive-int + */ + public $count; + + /** + * @readonly + * @var bool + */ + public $matched; + + /** + * @param 0|positive-int $count + * @param array> $matches + */ + public function __construct(int $count, array $matches) + { + $this->matches = $matches; + $this->matched = (bool) $count; + $this->count = $count; + } +} diff --git a/vendor/vendor/composer/pcre/src/MatchAllStrictGroupsResult.php b/vendor/vendor/composer/pcre/src/MatchAllStrictGroupsResult.php new file mode 100644 index 0000000..b7ec397 --- /dev/null +++ b/vendor/vendor/composer/pcre/src/MatchAllStrictGroupsResult.php @@ -0,0 +1,46 @@ + + * + * For the full copyright and license information, please view + * the LICENSE file that was distributed with this source code. + */ + +namespace Composer\Pcre; + +final class MatchAllStrictGroupsResult +{ + /** + * An array of match group => list of matched strings + * + * @readonly + * @var array> + */ + public $matches; + + /** + * @readonly + * @var 0|positive-int + */ + public $count; + + /** + * @readonly + * @var bool + */ + public $matched; + + /** + * @param 0|positive-int $count + * @param array> $matches + */ + public function __construct(int $count, array $matches) + { + $this->matches = $matches; + $this->matched = (bool) $count; + $this->count = $count; + } +} diff --git a/vendor/vendor/composer/pcre/src/MatchAllWithOffsetsResult.php b/vendor/vendor/composer/pcre/src/MatchAllWithOffsetsResult.php new file mode 100644 index 0000000..032a02c --- /dev/null +++ b/vendor/vendor/composer/pcre/src/MatchAllWithOffsetsResult.php @@ -0,0 +1,48 @@ + + * + * For the full copyright and license information, please view + * the LICENSE file that was distributed with this source code. + */ + +namespace Composer\Pcre; + +final class MatchAllWithOffsetsResult +{ + /** + * An array of match group => list of matches, every match being a pair of string matched + offset in bytes (or -1 if no match) + * + * @readonly + * @var array> + * @phpstan-var array}>> + */ + public $matches; + + /** + * @readonly + * @var 0|positive-int + */ + public $count; + + /** + * @readonly + * @var bool + */ + public $matched; + + /** + * @param 0|positive-int $count + * @param array> $matches + * @phpstan-param array}>> $matches + */ + public function __construct(int $count, array $matches) + { + $this->matches = $matches; + $this->matched = (bool) $count; + $this->count = $count; + } +} diff --git a/vendor/vendor/composer/pcre/src/MatchResult.php b/vendor/vendor/composer/pcre/src/MatchResult.php new file mode 100644 index 0000000..e951a5e --- /dev/null +++ b/vendor/vendor/composer/pcre/src/MatchResult.php @@ -0,0 +1,39 @@ + + * + * For the full copyright and license information, please view + * the LICENSE file that was distributed with this source code. + */ + +namespace Composer\Pcre; + +final class MatchResult +{ + /** + * An array of match group => string matched + * + * @readonly + * @var array + */ + public $matches; + + /** + * @readonly + * @var bool + */ + public $matched; + + /** + * @param 0|positive-int $count + * @param array $matches + */ + public function __construct(int $count, array $matches) + { + $this->matches = $matches; + $this->matched = (bool) $count; + } +} diff --git a/vendor/vendor/composer/pcre/src/MatchStrictGroupsResult.php b/vendor/vendor/composer/pcre/src/MatchStrictGroupsResult.php new file mode 100644 index 0000000..126ee62 --- /dev/null +++ b/vendor/vendor/composer/pcre/src/MatchStrictGroupsResult.php @@ -0,0 +1,39 @@ + + * + * For the full copyright and license information, please view + * the LICENSE file that was distributed with this source code. + */ + +namespace Composer\Pcre; + +final class MatchStrictGroupsResult +{ + /** + * An array of match group => string matched + * + * @readonly + * @var array + */ + public $matches; + + /** + * @readonly + * @var bool + */ + public $matched; + + /** + * @param 0|positive-int $count + * @param array $matches + */ + public function __construct(int $count, array $matches) + { + $this->matches = $matches; + $this->matched = (bool) $count; + } +} diff --git a/vendor/vendor/composer/pcre/src/MatchWithOffsetsResult.php b/vendor/vendor/composer/pcre/src/MatchWithOffsetsResult.php new file mode 100644 index 0000000..ba4d4bc --- /dev/null +++ b/vendor/vendor/composer/pcre/src/MatchWithOffsetsResult.php @@ -0,0 +1,41 @@ + + * + * For the full copyright and license information, please view + * the LICENSE file that was distributed with this source code. + */ + +namespace Composer\Pcre; + +final class MatchWithOffsetsResult +{ + /** + * An array of match group => pair of string matched + offset in bytes (or -1 if no match) + * + * @readonly + * @var array + * @phpstan-var array}> + */ + public $matches; + + /** + * @readonly + * @var bool + */ + public $matched; + + /** + * @param 0|positive-int $count + * @param array $matches + * @phpstan-param array}> $matches + */ + public function __construct(int $count, array $matches) + { + $this->matches = $matches; + $this->matched = (bool) $count; + } +} diff --git a/vendor/vendor/composer/pcre/src/PHPStan/InvalidRegexPatternRule.php b/vendor/vendor/composer/pcre/src/PHPStan/InvalidRegexPatternRule.php new file mode 100644 index 0000000..8a05fb2 --- /dev/null +++ b/vendor/vendor/composer/pcre/src/PHPStan/InvalidRegexPatternRule.php @@ -0,0 +1,142 @@ + + */ +class InvalidRegexPatternRule implements Rule +{ + public function getNodeType(): string + { + return StaticCall::class; + } + + public function processNode(Node $node, Scope $scope): array + { + $patterns = $this->extractPatterns($node, $scope); + + $errors = []; + foreach ($patterns as $pattern) { + $errorMessage = $this->validatePattern($pattern); + if ($errorMessage === null) { + continue; + } + + $errors[] = RuleErrorBuilder::message(sprintf('Regex pattern is invalid: %s', $errorMessage))->identifier('regexp.pattern')->build(); + } + + return $errors; + } + + /** + * @return string[] + */ + private function extractPatterns(StaticCall $node, Scope $scope): array + { + if (!$node->class instanceof FullyQualified) { + return []; + } + $isRegex = $node->class->toString() === Regex::class; + $isPreg = $node->class->toString() === Preg::class; + if (!$isRegex && !$isPreg) { + return []; + } + if (!$node->name instanceof Node\Identifier || !Preg::isMatch('{^(match|isMatch|grep|replace|split)}', $node->name->name)) { + return []; + } + + $functionName = $node->name->name; + if (!isset($node->getArgs()[0])) { + return []; + } + + $patternNode = $node->getArgs()[0]->value; + $patternType = $scope->getType($patternNode); + + $patternStrings = []; + + foreach ($patternType->getConstantStrings() as $constantStringType) { + if ($functionName === 'replaceCallbackArray') { + continue; + } + + $patternStrings[] = $constantStringType->getValue(); + } + + foreach ($patternType->getConstantArrays() as $constantArrayType) { + if ( + in_array($functionName, [ + 'replace', + 'replaceCallback', + ], true) + ) { + foreach ($constantArrayType->getValueTypes() as $arrayKeyType) { + foreach ($arrayKeyType->getConstantStrings() as $constantString) { + $patternStrings[] = $constantString->getValue(); + } + } + } + + if ($functionName !== 'replaceCallbackArray') { + continue; + } + + foreach ($constantArrayType->getKeyTypes() as $arrayKeyType) { + foreach ($arrayKeyType->getConstantStrings() as $constantString) { + $patternStrings[] = $constantString->getValue(); + } + } + } + + return $patternStrings; + } + + private function validatePattern(string $pattern): ?string + { + try { + $msg = null; + $prev = set_error_handler(function (int $severity, string $message, string $file) use (&$msg): bool { + $msg = preg_replace("#^preg_match(_all)?\\(.*?\\): #", '', $message); + + return true; + }); + + if ($pattern === '') { + return 'Empty string is not a valid regular expression'; + } + + Preg::match($pattern, ''); + if ($msg !== null) { + return $msg; + } + } catch (PcreException $e) { + if ($e->getCode() === PREG_INTERNAL_ERROR && $msg !== null) { + return $msg; + } + + return preg_replace('{.*? failed executing ".*": }', '', $e->getMessage()); + } finally { + restore_error_handler(); + } + + return null; + } + +} diff --git a/vendor/vendor/composer/pcre/src/PHPStan/PregMatchFlags.php b/vendor/vendor/composer/pcre/src/PHPStan/PregMatchFlags.php new file mode 100644 index 0000000..aa30ab3 --- /dev/null +++ b/vendor/vendor/composer/pcre/src/PHPStan/PregMatchFlags.php @@ -0,0 +1,70 @@ +getType($flagsArg->value); + + $constantScalars = $flagsType->getConstantScalarValues(); + if ($constantScalars === []) { + return null; + } + + $internalFlagsTypes = []; + foreach ($flagsType->getConstantScalarValues() as $constantScalarValue) { + if (!is_int($constantScalarValue)) { + return null; + } + + $internalFlagsTypes[] = new ConstantIntegerType($constantScalarValue | PREG_UNMATCHED_AS_NULL); + } + return TypeCombinator::union(...$internalFlagsTypes); + } + + static public function removeNullFromMatches(Type $matchesType): Type + { + return TypeTraverser::map($matchesType, static function (Type $type, callable $traverse): Type { + if ($type instanceof UnionType || $type instanceof IntersectionType) { + return $traverse($type); + } + + if ($type instanceof ConstantArrayType) { + return new ConstantArrayType( + $type->getKeyTypes(), + array_map(static function (Type $valueType) use ($traverse): Type { + return $traverse($valueType); + }, $type->getValueTypes()), + $type->getNextAutoIndexes(), + [], + $type->isList() + ); + } + + if ($type instanceof ArrayType) { + return new ArrayType($type->getKeyType(), $traverse($type->getItemType())); + } + + return TypeCombinator::removeNull($type); + }); + } + +} diff --git a/vendor/vendor/composer/pcre/src/PHPStan/PregMatchParameterOutTypeExtension.php b/vendor/vendor/composer/pcre/src/PHPStan/PregMatchParameterOutTypeExtension.php new file mode 100644 index 0000000..e0d6020 --- /dev/null +++ b/vendor/vendor/composer/pcre/src/PHPStan/PregMatchParameterOutTypeExtension.php @@ -0,0 +1,65 @@ +regexShapeMatcher = $regexShapeMatcher; + } + + public function isStaticMethodSupported(MethodReflection $methodReflection, ParameterReflection $parameter): bool + { + return + $methodReflection->getDeclaringClass()->getName() === Preg::class + && in_array($methodReflection->getName(), [ + 'match', 'isMatch', 'matchStrictGroups', 'isMatchStrictGroups', + 'matchAll', 'isMatchAll', 'matchAllStrictGroups', 'isMatchAllStrictGroups' + ], true) + && $parameter->getName() === 'matches'; + } + + public function getParameterOutTypeFromStaticMethodCall(MethodReflection $methodReflection, StaticCall $methodCall, ParameterReflection $parameter, Scope $scope): ?Type + { + $args = $methodCall->getArgs(); + $patternArg = $args[0] ?? null; + $matchesArg = $args[2] ?? null; + $flagsArg = $args[3] ?? null; + + if ( + $patternArg === null || $matchesArg === null + ) { + return null; + } + + $flagsType = PregMatchFlags::getType($flagsArg, $scope); + if ($flagsType === null) { + return null; + } + + if (stripos($methodReflection->getName(), 'matchAll') !== false) { + return $this->regexShapeMatcher->matchAllExpr($patternArg->value, $flagsType, TrinaryLogic::createMaybe(), $scope); + } + + return $this->regexShapeMatcher->matchExpr($patternArg->value, $flagsType, TrinaryLogic::createMaybe(), $scope); + } + +} diff --git a/vendor/vendor/composer/pcre/src/PHPStan/PregMatchTypeSpecifyingExtension.php b/vendor/vendor/composer/pcre/src/PHPStan/PregMatchTypeSpecifyingExtension.php new file mode 100644 index 0000000..3db0ce0 --- /dev/null +++ b/vendor/vendor/composer/pcre/src/PHPStan/PregMatchTypeSpecifyingExtension.php @@ -0,0 +1,119 @@ +regexShapeMatcher = $regexShapeMatcher; + } + + public function setTypeSpecifier(TypeSpecifier $typeSpecifier): void + { + $this->typeSpecifier = $typeSpecifier; + } + + public function getClass(): string + { + return Preg::class; + } + + public function isStaticMethodSupported(MethodReflection $methodReflection, StaticCall $node, TypeSpecifierContext $context): bool + { + return in_array($methodReflection->getName(), [ + 'match', 'isMatch', 'matchStrictGroups', 'isMatchStrictGroups', + 'matchAll', 'isMatchAll', 'matchAllStrictGroups', 'isMatchAllStrictGroups' + ], true) + && !$context->null(); + } + + public function specifyTypes(MethodReflection $methodReflection, StaticCall $node, Scope $scope, TypeSpecifierContext $context): SpecifiedTypes + { + $args = $node->getArgs(); + $patternArg = $args[0] ?? null; + $matchesArg = $args[2] ?? null; + $flagsArg = $args[3] ?? null; + + if ( + $patternArg === null || $matchesArg === null + ) { + return new SpecifiedTypes(); + } + + $flagsType = PregMatchFlags::getType($flagsArg, $scope); + if ($flagsType === null) { + return new SpecifiedTypes(); + } + + if (stripos($methodReflection->getName(), 'matchAll') !== false) { + $matchedType = $this->regexShapeMatcher->matchAllExpr($patternArg->value, $flagsType, TrinaryLogic::createFromBoolean($context->true()), $scope); + } else { + $matchedType = $this->regexShapeMatcher->matchExpr($patternArg->value, $flagsType, TrinaryLogic::createFromBoolean($context->true()), $scope); + } + + if ($matchedType === null) { + return new SpecifiedTypes(); + } + + if ( + in_array($methodReflection->getName(), ['matchStrictGroups', 'isMatchStrictGroups', 'matchAllStrictGroups', 'isMatchAllStrictGroups'], true) + ) { + $matchedType = PregMatchFlags::removeNullFromMatches($matchedType); + } + + $overwrite = false; + if ($context->false()) { + $overwrite = true; + $context = $context->negate(); + } + + // @phpstan-ignore function.alreadyNarrowedType + if (method_exists('PHPStan\Analyser\SpecifiedTypes', 'setRootExpr')) { + $typeSpecifier = $this->typeSpecifier->create( + $matchesArg->value, + $matchedType, + $context, + $scope + )->setRootExpr($node); + + return $overwrite ? $typeSpecifier->setAlwaysOverwriteTypes() : $typeSpecifier; + } + + // @phpstan-ignore arguments.count + return $this->typeSpecifier->create( + $matchesArg->value, + $matchedType, + $context, + // @phpstan-ignore argument.type + $overwrite, + $scope, + $node + ); + } +} diff --git a/vendor/vendor/composer/pcre/src/PHPStan/PregReplaceCallbackClosureTypeExtension.php b/vendor/vendor/composer/pcre/src/PHPStan/PregReplaceCallbackClosureTypeExtension.php new file mode 100644 index 0000000..7b95367 --- /dev/null +++ b/vendor/vendor/composer/pcre/src/PHPStan/PregReplaceCallbackClosureTypeExtension.php @@ -0,0 +1,91 @@ +regexShapeMatcher = $regexShapeMatcher; + } + + public function isStaticMethodSupported(MethodReflection $methodReflection, ParameterReflection $parameter): bool + { + return in_array($methodReflection->getDeclaringClass()->getName(), [Preg::class, Regex::class], true) + && in_array($methodReflection->getName(), ['replaceCallback', 'replaceCallbackStrictGroups'], true) + && $parameter->getName() === 'replacement'; + } + + public function getTypeFromStaticMethodCall(MethodReflection $methodReflection, StaticCall $methodCall, ParameterReflection $parameter, Scope $scope): ?Type + { + $args = $methodCall->getArgs(); + $patternArg = $args[0] ?? null; + $flagsArg = $args[5] ?? null; + + if ( + $patternArg === null + ) { + return null; + } + + $flagsType = PregMatchFlags::getType($flagsArg, $scope); + + $matchesType = $this->regexShapeMatcher->matchExpr($patternArg->value, $flagsType, TrinaryLogic::createYes(), $scope); + if ($matchesType === null) { + return null; + } + + if ($methodReflection->getName() === 'replaceCallbackStrictGroups' && count($matchesType->getConstantArrays()) === 1) { + $matchesType = $matchesType->getConstantArrays()[0]; + $matchesType = new ConstantArrayType( + $matchesType->getKeyTypes(), + array_map(static function (Type $valueType): Type { + if (count($valueType->getConstantArrays()) === 1) { + $valueTypeArray = $valueType->getConstantArrays()[0]; + return new ConstantArrayType( + $valueTypeArray->getKeyTypes(), + array_map(static function (Type $valueType): Type { + return TypeCombinator::removeNull($valueType); + }, $valueTypeArray->getValueTypes()), + $valueTypeArray->getNextAutoIndexes(), + [], + $valueTypeArray->isList() + ); + } + return TypeCombinator::removeNull($valueType); + }, $matchesType->getValueTypes()), + $matchesType->getNextAutoIndexes(), + [], + $matchesType->isList() + ); + } + + return new ClosureType( + [ + new NativeParameterReflection($parameter->getName(), $parameter->isOptional(), $matchesType, $parameter->passedByReference(), $parameter->isVariadic(), $parameter->getDefaultValue()), + ], + new StringType() + ); + } +} diff --git a/vendor/vendor/composer/pcre/src/PHPStan/UnsafeStrictGroupsCallRule.php b/vendor/vendor/composer/pcre/src/PHPStan/UnsafeStrictGroupsCallRule.php new file mode 100644 index 0000000..5bced50 --- /dev/null +++ b/vendor/vendor/composer/pcre/src/PHPStan/UnsafeStrictGroupsCallRule.php @@ -0,0 +1,112 @@ + + */ +final class UnsafeStrictGroupsCallRule implements Rule +{ + /** + * @var RegexArrayShapeMatcher + */ + private $regexShapeMatcher; + + public function __construct(RegexArrayShapeMatcher $regexShapeMatcher) + { + $this->regexShapeMatcher = $regexShapeMatcher; + } + + public function getNodeType(): string + { + return StaticCall::class; + } + + public function processNode(Node $node, Scope $scope): array + { + if (!$node->class instanceof FullyQualified) { + return []; + } + $isRegex = $node->class->toString() === Regex::class; + $isPreg = $node->class->toString() === Preg::class; + if (!$isRegex && !$isPreg) { + return []; + } + if (!$node->name instanceof Node\Identifier || !in_array($node->name->name, ['matchStrictGroups', 'isMatchStrictGroups', 'matchAllStrictGroups', 'isMatchAllStrictGroups'], true)) { + return []; + } + + $args = $node->getArgs(); + if (!isset($args[0])) { + return []; + } + + $patternArg = $args[0] ?? null; + if ($isPreg) { + if (!isset($args[2])) { // no matches set, skip as the matches won't be used anyway + return []; + } + $flagsArg = $args[3] ?? null; + } else { + $flagsArg = $args[2] ?? null; + } + + if ($patternArg === null) { + return []; + } + + $flagsType = PregMatchFlags::getType($flagsArg, $scope); + if ($flagsType === null) { + return []; + } + + $matchedType = $this->regexShapeMatcher->matchExpr($patternArg->value, $flagsType, TrinaryLogic::createYes(), $scope); + if ($matchedType === null) { + return [ + RuleErrorBuilder::message(sprintf('The %s call is potentially unsafe as $matches\' type could not be inferred.', $node->name->name)) + ->identifier('composerPcre.maybeUnsafeStrictGroups') + ->build(), + ]; + } + + if (count($matchedType->getConstantArrays()) === 1) { + $matchedType = $matchedType->getConstantArrays()[0]; + $nullableGroups = []; + foreach ($matchedType->getValueTypes() as $index => $type) { + if (TypeCombinator::containsNull($type)) { + $nullableGroups[] = $matchedType->getKeyTypes()[$index]->getValue(); + } + } + + if (\count($nullableGroups) > 0) { + return [ + RuleErrorBuilder::message(sprintf( + 'The %s call is unsafe as match group%s "%s" %s optional and may be null.', + $node->name->name, + \count($nullableGroups) > 1 ? 's' : '', + implode('", "', $nullableGroups), + \count($nullableGroups) > 1 ? 'are' : 'is' + ))->identifier('composerPcre.unsafeStrictGroups')->build(), + ]; + } + } + + return []; + } +} diff --git a/vendor/vendor/composer/pcre/src/PcreException.php b/vendor/vendor/composer/pcre/src/PcreException.php new file mode 100644 index 0000000..23d9327 --- /dev/null +++ b/vendor/vendor/composer/pcre/src/PcreException.php @@ -0,0 +1,55 @@ + + * + * For the full copyright and license information, please view + * the LICENSE file that was distributed with this source code. + */ + +namespace Composer\Pcre; + +class PcreException extends \RuntimeException +{ + /** + * @param string $function + * @param string|string[] $pattern + * @return self + */ + public static function fromFunction($function, $pattern) + { + $code = preg_last_error(); + + if (is_array($pattern)) { + $pattern = implode(', ', $pattern); + } + + return new PcreException($function.'(): failed executing "'.$pattern.'": '.self::pcreLastErrorMessage($code), $code); + } + + /** + * @param int $code + * @return string + */ + private static function pcreLastErrorMessage($code) + { + if (function_exists('preg_last_error_msg')) { + return preg_last_error_msg(); + } + + $constants = get_defined_constants(true); + if (!isset($constants['pcre']) || !is_array($constants['pcre'])) { + return 'UNDEFINED_ERROR'; + } + + foreach ($constants['pcre'] as $const => $val) { + if ($val === $code && substr($const, -6) === '_ERROR') { + return $const; + } + } + + return 'UNDEFINED_ERROR'; + } +} diff --git a/vendor/vendor/composer/pcre/src/Preg.php b/vendor/vendor/composer/pcre/src/Preg.php new file mode 100644 index 0000000..400abbf --- /dev/null +++ b/vendor/vendor/composer/pcre/src/Preg.php @@ -0,0 +1,430 @@ + + * + * For the full copyright and license information, please view + * the LICENSE file that was distributed with this source code. + */ + +namespace Composer\Pcre; + +class Preg +{ + /** @internal */ + public const ARRAY_MSG = '$subject as an array is not supported. You can use \'foreach\' instead.'; + /** @internal */ + public const INVALID_TYPE_MSG = '$subject must be a string, %s given.'; + + /** + * @param non-empty-string $pattern + * @param array $matches Set by method + * @param int-mask $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported + * @return 0|1 + * + * @param-out array $matches + */ + public static function match(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0): int + { + self::checkOffsetCapture($flags, 'matchWithOffsets'); + + $result = preg_match($pattern, $subject, $matches, $flags | PREG_UNMATCHED_AS_NULL, $offset); + if ($result === false) { + throw PcreException::fromFunction('preg_match', $pattern); + } + + return $result; + } + + /** + * Variant of `match()` which outputs non-null matches (or throws) + * + * @param non-empty-string $pattern + * @param array $matches Set by method + * @param int-mask $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported + * @return 0|1 + * @throws UnexpectedNullMatchException + * + * @param-out array $matches + */ + public static function matchStrictGroups(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0): int + { + $result = self::match($pattern, $subject, $matchesInternal, $flags, $offset); + $matches = self::enforceNonNullMatches($pattern, $matchesInternal, 'match'); + + return $result; + } + + /** + * Runs preg_match with PREG_OFFSET_CAPTURE + * + * @param non-empty-string $pattern + * @param array $matches Set by method + * @param int-mask $flags PREG_UNMATCHED_AS_NULL and PREG_OFFSET_CAPTURE are always set, no other flags are supported + * @return 0|1 + * + * @param-out array}> $matches + */ + public static function matchWithOffsets(string $pattern, string $subject, ?array &$matches, int $flags = 0, int $offset = 0): int + { + $result = preg_match($pattern, $subject, $matches, $flags | PREG_UNMATCHED_AS_NULL | PREG_OFFSET_CAPTURE, $offset); + if ($result === false) { + throw PcreException::fromFunction('preg_match', $pattern); + } + + return $result; + } + + /** + * @param non-empty-string $pattern + * @param array $matches Set by method + * @param int-mask $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported + * @return 0|positive-int + * + * @param-out array> $matches + */ + public static function matchAll(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0): int + { + self::checkOffsetCapture($flags, 'matchAllWithOffsets'); + self::checkSetOrder($flags); + + $result = preg_match_all($pattern, $subject, $matches, $flags | PREG_UNMATCHED_AS_NULL, $offset); + if (!is_int($result)) { // PHP < 8 may return null, 8+ returns int|false + throw PcreException::fromFunction('preg_match_all', $pattern); + } + + return $result; + } + + /** + * Variant of `match()` which outputs non-null matches (or throws) + * + * @param non-empty-string $pattern + * @param array $matches Set by method + * @param int-mask $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported + * @return 0|positive-int + * @throws UnexpectedNullMatchException + * + * @param-out array> $matches + */ + public static function matchAllStrictGroups(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0): int + { + $result = self::matchAll($pattern, $subject, $matchesInternal, $flags, $offset); + $matches = self::enforceNonNullMatchAll($pattern, $matchesInternal, 'matchAll'); + + return $result; + } + + /** + * Runs preg_match_all with PREG_OFFSET_CAPTURE + * + * @param non-empty-string $pattern + * @param array $matches Set by method + * @param int-mask $flags PREG_UNMATCHED_AS_NULL and PREG_MATCH_OFFSET are always set, no other flags are supported + * @return 0|positive-int + * + * @param-out array}>> $matches + */ + public static function matchAllWithOffsets(string $pattern, string $subject, ?array &$matches, int $flags = 0, int $offset = 0): int + { + self::checkSetOrder($flags); + + $result = preg_match_all($pattern, $subject, $matches, $flags | PREG_UNMATCHED_AS_NULL | PREG_OFFSET_CAPTURE, $offset); + if (!is_int($result)) { // PHP < 8 may return null, 8+ returns int|false + throw PcreException::fromFunction('preg_match_all', $pattern); + } + + return $result; + } + + /** + * @param string|string[] $pattern + * @param string|string[] $replacement + * @param string $subject + * @param int $count Set by method + * + * @param-out int<0, max> $count + */ + public static function replace($pattern, $replacement, $subject, int $limit = -1, ?int &$count = null): string + { + if (!is_scalar($subject)) { + if (is_array($subject)) { + throw new \InvalidArgumentException(static::ARRAY_MSG); + } + + throw new \TypeError(sprintf(static::INVALID_TYPE_MSG, gettype($subject))); + } + + $result = preg_replace($pattern, $replacement, $subject, $limit, $count); + if ($result === null) { + throw PcreException::fromFunction('preg_replace', $pattern); + } + + return $result; + } + + /** + * @param string|string[] $pattern + * @param ($flags is PREG_OFFSET_CAPTURE ? (callable(array}>): string) : callable(array): string) $replacement + * @param string $subject + * @param int $count Set by method + * @param int-mask $flags PREG_OFFSET_CAPTURE is supported, PREG_UNMATCHED_AS_NULL is always set + * + * @param-out int<0, max> $count + */ + public static function replaceCallback($pattern, callable $replacement, $subject, int $limit = -1, ?int &$count = null, int $flags = 0): string + { + if (!is_scalar($subject)) { + if (is_array($subject)) { + throw new \InvalidArgumentException(static::ARRAY_MSG); + } + + throw new \TypeError(sprintf(static::INVALID_TYPE_MSG, gettype($subject))); + } + + $result = preg_replace_callback($pattern, $replacement, $subject, $limit, $count, $flags | PREG_UNMATCHED_AS_NULL); + if ($result === null) { + throw PcreException::fromFunction('preg_replace_callback', $pattern); + } + + return $result; + } + + /** + * Variant of `replaceCallback()` which outputs non-null matches (or throws) + * + * @param string $pattern + * @param ($flags is PREG_OFFSET_CAPTURE ? (callable(array}>): string) : callable(array): string) $replacement + * @param string $subject + * @param int $count Set by method + * @param int-mask $flags PREG_OFFSET_CAPTURE is supported, PREG_UNMATCHED_AS_NULL is always set + * + * @param-out int<0, max> $count + */ + public static function replaceCallbackStrictGroups(string $pattern, callable $replacement, $subject, int $limit = -1, ?int &$count = null, int $flags = 0): string + { + return self::replaceCallback($pattern, function (array $matches) use ($pattern, $replacement) { + return $replacement(self::enforceNonNullMatches($pattern, $matches, 'replaceCallback')); + }, $subject, $limit, $count, $flags); + } + + /** + * @param ($flags is PREG_OFFSET_CAPTURE ? (array}>): string>) : array): string>) $pattern + * @param string $subject + * @param int $count Set by method + * @param int-mask $flags PREG_OFFSET_CAPTURE is supported, PREG_UNMATCHED_AS_NULL is always set + * + * @param-out int<0, max> $count + */ + public static function replaceCallbackArray(array $pattern, $subject, int $limit = -1, ?int &$count = null, int $flags = 0): string + { + if (!is_scalar($subject)) { + if (is_array($subject)) { + throw new \InvalidArgumentException(static::ARRAY_MSG); + } + + throw new \TypeError(sprintf(static::INVALID_TYPE_MSG, gettype($subject))); + } + + $result = preg_replace_callback_array($pattern, $subject, $limit, $count, $flags | PREG_UNMATCHED_AS_NULL); + if ($result === null) { + $pattern = array_keys($pattern); + throw PcreException::fromFunction('preg_replace_callback_array', $pattern); + } + + return $result; + } + + /** + * @param int-mask $flags PREG_SPLIT_NO_EMPTY or PREG_SPLIT_DELIM_CAPTURE + * @return list + */ + public static function split(string $pattern, string $subject, int $limit = -1, int $flags = 0): array + { + if (($flags & PREG_SPLIT_OFFSET_CAPTURE) !== 0) { + throw new \InvalidArgumentException('PREG_SPLIT_OFFSET_CAPTURE is not supported as it changes the type of $matches, use splitWithOffsets() instead'); + } + + $result = preg_split($pattern, $subject, $limit, $flags); + if ($result === false) { + throw PcreException::fromFunction('preg_split', $pattern); + } + + return $result; + } + + /** + * @param int-mask $flags PREG_SPLIT_NO_EMPTY or PREG_SPLIT_DELIM_CAPTURE, PREG_SPLIT_OFFSET_CAPTURE is always set + * @return list + * @phpstan-return list}> + */ + public static function splitWithOffsets(string $pattern, string $subject, int $limit = -1, int $flags = 0): array + { + $result = preg_split($pattern, $subject, $limit, $flags | PREG_SPLIT_OFFSET_CAPTURE); + if ($result === false) { + throw PcreException::fromFunction('preg_split', $pattern); + } + + return $result; + } + + /** + * @template T of string|\Stringable + * @param string $pattern + * @param array $array + * @param int-mask $flags PREG_GREP_INVERT + * @return array + */ + public static function grep(string $pattern, array $array, int $flags = 0): array + { + $result = preg_grep($pattern, $array, $flags); + if ($result === false) { + throw PcreException::fromFunction('preg_grep', $pattern); + } + + return $result; + } + + /** + * Variant of match() which returns a bool instead of int + * + * @param non-empty-string $pattern + * @param array $matches Set by method + * @param int-mask $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported + * + * @param-out array $matches + */ + public static function isMatch(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0): bool + { + return (bool) static::match($pattern, $subject, $matches, $flags, $offset); + } + + /** + * Variant of `isMatch()` which outputs non-null matches (or throws) + * + * @param non-empty-string $pattern + * @param array $matches Set by method + * @param int-mask $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported + * @throws UnexpectedNullMatchException + * + * @param-out array $matches + */ + public static function isMatchStrictGroups(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0): bool + { + return (bool) self::matchStrictGroups($pattern, $subject, $matches, $flags, $offset); + } + + /** + * Variant of matchAll() which returns a bool instead of int + * + * @param non-empty-string $pattern + * @param array $matches Set by method + * @param int-mask $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported + * + * @param-out array> $matches + */ + public static function isMatchAll(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0): bool + { + return (bool) static::matchAll($pattern, $subject, $matches, $flags, $offset); + } + + /** + * Variant of `isMatchAll()` which outputs non-null matches (or throws) + * + * @param non-empty-string $pattern + * @param array $matches Set by method + * @param int-mask $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported + * + * @param-out array> $matches + */ + public static function isMatchAllStrictGroups(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0): bool + { + return (bool) self::matchAllStrictGroups($pattern, $subject, $matches, $flags, $offset); + } + + /** + * Variant of matchWithOffsets() which returns a bool instead of int + * + * Runs preg_match with PREG_OFFSET_CAPTURE + * + * @param non-empty-string $pattern + * @param array $matches Set by method + * @param int-mask $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported + * + * @param-out array}> $matches + */ + public static function isMatchWithOffsets(string $pattern, string $subject, ?array &$matches, int $flags = 0, int $offset = 0): bool + { + return (bool) static::matchWithOffsets($pattern, $subject, $matches, $flags, $offset); + } + + /** + * Variant of matchAllWithOffsets() which returns a bool instead of int + * + * Runs preg_match_all with PREG_OFFSET_CAPTURE + * + * @param non-empty-string $pattern + * @param array $matches Set by method + * @param int-mask $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported + * + * @param-out array}>> $matches + */ + public static function isMatchAllWithOffsets(string $pattern, string $subject, ?array &$matches, int $flags = 0, int $offset = 0): bool + { + return (bool) static::matchAllWithOffsets($pattern, $subject, $matches, $flags, $offset); + } + + private static function checkOffsetCapture(int $flags, string $useFunctionName): void + { + if (($flags & PREG_OFFSET_CAPTURE) !== 0) { + throw new \InvalidArgumentException('PREG_OFFSET_CAPTURE is not supported as it changes the type of $matches, use ' . $useFunctionName . '() instead'); + } + } + + private static function checkSetOrder(int $flags): void + { + if (($flags & PREG_SET_ORDER) !== 0) { + throw new \InvalidArgumentException('PREG_SET_ORDER is not supported as it changes the type of $matches'); + } + } + + /** + * @param array $matches + * @return array + * @throws UnexpectedNullMatchException + */ + private static function enforceNonNullMatches(string $pattern, array $matches, string $variantMethod) + { + foreach ($matches as $group => $match) { + if (is_string($match) || (is_array($match) && is_string($match[0]))) { + continue; + } + + throw new UnexpectedNullMatchException('Pattern "'.$pattern.'" had an unexpected unmatched group "'.$group.'", make sure the pattern always matches or use '.$variantMethod.'() instead.'); + } + + /** @var array */ + return $matches; + } + + /** + * @param array> $matches + * @return array> + * @throws UnexpectedNullMatchException + */ + private static function enforceNonNullMatchAll(string $pattern, array $matches, string $variantMethod) + { + foreach ($matches as $group => $groupMatches) { + foreach ($groupMatches as $match) { + if (null === $match) { + throw new UnexpectedNullMatchException('Pattern "'.$pattern.'" had an unexpected unmatched group "'.$group.'", make sure the pattern always matches or use '.$variantMethod.'() instead.'); + } + } + } + + /** @var array> */ + return $matches; + } +} diff --git a/vendor/vendor/composer/pcre/src/Regex.php b/vendor/vendor/composer/pcre/src/Regex.php new file mode 100644 index 0000000..038cf06 --- /dev/null +++ b/vendor/vendor/composer/pcre/src/Regex.php @@ -0,0 +1,176 @@ + + * + * For the full copyright and license information, please view + * the LICENSE file that was distributed with this source code. + */ + +namespace Composer\Pcre; + +class Regex +{ + /** + * @param non-empty-string $pattern + */ + public static function isMatch(string $pattern, string $subject, int $offset = 0): bool + { + return (bool) Preg::match($pattern, $subject, $matches, 0, $offset); + } + + /** + * @param non-empty-string $pattern + * @param int-mask $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported + */ + public static function match(string $pattern, string $subject, int $flags = 0, int $offset = 0): MatchResult + { + self::checkOffsetCapture($flags, 'matchWithOffsets'); + + $count = Preg::match($pattern, $subject, $matches, $flags, $offset); + + return new MatchResult($count, $matches); + } + + /** + * Variant of `match()` which returns non-null matches (or throws) + * + * @param non-empty-string $pattern + * @param int-mask $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported + * @throws UnexpectedNullMatchException + */ + public static function matchStrictGroups(string $pattern, string $subject, int $flags = 0, int $offset = 0): MatchStrictGroupsResult + { + // @phpstan-ignore composerPcre.maybeUnsafeStrictGroups + $count = Preg::matchStrictGroups($pattern, $subject, $matches, $flags, $offset); + + return new MatchStrictGroupsResult($count, $matches); + } + + /** + * Runs preg_match with PREG_OFFSET_CAPTURE + * + * @param non-empty-string $pattern + * @param int-mask $flags PREG_UNMATCHED_AS_NULL and PREG_MATCH_OFFSET are always set, no other flags are supported + */ + public static function matchWithOffsets(string $pattern, string $subject, int $flags = 0, int $offset = 0): MatchWithOffsetsResult + { + $count = Preg::matchWithOffsets($pattern, $subject, $matches, $flags, $offset); + + return new MatchWithOffsetsResult($count, $matches); + } + + /** + * @param non-empty-string $pattern + * @param int-mask $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported + */ + public static function matchAll(string $pattern, string $subject, int $flags = 0, int $offset = 0): MatchAllResult + { + self::checkOffsetCapture($flags, 'matchAllWithOffsets'); + self::checkSetOrder($flags); + + $count = Preg::matchAll($pattern, $subject, $matches, $flags, $offset); + + return new MatchAllResult($count, $matches); + } + + /** + * Variant of `matchAll()` which returns non-null matches (or throws) + * + * @param non-empty-string $pattern + * @param int-mask $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported + * @throws UnexpectedNullMatchException + */ + public static function matchAllStrictGroups(string $pattern, string $subject, int $flags = 0, int $offset = 0): MatchAllStrictGroupsResult + { + self::checkOffsetCapture($flags, 'matchAllWithOffsets'); + self::checkSetOrder($flags); + + // @phpstan-ignore composerPcre.maybeUnsafeStrictGroups + $count = Preg::matchAllStrictGroups($pattern, $subject, $matches, $flags, $offset); + + return new MatchAllStrictGroupsResult($count, $matches); + } + + /** + * Runs preg_match_all with PREG_OFFSET_CAPTURE + * + * @param non-empty-string $pattern + * @param int-mask $flags PREG_UNMATCHED_AS_NULL and PREG_MATCH_OFFSET are always set, no other flags are supported + */ + public static function matchAllWithOffsets(string $pattern, string $subject, int $flags = 0, int $offset = 0): MatchAllWithOffsetsResult + { + self::checkSetOrder($flags); + + $count = Preg::matchAllWithOffsets($pattern, $subject, $matches, $flags, $offset); + + return new MatchAllWithOffsetsResult($count, $matches); + } + /** + * @param string|string[] $pattern + * @param string|string[] $replacement + * @param string $subject + */ + public static function replace($pattern, $replacement, $subject, int $limit = -1): ReplaceResult + { + $result = Preg::replace($pattern, $replacement, $subject, $limit, $count); + + return new ReplaceResult($count, $result); + } + + /** + * @param string|string[] $pattern + * @param ($flags is PREG_OFFSET_CAPTURE ? (callable(array}>): string) : callable(array): string) $replacement + * @param string $subject + * @param int-mask $flags PREG_OFFSET_CAPTURE is supported, PREG_UNMATCHED_AS_NULL is always set + */ + public static function replaceCallback($pattern, callable $replacement, $subject, int $limit = -1, int $flags = 0): ReplaceResult + { + $result = Preg::replaceCallback($pattern, $replacement, $subject, $limit, $count, $flags); + + return new ReplaceResult($count, $result); + } + + /** + * Variant of `replaceCallback()` which outputs non-null matches (or throws) + * + * @param string $pattern + * @param ($flags is PREG_OFFSET_CAPTURE ? (callable(array}>): string) : callable(array): string) $replacement + * @param string $subject + * @param int-mask $flags PREG_OFFSET_CAPTURE is supported, PREG_UNMATCHED_AS_NULL is always set + */ + public static function replaceCallbackStrictGroups($pattern, callable $replacement, $subject, int $limit = -1, int $flags = 0): ReplaceResult + { + $result = Preg::replaceCallbackStrictGroups($pattern, $replacement, $subject, $limit, $count, $flags); + + return new ReplaceResult($count, $result); + } + + /** + * @param ($flags is PREG_OFFSET_CAPTURE ? (array}>): string>) : array): string>) $pattern + * @param string $subject + * @param int-mask $flags PREG_OFFSET_CAPTURE is supported, PREG_UNMATCHED_AS_NULL is always set + */ + public static function replaceCallbackArray(array $pattern, $subject, int $limit = -1, int $flags = 0): ReplaceResult + { + $result = Preg::replaceCallbackArray($pattern, $subject, $limit, $count, $flags); + + return new ReplaceResult($count, $result); + } + + private static function checkOffsetCapture(int $flags, string $useFunctionName): void + { + if (($flags & PREG_OFFSET_CAPTURE) !== 0) { + throw new \InvalidArgumentException('PREG_OFFSET_CAPTURE is not supported as it changes the return type, use '.$useFunctionName.'() instead'); + } + } + + private static function checkSetOrder(int $flags): void + { + if (($flags & PREG_SET_ORDER) !== 0) { + throw new \InvalidArgumentException('PREG_SET_ORDER is not supported as it changes the return type'); + } + } +} diff --git a/vendor/vendor/composer/pcre/src/ReplaceResult.php b/vendor/vendor/composer/pcre/src/ReplaceResult.php new file mode 100644 index 0000000..3384771 --- /dev/null +++ b/vendor/vendor/composer/pcre/src/ReplaceResult.php @@ -0,0 +1,43 @@ + + * + * For the full copyright and license information, please view + * the LICENSE file that was distributed with this source code. + */ + +namespace Composer\Pcre; + +final class ReplaceResult +{ + /** + * @readonly + * @var string + */ + public $result; + + /** + * @readonly + * @var 0|positive-int + */ + public $count; + + /** + * @readonly + * @var bool + */ + public $matched; + + /** + * @param 0|positive-int $count + */ + public function __construct(int $count, string $result) + { + $this->count = $count; + $this->matched = (bool) $count; + $this->result = $result; + } +} diff --git a/vendor/vendor/composer/pcre/src/UnexpectedNullMatchException.php b/vendor/vendor/composer/pcre/src/UnexpectedNullMatchException.php new file mode 100644 index 0000000..f123828 --- /dev/null +++ b/vendor/vendor/composer/pcre/src/UnexpectedNullMatchException.php @@ -0,0 +1,20 @@ + + * + * For the full copyright and license information, please view + * the LICENSE file that was distributed with this source code. + */ + +namespace Composer\Pcre; + +class UnexpectedNullMatchException extends PcreException +{ + public static function fromFunction($function, $pattern) + { + throw new \LogicException('fromFunction should not be called on '.self::class.', use '.PcreException::class); + } +} diff --git a/vendor/vendor/composer/platform_check.php b/vendor/vendor/composer/platform_check.php new file mode 100644 index 0000000..580fa96 --- /dev/null +++ b/vendor/vendor/composer/platform_check.php @@ -0,0 +1,26 @@ += 70400)) { + $issues[] = 'Your Composer dependencies require a PHP version ">= 7.4.0". You are running ' . PHP_VERSION . '.'; +} + +if ($issues) { + if (!headers_sent()) { + header('HTTP/1.1 500 Internal Server Error'); + } + if (!ini_get('display_errors')) { + if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') { + fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, $issues) . PHP_EOL.PHP_EOL); + } elseif (!headers_sent()) { + echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)) . PHP_EOL.PHP_EOL; + } + } + trigger_error( + 'Composer detected issues in your platform: ' . implode(' ', $issues), + E_USER_ERROR + ); +} diff --git a/vendor/vendor/easywechat-composer/easywechat-composer/.gitignore b/vendor/vendor/easywechat-composer/easywechat-composer/.gitignore new file mode 100644 index 0000000..c7a0a65 --- /dev/null +++ b/vendor/vendor/easywechat-composer/easywechat-composer/.gitignore @@ -0,0 +1,5 @@ +.idea/ +/vendor +composer.lock +extensions.php +.php_cs.cache diff --git a/vendor/vendor/easywechat-composer/easywechat-composer/.php_cs b/vendor/vendor/easywechat-composer/easywechat-composer/.php_cs new file mode 100644 index 0000000..d256932 --- /dev/null +++ b/vendor/vendor/easywechat-composer/easywechat-composer/.php_cs @@ -0,0 +1,29 @@ + + +This source file is subject to the MIT license that is bundled +with this source code in the file LICENSE. +EOF; + +return PhpCsFixer\Config::create() + ->setRiskyAllowed(true) + ->setRules([ + '@Symfony' => true, + 'header_comment' => ['header' => $header], + 'declare_strict_types' => true, + 'ordered_imports' => true, + 'strict_comparison' => true, + 'no_empty_comment' => false, + 'yoda_style' => false, + ]) + ->setFinder( + PhpCsFixer\Finder::create() + ->exclude('vendor') + ->notPath('src/Laravel/config.php', 'src/Laravel/routes.php') + ->in(__DIR__) + ) +; diff --git a/vendor/vendor/easywechat-composer/easywechat-composer/.travis.yml b/vendor/vendor/easywechat-composer/easywechat-composer/.travis.yml new file mode 100644 index 0000000..e819807 --- /dev/null +++ b/vendor/vendor/easywechat-composer/easywechat-composer/.travis.yml @@ -0,0 +1,12 @@ +language: php + +php: + - 7.0 + - 7.1 + - 7.2 + - 7.3 + +install: + - travis_retry composer install --no-interaction --no-suggest + +script: ./vendor/bin/phpunit diff --git a/vendor/vendor/easywechat-composer/easywechat-composer/LICENSE b/vendor/vendor/easywechat-composer/easywechat-composer/LICENSE new file mode 100644 index 0000000..3559904 --- /dev/null +++ b/vendor/vendor/easywechat-composer/easywechat-composer/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 张铭阳 + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/vendor/vendor/easywechat-composer/easywechat-composer/README.md b/vendor/vendor/easywechat-composer/easywechat-composer/README.md new file mode 100644 index 0000000..a08c1be --- /dev/null +++ b/vendor/vendor/easywechat-composer/easywechat-composer/README.md @@ -0,0 +1,55 @@ +

    +

    EasyWeChat Composer Plugin

    +

    + +

    + Build Status + Scrutinizer Code Quality + Latest Stable Version + Total Downloads + License +

    + +Usage +--- + +Set the `type` to be `easywechat-extension` in your package composer.json file: + +```json +{ + "name": "your/package", + "type": "easywechat-extension" +} +``` + +Specify server observer classes in the extra section: + +```json +{ + "name": "your/package", + "type": "easywechat-extension", + "extra": { + "observers": [ + "Acme\\Observers\\Handler" + ] + } +} +``` + +Examples +--- +* [easywechat-composer/open-platform-testcase](https://github.com/mingyoung/open-platform-testcase) + +Server Delegation +--- + +> 目前仅支持 Laravel + +1. 在 `config/app.php` 中添加 `EasyWeChatComposer\Laravel\ServiceProvider::class` + +2. 在**本地项目**的 `.env` 文件中添加如下配置: + +``` +EASYWECHAT_DELEGATION=true # false 则不启用 +EASYWECHAT_DELEGATION_HOST=https://example.com # 线上域名 +``` diff --git a/vendor/vendor/easywechat-composer/easywechat-composer/composer.json b/vendor/vendor/easywechat-composer/easywechat-composer/composer.json new file mode 100644 index 0000000..32d7c94 --- /dev/null +++ b/vendor/vendor/easywechat-composer/easywechat-composer/composer.json @@ -0,0 +1,35 @@ +{ + "name": "easywechat-composer/easywechat-composer", + "description": "The composer plugin for EasyWeChat", + "type": "composer-plugin", + "license": "MIT", + "authors": [ + { + "name": "张铭阳", + "email": "mingyoungcheung@gmail.com" + } + ], + "require": { + "php": ">=7.0", + "composer-plugin-api": "^1.0 || ^2.0" + }, + "require-dev": { + "composer/composer": "^1.0 || ^2.0", + "phpunit/phpunit": "^6.5 || ^7.0" + }, + "autoload": { + "psr-4": { + "EasyWeChatComposer\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "EasyWeChatComposer\\Tests\\": "tests/" + } + }, + "extra": { + "class": "EasyWeChatComposer\\Plugin" + }, + "minimum-stability": "dev", + "prefer-stable": true +} diff --git a/vendor/vendor/easywechat-composer/easywechat-composer/phpunit.xml b/vendor/vendor/easywechat-composer/easywechat-composer/phpunit.xml new file mode 100644 index 0000000..361d92c --- /dev/null +++ b/vendor/vendor/easywechat-composer/easywechat-composer/phpunit.xml @@ -0,0 +1,20 @@ + + + + tests + + + + + src + + + diff --git a/vendor/vendor/easywechat-composer/easywechat-composer/src/Commands/ExtensionsCommand.php b/vendor/vendor/easywechat-composer/easywechat-composer/src/Commands/ExtensionsCommand.php new file mode 100644 index 0000000..bc0155e --- /dev/null +++ b/vendor/vendor/easywechat-composer/easywechat-composer/src/Commands/ExtensionsCommand.php @@ -0,0 +1,63 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChatComposer\Commands; + +use Composer\Command\BaseCommand; +use Symfony\Component\Console\Helper\Table; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; + +class ExtensionsCommand extends BaseCommand +{ + /** + * Configures the current command. + */ + protected function configure() + { + $this->setName('easywechat:extensions') + ->setDescription('Lists all installed extensions.'); + } + + /** + * Executes the current command. + * + * @param InputInterface $input + * @param OutputInterface $output + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + $extensions = require __DIR__.'/../../extensions.php'; + + if (empty($extensions) || !is_array($extensions)) { + return $output->writeln('No extension installed.'); + } + + $table = new Table($output); + $table->setHeaders(['Name', 'Observers']) + ->setRows( + array_map([$this, 'getRows'], array_keys($extensions), $extensions) + )->render(); + } + + /** + * @param string $name + * @param array $extension + * + * @return array + */ + protected function getRows($name, $extension) + { + return [$name, implode("\n", $extension['observers'] ?? [])]; + } +} diff --git a/vendor/vendor/easywechat-composer/easywechat-composer/src/Commands/Provider.php b/vendor/vendor/easywechat-composer/easywechat-composer/src/Commands/Provider.php new file mode 100644 index 0000000..928f096 --- /dev/null +++ b/vendor/vendor/easywechat-composer/easywechat-composer/src/Commands/Provider.php @@ -0,0 +1,31 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChatComposer\Commands; + +use Composer\Plugin\Capability\CommandProvider; + +class Provider implements CommandProvider +{ + /** + * Retrieves an array of commands. + * + * @return \Composer\Command\BaseCommand[] + */ + public function getCommands() + { + return [ + new ExtensionsCommand(), + ]; + } +} diff --git a/vendor/vendor/easywechat-composer/easywechat-composer/src/Contracts/Encrypter.php b/vendor/vendor/easywechat-composer/easywechat-composer/src/Contracts/Encrypter.php new file mode 100644 index 0000000..af8b8d1 --- /dev/null +++ b/vendor/vendor/easywechat-composer/easywechat-composer/src/Contracts/Encrypter.php @@ -0,0 +1,35 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChatComposer\Contracts; + +interface Encrypter +{ + /** + * Encrypt the given value. + * + * @param string $value + * + * @return string + */ + public function encrypt($value); + + /** + * Decrypt the given value. + * + * @param string $payload + * + * @return string + */ + public function decrypt($payload); +} diff --git a/vendor/vendor/easywechat-composer/easywechat-composer/src/Delegation/DelegationOptions.php b/vendor/vendor/easywechat-composer/easywechat-composer/src/Delegation/DelegationOptions.php new file mode 100644 index 0000000..a333261 --- /dev/null +++ b/vendor/vendor/easywechat-composer/easywechat-composer/src/Delegation/DelegationOptions.php @@ -0,0 +1,80 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChatComposer\Delegation; + +use EasyWeChatComposer\EasyWeChat; + +class DelegationOptions +{ + /** + * @var array + */ + protected $config = [ + 'enabled' => false, + ]; + + /** + * @return $this + */ + public function enable() + { + $this->config['enabled'] = true; + + return $this; + } + + /** + * @return $this + */ + public function disable() + { + $this->config['enabled'] = false; + + return $this; + } + + /** + * @param bool $ability + * + * @return $this + */ + public function ability($ability) + { + $this->config['enabled'] = (bool) $ability; + + return $this; + } + + /** + * @param string $host + * + * @return $this + */ + public function toHost($host) + { + $this->config['host'] = $host; + + return $this; + } + + /** + * Destructor. + */ + public function __destruct() + { + EasyWeChat::mergeConfig([ + 'delegation' => $this->config, + ]); + } +} diff --git a/vendor/vendor/easywechat-composer/easywechat-composer/src/Delegation/DelegationTo.php b/vendor/vendor/easywechat-composer/easywechat-composer/src/Delegation/DelegationTo.php new file mode 100644 index 0000000..2e9e6db --- /dev/null +++ b/vendor/vendor/easywechat-composer/easywechat-composer/src/Delegation/DelegationTo.php @@ -0,0 +1,83 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChatComposer\Delegation; + +use EasyWeChatComposer\Traits\MakesHttpRequests; + +class DelegationTo +{ + use MakesHttpRequests; + + /** + * @var \EasyWeChat\Kernel\ServiceContainer + */ + protected $app; + + /** + * @var array + */ + protected $identifiers = []; + + /** + * @param \EasyWeChat\Kernel\ServiceContainer $app + * @param string $identifier + */ + public function __construct($app, $identifier) + { + $this->app = $app; + + $this->push($identifier); + } + + /** + * @param string $identifier + */ + public function push($identifier) + { + $this->identifiers[] = $identifier; + } + + /** + * @param string $identifier + * + * @return $this + */ + public function __get($identifier) + { + $this->push($identifier); + + return $this; + } + + /** + * @param string $method + * @param array $arguments + * + * @return mixed + */ + public function __call($method, $arguments) + { + $config = array_intersect_key($this->app->getConfig(), array_flip(['app_id', 'secret', 'token', 'aes_key', 'response_type', 'component_app_id', 'refresh_token'])); + + $data = [ + 'config' => $config, + 'application' => get_class($this->app), + 'identifiers' => $this->identifiers, + 'method' => $method, + 'arguments' => $arguments, + ]; + + return $this->request('easywechat-composer/delegate', $data); + } +} diff --git a/vendor/vendor/easywechat-composer/easywechat-composer/src/Delegation/Hydrate.php b/vendor/vendor/easywechat-composer/easywechat-composer/src/Delegation/Hydrate.php new file mode 100644 index 0000000..b83bbe9 --- /dev/null +++ b/vendor/vendor/easywechat-composer/easywechat-composer/src/Delegation/Hydrate.php @@ -0,0 +1,83 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChatComposer\Delegation; + +use EasyWeChat; +use EasyWeChatComposer\Http\DelegationResponse; + +class Hydrate +{ + /** + * @var array + */ + protected $attributes; + + /** + * @param array $attributes + */ + public function __construct(array $attributes) + { + $this->attributes = $attributes; + } + + /** + * @return array + */ + public function handle() + { + $app = $this->createsApplication()->shouldntDelegate(); + + foreach ($this->attributes['identifiers'] as $identifier) { + $app = $app->$identifier; + } + + return call_user_func_array([$app, $this->attributes['method']], $this->attributes['arguments']); + } + + /** + * @return \EasyWeChat\Kernel\ServiceContainer + */ + protected function createsApplication() + { + $application = $this->attributes['application']; + + if ($application === EasyWeChat\OpenPlatform\Authorizer\OfficialAccount\Application::class) { + return $this->createsOpenPlatformApplication('officialAccount'); + } + + if ($application === EasyWeChat\OpenPlatform\Authorizer\MiniProgram\Application::class) { + return $this->createsOpenPlatformApplication('miniProgram'); + } + + return new $application($this->buildConfig($this->attributes['config'])); + } + + protected function createsOpenPlatformApplication($type) + { + $config = $this->attributes['config']; + + $authorizerAppId = $config['app_id']; + + $config['app_id'] = $config['component_app_id']; + + return EasyWeChat\Factory::openPlatform($this->buildConfig($config))->$type($authorizerAppId, $config['refresh_token']); + } + + protected function buildConfig(array $config) + { + $config['response_type'] = DelegationResponse::class; + + return $config; + } +} diff --git a/vendor/vendor/easywechat-composer/easywechat-composer/src/EasyWeChat.php b/vendor/vendor/easywechat-composer/easywechat-composer/src/EasyWeChat.php new file mode 100644 index 0000000..4ff3d9b --- /dev/null +++ b/vendor/vendor/easywechat-composer/easywechat-composer/src/EasyWeChat.php @@ -0,0 +1,79 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChatComposer; + +use EasyWeChatComposer\Delegation\DelegationOptions; + +class EasyWeChat +{ + /** + * @var array + */ + protected static $config = []; + + /** + * Encryption key. + * + * @var string + */ + protected static $encryptionKey; + + /** + * @param array $config + */ + public static function mergeConfig(array $config) + { + static::$config = array_merge(static::$config, $config); + } + + /** + * @return array + */ + public static function config() + { + return static::$config; + } + + /** + * Set encryption key. + * + * @param string $key + * + * @return static + */ + public static function setEncryptionKey(string $key) + { + static::$encryptionKey = $key; + + return new static(); + } + + /** + * Get encryption key. + * + * @return string + */ + public static function getEncryptionKey(): string + { + return static::$encryptionKey; + } + + /** + * @return \EasyWeChatComposer\Delegation\DelegationOptions + */ + public static function withDelegation() + { + return new DelegationOptions(); + } +} diff --git a/vendor/vendor/easywechat-composer/easywechat-composer/src/Encryption/DefaultEncrypter.php b/vendor/vendor/easywechat-composer/easywechat-composer/src/Encryption/DefaultEncrypter.php new file mode 100644 index 0000000..2c4cd53 --- /dev/null +++ b/vendor/vendor/easywechat-composer/easywechat-composer/src/Encryption/DefaultEncrypter.php @@ -0,0 +1,89 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChatComposer\Encryption; + +use EasyWeChatComposer\Contracts\Encrypter; +use EasyWeChatComposer\Exceptions\DecryptException; +use EasyWeChatComposer\Exceptions\EncryptException; + +class DefaultEncrypter implements Encrypter +{ + /** + * @var string + */ + protected $key; + + /** + * @var string + */ + protected $cipher; + + /** + * @param string $key + * @param string $cipher + */ + public function __construct($key, $cipher = 'AES-256-CBC') + { + $this->key = $key; + $this->cipher = $cipher; + } + + /** + * Encrypt the given value. + * + * @param string $value + * + * @return string + * + * @throws \EasyWeChatComposer\Exceptions\EncryptException + */ + public function encrypt($value) + { + $iv = random_bytes(openssl_cipher_iv_length($this->cipher)); + + $value = openssl_encrypt($value, $this->cipher, $this->key, 0, $iv); + + if ($value === false) { + throw new EncryptException('Could not encrypt the data.'); + } + + $iv = base64_encode($iv); + + return base64_encode(json_encode(compact('iv', 'value'))); + } + + /** + * Decrypt the given value. + * + * @param string $payload + * + * @return string + * + * @throws \EasyWeChatComposer\Exceptions\DecryptException + */ + public function decrypt($payload) + { + $payload = json_decode(base64_decode($payload), true); + + $iv = base64_decode($payload['iv']); + + $decrypted = openssl_decrypt($payload['value'], $this->cipher, $this->key, 0, $iv); + + if ($decrypted === false) { + throw new DecryptException('Could not decrypt the data.'); + } + + return $decrypted; + } +} diff --git a/vendor/vendor/easywechat-composer/easywechat-composer/src/Exceptions/DecryptException.php b/vendor/vendor/easywechat-composer/easywechat-composer/src/Exceptions/DecryptException.php new file mode 100644 index 0000000..e210d1f --- /dev/null +++ b/vendor/vendor/easywechat-composer/easywechat-composer/src/Exceptions/DecryptException.php @@ -0,0 +1,21 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChatComposer\Exceptions; + +use Exception; + +class DecryptException extends Exception +{ + // +} diff --git a/vendor/vendor/easywechat-composer/easywechat-composer/src/Exceptions/DelegationException.php b/vendor/vendor/easywechat-composer/easywechat-composer/src/Exceptions/DelegationException.php new file mode 100644 index 0000000..0af9c2d --- /dev/null +++ b/vendor/vendor/easywechat-composer/easywechat-composer/src/Exceptions/DelegationException.php @@ -0,0 +1,42 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChatComposer\Exceptions; + +use Exception; + +class DelegationException extends Exception +{ + /** + * @var string + */ + protected $exception; + + /** + * @param string $exception + */ + public function setException($exception) + { + $this->exception = $exception; + + return $this; + } + + /** + * @return string + */ + public function getException() + { + return $this->exception; + } +} diff --git a/vendor/vendor/easywechat-composer/easywechat-composer/src/Exceptions/EncryptException.php b/vendor/vendor/easywechat-composer/easywechat-composer/src/Exceptions/EncryptException.php new file mode 100644 index 0000000..f88f8f4 --- /dev/null +++ b/vendor/vendor/easywechat-composer/easywechat-composer/src/Exceptions/EncryptException.php @@ -0,0 +1,21 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChatComposer\Exceptions; + +use Exception; + +class EncryptException extends Exception +{ + // +} diff --git a/vendor/vendor/easywechat-composer/easywechat-composer/src/Extension.php b/vendor/vendor/easywechat-composer/easywechat-composer/src/Extension.php new file mode 100644 index 0000000..6a521d1 --- /dev/null +++ b/vendor/vendor/easywechat-composer/easywechat-composer/src/Extension.php @@ -0,0 +1,143 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChatComposer; + +use EasyWeChat\Kernel\Contracts\EventHandlerInterface; +use Pimple\Container; +use ReflectionClass; + +class Extension +{ + /** + * @var \Pimple\Container + */ + protected $app; + + /** + * @var string + */ + protected $manifestPath; + + /** + * @var array|null + */ + protected $manifest; + + /** + * @param \Pimple\Container $app + */ + public function __construct(Container $app) + { + $this->app = $app; + $this->manifestPath = __DIR__.'/../extensions.php'; + } + + /** + * Get observers. + * + * @return array + */ + public function observers(): array + { + if ($this->shouldIgnore()) { + return []; + } + + $observers = []; + + foreach ($this->getManifest() as $name => $extra) { + $observers = array_merge($observers, $extra['observers'] ?? []); + } + + return array_map([$this, 'listObserver'], array_filter($observers, [$this, 'validateObserver'])); + } + + /** + * @param mixed $observer + * + * @return bool + */ + protected function isDisable($observer): bool + { + return in_array($observer, $this->app->config->get('disable_observers', [])); + } + + /** + * Get the observers should be ignore. + * + * @return bool + */ + protected function shouldIgnore(): bool + { + return !file_exists($this->manifestPath) || $this->isDisable('*'); + } + + /** + * Validate the given observer. + * + * @param mixed $observer + * + * @return bool + * + * @throws \ReflectionException + */ + protected function validateObserver($observer): bool + { + return !$this->isDisable($observer) + && (new ReflectionClass($observer))->implementsInterface(EventHandlerInterface::class) + && $this->accessible($observer); + } + + /** + * Determine whether the given observer is accessible. + * + * @param string $observer + * + * @return bool + */ + protected function accessible($observer): bool + { + if (!method_exists($observer, 'getAccessor')) { + return true; + } + + return in_array(get_class($this->app), (array) $observer::getAccessor()); + } + + /** + * @param mixed $observer + * + * @return array + */ + protected function listObserver($observer): array + { + $condition = method_exists($observer, 'onCondition') ? $observer::onCondition() : '*'; + + return [$observer, $condition]; + } + + /** + * Get the easywechat manifest. + * + * @return array + */ + protected function getManifest(): array + { + if (!is_null($this->manifest)) { + return $this->manifest; + } + + return $this->manifest = file_exists($this->manifestPath) ? require $this->manifestPath : []; + } +} diff --git a/vendor/vendor/easywechat-composer/easywechat-composer/src/Http/DelegationResponse.php b/vendor/vendor/easywechat-composer/easywechat-composer/src/Http/DelegationResponse.php new file mode 100644 index 0000000..329eb54 --- /dev/null +++ b/vendor/vendor/easywechat-composer/easywechat-composer/src/Http/DelegationResponse.php @@ -0,0 +1,25 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChatComposer\Http; + +class DelegationResponse extends Response +{ + /** + * @return string + */ + public function getBodyContents() + { + return $this->response->getBodyContents(); + } +} diff --git a/vendor/vendor/easywechat-composer/easywechat-composer/src/Http/Response.php b/vendor/vendor/easywechat-composer/easywechat-composer/src/Http/Response.php new file mode 100644 index 0000000..534bf54 --- /dev/null +++ b/vendor/vendor/easywechat-composer/easywechat-composer/src/Http/Response.php @@ -0,0 +1,104 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChatComposer\Http; + +use EasyWeChat\Kernel\Contracts\Arrayable; +use EasyWeChat\Kernel\Http\Response as HttpResponse; +use JsonSerializable; + +class Response implements Arrayable, JsonSerializable +{ + /** + * @var \EasyWeChat\Kernel\Http\Response + */ + protected $response; + + /** + * @var array + */ + protected $array; + + /** + * @param \EasyWeChat\Kernel\Http\Response $response + */ + public function __construct(HttpResponse $response) + { + $this->response = $response; + } + + /** + * @see \ArrayAccess::offsetExists + * + * @param string $offset + * + * @return bool + */ + public function offsetExists($offset) + { + return isset($this->toArray()[$offset]); + } + + /** + * @see \ArrayAccess::offsetGet + * + * @param string $offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return $this->toArray()[$offset] ?? null; + } + + /** + * @see \ArrayAccess::offsetSet + * + * @param string $offset + * @param mixed $value + */ + public function offsetSet($offset, $value) + { + // + } + + /** + * @see \ArrayAccess::offsetUnset + * + * @param string $offset + */ + public function offsetUnset($offset) + { + // + } + + /** + * Get the instance as an array. + * + * @return array + */ + public function toArray() + { + return $this->array ?: $this->array = $this->response->toArray(); + } + + /** + * Convert the object into something JSON serializable. + * + * @return array + */ + public function jsonSerialize() + { + return $this->toArray(); + } +} diff --git a/vendor/vendor/easywechat-composer/easywechat-composer/src/Laravel/Http/Controllers/DelegatesController.php b/vendor/vendor/easywechat-composer/easywechat-composer/src/Laravel/Http/Controllers/DelegatesController.php new file mode 100644 index 0000000..ad014d8 --- /dev/null +++ b/vendor/vendor/easywechat-composer/easywechat-composer/src/Laravel/Http/Controllers/DelegatesController.php @@ -0,0 +1,49 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChatComposer\Laravel\Http\Controllers; + +use EasyWeChatComposer\Delegation\Hydrate; +use EasyWeChatComposer\Encryption\DefaultEncrypter; +use Illuminate\Http\Request; +use Throwable; + +class DelegatesController +{ + /** + * @param \Illuminate\Http\Request $request + * @param \EasyWeChatComposer\Encryption\DefaultEncrypter $encrypter + * + * @return \Illuminate\Http\Response + */ + public function __invoke(Request $request, DefaultEncrypter $encrypter) + { + try { + $data = json_decode($encrypter->decrypt($request->get('encrypted')), true); + + $hydrate = new Hydrate($data); + + $response = $hydrate->handle(); + + return response()->json([ + 'response_type' => get_class($response), + 'response' => $encrypter->encrypt($response->getBodyContents()), + ]); + } catch (Throwable $t) { + return [ + 'exception' => get_class($t), + 'message' => $t->getMessage(), + ]; + } + } +} diff --git a/vendor/vendor/easywechat-composer/easywechat-composer/src/Laravel/ServiceProvider.php b/vendor/vendor/easywechat-composer/easywechat-composer/src/Laravel/ServiceProvider.php new file mode 100644 index 0000000..4c43b04 --- /dev/null +++ b/vendor/vendor/easywechat-composer/easywechat-composer/src/Laravel/ServiceProvider.php @@ -0,0 +1,116 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChatComposer\Laravel; + +use EasyWeChatComposer\EasyWeChat; +use EasyWeChatComposer\Encryption\DefaultEncrypter; +use Illuminate\Foundation\Application; +use Illuminate\Support\Arr; +use Illuminate\Support\Facades\Cache; +use Illuminate\Support\Facades\Route; +use Illuminate\Support\ServiceProvider as LaravelServiceProvider; +use RuntimeException; + +class ServiceProvider extends LaravelServiceProvider +{ + /** + * Bootstrap any application services. + */ + public function boot() + { + $this->registerRoutes(); + $this->publishes([ + __DIR__.'/config.php' => config_path('easywechat-composer.php'), + ]); + + EasyWeChat::setEncryptionKey( + $defaultKey = $this->getKey() + ); + + EasyWeChat::withDelegation() + ->toHost($this->config('delegation.host')) + ->ability($this->config('delegation.enabled')); + + $this->app->when(DefaultEncrypter::class)->needs('$key')->give($defaultKey); + } + + /** + * Register routes. + */ + protected function registerRoutes() + { + Route::prefix('easywechat-composer')->namespace('EasyWeChatComposer\Laravel\Http\Controllers')->group(function () { + $this->loadRoutesFrom(__DIR__.'/routes.php'); + }); + } + + /** + * Register any application services. + */ + public function register() + { + $this->configure(); + } + + /** + * Register config. + */ + protected function configure() + { + $this->mergeConfigFrom( + __DIR__.'/config.php', 'easywechat-composer' + ); + } + + /** + * Get the specified configuration value. + * + * @param string|null $key + * @param mixed $default + * + * @return mixed + */ + protected function config($key = null, $default = null) + { + $config = $this->app['config']->get('easywechat-composer'); + + if (is_null($key)) { + return $config; + } + + return Arr::get($config, $key, $default); + } + + /** + * @return string + */ + protected function getKey() + { + return $this->config('encryption.key') ?: $this->getMd5Key(); + } + + /** + * @return string + */ + protected function getMd5Key() + { + $ttl = (version_compare(Application::VERSION, '5.8') === -1) ? 30 : 1800; + + return Cache::remember('easywechat-composer.encryption_key', $ttl, function () { + throw_unless(file_exists($path = base_path('composer.lock')), RuntimeException::class, 'No encryption key provided.'); + + return md5_file($path); + }); + } +} diff --git a/vendor/vendor/easywechat-composer/easywechat-composer/src/Laravel/config.php b/vendor/vendor/easywechat-composer/easywechat-composer/src/Laravel/config.php new file mode 100644 index 0000000..5deabef --- /dev/null +++ b/vendor/vendor/easywechat-composer/easywechat-composer/src/Laravel/config.php @@ -0,0 +1,29 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +return [ + + 'encryption' => [ + + 'key' => env('EASYWECHAT_KEY'), + + ], + + 'delegation' => [ + + 'enabled' => env('EASYWECHAT_DELEGATION', false), + + 'host' => env('EASYWECHAT_DELEGATION_HOST'), + ], + +]; diff --git a/vendor/vendor/easywechat-composer/easywechat-composer/src/Laravel/routes.php b/vendor/vendor/easywechat-composer/easywechat-composer/src/Laravel/routes.php new file mode 100644 index 0000000..6a3041a --- /dev/null +++ b/vendor/vendor/easywechat-composer/easywechat-composer/src/Laravel/routes.php @@ -0,0 +1,16 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +use Illuminate\Support\Facades\Route; + +Route::post('delegate', 'DelegatesController'); diff --git a/vendor/vendor/easywechat-composer/easywechat-composer/src/ManifestManager.php b/vendor/vendor/easywechat-composer/easywechat-composer/src/ManifestManager.php new file mode 100644 index 0000000..e1af69c --- /dev/null +++ b/vendor/vendor/easywechat-composer/easywechat-composer/src/ManifestManager.php @@ -0,0 +1,127 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChatComposer; + +use Composer\Plugin\PluginInterface; + +class ManifestManager +{ + const PACKAGE_TYPE = 'easywechat-extension'; + + const EXTRA_OBSERVER = 'observers'; + + /** + * The vendor path. + * + * @var string + */ + protected $vendorPath; + + /** + * The manifest path. + * + * @var string + */ + protected $manifestPath; + + /** + * @param string $vendorPath + * @param string|null $manifestPath + */ + public function __construct(string $vendorPath, string $manifestPath = null) + { + $this->vendorPath = $vendorPath; + $this->manifestPath = $manifestPath ?: $vendorPath.'/easywechat-composer/easywechat-composer/extensions.php'; + } + + /** + * Remove manifest file. + * + * @return $this + */ + public function unlink() + { + if (file_exists($this->manifestPath)) { + @unlink($this->manifestPath); + } + + return $this; + } + + /** + * Build the manifest file. + */ + public function build() + { + $packages = []; + + if (file_exists($installed = $this->vendorPath.'/composer/installed.json')) { + $packages = json_decode(file_get_contents($installed), true); + if (version_compare(PluginInterface::PLUGIN_API_VERSION, '2.0.0', 'ge')) { + $packages = $packages['packages']; + } + } + + $this->write($this->map($packages)); + } + + /** + * @param array $packages + * + * @return array + */ + protected function map(array $packages): array + { + $manifest = []; + + $packages = array_filter($packages, function ($package) { + if(isset($package['type'])){ + return $package['type'] === self::PACKAGE_TYPE; + } + }); + + foreach ($packages as $package) { + $manifest[$package['name']] = [self::EXTRA_OBSERVER => $package['extra'][self::EXTRA_OBSERVER] ?? []]; + } + + return $manifest; + } + + /** + * Write the manifest array to a file. + * + * @param array $manifest + */ + protected function write(array $manifest) + { + file_put_contents( + $this->manifestPath, + 'invalidate($this->manifestPath); + } + + /** + * Invalidate the given file. + * + * @param string $file + */ + protected function invalidate($file) + { + if (function_exists('opcache_invalidate')) { + @opcache_invalidate($file, true); + } + } +} diff --git a/vendor/vendor/easywechat-composer/easywechat-composer/src/Plugin.php b/vendor/vendor/easywechat-composer/easywechat-composer/src/Plugin.php new file mode 100644 index 0000000..cd9e504 --- /dev/null +++ b/vendor/vendor/easywechat-composer/easywechat-composer/src/Plugin.php @@ -0,0 +1,107 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChatComposer; + +use Composer\Composer; +use Composer\EventDispatcher\EventSubscriberInterface; +use Composer\Installer\PackageEvent; +use Composer\Installer\PackageEvents; +use Composer\IO\IOInterface; +use Composer\Plugin\Capable; +use Composer\Plugin\PluginInterface; +use Composer\Script\Event; +use Composer\Script\ScriptEvents; + +class Plugin implements PluginInterface, EventSubscriberInterface, Capable +{ + /** + * @var bool + */ + protected $activated = true; + + /** + * Apply plugin modifications to Composer. + */ + public function activate(Composer $composer, IOInterface $io) + { + // + } + + /** + * Remove any hooks from Composer. + * + * This will be called when a plugin is deactivated before being + * uninstalled, but also before it gets upgraded to a new version + * so the old one can be deactivated and the new one activated. + */ + public function deactivate(Composer $composer, IOInterface $io) + { + // + } + + /** + * Prepare the plugin to be uninstalled. + * + * This will be called after deactivate. + */ + public function uninstall(Composer $composer, IOInterface $io) + { + } + + /** + * @return array + */ + public function getCapabilities() + { + return [ + 'Composer\Plugin\Capability\CommandProvider' => 'EasyWeChatComposer\Commands\Provider', + ]; + } + + /** + * Listen events. + * + * @return array + */ + public static function getSubscribedEvents() + { + return [ + PackageEvents::PRE_PACKAGE_UNINSTALL => 'prePackageUninstall', + ScriptEvents::POST_AUTOLOAD_DUMP => 'postAutoloadDump', + ]; + } + + /** + * @param \Composer\Installer\PackageEvent + */ + public function prePackageUninstall(PackageEvent $event) + { + if ($event->getOperation()->getPackage()->getName() === 'overtrue/wechat') { + $this->activated = false; + } + } + + public function postAutoloadDump(Event $event) + { + if (!$this->activated) { + return; + } + + $manifest = new ManifestManager( + rtrim($event->getComposer()->getConfig()->get('vendor-dir'), '/') + ); + + $manifest->unlink()->build(); + } +} diff --git a/vendor/vendor/easywechat-composer/easywechat-composer/src/Traits/MakesHttpRequests.php b/vendor/vendor/easywechat-composer/easywechat-composer/src/Traits/MakesHttpRequests.php new file mode 100644 index 0000000..091a75c --- /dev/null +++ b/vendor/vendor/easywechat-composer/easywechat-composer/src/Traits/MakesHttpRequests.php @@ -0,0 +1,110 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChatComposer\Traits; + +use EasyWeChat\Kernel\Http\StreamResponse; +use EasyWeChat\Kernel\Traits\ResponseCastable; +use EasyWeChatComposer\Contracts\Encrypter; +use EasyWeChatComposer\EasyWeChat; +use EasyWeChatComposer\Encryption\DefaultEncrypter; +use EasyWeChatComposer\Exceptions\DelegationException; +use GuzzleHttp\Client; +use GuzzleHttp\ClientInterface; + +trait MakesHttpRequests +{ + use ResponseCastable; + + /** + * @var \GuzzleHttp\ClientInterface + */ + protected $httpClient; + + /** + * @var \EasyWeChatComposer\Contracts\Encrypter + */ + protected $encrypter; + + /** + * @param string $endpoint + * @param array $payload + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + protected function request($endpoint, array $payload) + { + $response = $this->getHttpClient()->request('POST', $endpoint, [ + 'form_params' => $this->buildFormParams($payload), + ]); + + $parsed = $this->parseResponse($response); + + return $this->detectAndCastResponseToType( + $this->getEncrypter()->decrypt($parsed['response']), + ($parsed['response_type'] === StreamResponse::class) ? 'raw' : $this->app['config']['response_type'] + ); + } + + /** + * @param array $payload + * + * @return array + */ + protected function buildFormParams($payload) + { + return [ + 'encrypted' => $this->getEncrypter()->encrypt(json_encode($payload)), + ]; + } + + /** + * @param \Psr\Http\Message\ResponseInterface $response + * + * @return array + */ + protected function parseResponse($response) + { + $result = json_decode((string) $response->getBody(), true); + + if (isset($result['exception'])) { + throw (new DelegationException($result['message']))->setException($result['exception']); + } + + return $result; + } + + /** + * @return \GuzzleHttp\ClientInterface + */ + protected function getHttpClient(): ClientInterface + { + return $this->httpClient ?: $this->httpClient = new Client([ + 'base_uri' => $this->app['config']['delegation']['host'], + ]); + } + + /** + * @return \EasyWeChatComposer\Contracts\Encrypter + */ + protected function getEncrypter(): Encrypter + { + return $this->encrypter ?: $this->encrypter = new DefaultEncrypter( + EasyWeChat::getEncryptionKey() + ); + } +} diff --git a/vendor/vendor/easywechat-composer/easywechat-composer/src/Traits/WithAggregator.php b/vendor/vendor/easywechat-composer/easywechat-composer/src/Traits/WithAggregator.php new file mode 100644 index 0000000..a3eb16e --- /dev/null +++ b/vendor/vendor/easywechat-composer/easywechat-composer/src/Traits/WithAggregator.php @@ -0,0 +1,60 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChatComposer\Traits; + +use EasyWeChat\Kernel\BaseClient; +use EasyWeChatComposer\Delegation\DelegationTo; +use EasyWeChatComposer\EasyWeChat; + +trait WithAggregator +{ + /** + * Aggregate. + */ + protected function aggregate() + { + foreach (EasyWeChat::config() as $key => $value) { + $this['config']->set($key, $value); + } + } + + /** + * @return bool + */ + public function shouldDelegate($id) + { + return $this['config']->get('delegation.enabled') + && $this->offsetGet($id) instanceof BaseClient; + } + + /** + * @return $this + */ + public function shouldntDelegate() + { + $this['config']->set('delegation.enabled', false); + + return $this; + } + + /** + * @param string $id + * + * @return \EasyWeChatComposer\Delegation + */ + public function delegateTo($id) + { + return new DelegationTo($this, $id); + } +} diff --git a/vendor/vendor/easywechat-composer/easywechat-composer/tests/ManifestManagerTest.php b/vendor/vendor/easywechat-composer/easywechat-composer/tests/ManifestManagerTest.php new file mode 100644 index 0000000..23b8e2c --- /dev/null +++ b/vendor/vendor/easywechat-composer/easywechat-composer/tests/ManifestManagerTest.php @@ -0,0 +1,37 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChatComposer\Tests; + +use EasyWeChatComposer\ManifestManager; +use PHPUnit\Framework\TestCase; + +class ManifestManagerTest extends TestCase +{ + private $vendorPath; + private $manifestPath; + + protected function getManifestManager() + { + return new ManifestManager( + $this->vendorPath = __DIR__.'/__fixtures__/vendor/', + $this->manifestPath = __DIR__.'/__fixtures__/extensions.php' + ); + } + + public function testUnlink() + { + $this->assertInstanceOf(ManifestManager::class, $this->getManifestManager()->unlink()); + $this->assertFalse(file_exists($this->manifestPath)); + } +} diff --git a/vendor/vendor/ezyang/htmlpurifier/CREDITS b/vendor/vendor/ezyang/htmlpurifier/CREDITS new file mode 100644 index 0000000..7921b45 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/CREDITS @@ -0,0 +1,9 @@ + +CREDITS + +Almost everything written by Edward Z. Yang (Ambush Commander). Lots of thanks +to the DevNetwork Community for their help (see docs/ref-devnetwork.html for +more details), Feyd especially (namely IPv6 and optimization). Thanks to RSnake +for letting me package his fantastic XSS cheatsheet for a smoketest. + + vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/LICENSE b/vendor/vendor/ezyang/htmlpurifier/LICENSE new file mode 100644 index 0000000..8c88a20 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/LICENSE @@ -0,0 +1,504 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! + + vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/README.md b/vendor/vendor/ezyang/htmlpurifier/README.md new file mode 100644 index 0000000..e6b7199 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/README.md @@ -0,0 +1,29 @@ +HTML Purifier [![Build Status](https://github.com/ezyang/htmlpurifier/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/ezyang/htmlpurifier/actions/workflows/ci.yml) +============= + +HTML Purifier is an HTML filtering solution that uses a unique combination +of robust whitelists and aggressive parsing to ensure that not only are +XSS attacks thwarted, but the resulting HTML is standards compliant. + +HTML Purifier is oriented towards richly formatted documents from +untrusted sources that require CSS and a full tag-set. This library can +be configured to accept a more restrictive set of tags, but it won't be +as efficient as more bare-bones parsers. It will, however, do the job +right, which may be more important. + +Places to go: + +* See INSTALL for a quick installation guide +* See docs/ for developer-oriented documentation, code examples and + an in-depth installation guide. +* See WYSIWYG for information on editors like TinyMCE and FCKeditor + +HTML Purifier can be found on the web at: [http://htmlpurifier.org/](http://htmlpurifier.org/) + +## Installation + +Package available on [Composer](https://packagist.org/packages/ezyang/htmlpurifier). + +If you're using Composer to manage dependencies, you can use + + $ composer require ezyang/htmlpurifier diff --git a/vendor/vendor/ezyang/htmlpurifier/VERSION b/vendor/vendor/ezyang/htmlpurifier/VERSION new file mode 100644 index 0000000..ef8ffbd --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/VERSION @@ -0,0 +1 @@ +4.18.0 \ No newline at end of file diff --git a/vendor/vendor/ezyang/htmlpurifier/composer.json b/vendor/vendor/ezyang/htmlpurifier/composer.json new file mode 100644 index 0000000..7799d1d --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/composer.json @@ -0,0 +1,45 @@ +{ + "name": "ezyang/htmlpurifier", + "description": "Standards compliant HTML filter written in PHP", + "type": "library", + "keywords": ["html"], + "homepage": "http://htmlpurifier.org/", + "license": "LGPL-2.1-or-later", + "authors": [ + { + "name": "Edward Z. Yang", + "email": "admin@htmlpurifier.org", + "homepage": "http://ezyang.com" + } + ], + "require": { + "php": "~5.6.0 || ~7.0.0 || ~7.1.0 || ~7.2.0 || ~7.3.0 || ~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0" + }, + "require-dev": { + "cerdic/css-tidy": "^1.7 || ^2.0", + "simpletest/simpletest": "dev-master" + }, + "autoload": { + "psr-0": { "HTMLPurifier": "library/" }, + "files": ["library/HTMLPurifier.composer.php"], + "exclude-from-classmap": [ + "/library/HTMLPurifier/Language/" + ] + }, + "suggest": { + "cerdic/css-tidy": "If you want to use the filter 'Filter.ExtractStyleBlocks'.", + "ext-iconv": "Converts text to and from non-UTF-8 encodings", + "ext-bcmath": "Used for unit conversion and imagecrash protection", + "ext-tidy": "Used for pretty-printing HTML" + }, + "config": { + "sort-packages": true + }, + "repositories": [ + { + "type": "vcs", + "url": "https://github.com/ezyang/simpletest.git", + "no-api": true + } + ] +} diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier.auto.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier.auto.php new file mode 100644 index 0000000..1960c39 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier.auto.php @@ -0,0 +1,11 @@ +purify($html, $config); +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier.includes.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier.includes.php new file mode 100644 index 0000000..4c713a3 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier.includes.php @@ -0,0 +1,236 @@ + $attributes) { + $allowed_elements[$element] = true; + foreach ($attributes as $attribute => $x) { + $allowed_attributes["$element.$attribute"] = true; + } + } + $config->set('HTML.AllowedElements', $allowed_elements); + $config->set('HTML.AllowedAttributes', $allowed_attributes); + if ($allowed_protocols !== null) { + $config->set('URI.AllowedSchemes', $allowed_protocols); + } + $purifier = new HTMLPurifier($config); + return $purifier->purify($string); +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier.path.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier.path.php new file mode 100644 index 0000000..39b1b65 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier.path.php @@ -0,0 +1,11 @@ +config = HTMLPurifier_Config::create($config); + $this->strategy = new HTMLPurifier_Strategy_Core(); + } + + /** + * Adds a filter to process the output. First come first serve + * + * @param HTMLPurifier_Filter $filter HTMLPurifier_Filter object + */ + public function addFilter($filter) + { + trigger_error( + 'HTMLPurifier->addFilter() is deprecated, use configuration directives' . + ' in the Filter namespace or Filter.Custom', + E_USER_WARNING + ); + $this->filters[] = $filter; + } + + /** + * Filters an HTML snippet/document to be XSS-free and standards-compliant. + * + * @param string $html String of HTML to purify + * @param HTMLPurifier_Config $config Config object for this operation, + * if omitted, defaults to the config object specified during this + * object's construction. The parameter can also be any type + * that HTMLPurifier_Config::create() supports. + * + * @return string Purified HTML + */ + public function purify($html, $config = null) + { + // :TODO: make the config merge in, instead of replace + $config = $config ? HTMLPurifier_Config::create($config) : $this->config; + + // implementation is partially environment dependant, partially + // configuration dependant + $lexer = HTMLPurifier_Lexer::create($config); + + $context = new HTMLPurifier_Context(); + + // setup HTML generator + $this->generator = new HTMLPurifier_Generator($config, $context); + $context->register('Generator', $this->generator); + + // set up global context variables + if ($config->get('Core.CollectErrors')) { + // may get moved out if other facilities use it + $language_factory = HTMLPurifier_LanguageFactory::instance(); + $language = $language_factory->create($config, $context); + $context->register('Locale', $language); + + $error_collector = new HTMLPurifier_ErrorCollector($context); + $context->register('ErrorCollector', $error_collector); + } + + // setup id_accumulator context, necessary due to the fact that + // AttrValidator can be called from many places + $id_accumulator = HTMLPurifier_IDAccumulator::build($config, $context); + $context->register('IDAccumulator', $id_accumulator); + + $html = HTMLPurifier_Encoder::convertToUTF8($html, $config, $context); + + // setup filters + $filter_flags = $config->getBatch('Filter'); + $custom_filters = $filter_flags['Custom']; + unset($filter_flags['Custom']); + $filters = array(); + foreach ($filter_flags as $filter => $flag) { + if (!$flag) { + continue; + } + if (strpos($filter, '.') !== false) { + continue; + } + $class = "HTMLPurifier_Filter_$filter"; + $filters[] = new $class; + } + foreach ($custom_filters as $filter) { + // maybe "HTMLPurifier_Filter_$filter", but be consistent with AutoFormat + $filters[] = $filter; + } + $filters = array_merge($filters, $this->filters); + // maybe prepare(), but later + + for ($i = 0, $filter_size = count($filters); $i < $filter_size; $i++) { + $html = $filters[$i]->preFilter($html, $config, $context); + } + + // purified HTML + $html = + $this->generator->generateFromTokens( + // list of tokens + $this->strategy->execute( + // list of un-purified tokens + $lexer->tokenizeHTML( + // un-purified HTML + $html, + $config, + $context + ), + $config, + $context + ) + ); + + for ($i = $filter_size - 1; $i >= 0; $i--) { + $html = $filters[$i]->postFilter($html, $config, $context); + } + + $html = HTMLPurifier_Encoder::convertFromUTF8($html, $config, $context); + $this->context =& $context; + return $html; + } + + /** + * Filters an array of HTML snippets + * + * @param string[] $array_of_html Array of html snippets + * @param HTMLPurifier_Config $config Optional config object for this operation. + * See HTMLPurifier::purify() for more details. + * + * @return string[] Array of purified HTML + */ + public function purifyArray($array_of_html, $config = null) + { + $context_array = array(); + $array = array(); + foreach($array_of_html as $key=>$value){ + if (is_array($value)) { + $array[$key] = $this->purifyArray($value, $config); + } else { + $array[$key] = $this->purify($value, $config); + } + $context_array[$key] = $this->context; + } + $this->context = $context_array; + return $array; + } + + /** + * Singleton for enforcing just one HTML Purifier in your system + * + * @param HTMLPurifier|HTMLPurifier_Config $prototype Optional prototype + * HTMLPurifier instance to overload singleton with, + * or HTMLPurifier_Config instance to configure the + * generated version with. + * + * @return HTMLPurifier + */ + public static function instance($prototype = null) + { + if (!self::$instance || $prototype) { + if ($prototype instanceof HTMLPurifier) { + self::$instance = $prototype; + } elseif ($prototype) { + self::$instance = new HTMLPurifier($prototype); + } else { + self::$instance = new HTMLPurifier(); + } + } + return self::$instance; + } + + /** + * Singleton for enforcing just one HTML Purifier in your system + * + * @param HTMLPurifier|HTMLPurifier_Config $prototype Optional prototype + * HTMLPurifier instance to overload singleton with, + * or HTMLPurifier_Config instance to configure the + * generated version with. + * + * @return HTMLPurifier + * @note Backwards compatibility, see instance() + */ + public static function getInstance($prototype = null) + { + return HTMLPurifier::instance($prototype); + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier.safe-includes.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier.safe-includes.php new file mode 100644 index 0000000..8a417d2 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier.safe-includes.php @@ -0,0 +1,230 @@ +getHTMLDefinition(); + $parent = new HTMLPurifier_Token_Start($definition->info_parent); + $stack = array($parent->toNode()); + foreach ($tokens as $token) { + $token->skip = null; // [MUT] + $token->carryover = null; // [MUT] + if ($token instanceof HTMLPurifier_Token_End) { + $token->start = null; // [MUT] + $r = array_pop($stack); + //assert($r->name === $token->name); + //assert(empty($token->attr)); + $r->endCol = $token->col; + $r->endLine = $token->line; + $r->endArmor = $token->armor; + continue; + } + $node = $token->toNode(); + $stack[count($stack)-1]->children[] = $node; + if ($token instanceof HTMLPurifier_Token_Start) { + $stack[] = $node; + } + } + //assert(count($stack) == 1); + return $stack[0]; + } + + public static function flatten($node, $config, $context) { + $level = 0; + $nodes = array($level => new HTMLPurifier_Queue(array($node))); + $closingTokens = array(); + $tokens = array(); + do { + while (!$nodes[$level]->isEmpty()) { + $node = $nodes[$level]->shift(); // FIFO + list($start, $end) = $node->toTokenPair(); + if ($level > 0) { + $tokens[] = $start; + } + if ($end !== NULL) { + $closingTokens[$level][] = $end; + } + if ($node instanceof HTMLPurifier_Node_Element) { + $level++; + $nodes[$level] = new HTMLPurifier_Queue(); + foreach ($node->children as $childNode) { + $nodes[$level]->push($childNode); + } + } + } + $level--; + if ($level && isset($closingTokens[$level])) { + while ($token = array_pop($closingTokens[$level])) { + $tokens[] = $token; + } + } + } while ($level > 0); + return $tokens; + } +} diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrCollections.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrCollections.php new file mode 100644 index 0000000..c7b17cf --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrCollections.php @@ -0,0 +1,148 @@ +doConstruct($attr_types, $modules); + } + + public function doConstruct($attr_types, $modules) + { + // load extensions from the modules + foreach ($modules as $module) { + foreach ($module->attr_collections as $coll_i => $coll) { + if (!isset($this->info[$coll_i])) { + $this->info[$coll_i] = array(); + } + foreach ($coll as $attr_i => $attr) { + if ($attr_i === 0 && isset($this->info[$coll_i][$attr_i])) { + // merge in includes + $this->info[$coll_i][$attr_i] = array_merge( + $this->info[$coll_i][$attr_i], + $attr + ); + continue; + } + $this->info[$coll_i][$attr_i] = $attr; + } + } + } + // perform internal expansions and inclusions + foreach ($this->info as $name => $attr) { + // merge attribute collections that include others + $this->performInclusions($this->info[$name]); + // replace string identifiers with actual attribute objects + $this->expandIdentifiers($this->info[$name], $attr_types); + } + } + + /** + * Takes a reference to an attribute associative array and performs + * all inclusions specified by the zero index. + * @param array &$attr Reference to attribute array + */ + public function performInclusions(&$attr) + { + if (!isset($attr[0])) { + return; + } + $merge = $attr[0]; + $seen = array(); // recursion guard + // loop through all the inclusions + for ($i = 0; isset($merge[$i]); $i++) { + if (isset($seen[$merge[$i]])) { + continue; + } + $seen[$merge[$i]] = true; + // foreach attribute of the inclusion, copy it over + if (!isset($this->info[$merge[$i]])) { + continue; + } + foreach ($this->info[$merge[$i]] as $key => $value) { + if (isset($attr[$key])) { + continue; + } // also catches more inclusions + $attr[$key] = $value; + } + if (isset($this->info[$merge[$i]][0])) { + // recursion + $merge = array_merge($merge, $this->info[$merge[$i]][0]); + } + } + unset($attr[0]); + } + + /** + * Expands all string identifiers in an attribute array by replacing + * them with the appropriate values inside HTMLPurifier_AttrTypes + * @param array &$attr Reference to attribute array + * @param HTMLPurifier_AttrTypes $attr_types HTMLPurifier_AttrTypes instance + */ + public function expandIdentifiers(&$attr, $attr_types) + { + // because foreach will process new elements we add, make sure we + // skip duplicates + $processed = array(); + + foreach ($attr as $def_i => $def) { + // skip inclusions + if ($def_i === 0) { + continue; + } + + if (isset($processed[$def_i])) { + continue; + } + + // determine whether or not attribute is required + if ($required = (strpos($def_i, '*') !== false)) { + // rename the definition + unset($attr[$def_i]); + $def_i = trim($def_i, '*'); + $attr[$def_i] = $def; + } + + $processed[$def_i] = true; + + // if we've already got a literal object, move on + if (is_object($def)) { + // preserve previous required + $attr[$def_i]->required = ($required || $attr[$def_i]->required); + continue; + } + + if ($def === false) { + unset($attr[$def_i]); + continue; + } + + if ($t = $attr_types->get($def)) { + $attr[$def_i] = $t; + $attr[$def_i]->required = $required; + } else { + unset($attr[$def_i]); + } + } + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef.php new file mode 100644 index 0000000..739646f --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef.php @@ -0,0 +1,144 @@ + by removing + * leading and trailing whitespace, ignoring line feeds, and replacing + * carriage returns and tabs with spaces. While most useful for HTML + * attributes specified as CDATA, it can also be applied to most CSS + * values. + * + * @note This method is not entirely standards compliant, as trim() removes + * more types of whitespace than specified in the spec. In practice, + * this is rarely a problem, as those extra characters usually have + * already been removed by HTMLPurifier_Encoder. + * + * @warning This processing is inconsistent with XML's whitespace handling + * as specified by section 3.3.3 and referenced XHTML 1.0 section + * 4.7. However, note that we are NOT necessarily + * parsing XML, thus, this behavior may still be correct. We + * assume that newlines have been normalized. + */ + public function parseCDATA($string) + { + $string = trim($string); + $string = str_replace(array("\n", "\t", "\r"), ' ', $string); + return $string; + } + + /** + * Factory method for creating this class from a string. + * @param string $string String construction info + * @return HTMLPurifier_AttrDef Created AttrDef object corresponding to $string + */ + public function make($string) + { + // default implementation, return a flyweight of this object. + // If $string has an effect on the returned object (i.e. you + // need to overload this method), it is best + // to clone or instantiate new copies. (Instantiation is safer.) + return $this; + } + + /** + * Removes spaces from rgb(0, 0, 0) so that shorthand CSS properties work + * properly. THIS IS A HACK! + * @param string $string a CSS colour definition + * @return string + */ + protected function mungeRgb($string) + { + $p = '\s*(\d+(\.\d+)?([%]?))\s*'; + + if (preg_match('/(rgba|hsla)\(/', $string)) { + return preg_replace('/(rgba|hsla)\('.$p.','.$p.','.$p.','.$p.'\)/', '\1(\2,\5,\8,\11)', $string); + } + + return preg_replace('/(rgb|hsl)\('.$p.','.$p.','.$p.'\)/', '\1(\2,\5,\8)', $string); + } + + /** + * Parses a possibly escaped CSS string and returns the "pure" + * version of it. + */ + protected function expandCSSEscape($string) + { + // flexibly parse it + $ret = ''; + for ($i = 0, $c = strlen($string); $i < $c; $i++) { + if ($string[$i] === '\\') { + $i++; + if ($i >= $c) { + $ret .= '\\'; + break; + } + if (ctype_xdigit($string[$i])) { + $code = $string[$i]; + for ($a = 1, $i++; $i < $c && $a < 6; $i++, $a++) { + if (!ctype_xdigit($string[$i])) { + break; + } + $code .= $string[$i]; + } + // We have to be extremely careful when adding + // new characters, to make sure we're not breaking + // the encoding. + $char = HTMLPurifier_Encoder::unichr(hexdec($code)); + if (HTMLPurifier_Encoder::cleanUTF8($char) === '') { + continue; + } + $ret .= $char; + if ($i < $c && trim($string[$i]) !== '') { + $i--; + } + continue; + } + if ($string[$i] === "\n") { + continue; + } + } + $ret .= $string[$i]; + } + return $ret; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS.php new file mode 100644 index 0000000..af6b8a0 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS.php @@ -0,0 +1,140 @@ +parseCDATA($css); + + $definition = $config->getCSSDefinition(); + $allow_duplicates = $config->get("CSS.AllowDuplicates"); + + $universal_attrdef = new HTMLPurifier_AttrDef_Enum( + array( + 'initial', + 'inherit', + 'unset', + ) + ); + + // According to the CSS2.1 spec, the places where a + // non-delimiting semicolon can appear are in strings + // escape sequences. So here is some dumb hack to + // handle quotes. + $len = strlen($css); + $accum = ""; + $declarations = array(); + $quoted = false; + for ($i = 0; $i < $len; $i++) { + $c = strcspn($css, ";'\"", $i); + $accum .= substr($css, $i, $c); + $i += $c; + if ($i == $len) break; + $d = $css[$i]; + if ($quoted) { + $accum .= $d; + if ($d == $quoted) { + $quoted = false; + } + } else { + if ($d == ";") { + $declarations[] = $accum; + $accum = ""; + } else { + $accum .= $d; + $quoted = $d; + } + } + } + if ($accum != "") $declarations[] = $accum; + + $propvalues = array(); + $new_declarations = ''; + + /** + * Name of the current CSS property being validated. + */ + $property = false; + $context->register('CurrentCSSProperty', $property); + + foreach ($declarations as $declaration) { + if (!$declaration) { + continue; + } + if (!strpos($declaration, ':')) { + continue; + } + list($property, $value) = explode(':', $declaration, 2); + $property = trim($property); + $value = trim($value); + $ok = false; + do { + if (isset($definition->info[$property])) { + $ok = true; + break; + } + if (ctype_lower($property)) { + break; + } + $property = strtolower($property); + if (isset($definition->info[$property])) { + $ok = true; + break; + } + } while (0); + if (!$ok) { + continue; + } + $result = $universal_attrdef->validate($value, $config, $context); + if ($result === false) { + $result = $definition->info[$property]->validate( + $value, + $config, + $context + ); + } + if ($result === false) { + continue; + } + if ($allow_duplicates) { + $new_declarations .= "$property:$result;"; + } else { + $propvalues[$property] = $result; + } + } + + $context->destroy('CurrentCSSProperty'); + + // procedure does not write the new CSS simultaneously, so it's + // slightly inefficient, but it's the only way of getting rid of + // duplicates. Perhaps config to optimize it, but not now. + + foreach ($propvalues as $prop => $value) { + $new_declarations .= "$prop:$value;"; + } + + return $new_declarations ? $new_declarations : false; + + } + +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/AlphaValue.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/AlphaValue.php new file mode 100644 index 0000000..af2b83d --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/AlphaValue.php @@ -0,0 +1,34 @@ + 1.0) { + $result = '1'; + } + return $result; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Background.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Background.php new file mode 100644 index 0000000..28c4988 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Background.php @@ -0,0 +1,113 @@ +getCSSDefinition(); + $this->info['background-color'] = $def->info['background-color']; + $this->info['background-image'] = $def->info['background-image']; + $this->info['background-repeat'] = $def->info['background-repeat']; + $this->info['background-attachment'] = $def->info['background-attachment']; + $this->info['background-position'] = $def->info['background-position']; + $this->info['background-size'] = $def->info['background-size']; + } + + /** + * @param string $string + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return bool|string + */ + public function validate($string, $config, $context) + { + // regular pre-processing + $string = $this->parseCDATA($string); + if ($string === '') { + return false; + } + + // munge rgb() decl if necessary + $string = $this->mungeRgb($string); + + // assumes URI doesn't have spaces in it + $bits = explode(' ', $string); // bits to process + + $caught = array(); + $caught['color'] = false; + $caught['image'] = false; + $caught['repeat'] = false; + $caught['attachment'] = false; + $caught['position'] = false; + $caught['size'] = false; + + $i = 0; // number of catches + + foreach ($bits as $bit) { + if ($bit === '') { + continue; + } + foreach ($caught as $key => $status) { + if ($key != 'position') { + if ($status !== false) { + continue; + } + $r = $this->info['background-' . $key]->validate($bit, $config, $context); + } else { + $r = $bit; + } + if ($r === false) { + continue; + } + if ($key == 'position') { + if ($caught[$key] === false) { + $caught[$key] = ''; + } + $caught[$key] .= $r . ' '; + } else { + $caught[$key] = $r; + } + $i++; + break; + } + } + + if (!$i) { + return false; + } + if ($caught['position'] !== false) { + $caught['position'] = $this->info['background-position']-> + validate($caught['position'], $config, $context); + } + + $ret = array(); + foreach ($caught as $value) { + if ($value === false) { + continue; + } + $ret[] = $value; + } + + if (empty($ret)) { + return false; + } + return implode(' ', $ret); + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/BackgroundPosition.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/BackgroundPosition.php new file mode 100644 index 0000000..4580ef5 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/BackgroundPosition.php @@ -0,0 +1,157 @@ + | | left | center | right + ] + [ + | | top | center | bottom + ]? + ] | + [ // this signifies that the vertical and horizontal adjectives + // can be arbitrarily ordered, however, there can only be two, + // one of each, or none at all + [ + left | center | right + ] || + [ + top | center | bottom + ] + ] + top, left = 0% + center, (none) = 50% + bottom, right = 100% +*/ + +/* QuirksMode says: + keyword + length/percentage must be ordered correctly, as per W3C + + Internet Explorer and Opera, however, support arbitrary ordering. We + should fix it up. + + Minor issue though, not strictly necessary. +*/ + +// control freaks may appreciate the ability to convert these to +// percentages or something, but it's not necessary + +/** + * Validates the value of background-position. + */ +class HTMLPurifier_AttrDef_CSS_BackgroundPosition extends HTMLPurifier_AttrDef +{ + + /** + * @type HTMLPurifier_AttrDef_CSS_Length + */ + protected $length; + + /** + * @type HTMLPurifier_AttrDef_CSS_Percentage + */ + protected $percentage; + + public function __construct() + { + $this->length = new HTMLPurifier_AttrDef_CSS_Length(); + $this->percentage = new HTMLPurifier_AttrDef_CSS_Percentage(); + } + + /** + * @param string $string + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return bool|string + */ + public function validate($string, $config, $context) + { + $string = $this->parseCDATA($string); + $bits = explode(' ', $string); + + $keywords = array(); + $keywords['h'] = false; // left, right + $keywords['v'] = false; // top, bottom + $keywords['ch'] = false; // center (first word) + $keywords['cv'] = false; // center (second word) + $measures = array(); + + $i = 0; + + $lookup = array( + 'top' => 'v', + 'bottom' => 'v', + 'left' => 'h', + 'right' => 'h', + 'center' => 'c' + ); + + foreach ($bits as $bit) { + if ($bit === '') { + continue; + } + + // test for keyword + $lbit = ctype_lower($bit) ? $bit : strtolower($bit); + if (isset($lookup[$lbit])) { + $status = $lookup[$lbit]; + if ($status == 'c') { + if ($i == 0) { + $status = 'ch'; + } else { + $status = 'cv'; + } + } + $keywords[$status] = $lbit; + $i++; + } + + // test for length + $r = $this->length->validate($bit, $config, $context); + if ($r !== false) { + $measures[] = $r; + $i++; + } + + // test for percentage + $r = $this->percentage->validate($bit, $config, $context); + if ($r !== false) { + $measures[] = $r; + $i++; + } + } + + if (!$i) { + return false; + } // no valid values were caught + + $ret = array(); + + // first keyword + if ($keywords['h']) { + $ret[] = $keywords['h']; + } elseif ($keywords['ch']) { + $ret[] = $keywords['ch']; + $keywords['cv'] = false; // prevent re-use: center = center center + } elseif (count($measures)) { + $ret[] = array_shift($measures); + } + + if ($keywords['v']) { + $ret[] = $keywords['v']; + } elseif ($keywords['cv']) { + $ret[] = $keywords['cv']; + } elseif (count($measures)) { + $ret[] = array_shift($measures); + } + + if (empty($ret)) { + return false; + } + return implode(' ', $ret); + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Border.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Border.php new file mode 100644 index 0000000..16243ba --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Border.php @@ -0,0 +1,56 @@ +getCSSDefinition(); + $this->info['border-width'] = $def->info['border-width']; + $this->info['border-style'] = $def->info['border-style']; + $this->info['border-top-color'] = $def->info['border-top-color']; + } + + /** + * @param string $string + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return bool|string + */ + public function validate($string, $config, $context) + { + $string = $this->parseCDATA($string); + $string = $this->mungeRgb($string); + $bits = explode(' ', $string); + $done = array(); // segments we've finished + $ret = ''; // return value + foreach ($bits as $bit) { + foreach ($this->info as $propname => $validator) { + if (isset($done[$propname])) { + continue; + } + $r = $validator->validate($bit, $config, $context); + if ($r !== false) { + $ret .= $r . ' '; + $done[$propname] = true; + break; + } + } + } + return rtrim($ret); + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Color.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Color.php new file mode 100644 index 0000000..d7287a0 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Color.php @@ -0,0 +1,161 @@ +alpha = new HTMLPurifier_AttrDef_CSS_AlphaValue(); + } + + /** + * @param string $color + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return bool|string + */ + public function validate($color, $config, $context) + { + static $colors = null; + if ($colors === null) { + $colors = $config->get('Core.ColorKeywords'); + } + + $color = trim($color); + if ($color === '') { + return false; + } + + $lower = strtolower($color); + if (isset($colors[$lower])) { + return $colors[$lower]; + } + + if (preg_match('#(rgb|rgba|hsl|hsla)\(#', $color, $matches) === 1) { + $length = strlen($color); + if (strpos($color, ')') !== $length - 1) { + return false; + } + + // get used function : rgb, rgba, hsl or hsla + $function = $matches[1]; + + $parameters_size = 3; + $alpha_channel = false; + if (substr($function, -1) === 'a') { + $parameters_size = 4; + $alpha_channel = true; + } + + /* + * Allowed types for values : + * parameter_position => [type => max_value] + */ + $allowed_types = array( + 1 => array('percentage' => 100, 'integer' => 255), + 2 => array('percentage' => 100, 'integer' => 255), + 3 => array('percentage' => 100, 'integer' => 255), + ); + $allow_different_types = false; + + if (strpos($function, 'hsl') !== false) { + $allowed_types = array( + 1 => array('integer' => 360), + 2 => array('percentage' => 100), + 3 => array('percentage' => 100), + ); + $allow_different_types = true; + } + + $values = trim(str_replace($function, '', $color), ' ()'); + + $parts = explode(',', $values); + if (count($parts) !== $parameters_size) { + return false; + } + + $type = false; + $new_parts = array(); + $i = 0; + + foreach ($parts as $part) { + $i++; + $part = trim($part); + + if ($part === '') { + return false; + } + + // different check for alpha channel + if ($alpha_channel === true && $i === count($parts)) { + $result = $this->alpha->validate($part, $config, $context); + + if ($result === false) { + return false; + } + + $new_parts[] = (string)$result; + continue; + } + + if (substr($part, -1) === '%') { + $current_type = 'percentage'; + } else { + $current_type = 'integer'; + } + + if (!array_key_exists($current_type, $allowed_types[$i])) { + return false; + } + + if (!$type) { + $type = $current_type; + } + + if ($allow_different_types === false && $type != $current_type) { + return false; + } + + $max_value = $allowed_types[$i][$current_type]; + + if ($current_type == 'integer') { + // Return value between range 0 -> $max_value + $new_parts[] = (int)max(min($part, $max_value), 0); + } elseif ($current_type == 'percentage') { + $new_parts[] = (float)max(min(rtrim($part, '%'), $max_value), 0) . '%'; + } + } + + $new_values = implode(',', $new_parts); + + $color = $function . '(' . $new_values . ')'; + } else { + // hexadecimal handling + if ($color[0] === '#') { + $hex = substr($color, 1); + } else { + $hex = $color; + $color = '#' . $color; + } + $length = strlen($hex); + if ($length !== 3 && $length !== 6) { + return false; + } + if (!ctype_xdigit($hex)) { + return false; + } + } + return $color; + } + +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Composite.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Composite.php new file mode 100644 index 0000000..9c17505 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Composite.php @@ -0,0 +1,48 @@ +defs = $defs; + } + + /** + * @param string $string + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return bool|string + */ + public function validate($string, $config, $context) + { + foreach ($this->defs as $i => $def) { + $result = $this->defs[$i]->validate($string, $config, $context); + if ($result !== false) { + return $result; + } + } + return false; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/DenyElementDecorator.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/DenyElementDecorator.php new file mode 100644 index 0000000..9d77cc9 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/DenyElementDecorator.php @@ -0,0 +1,44 @@ +def = $def; + $this->element = $element; + } + + /** + * Checks if CurrentToken is set and equal to $this->element + * @param string $string + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return bool|string + */ + public function validate($string, $config, $context) + { + $token = $context->get('CurrentToken', true); + if ($token && $token->name == $this->element) { + return false; + } + return $this->def->validate($string, $config, $context); + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Filter.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Filter.php new file mode 100644 index 0000000..bde4c33 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Filter.php @@ -0,0 +1,77 @@ +intValidator = new HTMLPurifier_AttrDef_Integer(); + } + + /** + * @param string $value + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return bool|string + */ + public function validate($value, $config, $context) + { + $value = $this->parseCDATA($value); + if ($value === 'none') { + return $value; + } + // if we looped this we could support multiple filters + $function_length = strcspn($value, '('); + $function = trim(substr($value, 0, $function_length)); + if ($function !== 'alpha' && + $function !== 'Alpha' && + $function !== 'progid:DXImageTransform.Microsoft.Alpha' + ) { + return false; + } + $cursor = $function_length + 1; + $parameters_length = strcspn($value, ')', $cursor); + $parameters = substr($value, $cursor, $parameters_length); + $params = explode(',', $parameters); + $ret_params = array(); + $lookup = array(); + foreach ($params as $param) { + list($key, $value) = explode('=', $param); + $key = trim($key); + $value = trim($value); + if (isset($lookup[$key])) { + continue; + } + if ($key !== 'opacity') { + continue; + } + $value = $this->intValidator->validate($value, $config, $context); + if ($value === false) { + continue; + } + $int = (int)$value; + if ($int > 100) { + $value = '100'; + } + if ($int < 0) { + $value = '0'; + } + $ret_params[] = "$key=$value"; + $lookup[$key] = true; + } + $ret_parameters = implode(',', $ret_params); + $ret_function = "$function($ret_parameters)"; + return $ret_function; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Font.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Font.php new file mode 100644 index 0000000..579b97e --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Font.php @@ -0,0 +1,176 @@ +getCSSDefinition(); + $this->info['font-style'] = $def->info['font-style']; + $this->info['font-variant'] = $def->info['font-variant']; + $this->info['font-weight'] = $def->info['font-weight']; + $this->info['font-size'] = $def->info['font-size']; + $this->info['line-height'] = $def->info['line-height']; + $this->info['font-family'] = $def->info['font-family']; + } + + /** + * @param string $string + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return bool|string + */ + public function validate($string, $config, $context) + { + static $system_fonts = array( + 'caption' => true, + 'icon' => true, + 'menu' => true, + 'message-box' => true, + 'small-caption' => true, + 'status-bar' => true + ); + + // regular pre-processing + $string = $this->parseCDATA($string); + if ($string === '') { + return false; + } + + // check if it's one of the keywords + $lowercase_string = strtolower($string); + if (isset($system_fonts[$lowercase_string])) { + return $lowercase_string; + } + + $bits = explode(' ', $string); // bits to process + $stage = 0; // this indicates what we're looking for + $caught = array(); // which stage 0 properties have we caught? + $stage_1 = array('font-style', 'font-variant', 'font-weight'); + $final = ''; // output + + for ($i = 0, $size = count($bits); $i < $size; $i++) { + if ($bits[$i] === '') { + continue; + } + switch ($stage) { + case 0: // attempting to catch font-style, font-variant or font-weight + foreach ($stage_1 as $validator_name) { + if (isset($caught[$validator_name])) { + continue; + } + $r = $this->info[$validator_name]->validate( + $bits[$i], + $config, + $context + ); + if ($r !== false) { + $final .= $r . ' '; + $caught[$validator_name] = true; + break; + } + } + // all three caught, continue on + if (count($caught) >= 3) { + $stage = 1; + } + if ($r !== false) { + break; + } + case 1: // attempting to catch font-size and perhaps line-height + $found_slash = false; + if (strpos($bits[$i], '/') !== false) { + list($font_size, $line_height) = + explode('/', $bits[$i]); + if ($line_height === '') { + // ooh, there's a space after the slash! + $line_height = false; + $found_slash = true; + } + } else { + $font_size = $bits[$i]; + $line_height = false; + } + $r = $this->info['font-size']->validate( + $font_size, + $config, + $context + ); + if ($r !== false) { + $final .= $r; + // attempt to catch line-height + if ($line_height === false) { + // we need to scroll forward + for ($j = $i + 1; $j < $size; $j++) { + if ($bits[$j] === '') { + continue; + } + if ($bits[$j] === '/') { + if ($found_slash) { + return false; + } else { + $found_slash = true; + continue; + } + } + $line_height = $bits[$j]; + break; + } + } else { + // slash already found + $found_slash = true; + $j = $i; + } + if ($found_slash) { + $i = $j; + $r = $this->info['line-height']->validate( + $line_height, + $config, + $context + ); + if ($r !== false) { + $final .= '/' . $r; + } + } + $final .= ' '; + $stage = 2; + break; + } + return false; + case 2: // attempting to catch font-family + $font_family = + implode(' ', array_slice($bits, $i, $size - $i)); + $r = $this->info['font-family']->validate( + $font_family, + $config, + $context + ); + if ($r !== false) { + $final .= $r . ' '; + // processing completed successfully + return rtrim($final); + } + return false; + } + } + return false; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/FontFamily.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/FontFamily.php new file mode 100644 index 0000000..f1ff116 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/FontFamily.php @@ -0,0 +1,217 @@ +mask = array_reduce($c, function ($carry, $value) { + return $carry . $value; + }, '_- '); + + /* + PHP's internal strcspn implementation is + O(length of string * length of mask), making it inefficient + for large masks. However, it's still faster than + preg_match 8) + for (p = s1;;) { + spanp = s2; + do { + if (*spanp == c || p == s1_end) { + return p - s1; + } + } while (spanp++ < (s2_end - 1)); + c = *++p; + } + */ + // possible optimization: invert the mask. + } + + /** + * @param string $string + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return bool|string + */ + public function validate($string, $config, $context) + { + static $generic_names = array( + 'serif' => true, + 'sans-serif' => true, + 'monospace' => true, + 'fantasy' => true, + 'cursive' => true + ); + $allowed_fonts = $config->get('CSS.AllowedFonts'); + + // assume that no font names contain commas in them + $fonts = explode(',', $string); + $final = ''; + foreach ($fonts as $font) { + $font = trim($font); + if ($font === '') { + continue; + } + // match a generic name + if (isset($generic_names[$font])) { + if ($allowed_fonts === null || isset($allowed_fonts[$font])) { + $final .= $font . ', '; + } + continue; + } + // match a quoted name + if ($font[0] === '"' || $font[0] === "'") { + $length = strlen($font); + if ($length <= 2) { + continue; + } + $quote = $font[0]; + if ($font[$length - 1] !== $quote) { + continue; + } + $font = substr($font, 1, $length - 2); + } + + $font = $this->expandCSSEscape($font); + + // $font is a pure representation of the font name + + if ($allowed_fonts !== null && !isset($allowed_fonts[$font])) { + continue; + } + + if (ctype_alnum($font) && $font !== '') { + // very simple font, allow it in unharmed + $final .= $font . ', '; + continue; + } + + // bugger out on whitespace. form feed (0C) really + // shouldn't show up regardless + $font = str_replace(array("\n", "\t", "\r", "\x0C"), ' ', $font); + + // Here, there are various classes of characters which need + // to be treated differently: + // - Alphanumeric characters are essentially safe. We + // handled these above. + // - Spaces require quoting, though most parsers will do + // the right thing if there aren't any characters that + // can be misinterpreted + // - Dashes rarely occur, but they fairly unproblematic + // for parsing/rendering purposes. + // The above characters cover the majority of Western font + // names. + // - Arbitrary Unicode characters not in ASCII. Because + // most parsers give little thought to Unicode, treatment + // of these codepoints is basically uniform, even for + // punctuation-like codepoints. These characters can + // show up in non-Western pages and are supported by most + // major browsers, for example: "MS 明朝" is a + // legitimate font-name + // . See + // the CSS3 spec for more examples: + // + // You can see live samples of these on the Internet: + // + // However, most of these fonts have ASCII equivalents: + // for example, 'MS Mincho', and it's considered + // professional to use ASCII font names instead of + // Unicode font names. Thanks Takeshi Terada for + // providing this information. + // The following characters, to my knowledge, have not been + // used to name font names. + // - Single quote. While theoretically you might find a + // font name that has a single quote in its name (serving + // as an apostrophe, e.g. Dave's Scribble), I haven't + // been able to find any actual examples of this. + // Internet Explorer's cssText translation (which I + // believe is invoked by innerHTML) normalizes any + // quoting to single quotes, and fails to escape single + // quotes. (Note that this is not IE's behavior for all + // CSS properties, just some sort of special casing for + // font-family). So a single quote *cannot* be used + // safely in the font-family context if there will be an + // innerHTML/cssText translation. Note that Firefox 3.x + // does this too. + // - Double quote. In IE, these get normalized to + // single-quotes, no matter what the encoding. (Fun + // fact, in IE8, the 'content' CSS property gained + // support, where they special cased to preserve encoded + // double quotes, but still translate unadorned double + // quotes into single quotes.) So, because their + // fixpoint behavior is identical to single quotes, they + // cannot be allowed either. Firefox 3.x displays + // single-quote style behavior. + // - Backslashes are reduced by one (so \\ -> \) every + // iteration, so they cannot be used safely. This shows + // up in IE7, IE8 and FF3 + // - Semicolons, commas and backticks are handled properly. + // - The rest of the ASCII punctuation is handled properly. + // We haven't checked what browsers do to unadorned + // versions, but this is not important as long as the + // browser doesn't /remove/ surrounding quotes (as IE does + // for HTML). + // + // With these results in hand, we conclude that there are + // various levels of safety: + // - Paranoid: alphanumeric, spaces and dashes(?) + // - International: Paranoid + non-ASCII Unicode + // - Edgy: Everything except quotes, backslashes + // - NoJS: Standards compliance, e.g. sod IE. Note that + // with some judicious character escaping (since certain + // types of escaping doesn't work) this is theoretically + // OK as long as innerHTML/cssText is not called. + // We believe that international is a reasonable default + // (that we will implement now), and once we do more + // extensive research, we may feel comfortable with dropping + // it down to edgy. + + // Edgy: alphanumeric, spaces, dashes, underscores and Unicode. Use of + // str(c)spn assumes that the string was already well formed + // Unicode (which of course it is). + if (strspn($font, $this->mask) !== strlen($font)) { + continue; + } + + // Historical: + // In the absence of innerHTML/cssText, these ugly + // transforms don't pose a security risk (as \\ and \" + // might--these escapes are not supported by most browsers). + // We could try to be clever and use single-quote wrapping + // when there is a double quote present, but I have choosen + // not to implement that. (NOTE: you can reduce the amount + // of escapes by one depending on what quoting style you use) + // $font = str_replace('\\', '\\5C ', $font); + // $font = str_replace('"', '\\22 ', $font); + // $font = str_replace("'", '\\27 ', $font); + + // font possibly with spaces, requires quoting + $final .= "'$font', "; + } + $final = rtrim($final, ', '); + if ($final === '') { + return false; + } + return $final; + } + +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Ident.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Ident.php new file mode 100644 index 0000000..973002c --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Ident.php @@ -0,0 +1,32 @@ +def = $def; + $this->allow = $allow; + } + + /** + * Intercepts and removes !important if necessary + * @param string $string + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return bool|string + */ + public function validate($string, $config, $context) + { + // test for ! and important tokens + $string = trim($string); + $is_important = false; + // :TODO: optimization: test directly for !important and ! important + if (strlen($string) >= 9 && substr($string, -9) === 'important') { + $temp = rtrim(substr($string, 0, -9)); + // use a temp, because we might want to restore important + if (strlen($temp) >= 1 && substr($temp, -1) === '!') { + $string = rtrim(substr($temp, 0, -1)); + $is_important = true; + } + } + $string = $this->def->validate($string, $config, $context); + if ($this->allow && $is_important) { + $string .= ' !important'; + } + return $string; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Length.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Length.php new file mode 100644 index 0000000..f12453a --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Length.php @@ -0,0 +1,77 @@ +min = $min !== null ? HTMLPurifier_Length::make($min) : null; + $this->max = $max !== null ? HTMLPurifier_Length::make($max) : null; + } + + /** + * @param string $string + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return bool|string + */ + public function validate($string, $config, $context) + { + $string = $this->parseCDATA($string); + + // Optimizations + if ($string === '') { + return false; + } + if ($string === '0') { + return '0'; + } + if (strlen($string) === 1) { + return false; + } + + $length = HTMLPurifier_Length::make($string); + if (!$length->isValid()) { + return false; + } + + if ($this->min) { + $c = $length->compareTo($this->min); + if ($c === false) { + return false; + } + if ($c < 0) { + return false; + } + } + if ($this->max) { + $c = $length->compareTo($this->max); + if ($c === false) { + return false; + } + if ($c > 0) { + return false; + } + } + return $length->toString(); + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/ListStyle.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/ListStyle.php new file mode 100644 index 0000000..e74d426 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/ListStyle.php @@ -0,0 +1,112 @@ +getCSSDefinition(); + $this->info['list-style-type'] = $def->info['list-style-type']; + $this->info['list-style-position'] = $def->info['list-style-position']; + $this->info['list-style-image'] = $def->info['list-style-image']; + } + + /** + * @param string $string + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return bool|string + */ + public function validate($string, $config, $context) + { + // regular pre-processing + $string = $this->parseCDATA($string); + if ($string === '') { + return false; + } + + // assumes URI doesn't have spaces in it + $bits = explode(' ', strtolower($string)); // bits to process + + $caught = array(); + $caught['type'] = false; + $caught['position'] = false; + $caught['image'] = false; + + $i = 0; // number of catches + $none = false; + + foreach ($bits as $bit) { + if ($i >= 3) { + return; + } // optimization bit + if ($bit === '') { + continue; + } + foreach ($caught as $key => $status) { + if ($status !== false) { + continue; + } + $r = $this->info['list-style-' . $key]->validate($bit, $config, $context); + if ($r === false) { + continue; + } + if ($r === 'none') { + if ($none) { + continue; + } else { + $none = true; + } + if ($key == 'image') { + continue; + } + } + $caught[$key] = $r; + $i++; + break; + } + } + + if (!$i) { + return false; + } + + $ret = array(); + + // construct type + if ($caught['type']) { + $ret[] = $caught['type']; + } + + // construct image + if ($caught['image']) { + $ret[] = $caught['image']; + } + + // construct position + if ($caught['position']) { + $ret[] = $caught['position']; + } + + if (empty($ret)) { + return false; + } + return implode(' ', $ret); + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Multiple.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Multiple.php new file mode 100644 index 0000000..e707f87 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Multiple.php @@ -0,0 +1,71 @@ +single = $single; + $this->max = $max; + } + + /** + * @param string $string + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return bool|string + */ + public function validate($string, $config, $context) + { + $string = $this->mungeRgb($this->parseCDATA($string)); + if ($string === '') { + return false; + } + $parts = explode(' ', $string); // parseCDATA replaced \r, \t and \n + $length = count($parts); + $final = ''; + for ($i = 0, $num = 0; $i < $length && $num < $this->max; $i++) { + if (ctype_space($parts[$i])) { + continue; + } + $result = $this->single->validate($parts[$i], $config, $context); + if ($result !== false) { + $final .= $result . ' '; + $num++; + } + } + if ($final === '') { + return false; + } + return rtrim($final); + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Number.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Number.php new file mode 100644 index 0000000..ef49d20 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Number.php @@ -0,0 +1,90 @@ +non_negative = $non_negative; + } + + /** + * @param string $number + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return string|bool + * @warning Some contexts do not pass $config, $context. These + * variables should not be used without checking HTMLPurifier_Length + */ + public function validate($number, $config, $context) + { + $number = $this->parseCDATA($number); + + if ($number === '') { + return false; + } + if ($number === '0') { + return '0'; + } + + $sign = ''; + switch ($number[0]) { + case '-': + if ($this->non_negative) { + return false; + } + $sign = '-'; + case '+': + $number = substr($number, 1); + } + + if (ctype_digit($number)) { + $number = ltrim($number, '0'); + return $number ? $sign . $number : '0'; + } + + // Period is the only non-numeric character allowed + if (strpos($number, '.') === false) { + return false; + } + + list($left, $right) = explode('.', $number, 2); + + if ($left === '' && $right === '') { + return false; + } + if ($left !== '' && !ctype_digit($left)) { + return false; + } + + // Remove leading zeros until positive number or a zero stays left + if (ltrim($left, '0') != '') { + $left = ltrim($left, '0'); + } else { + $left = '0'; + } + + $right = rtrim($right, '0'); + + if ($right === '') { + return $left ? $sign . $left : '0'; + } elseif (!ctype_digit($right)) { + return false; + } + return $sign . $left . '.' . $right; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Percentage.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Percentage.php new file mode 100644 index 0000000..f0f25c5 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Percentage.php @@ -0,0 +1,54 @@ +number_def = new HTMLPurifier_AttrDef_CSS_Number($non_negative); + } + + /** + * @param string $string + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return bool|string + */ + public function validate($string, $config, $context) + { + $string = $this->parseCDATA($string); + + if ($string === '') { + return false; + } + $length = strlen($string); + if ($length === 1) { + return false; + } + if ($string[$length - 1] !== '%') { + return false; + } + + $number = substr($string, 0, $length - 1); + $number = $this->number_def->validate($number, $config, $context); + + if ($number === false) { + return false; + } + return "$number%"; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Ratio.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Ratio.php new file mode 100644 index 0000000..e08e2c4 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Ratio.php @@ -0,0 +1,46 @@ +parseCDATA($ratio); + + $parts = explode('/', $ratio, 2); + $length = count($parts); + + if ($length < 1 || $length > 2) { + return false; + } + + $num = new \HTMLPurifier_AttrDef_CSS_Number(); + + if ($length === 1) { + return $num->validate($parts[0], $config, $context); + } + + $num1 = $num->validate($parts[0], $config, $context); + $num2 = $num->validate($parts[1], $config, $context); + + if ($num1 === false || $num2 === false) { + return false; + } + + return $num1 . '/' . $num2; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/TextDecoration.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/TextDecoration.php new file mode 100644 index 0000000..5fd4b7f --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/TextDecoration.php @@ -0,0 +1,46 @@ + true, + 'overline' => true, + 'underline' => true, + ); + + $string = strtolower($this->parseCDATA($string)); + + if ($string === 'none') { + return $string; + } + + $parts = explode(' ', $string); + $final = ''; + foreach ($parts as $part) { + if (isset($allowed_values[$part])) { + $final .= $part . ' '; + } + } + $final = rtrim($final); + if ($final === '') { + return false; + } + return $final; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/URI.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/URI.php new file mode 100644 index 0000000..6617aca --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/URI.php @@ -0,0 +1,77 @@ +parseCDATA($uri_string); + if (strpos($uri_string, 'url(') !== 0) { + return false; + } + $uri_string = substr($uri_string, 4); + if (strlen($uri_string) == 0) { + return false; + } + $new_length = strlen($uri_string) - 1; + if ($uri_string[$new_length] != ')') { + return false; + } + $uri = trim(substr($uri_string, 0, $new_length)); + + if (!empty($uri) && ($uri[0] == "'" || $uri[0] == '"')) { + $quote = $uri[0]; + $new_length = strlen($uri) - 1; + if ($uri[$new_length] !== $quote) { + return false; + } + $uri = substr($uri, 1, $new_length - 1); + } + + $uri = $this->expandCSSEscape($uri); + + $result = parent::validate($uri, $config, $context); + + if ($result === false) { + return false; + } + + // extra sanity check; should have been done by URI + $result = str_replace(array('"', "\\", "\n", "\x0c", "\r"), "", $result); + + // suspicious characters are ()'; we're going to percent encode + // them for safety. + $result = str_replace(array('(', ')', "'"), array('%28', '%29', '%27'), $result); + + // there's an extra bug where ampersands lose their escaping on + // an innerHTML cycle, so a very unlucky query parameter could + // then change the meaning of the URL. Unfortunately, there's + // not much we can do about that... + return "url(\"$result\")"; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/Clone.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/Clone.php new file mode 100644 index 0000000..6698a00 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/Clone.php @@ -0,0 +1,44 @@ +clone = $clone; + } + + /** + * @param string $v + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return bool|string + */ + public function validate($v, $config, $context) + { + return $this->clone->validate($v, $config, $context); + } + + /** + * @param string $string + * @return HTMLPurifier_AttrDef + */ + public function make($string) + { + return clone $this->clone; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/Enum.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/Enum.php new file mode 100644 index 0000000..8abda7f --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/Enum.php @@ -0,0 +1,73 @@ +valid_values = array_flip($valid_values); + $this->case_sensitive = $case_sensitive; + } + + /** + * @param string $string + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return bool|string + */ + public function validate($string, $config, $context) + { + $string = trim($string); + if (!$this->case_sensitive) { + // we may want to do full case-insensitive libraries + $string = ctype_lower($string) ? $string : strtolower($string); + } + $result = isset($this->valid_values[$string]); + + return $result ? $string : false; + } + + /** + * @param string $string In form of comma-delimited list of case-insensitive + * valid values. Example: "foo,bar,baz". Prepend "s:" to make + * case sensitive + * @return HTMLPurifier_AttrDef_Enum + */ + public function make($string) + { + if (strlen($string) > 2 && $string[0] == 's' && $string[1] == ':') { + $string = substr($string, 2); + $sensitive = true; + } else { + $sensitive = false; + } + $values = explode(',', $string); + return new HTMLPurifier_AttrDef_Enum($values, $sensitive); + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/Bool.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/Bool.php new file mode 100644 index 0000000..be3bbc8 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/Bool.php @@ -0,0 +1,48 @@ +name = $name; + } + + /** + * @param string $string + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return bool|string + */ + public function validate($string, $config, $context) + { + return $this->name; + } + + /** + * @param string $string Name of attribute + * @return HTMLPurifier_AttrDef_HTML_Bool + */ + public function make($string) + { + return new HTMLPurifier_AttrDef_HTML_Bool($string); + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/Class.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/Class.php new file mode 100644 index 0000000..d501348 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/Class.php @@ -0,0 +1,48 @@ +getDefinition('HTML')->doctype->name; + if ($name == "XHTML 1.1" || $name == "XHTML 2.0") { + return parent::split($string, $config, $context); + } else { + return preg_split('/\s+/', $string); + } + } + + /** + * @param array $tokens + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return array + */ + protected function filter($tokens, $config, $context) + { + $allowed = $config->get('Attr.AllowedClasses'); + $forbidden = $config->get('Attr.ForbiddenClasses'); + $ret = array(); + foreach ($tokens as $token) { + if (($allowed === null || isset($allowed[$token])) && + !isset($forbidden[$token]) && + // We need this O(n) check because of PHP's array + // implementation that casts -0 to 0. + !in_array($token, $ret, true) + ) { + $ret[] = $token; + } + } + return $ret; + } +} diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/Color.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/Color.php new file mode 100644 index 0000000..946ebb7 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/Color.php @@ -0,0 +1,51 @@ +get('Core.ColorKeywords'); + } + + $string = trim($string); + + if (empty($string)) { + return false; + } + $lower = strtolower($string); + if (isset($colors[$lower])) { + return $colors[$lower]; + } + if ($string[0] === '#') { + $hex = substr($string, 1); + } else { + $hex = $string; + } + + $length = strlen($hex); + if ($length !== 3 && $length !== 6) { + return false; + } + if (!ctype_xdigit($hex)) { + return false; + } + if ($length === 3) { + $hex = $hex[0] . $hex[0] . $hex[1] . $hex[1] . $hex[2] . $hex[2]; + } + return "#$hex"; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/ContentEditable.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/ContentEditable.php new file mode 100644 index 0000000..5b03d3e --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/ContentEditable.php @@ -0,0 +1,16 @@ +get('HTML.Trusted')) { + $allowed = array('', 'true', 'false'); + } + + $enum = new HTMLPurifier_AttrDef_Enum($allowed); + + return $enum->validate($string, $config, $context); + } +} diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/FrameTarget.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/FrameTarget.php new file mode 100644 index 0000000..d79ba12 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/FrameTarget.php @@ -0,0 +1,38 @@ +valid_values === false) { + $this->valid_values = $config->get('Attr.AllowedFrameTargets'); + } + return parent::validate($string, $config, $context); + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/ID.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/ID.php new file mode 100644 index 0000000..4ba4561 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/ID.php @@ -0,0 +1,113 @@ +selector = $selector; + } + + /** + * @param string $id + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return bool|string + */ + public function validate($id, $config, $context) + { + if (!$this->selector && !$config->get('Attr.EnableID')) { + return false; + } + + $id = trim($id); // trim it first + + if ($id === '') { + return false; + } + + $prefix = $config->get('Attr.IDPrefix'); + if ($prefix !== '') { + $prefix .= $config->get('Attr.IDPrefixLocal'); + // prevent re-appending the prefix + if (strpos($id, $prefix) !== 0) { + $id = $prefix . $id; + } + } elseif ($config->get('Attr.IDPrefixLocal') !== '') { + trigger_error( + '%Attr.IDPrefixLocal cannot be used unless ' . + '%Attr.IDPrefix is set', + E_USER_WARNING + ); + } + + if (!$this->selector) { + $id_accumulator =& $context->get('IDAccumulator'); + if (isset($id_accumulator->ids[$id])) { + return false; + } + } + + // we purposely avoid using regex, hopefully this is faster + + if ($config->get('Attr.ID.HTML5') === true) { + if (preg_match('/[\t\n\x0b\x0c ]/', $id)) { + return false; + } + } else { + if (ctype_alpha($id)) { + // OK + } else { + if (!ctype_alpha(@$id[0])) { + return false; + } + // primitive style of regexps, I suppose + $trim = trim( + $id, + 'A..Za..z0..9:-._' + ); + if ($trim !== '') { + return false; + } + } + } + + $regexp = $config->get('Attr.IDBlacklistRegexp'); + if ($regexp && preg_match($regexp, $id)) { + return false; + } + + if (!$this->selector) { + $id_accumulator->add($id); + } + + // if no change was made to the ID, return the result + // else, return the new id if stripping whitespace made it + // valid, or return false. + return $id; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/Length.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/Length.php new file mode 100644 index 0000000..1c4006f --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/Length.php @@ -0,0 +1,56 @@ + 100) { + return '100%'; + } + return ((string)$points) . '%'; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/LinkTypes.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/LinkTypes.php new file mode 100644 index 0000000..63fa04c --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/LinkTypes.php @@ -0,0 +1,72 @@ + 'AllowedRel', + 'rev' => 'AllowedRev' + ); + if (!isset($configLookup[$name])) { + trigger_error( + 'Unrecognized attribute name for link ' . + 'relationship.', + E_USER_ERROR + ); + return; + } + $this->name = $configLookup[$name]; + } + + /** + * @param string $string + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return bool|string + */ + public function validate($string, $config, $context) + { + $allowed = $config->get('Attr.' . $this->name); + if (empty($allowed)) { + return false; + } + + $string = $this->parseCDATA($string); + $parts = explode(' ', $string); + + // lookup to prevent duplicates + $ret_lookup = array(); + foreach ($parts as $part) { + $part = strtolower(trim($part)); + if (!isset($allowed[$part])) { + continue; + } + $ret_lookup[$part] = true; + } + + if (empty($ret_lookup)) { + return false; + } + $string = implode(' ', array_keys($ret_lookup)); + return $string; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/MultiLength.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/MultiLength.php new file mode 100644 index 0000000..bbb20f2 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/MultiLength.php @@ -0,0 +1,60 @@ +split($string, $config, $context); + $tokens = $this->filter($tokens, $config, $context); + if (empty($tokens)) { + return false; + } + return implode(' ', $tokens); + } + + /** + * Splits a space separated list of tokens into its constituent parts. + * @param string $string + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return array + */ + protected function split($string, $config, $context) + { + // OPTIMIZABLE! + // do the preg_match, capture all subpatterns for reformulation + + // we don't support U+00A1 and up codepoints or + // escaping because I don't know how to do that with regexps + // and plus it would complicate optimization efforts (you never + // see that anyway). + $pattern = '/(?:(?<=\s)|\A)' . // look behind for space or string start + '((?:--|-?[A-Za-z_])[A-Za-z_\-0-9]*)' . + '(?:(?=\s)|\z)/'; // look ahead for space or string end + preg_match_all($pattern, $string, $matches); + return $matches[1]; + } + + /** + * Template method for removing certain tokens based on arbitrary criteria. + * @note If we wanted to be really functional, we'd do an array_filter + * with a callback. But... we're not. + * @param array $tokens + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return array + */ + protected function filter($tokens, $config, $context) + { + return $tokens; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/Pixels.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/Pixels.php new file mode 100644 index 0000000..a1d019e --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/Pixels.php @@ -0,0 +1,76 @@ +max = $max; + } + + /** + * @param string $string + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return bool|string + */ + public function validate($string, $config, $context) + { + $string = trim($string); + if ($string === '0') { + return $string; + } + if ($string === '') { + return false; + } + $length = strlen($string); + if (substr($string, $length - 2) == 'px') { + $string = substr($string, 0, $length - 2); + } + if (!is_numeric($string)) { + return false; + } + $int = (int)$string; + + if ($int < 0) { + return '0'; + } + + // upper-bound value, extremely high values can + // crash operating systems, see + // WARNING, above link WILL crash you if you're using Windows + + if ($this->max !== null && $int > $this->max) { + return (string)$this->max; + } + return (string)$int; + } + + /** + * @param string $string + * @return HTMLPurifier_AttrDef + */ + public function make($string) + { + if ($string === '') { + $max = null; + } else { + $max = (int)$string; + } + $class = get_class($this); + return new $class($max); + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/Integer.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/Integer.php new file mode 100644 index 0000000..400e707 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/Integer.php @@ -0,0 +1,91 @@ +negative = $negative; + $this->zero = $zero; + $this->positive = $positive; + } + + /** + * @param string $integer + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return bool|string + */ + public function validate($integer, $config, $context) + { + $integer = $this->parseCDATA($integer); + if ($integer === '') { + return false; + } + + // we could possibly simply typecast it to integer, but there are + // certain fringe cases that must not return an integer. + + // clip leading sign + if ($this->negative && $integer[0] === '-') { + $digits = substr($integer, 1); + if ($digits === '0') { + $integer = '0'; + } // rm minus sign for zero + } elseif ($this->positive && $integer[0] === '+') { + $digits = $integer = substr($integer, 1); // rm unnecessary plus + } else { + $digits = $integer; + } + + // test if it's numeric + if (!ctype_digit($digits)) { + return false; + } + + // perform scope tests + if (!$this->zero && $integer == 0) { + return false; + } + if (!$this->positive && $integer > 0) { + return false; + } + if (!$this->negative && $integer < 0) { + return false; + } + + return $integer; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/Lang.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/Lang.php new file mode 100644 index 0000000..2a55cea --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/Lang.php @@ -0,0 +1,86 @@ + 8 || !ctype_alnum($subtags[1])) { + return $new_string; + } + if (!ctype_lower($subtags[1])) { + $subtags[1] = strtolower($subtags[1]); + } + + $new_string .= '-' . $subtags[1]; + if ($num_subtags == 2) { + return $new_string; + } + + // process all other subtags, index 2 and up + for ($i = 2; $i < $num_subtags; $i++) { + $length = strlen($subtags[$i]); + if ($length == 0 || $length > 8 || !ctype_alnum($subtags[$i])) { + return $new_string; + } + if (!ctype_lower($subtags[$i])) { + $subtags[$i] = strtolower($subtags[$i]); + } + $new_string .= '-' . $subtags[$i]; + } + return $new_string; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/Switch.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/Switch.php new file mode 100644 index 0000000..c7eb319 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/Switch.php @@ -0,0 +1,53 @@ +tag = $tag; + $this->withTag = $with_tag; + $this->withoutTag = $without_tag; + } + + /** + * @param string $string + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return bool|string + */ + public function validate($string, $config, $context) + { + $token = $context->get('CurrentToken', true); + if (!$token || $token->name !== $this->tag) { + return $this->withoutTag->validate($string, $config, $context); + } else { + return $this->withTag->validate($string, $config, $context); + } + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/Text.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/Text.php new file mode 100644 index 0000000..4553a4e --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/Text.php @@ -0,0 +1,21 @@ +parseCDATA($string); + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/URI.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/URI.php new file mode 100644 index 0000000..c1cd897 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/URI.php @@ -0,0 +1,111 @@ +parser = new HTMLPurifier_URIParser(); + $this->embedsResource = (bool)$embeds_resource; + } + + /** + * @param string $string + * @return HTMLPurifier_AttrDef_URI + */ + public function make($string) + { + $embeds = ($string === 'embedded'); + return new HTMLPurifier_AttrDef_URI($embeds); + } + + /** + * @param string $uri + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return bool|string + */ + public function validate($uri, $config, $context) + { + if ($config->get('URI.Disable')) { + return false; + } + + $uri = $this->parseCDATA($uri); + + // parse the URI + $uri = $this->parser->parse($uri); + if ($uri === false) { + return false; + } + + // add embedded flag to context for validators + $context->register('EmbeddedURI', $this->embedsResource); + + $ok = false; + do { + + // generic validation + $result = $uri->validate($config, $context); + if (!$result) { + break; + } + + // chained filtering + $uri_def = $config->getDefinition('URI'); + $result = $uri_def->filter($uri, $config, $context); + if (!$result) { + break; + } + + // scheme-specific validation + $scheme_obj = $uri->getSchemeObj($config, $context); + if (!$scheme_obj) { + break; + } + if ($this->embedsResource && !$scheme_obj->browsable) { + break; + } + $result = $scheme_obj->validate($uri, $config, $context); + if (!$result) { + break; + } + + // Post chained filtering + $result = $uri_def->postFilter($uri, $config, $context); + if (!$result) { + break; + } + + // survived gauntlet + $ok = true; + + } while (false); + + $context->destroy('EmbeddedURI'); + if (!$ok) { + return false; + } + // back to string + return $uri->toString(); + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/URI/Email.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/URI/Email.php new file mode 100644 index 0000000..daf32b7 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/URI/Email.php @@ -0,0 +1,20 @@ +" + // that needs more percent encoding to be done + if ($string == '') { + return false; + } + $string = trim($string); + $result = preg_match('/^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i', $string); + return $result ? $string : false; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/URI/Host.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/URI/Host.php new file mode 100644 index 0000000..17a97c1 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/URI/Host.php @@ -0,0 +1,136 @@ +ipv4 = new HTMLPurifier_AttrDef_URI_IPv4(); + $this->ipv6 = new HTMLPurifier_AttrDef_URI_IPv6(); + } + + /** + * @param string $string + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return bool|string + */ + public function validate($string, $config, $context) + { + $length = strlen($string); + // empty hostname is OK; it's usually semantically equivalent: + // the default host as defined by a URI scheme is used: + // + // If the URI scheme defines a default for host, then that + // default applies when the host subcomponent is undefined + // or when the registered name is empty (zero length). + if ($string === '') { + return ''; + } + if ($length > 1 && $string[0] === '[' && $string[$length - 1] === ']') { + //IPv6 + $ip = substr($string, 1, $length - 2); + $valid = $this->ipv6->validate($ip, $config, $context); + if ($valid === false) { + return false; + } + return '[' . $valid . ']'; + } + + // need to do checks on unusual encodings too + $ipv4 = $this->ipv4->validate($string, $config, $context); + if ($ipv4 !== false) { + return $ipv4; + } + + // A regular domain name. + + // This doesn't match I18N domain names, but we don't have proper IRI support, + // so force users to insert Punycode. + + // Underscores defined as Unreserved Characters in RFC 3986 are + // allowed in a URI. There are cases where we want to consider a + // URI containing "_" such as "_dmarc.example.com". + // Underscores are not allowed in the default. If you want to + // allow it, set Core.AllowHostnameUnderscore to true. + $underscore = $config->get('Core.AllowHostnameUnderscore') ? '_' : ''; + + // Based off of RFC 1738, but amended so that + // as per RFC 3696, the top label need only not be all numeric. + // The productions describing this are: + $a = '[a-z]'; // alpha + $an = "[a-z0-9$underscore]"; // alphanum + $and = "[a-z0-9-$underscore]"; // alphanum | "-" + // domainlabel = alphanum | alphanum *( alphanum | "-" ) alphanum + $domainlabel = "$an(?:$and*$an)?"; + // AMENDED as per RFC 3696 + // toplabel = alphanum | alphanum *( alphanum | "-" ) alphanum + // side condition: not all numeric + $toplabel = "$an(?:$and*$an)?"; + // hostname = *( domainlabel "." ) toplabel [ "." ] + if (preg_match("/^(?:$domainlabel\.)*($toplabel)\.?$/i", $string, $matches)) { + if (!ctype_digit($matches[1])) { + return $string; + } + } + + // PHP 5.3 and later support this functionality natively + if (function_exists('idn_to_ascii')) { + if (defined('IDNA_NONTRANSITIONAL_TO_ASCII') && defined('INTL_IDNA_VARIANT_UTS46')) { + $string = idn_to_ascii($string, IDNA_NONTRANSITIONAL_TO_ASCII, INTL_IDNA_VARIANT_UTS46); + } else { + $string = idn_to_ascii($string); + } + + // If we have Net_IDNA2 support, we can support IRIs by + // punycoding them. (This is the most portable thing to do, + // since otherwise we have to assume browsers support + } elseif ($config->get('Core.EnableIDNA') && class_exists('Net_IDNA2')) { + $idna = new Net_IDNA2(array('encoding' => 'utf8', 'overlong' => false, 'strict' => true)); + // we need to encode each period separately + $parts = explode('.', $string); + try { + $new_parts = array(); + foreach ($parts as $part) { + $encodable = false; + for ($i = 0, $c = strlen($part); $i < $c; $i++) { + if (ord($part[$i]) > 0x7a) { + $encodable = true; + break; + } + } + if (!$encodable) { + $new_parts[] = $part; + } else { + $new_parts[] = $idna->encode($part); + } + } + $string = implode('.', $new_parts); + } catch (Exception $e) { + // XXX error reporting + } + } + // Try again + if (preg_match("/^($domainlabel\.)*$toplabel\.?$/i", $string)) { + return $string; + } + return false; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/URI/IPv4.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/URI/IPv4.php new file mode 100644 index 0000000..30ac16c --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/URI/IPv4.php @@ -0,0 +1,45 @@ +ip4) { + $this->_loadRegex(); + } + + if (preg_match('#^' . $this->ip4 . '$#s', $aIP)) { + return $aIP; + } + return false; + } + + /** + * Lazy load function to prevent regex from being stuffed in + * cache. + */ + protected function _loadRegex() + { + $oct = '(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]|[0-9])'; // 0-255 + $this->ip4 = "(?:{$oct}\\.{$oct}\\.{$oct}\\.{$oct})"; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/URI/IPv6.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/URI/IPv6.php new file mode 100644 index 0000000..f243793 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/URI/IPv6.php @@ -0,0 +1,89 @@ +ip4) { + $this->_loadRegex(); + } + + $original = $aIP; + + $hex = '[0-9a-fA-F]'; + $blk = '(?:' . $hex . '{1,4})'; + $pre = '(?:/(?:12[0-8]|1[0-1][0-9]|[1-9][0-9]|[0-9]))'; // /0 - /128 + + // prefix check + if (strpos($aIP, '/') !== false) { + if (preg_match('#' . $pre . '$#s', $aIP, $find)) { + $aIP = substr($aIP, 0, 0 - strlen($find[0])); + unset($find); + } else { + return false; + } + } + + // IPv4-compatiblity check + if (preg_match('#(?<=:' . ')' . $this->ip4 . '$#s', $aIP, $find)) { + $aIP = substr($aIP, 0, 0 - strlen($find[0])); + $ip = explode('.', $find[0]); + $ip = array_map('dechex', $ip); + $aIP .= $ip[0] . $ip[1] . ':' . $ip[2] . $ip[3]; + unset($find, $ip); + } + + // compression check + $aIP = explode('::', $aIP); + $c = count($aIP); + if ($c > 2) { + return false; + } elseif ($c == 2) { + list($first, $second) = $aIP; + $first = explode(':', $first); + $second = explode(':', $second); + + if (count($first) + count($second) > 8) { + return false; + } + + while (count($first) < 8) { + array_push($first, '0'); + } + + array_splice($first, 8 - count($second), 8, $second); + $aIP = $first; + unset($first, $second); + } else { + $aIP = explode(':', $aIP[0]); + } + $c = count($aIP); + + if ($c != 8) { + return false; + } + + // All the pieces should be 16-bit hex strings. Are they? + foreach ($aIP as $piece) { + if (!preg_match('#^[0-9a-fA-F]{4}$#s', sprintf('%04s', $piece))) { + return false; + } + } + return $original; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform.php new file mode 100644 index 0000000..b428331 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform.php @@ -0,0 +1,60 @@ +confiscateAttr($attr, 'background'); + // some validation should happen here + + $this->prependCSS($attr, "background-image:url($background);"); + return $attr; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/BdoDir.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/BdoDir.php new file mode 100644 index 0000000..d66c04a --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/BdoDir.php @@ -0,0 +1,27 @@ +get('Attr.DefaultTextDir'); + return $attr; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/BgColor.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/BgColor.php new file mode 100644 index 0000000..0f51fd2 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/BgColor.php @@ -0,0 +1,28 @@ +confiscateAttr($attr, 'bgcolor'); + // some validation should happen here + + $this->prependCSS($attr, "background-color:$bgcolor;"); + return $attr; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/BoolToCSS.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/BoolToCSS.php new file mode 100644 index 0000000..f25cd01 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/BoolToCSS.php @@ -0,0 +1,47 @@ +attr = $attr; + $this->css = $css; + } + + /** + * @param array $attr + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return array + */ + public function transform($attr, $config, $context) + { + if (!isset($attr[$this->attr])) { + return $attr; + } + unset($attr[$this->attr]); + $this->prependCSS($attr, $this->css); + return $attr; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/Border.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/Border.php new file mode 100644 index 0000000..057dc01 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/Border.php @@ -0,0 +1,26 @@ +confiscateAttr($attr, 'border'); + // some validation should happen here + $this->prependCSS($attr, "border:{$border_width}px solid;"); + return $attr; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/EnumToCSS.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/EnumToCSS.php new file mode 100644 index 0000000..7ccd0e3 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/EnumToCSS.php @@ -0,0 +1,68 @@ +attr = $attr; + $this->enumToCSS = $enum_to_css; + $this->caseSensitive = (bool)$case_sensitive; + } + + /** + * @param array $attr + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return array + */ + public function transform($attr, $config, $context) + { + if (!isset($attr[$this->attr])) { + return $attr; + } + + $value = trim($attr[$this->attr]); + unset($attr[$this->attr]); + + if (!$this->caseSensitive) { + $value = strtolower($value); + } + + if (!isset($this->enumToCSS[$value])) { + return $attr; + } + $this->prependCSS($attr, $this->enumToCSS[$value]); + return $attr; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/ImgRequired.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/ImgRequired.php new file mode 100644 index 0000000..235ebb3 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/ImgRequired.php @@ -0,0 +1,47 @@ +get('Core.RemoveInvalidImg')) { + return $attr; + } + $attr['src'] = $config->get('Attr.DefaultInvalidImage'); + $src = false; + } + + if (!isset($attr['alt'])) { + if ($src) { + $alt = $config->get('Attr.DefaultImageAlt'); + if ($alt === null) { + $attr['alt'] = basename($attr['src']); + } else { + $attr['alt'] = $alt; + } + } else { + $attr['alt'] = $config->get('Attr.DefaultInvalidImageAlt'); + } + } + return $attr; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/ImgSpace.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/ImgSpace.php new file mode 100644 index 0000000..350b335 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/ImgSpace.php @@ -0,0 +1,61 @@ + array('left', 'right'), + 'vspace' => array('top', 'bottom') + ); + + /** + * @param string $attr + */ + public function __construct($attr) + { + $this->attr = $attr; + if (!isset($this->css[$attr])) { + trigger_error(htmlspecialchars($attr) . ' is not valid space attribute'); + } + } + + /** + * @param array $attr + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return array + */ + public function transform($attr, $config, $context) + { + if (!isset($attr[$this->attr])) { + return $attr; + } + + $width = $this->confiscateAttr($attr, $this->attr); + // some validation could happen here + + if (!isset($this->css[$this->attr])) { + return $attr; + } + + $style = ''; + foreach ($this->css[$this->attr] as $suffix) { + $property = "margin-$suffix"; + $style .= "$property:{$width}px;"; + } + $this->prependCSS($attr, $style); + return $attr; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/Input.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/Input.php new file mode 100644 index 0000000..3ab47ed --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/Input.php @@ -0,0 +1,56 @@ +pixels = new HTMLPurifier_AttrDef_HTML_Pixels(); + } + + /** + * @param array $attr + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return array + */ + public function transform($attr, $config, $context) + { + if (!isset($attr['type'])) { + $t = 'text'; + } else { + $t = strtolower($attr['type']); + } + if (isset($attr['checked']) && $t !== 'radio' && $t !== 'checkbox') { + unset($attr['checked']); + } + if (isset($attr['maxlength']) && $t !== 'text' && $t !== 'password') { + unset($attr['maxlength']); + } + if (isset($attr['size']) && $t !== 'text' && $t !== 'password') { + $result = $this->pixels->validate($attr['size'], $config, $context); + if ($result === false) { + unset($attr['size']); + } else { + $attr['size'] = $result; + } + } + if (isset($attr['src']) && $t !== 'image') { + unset($attr['src']); + } + if (!isset($attr['value']) && ($t === 'radio' || $t === 'checkbox')) { + $attr['value'] = ''; + } + return $attr; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/Lang.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/Lang.php new file mode 100644 index 0000000..5b0aff0 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/Lang.php @@ -0,0 +1,31 @@ +name = $name; + $this->cssName = $css_name ? $css_name : $name; + } + + /** + * @param array $attr + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return array + */ + public function transform($attr, $config, $context) + { + if (!isset($attr[$this->name])) { + return $attr; + } + $length = $this->confiscateAttr($attr, $this->name); + if (ctype_digit($length)) { + $length .= 'px'; + } + $this->prependCSS($attr, $this->cssName . ":$length;"); + return $attr; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/Name.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/Name.php new file mode 100644 index 0000000..63cce68 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/Name.php @@ -0,0 +1,33 @@ +get('HTML.Attr.Name.UseCDATA')) { + return $attr; + } + if (!isset($attr['name'])) { + return $attr; + } + $id = $this->confiscateAttr($attr, 'name'); + if (isset($attr['id'])) { + return $attr; + } + $attr['id'] = $id; + return $attr; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/NameSync.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/NameSync.php new file mode 100644 index 0000000..5a1fdbb --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/NameSync.php @@ -0,0 +1,46 @@ +idDef = new HTMLPurifier_AttrDef_HTML_ID(); + } + + /** + * @param array $attr + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return array + */ + public function transform($attr, $config, $context) + { + if (!isset($attr['name'])) { + return $attr; + } + $name = $attr['name']; + if (isset($attr['id']) && $attr['id'] === $name) { + return $attr; + } + $result = $this->idDef->validate($name, $config, $context); + if ($result === false) { + unset($attr['name']); + } else { + $attr['name'] = $result; + } + return $attr; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/Nofollow.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/Nofollow.php new file mode 100644 index 0000000..1057ebe --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/Nofollow.php @@ -0,0 +1,52 @@ +parser = new HTMLPurifier_URIParser(); + } + + /** + * @param array $attr + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return array + */ + public function transform($attr, $config, $context) + { + if (!isset($attr['href'])) { + return $attr; + } + + // XXX Kind of inefficient + $url = $this->parser->parse($attr['href']); + $scheme = $url->getSchemeObj($config, $context); + + if ($scheme->browsable && !$url->isLocal($config, $context)) { + if (isset($attr['rel'])) { + $rels = explode(' ', $attr['rel']); + if (!in_array('nofollow', $rels)) { + $rels[] = 'nofollow'; + } + $attr['rel'] = implode(' ', $rels); + } else { + $attr['rel'] = 'nofollow'; + } + } + return $attr; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/SafeEmbed.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/SafeEmbed.php new file mode 100644 index 0000000..231c81a --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/SafeEmbed.php @@ -0,0 +1,25 @@ +uri = new HTMLPurifier_AttrDef_URI(true); // embedded + $this->wmode = new HTMLPurifier_AttrDef_Enum(array('window', 'opaque', 'transparent')); + } + + /** + * @param array $attr + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return array + */ + public function transform($attr, $config, $context) + { + // If we add support for other objects, we'll need to alter the + // transforms. + switch ($attr['name']) { + // application/x-shockwave-flash + // Keep this synchronized with Injector/SafeObject.php + case 'allowScriptAccess': + $attr['value'] = 'never'; + break; + case 'allowNetworking': + $attr['value'] = 'internal'; + break; + case 'allowFullScreen': + if ($config->get('HTML.FlashAllowFullScreen')) { + $attr['value'] = ($attr['value'] == 'true') ? 'true' : 'false'; + } else { + $attr['value'] = 'false'; + } + break; + case 'wmode': + $attr['value'] = $this->wmode->validate($attr['value'], $config, $context); + break; + case 'movie': + case 'src': + $attr['name'] = "movie"; + $attr['value'] = $this->uri->validate($attr['value'], $config, $context); + break; + case 'flashvars': + // we're going to allow arbitrary inputs to the SWF, on + // the reasoning that it could only hack the SWF, not us. + break; + // add other cases to support other param name/value pairs + default: + $attr['name'] = $attr['value'] = null; + } + return $attr; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/ScriptRequired.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/ScriptRequired.php new file mode 100644 index 0000000..b7057bb --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/ScriptRequired.php @@ -0,0 +1,23 @@ + + */ +class HTMLPurifier_AttrTransform_ScriptRequired extends HTMLPurifier_AttrTransform +{ + /** + * @param array $attr + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return array + */ + public function transform($attr, $config, $context) + { + if (!isset($attr['type'])) { + $attr['type'] = 'text/javascript'; + } + return $attr; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/TargetBlank.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/TargetBlank.php new file mode 100644 index 0000000..cc30ab8 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/TargetBlank.php @@ -0,0 +1,49 @@ +parser = new HTMLPurifier_URIParser(); + } + + /** + * @param array $attr + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return array + */ + public function transform($attr, $config, $context) + { + if (!isset($attr['href'])) { + return $attr; + } + + // XXX Kind of inefficient + $url = $this->parser->parse($attr['href']); + + // Ignore invalid schemes (e.g. `javascript:`) + if (!($scheme = $url->getSchemeObj($config, $context))) { + return $attr; + } + + if ($scheme->browsable && !$url->isBenign($config, $context)) { + $attr['target'] = '_blank'; + } + return $attr; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/TargetNoopener.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/TargetNoopener.php new file mode 100644 index 0000000..1db3c6c --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/TargetNoopener.php @@ -0,0 +1,37 @@ + + */ +class HTMLPurifier_AttrTransform_Textarea extends HTMLPurifier_AttrTransform +{ + /** + * @param array $attr + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return array + */ + public function transform($attr, $config, $context) + { + // Calculated from Firefox + if (!isset($attr['cols'])) { + $attr['cols'] = '22'; + } + if (!isset($attr['rows'])) { + $attr['rows'] = '3'; + } + return $attr; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTypes.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTypes.php new file mode 100644 index 0000000..e4429e8 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTypes.php @@ -0,0 +1,97 @@ +info['Enum'] = new HTMLPurifier_AttrDef_Enum(); + $this->info['Bool'] = new HTMLPurifier_AttrDef_HTML_Bool(); + + $this->info['CDATA'] = new HTMLPurifier_AttrDef_Text(); + $this->info['ID'] = new HTMLPurifier_AttrDef_HTML_ID(); + $this->info['Length'] = new HTMLPurifier_AttrDef_HTML_Length(); + $this->info['MultiLength'] = new HTMLPurifier_AttrDef_HTML_MultiLength(); + $this->info['NMTOKENS'] = new HTMLPurifier_AttrDef_HTML_Nmtokens(); + $this->info['Pixels'] = new HTMLPurifier_AttrDef_HTML_Pixels(); + $this->info['Text'] = new HTMLPurifier_AttrDef_Text(); + $this->info['URI'] = new HTMLPurifier_AttrDef_URI(); + $this->info['LanguageCode'] = new HTMLPurifier_AttrDef_Lang(); + $this->info['Color'] = new HTMLPurifier_AttrDef_HTML_Color(); + $this->info['IAlign'] = self::makeEnum('top,middle,bottom,left,right'); + $this->info['LAlign'] = self::makeEnum('top,bottom,left,right'); + $this->info['FrameTarget'] = new HTMLPurifier_AttrDef_HTML_FrameTarget(); + $this->info['ContentEditable'] = new HTMLPurifier_AttrDef_HTML_ContentEditable(); + + // unimplemented aliases + $this->info['ContentType'] = new HTMLPurifier_AttrDef_Text(); + $this->info['ContentTypes'] = new HTMLPurifier_AttrDef_Text(); + $this->info['Charsets'] = new HTMLPurifier_AttrDef_Text(); + $this->info['Character'] = new HTMLPurifier_AttrDef_Text(); + + // "proprietary" types + $this->info['Class'] = new HTMLPurifier_AttrDef_HTML_Class(); + + // number is really a positive integer (one or more digits) + // FIXME: ^^ not always, see start and value of list items + $this->info['Number'] = new HTMLPurifier_AttrDef_Integer(false, false, true); + } + + private static function makeEnum($in) + { + return new HTMLPurifier_AttrDef_Clone(new HTMLPurifier_AttrDef_Enum(explode(',', $in))); + } + + /** + * Retrieves a type + * @param string $type String type name + * @return HTMLPurifier_AttrDef Object AttrDef for type + */ + public function get($type) + { + // determine if there is any extra info tacked on + if (strpos($type, '#') !== false) { + list($type, $string) = explode('#', $type, 2); + } else { + $string = ''; + } + + if (!isset($this->info[$type])) { + trigger_error('Cannot retrieve undefined attribute type ' . $type, E_USER_ERROR); + return; + } + return $this->info[$type]->make($string); + } + + /** + * Sets a new implementation for a type + * @param string $type String type name + * @param HTMLPurifier_AttrDef $impl Object AttrDef for type + */ + public function set($type, $impl) + { + $this->info[$type] = $impl; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrValidator.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrValidator.php new file mode 100644 index 0000000..f97dc93 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrValidator.php @@ -0,0 +1,178 @@ +getHTMLDefinition(); + $e =& $context->get('ErrorCollector', true); + + // initialize IDAccumulator if necessary + $ok =& $context->get('IDAccumulator', true); + if (!$ok) { + $id_accumulator = HTMLPurifier_IDAccumulator::build($config, $context); + $context->register('IDAccumulator', $id_accumulator); + } + + // initialize CurrentToken if necessary + $current_token =& $context->get('CurrentToken', true); + if (!$current_token) { + $context->register('CurrentToken', $token); + } + + if (!$token instanceof HTMLPurifier_Token_Start && + !$token instanceof HTMLPurifier_Token_Empty + ) { + return; + } + + // create alias to global definition array, see also $defs + // DEFINITION CALL + $d_defs = $definition->info_global_attr; + + // don't update token until the very end, to ensure an atomic update + $attr = $token->attr; + + // do global transformations (pre) + // nothing currently utilizes this + foreach ($definition->info_attr_transform_pre as $transform) { + $attr = $transform->transform($o = $attr, $config, $context); + if ($e) { + if ($attr != $o) { + $e->send(E_NOTICE, 'AttrValidator: Attributes transformed', $o, $attr); + } + } + } + + // do local transformations only applicable to this element (pre) + // ex.

    to

    + foreach ($definition->info[$token->name]->attr_transform_pre as $transform) { + $attr = $transform->transform($o = $attr, $config, $context); + if ($e) { + if ($attr != $o) { + $e->send(E_NOTICE, 'AttrValidator: Attributes transformed', $o, $attr); + } + } + } + + // create alias to this element's attribute definition array, see + // also $d_defs (global attribute definition array) + // DEFINITION CALL + $defs = $definition->info[$token->name]->attr; + + $attr_key = false; + $context->register('CurrentAttr', $attr_key); + + // iterate through all the attribute keypairs + // Watch out for name collisions: $key has previously been used + foreach ($attr as $attr_key => $value) { + + // call the definition + if (isset($defs[$attr_key])) { + // there is a local definition defined + if ($defs[$attr_key] === false) { + // We've explicitly been told not to allow this element. + // This is usually when there's a global definition + // that must be overridden. + // Theoretically speaking, we could have a + // AttrDef_DenyAll, but this is faster! + $result = false; + } else { + // validate according to the element's definition + $result = $defs[$attr_key]->validate( + $value, + $config, + $context + ); + } + } elseif (isset($d_defs[$attr_key])) { + // there is a global definition defined, validate according + // to the global definition + $result = $d_defs[$attr_key]->validate( + $value, + $config, + $context + ); + } else { + // system never heard of the attribute? DELETE! + $result = false; + } + + // put the results into effect + if ($result === false || $result === null) { + // this is a generic error message that should replaced + // with more specific ones when possible + if ($e) { + $e->send(E_ERROR, 'AttrValidator: Attribute removed'); + } + + // remove the attribute + unset($attr[$attr_key]); + } elseif (is_string($result)) { + // generally, if a substitution is happening, there + // was some sort of implicit correction going on. We'll + // delegate it to the attribute classes to say exactly what. + + // simple substitution + $attr[$attr_key] = $result; + } else { + // nothing happens + } + + // we'd also want slightly more complicated substitution + // involving an array as the return value, + // although we're not sure how colliding attributes would + // resolve (certain ones would be completely overriden, + // others would prepend themselves). + } + + $context->destroy('CurrentAttr'); + + // post transforms + + // global (error reporting untested) + foreach ($definition->info_attr_transform_post as $transform) { + $attr = $transform->transform($o = $attr, $config, $context); + if ($e) { + if ($attr != $o) { + $e->send(E_NOTICE, 'AttrValidator: Attributes transformed', $o, $attr); + } + } + } + + // local (error reporting untested) + foreach ($definition->info[$token->name]->attr_transform_post as $transform) { + $attr = $transform->transform($o = $attr, $config, $context); + if ($e) { + if ($attr != $o) { + $e->send(E_NOTICE, 'AttrValidator: Attributes transformed', $o, $attr); + } + } + } + + $token->attr = $attr; + + // destroy CurrentToken if we made it ourselves + if (!$current_token) { + $context->destroy('CurrentToken'); + } + + } + + +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Bootstrap.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Bootstrap.php new file mode 100644 index 0000000..bd8f998 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Bootstrap.php @@ -0,0 +1,91 @@ + +if (!defined('PHP_EOL')) { + switch (strtoupper(substr(PHP_OS, 0, 3))) { + case 'WIN': + define('PHP_EOL', "\r\n"); + break; + case 'DAR': + define('PHP_EOL', "\r"); + break; + default: + define('PHP_EOL', "\n"); + } +} + +/** + * Bootstrap class that contains meta-functionality for HTML Purifier such as + * the autoload function. + * + * @note + * This class may be used without any other files from HTML Purifier. + */ +class HTMLPurifier_Bootstrap +{ + + /** + * Autoload function for HTML Purifier + * @param string $class Class to load + * @return bool + */ + public static function autoload($class) + { + $file = HTMLPurifier_Bootstrap::getPath($class); + if (!$file) { + return false; + } + // Technically speaking, it should be ok and more efficient to + // just do 'require', but Antonio Parraga reports that with + // Zend extensions such as Zend debugger and APC, this invariant + // may be broken. Since we have efficient alternatives, pay + // the cost here and avoid the bug. + require_once HTMLPURIFIER_PREFIX . '/' . $file; + return true; + } + + /** + * Returns the path for a specific class. + * @param string $class Class path to get + * @return string + */ + public static function getPath($class) + { + if (strncmp('HTMLPurifier', $class, 12) !== 0) { + return false; + } + // Custom implementations + if (strncmp('HTMLPurifier_Language_', $class, 22) === 0) { + $code = str_replace('_', '-', substr($class, 22)); + $file = 'HTMLPurifier/Language/classes/' . $code . '.php'; + } else { + $file = str_replace('_', '/', $class) . '.php'; + } + if (!file_exists(HTMLPURIFIER_PREFIX . '/' . $file)) { + return false; + } + return $file; + } + + /** + * "Pre-registers" our autoloader on the SPL stack. + */ + public static function registerAutoload() + { + $autoload = array('HTMLPurifier_Bootstrap', 'autoload'); + if (spl_autoload_functions() === false) { + spl_autoload_register($autoload); + } else { + // prepend flag exists, no need for shenanigans + spl_autoload_register($autoload, true, true); + } + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/CSSDefinition.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/CSSDefinition.php new file mode 100644 index 0000000..3732c07 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/CSSDefinition.php @@ -0,0 +1,565 @@ +info['text-align'] = new HTMLPurifier_AttrDef_Enum( + ['left', 'right', 'center', 'justify'], + false + ); + + $border_style = + $this->info['border-bottom-style'] = + $this->info['border-right-style'] = + $this->info['border-left-style'] = + $this->info['border-top-style'] = new HTMLPurifier_AttrDef_Enum( + [ + 'none', + 'hidden', + 'dotted', + 'dashed', + 'solid', + 'double', + 'groove', + 'ridge', + 'inset', + 'outset' + ], + false + ); + + $this->info['border-style'] = new HTMLPurifier_AttrDef_CSS_Multiple($border_style); + + $this->info['clear'] = new HTMLPurifier_AttrDef_Enum( + ['none', 'left', 'right', 'both'], + false + ); + $this->info['float'] = new HTMLPurifier_AttrDef_Enum( + ['none', 'left', 'right'], + false + ); + $this->info['font-style'] = new HTMLPurifier_AttrDef_Enum( + ['normal', 'italic', 'oblique'], + false + ); + $this->info['font-variant'] = new HTMLPurifier_AttrDef_Enum( + ['normal', 'small-caps'], + false + ); + + $uri_or_none = new HTMLPurifier_AttrDef_CSS_Composite( + [ + new HTMLPurifier_AttrDef_Enum(['none']), + new HTMLPurifier_AttrDef_CSS_URI() + ] + ); + + $this->info['list-style-position'] = new HTMLPurifier_AttrDef_Enum( + ['inside', 'outside'], + false + ); + $this->info['list-style-type'] = new HTMLPurifier_AttrDef_Enum( + [ + 'disc', + 'circle', + 'square', + 'decimal', + 'lower-roman', + 'upper-roman', + 'lower-alpha', + 'upper-alpha', + 'none' + ], + false + ); + $this->info['list-style-image'] = $uri_or_none; + + $this->info['list-style'] = new HTMLPurifier_AttrDef_CSS_ListStyle($config); + + $this->info['text-transform'] = new HTMLPurifier_AttrDef_Enum( + ['capitalize', 'uppercase', 'lowercase', 'none'], + false + ); + $this->info['color'] = new HTMLPurifier_AttrDef_CSS_Color(); + + $this->info['background-image'] = $uri_or_none; + $this->info['background-repeat'] = new HTMLPurifier_AttrDef_Enum( + ['repeat', 'repeat-x', 'repeat-y', 'no-repeat'] + ); + $this->info['background-attachment'] = new HTMLPurifier_AttrDef_Enum( + ['scroll', 'fixed'] + ); + $this->info['background-position'] = new HTMLPurifier_AttrDef_CSS_BackgroundPosition(); + + $this->info['background-size'] = new HTMLPurifier_AttrDef_CSS_Composite( + [ + new HTMLPurifier_AttrDef_Enum( + [ + 'auto', + 'cover', + 'contain', + ] + ), + new HTMLPurifier_AttrDef_CSS_Percentage(), + new HTMLPurifier_AttrDef_CSS_Length() + ] + ); + + $border_color = + $this->info['border-top-color'] = + $this->info['border-bottom-color'] = + $this->info['border-left-color'] = + $this->info['border-right-color'] = + $this->info['background-color'] = new HTMLPurifier_AttrDef_CSS_Composite( + [ + new HTMLPurifier_AttrDef_Enum(['transparent']), + new HTMLPurifier_AttrDef_CSS_Color() + ] + ); + + $this->info['background'] = new HTMLPurifier_AttrDef_CSS_Background($config); + + $this->info['border-color'] = new HTMLPurifier_AttrDef_CSS_Multiple($border_color); + + $border_width = + $this->info['border-top-width'] = + $this->info['border-bottom-width'] = + $this->info['border-left-width'] = + $this->info['border-right-width'] = new HTMLPurifier_AttrDef_CSS_Composite( + [ + new HTMLPurifier_AttrDef_Enum(['thin', 'medium', 'thick']), + new HTMLPurifier_AttrDef_CSS_Length('0') //disallow negative + ] + ); + + $this->info['border-width'] = new HTMLPurifier_AttrDef_CSS_Multiple($border_width); + + $this->info['letter-spacing'] = new HTMLPurifier_AttrDef_CSS_Composite( + [ + new HTMLPurifier_AttrDef_Enum(['normal']), + new HTMLPurifier_AttrDef_CSS_Length() + ] + ); + + $this->info['word-spacing'] = new HTMLPurifier_AttrDef_CSS_Composite( + [ + new HTMLPurifier_AttrDef_Enum(['normal']), + new HTMLPurifier_AttrDef_CSS_Length() + ] + ); + + $this->info['font-size'] = new HTMLPurifier_AttrDef_CSS_Composite( + [ + new HTMLPurifier_AttrDef_Enum( + [ + 'xx-small', + 'x-small', + 'small', + 'medium', + 'large', + 'x-large', + 'xx-large', + 'larger', + 'smaller' + ] + ), + new HTMLPurifier_AttrDef_CSS_Percentage(), + new HTMLPurifier_AttrDef_CSS_Length() + ] + ); + + $this->info['line-height'] = new HTMLPurifier_AttrDef_CSS_Composite( + [ + new HTMLPurifier_AttrDef_Enum(['normal']), + new HTMLPurifier_AttrDef_CSS_Number(true), // no negatives + new HTMLPurifier_AttrDef_CSS_Length('0'), + new HTMLPurifier_AttrDef_CSS_Percentage(true) + ] + ); + + $margin = + $this->info['margin-top'] = + $this->info['margin-bottom'] = + $this->info['margin-left'] = + $this->info['margin-right'] = new HTMLPurifier_AttrDef_CSS_Composite( + [ + new HTMLPurifier_AttrDef_CSS_Length(), + new HTMLPurifier_AttrDef_CSS_Percentage(), + new HTMLPurifier_AttrDef_Enum(['auto']) + ] + ); + + $this->info['margin'] = new HTMLPurifier_AttrDef_CSS_Multiple($margin); + + // non-negative + $padding = + $this->info['padding-top'] = + $this->info['padding-bottom'] = + $this->info['padding-left'] = + $this->info['padding-right'] = new HTMLPurifier_AttrDef_CSS_Composite( + [ + new HTMLPurifier_AttrDef_CSS_Length('0'), + new HTMLPurifier_AttrDef_CSS_Percentage(true) + ] + ); + + $this->info['padding'] = new HTMLPurifier_AttrDef_CSS_Multiple($padding); + + $this->info['text-indent'] = new HTMLPurifier_AttrDef_CSS_Composite( + [ + new HTMLPurifier_AttrDef_CSS_Length(), + new HTMLPurifier_AttrDef_CSS_Percentage() + ] + ); + + $trusted_wh = new HTMLPurifier_AttrDef_CSS_Composite( + [ + new HTMLPurifier_AttrDef_CSS_Length('0'), + new HTMLPurifier_AttrDef_CSS_Percentage(true), + new HTMLPurifier_AttrDef_Enum(['auto']) + ] + ); + $trusted_min_wh = new HTMLPurifier_AttrDef_CSS_Composite( + [ + new HTMLPurifier_AttrDef_CSS_Length('0'), + new HTMLPurifier_AttrDef_CSS_Percentage(true), + ] + ); + $trusted_max_wh = new HTMLPurifier_AttrDef_CSS_Composite( + [ + new HTMLPurifier_AttrDef_CSS_Length('0'), + new HTMLPurifier_AttrDef_CSS_Percentage(true), + new HTMLPurifier_AttrDef_Enum(['none']) + ] + ); + $max = $config->get('CSS.MaxImgLength'); + + $this->info['width'] = + $this->info['height'] = + $max === null ? + $trusted_wh : + new HTMLPurifier_AttrDef_Switch( + 'img', + // For img tags: + new HTMLPurifier_AttrDef_CSS_Composite( + [ + new HTMLPurifier_AttrDef_CSS_Length('0', $max), + new HTMLPurifier_AttrDef_Enum(['auto']) + ] + ), + // For everyone else: + $trusted_wh + ); + $this->info['min-width'] = + $this->info['min-height'] = + $max === null ? + $trusted_min_wh : + new HTMLPurifier_AttrDef_Switch( + 'img', + // For img tags: + new HTMLPurifier_AttrDef_CSS_Length('0', $max), + // For everyone else: + $trusted_min_wh + ); + $this->info['max-width'] = + $this->info['max-height'] = + $max === null ? + $trusted_max_wh : + new HTMLPurifier_AttrDef_Switch( + 'img', + // For img tags: + new HTMLPurifier_AttrDef_CSS_Composite( + [ + new HTMLPurifier_AttrDef_CSS_Length('0', $max), + new HTMLPurifier_AttrDef_Enum(['none']) + ] + ), + // For everyone else: + $trusted_max_wh + ); + + $this->info['aspect-ratio'] = new HTMLPurifier_AttrDef_CSS_Multiple( + new HTMLPurifier_AttrDef_CSS_Composite([ + new HTMLPurifier_AttrDef_CSS_Ratio(), + new HTMLPurifier_AttrDef_Enum(['auto']), + ]) + ); + + // text-decoration and related shorthands + $this->info['text-decoration'] = new HTMLPurifier_AttrDef_CSS_TextDecoration(); + + $this->info['text-decoration-line'] = new HTMLPurifier_AttrDef_Enum( + ['none', 'underline', 'overline', 'line-through'] + ); + + $this->info['text-decoration-style'] = new HTMLPurifier_AttrDef_Enum( + ['solid', 'double', 'dotted', 'dashed', 'wavy'] + ); + + $this->info['text-decoration-color'] = new HTMLPurifier_AttrDef_CSS_Color(); + + $this->info['text-decoration-thickness'] = new HTMLPurifier_AttrDef_CSS_Composite([ + new HTMLPurifier_AttrDef_CSS_Length(), + new HTMLPurifier_AttrDef_CSS_Percentage(), + new HTMLPurifier_AttrDef_Enum(['auto', 'from-font']) + ]); + + $this->info['font-family'] = new HTMLPurifier_AttrDef_CSS_FontFamily(); + + // this could use specialized code + $this->info['font-weight'] = new HTMLPurifier_AttrDef_Enum( + [ + 'normal', + 'bold', + 'bolder', + 'lighter', + '100', + '200', + '300', + '400', + '500', + '600', + '700', + '800', + '900' + ], + false + ); + + // MUST be called after other font properties, as it references + // a CSSDefinition object + $this->info['font'] = new HTMLPurifier_AttrDef_CSS_Font($config); + + // same here + $this->info['border'] = + $this->info['border-bottom'] = + $this->info['border-top'] = + $this->info['border-left'] = + $this->info['border-right'] = new HTMLPurifier_AttrDef_CSS_Border($config); + + $this->info['border-collapse'] = new HTMLPurifier_AttrDef_Enum( + ['collapse', 'separate'] + ); + + $this->info['caption-side'] = new HTMLPurifier_AttrDef_Enum( + ['top', 'bottom'] + ); + + $this->info['table-layout'] = new HTMLPurifier_AttrDef_Enum( + ['auto', 'fixed'] + ); + + $this->info['vertical-align'] = new HTMLPurifier_AttrDef_CSS_Composite( + [ + new HTMLPurifier_AttrDef_Enum( + [ + 'baseline', + 'sub', + 'super', + 'top', + 'text-top', + 'middle', + 'bottom', + 'text-bottom' + ] + ), + new HTMLPurifier_AttrDef_CSS_Length(), + new HTMLPurifier_AttrDef_CSS_Percentage() + ] + ); + + $this->info['border-spacing'] = new HTMLPurifier_AttrDef_CSS_Multiple(new HTMLPurifier_AttrDef_CSS_Length(), 2); + + // These CSS properties don't work on many browsers, but we live + // in THE FUTURE! + $this->info['white-space'] = new HTMLPurifier_AttrDef_Enum( + ['nowrap', 'normal', 'pre', 'pre-wrap', 'pre-line'] + ); + + if ($config->get('CSS.Proprietary')) { + $this->doSetupProprietary($config); + } + + if ($config->get('CSS.AllowTricky')) { + $this->doSetupTricky($config); + } + + if ($config->get('CSS.Trusted')) { + $this->doSetupTrusted($config); + } + + $allow_important = $config->get('CSS.AllowImportant'); + // wrap all attr-defs with decorator that handles !important + foreach ($this->info as $k => $v) { + $this->info[$k] = new HTMLPurifier_AttrDef_CSS_ImportantDecorator($v, $allow_important); + } + + $this->setupConfigStuff($config); + } + + /** + * @param HTMLPurifier_Config $config + */ + protected function doSetupProprietary($config) + { + // Internet Explorer only scrollbar colors + $this->info['scrollbar-arrow-color'] = new HTMLPurifier_AttrDef_CSS_Color(); + $this->info['scrollbar-base-color'] = new HTMLPurifier_AttrDef_CSS_Color(); + $this->info['scrollbar-darkshadow-color'] = new HTMLPurifier_AttrDef_CSS_Color(); + $this->info['scrollbar-face-color'] = new HTMLPurifier_AttrDef_CSS_Color(); + $this->info['scrollbar-highlight-color'] = new HTMLPurifier_AttrDef_CSS_Color(); + $this->info['scrollbar-shadow-color'] = new HTMLPurifier_AttrDef_CSS_Color(); + + // vendor specific prefixes of opacity + $this->info['-moz-opacity'] = new HTMLPurifier_AttrDef_CSS_AlphaValue(); + $this->info['-khtml-opacity'] = new HTMLPurifier_AttrDef_CSS_AlphaValue(); + + // only opacity, for now + $this->info['filter'] = new HTMLPurifier_AttrDef_CSS_Filter(); + + // more CSS3 + $this->info['page-break-after'] = + $this->info['page-break-before'] = new HTMLPurifier_AttrDef_Enum( + [ + 'auto', + 'always', + 'avoid', + 'left', + 'right' + ] + ); + $this->info['page-break-inside'] = new HTMLPurifier_AttrDef_Enum(['auto', 'avoid']); + + $border_radius = new HTMLPurifier_AttrDef_CSS_Composite( + [ + new HTMLPurifier_AttrDef_CSS_Percentage(true), // disallow negative + new HTMLPurifier_AttrDef_CSS_Length('0') // disallow negative + ]); + + $this->info['border-top-left-radius'] = + $this->info['border-top-right-radius'] = + $this->info['border-bottom-right-radius'] = + $this->info['border-bottom-left-radius'] = new HTMLPurifier_AttrDef_CSS_Multiple($border_radius, 2); + // TODO: support SLASH syntax + $this->info['border-radius'] = new HTMLPurifier_AttrDef_CSS_Multiple($border_radius, 4); + + } + + /** + * @param HTMLPurifier_Config $config + */ + protected function doSetupTricky($config) + { + $this->info['display'] = new HTMLPurifier_AttrDef_Enum( + [ + 'inline', + 'block', + 'list-item', + 'run-in', + 'compact', + 'marker', + 'table', + 'inline-block', + 'inline-table', + 'table-row-group', + 'table-header-group', + 'table-footer-group', + 'table-row', + 'table-column-group', + 'table-column', + 'table-cell', + 'table-caption', + 'none' + ] + ); + $this->info['visibility'] = new HTMLPurifier_AttrDef_Enum( + ['visible', 'hidden', 'collapse'] + ); + $this->info['overflow'] = new HTMLPurifier_AttrDef_Enum(['visible', 'hidden', 'auto', 'scroll']); + $this->info['opacity'] = new HTMLPurifier_AttrDef_CSS_AlphaValue(); + } + + /** + * @param HTMLPurifier_Config $config + */ + protected function doSetupTrusted($config) + { + $this->info['position'] = new HTMLPurifier_AttrDef_Enum( + ['static', 'relative', 'absolute', 'fixed'] + ); + $this->info['top'] = + $this->info['left'] = + $this->info['right'] = + $this->info['bottom'] = new HTMLPurifier_AttrDef_CSS_Composite( + [ + new HTMLPurifier_AttrDef_CSS_Length(), + new HTMLPurifier_AttrDef_CSS_Percentage(), + new HTMLPurifier_AttrDef_Enum(['auto']), + ] + ); + $this->info['z-index'] = new HTMLPurifier_AttrDef_CSS_Composite( + [ + new HTMLPurifier_AttrDef_Integer(), + new HTMLPurifier_AttrDef_Enum(['auto']), + ] + ); + } + + /** + * Performs extra config-based processing. Based off of + * HTMLPurifier_HTMLDefinition. + * @param HTMLPurifier_Config $config + * @todo Refactor duplicate elements into common class (probably using + * composition, not inheritance). + */ + protected function setupConfigStuff($config) + { + // setup allowed elements + $support = "(for information on implementing this, see the " . + "support forums) "; + $allowed_properties = $config->get('CSS.AllowedProperties'); + if ($allowed_properties !== null) { + foreach ($this->info as $name => $d) { + if (!isset($allowed_properties[$name])) { + unset($this->info[$name]); + } + unset($allowed_properties[$name]); + } + // emit errors + foreach ($allowed_properties as $name => $d) { + // :TODO: Is this htmlspecialchars() call really necessary? + $name = htmlspecialchars($name); + trigger_error("Style attribute '$name' is not supported $support", E_USER_WARNING); + } + } + + $forbidden_properties = $config->get('CSS.ForbiddenProperties'); + if ($forbidden_properties !== null) { + foreach ($this->info as $name => $d) { + if (isset($forbidden_properties[$name])) { + unset($this->info[$name]); + } + } + } + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ChildDef.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ChildDef.php new file mode 100644 index 0000000..8eb17b8 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ChildDef.php @@ -0,0 +1,52 @@ +elements; + } + + /** + * Validates nodes according to definition and returns modification. + * + * @param HTMLPurifier_Node[] $children Array of HTMLPurifier_Node + * @param HTMLPurifier_Config $config HTMLPurifier_Config object + * @param HTMLPurifier_Context $context HTMLPurifier_Context object + * @return bool|array true to leave nodes as is, false to remove parent node, array of replacement children + */ + abstract public function validateChildren($children, $config, $context); +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ChildDef/Chameleon.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ChildDef/Chameleon.php new file mode 100644 index 0000000..7439be2 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ChildDef/Chameleon.php @@ -0,0 +1,67 @@ +inline = new HTMLPurifier_ChildDef_Optional($inline); + $this->block = new HTMLPurifier_ChildDef_Optional($block); + $this->elements = $this->block->elements; + } + + /** + * @param HTMLPurifier_Node[] $children + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return bool + */ + public function validateChildren($children, $config, $context) + { + if ($context->get('IsInline') === false) { + return $this->block->validateChildren( + $children, + $config, + $context + ); + } else { + return $this->inline->validateChildren( + $children, + $config, + $context + ); + } + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ChildDef/Custom.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ChildDef/Custom.php new file mode 100644 index 0000000..f515888 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ChildDef/Custom.php @@ -0,0 +1,102 @@ +dtd_regex = $dtd_regex; + $this->_compileRegex(); + } + + /** + * Compiles the PCRE regex from a DTD regex ($dtd_regex to $_pcre_regex) + */ + protected function _compileRegex() + { + $raw = str_replace(' ', '', $this->dtd_regex); + if ($raw[0] != '(') { + $raw = "($raw)"; + } + $el = '[#a-zA-Z0-9_.-]+'; + $reg = $raw; + + // COMPLICATED! AND MIGHT BE BUGGY! I HAVE NO CLUE WHAT I'M + // DOING! Seriously: if there's problems, please report them. + + // collect all elements into the $elements array + preg_match_all("/$el/", $reg, $matches); + foreach ($matches[0] as $match) { + $this->elements[$match] = true; + } + + // setup all elements as parentheticals with leading commas + $reg = preg_replace("/$el/", '(,\\0)', $reg); + + // remove commas when they were not solicited + $reg = preg_replace("/([^,(|]\(+),/", '\\1', $reg); + + // remove all non-paranthetical commas: they are handled by first regex + $reg = preg_replace("/,\(/", '(', $reg); + + $this->_pcre_regex = $reg; + } + + /** + * @param HTMLPurifier_Node[] $children + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return bool + */ + public function validateChildren($children, $config, $context) + { + $list_of_children = ''; + $nesting = 0; // depth into the nest + foreach ($children as $node) { + if (!empty($node->is_whitespace)) { + continue; + } + $list_of_children .= $node->name . ','; + } + // add leading comma to deal with stray comma declarations + $list_of_children = ',' . rtrim($list_of_children, ','); + $okay = + preg_match( + '/^,?' . $this->_pcre_regex . '$/', + $list_of_children + ); + return (bool)$okay; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ChildDef/Empty.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ChildDef/Empty.php new file mode 100644 index 0000000..a8a6cbd --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ChildDef/Empty.php @@ -0,0 +1,38 @@ + true, 'ul' => true, 'ol' => true); + + public $whitespace; + + /** + * @param array $children + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return array + */ + public function validateChildren($children, $config, $context) + { + // Flag for subclasses + $this->whitespace = false; + + // if there are no tokens, delete parent node + if (empty($children)) { + return false; + } + + // if li is not allowed, delete parent node + if (!isset($config->getHTMLDefinition()->info['li'])) { + trigger_error("Cannot allow ul/ol without allowing li", E_USER_WARNING); + return false; + } + + // the new set of children + $result = array(); + + // a little sanity check to make sure it's not ALL whitespace + $all_whitespace = true; + + $current_li = null; + + foreach ($children as $node) { + if (!empty($node->is_whitespace)) { + $result[] = $node; + continue; + } + $all_whitespace = false; // phew, we're not talking about whitespace + + if ($node->name === 'li') { + // good + $current_li = $node; + $result[] = $node; + } else { + // we want to tuck this into the previous li + // Invariant: we expect the node to be ol/ul + // ToDo: Make this more robust in the case of not ol/ul + // by distinguishing between existing li and li created + // to handle non-list elements; non-list elements should + // not be appended to an existing li; only li created + // for non-list. This distinction is not currently made. + if ($current_li === null) { + $current_li = new HTMLPurifier_Node_Element('li'); + $result[] = $current_li; + } + $current_li->children[] = $node; + $current_li->empty = false; // XXX fascinating! Check for this error elsewhere ToDo + } + } + if (empty($result)) { + return false; + } + if ($all_whitespace) { + return false; + } + return $result; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ChildDef/Optional.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ChildDef/Optional.php new file mode 100644 index 0000000..b946806 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ChildDef/Optional.php @@ -0,0 +1,45 @@ +whitespace) { + return $children; + } else { + return array(); + } + } + return $result; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ChildDef/Required.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ChildDef/Required.php new file mode 100644 index 0000000..0d1c8f5 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ChildDef/Required.php @@ -0,0 +1,118 @@ + $x) { + $elements[$i] = true; + if (empty($i)) { + unset($elements[$i]); + } // remove blank + } + } + $this->elements = $elements; + } + + /** + * @type bool + */ + public $allow_empty = false; + + /** + * @type string + */ + public $type = 'required'; + + /** + * @param array $children + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return array + */ + public function validateChildren($children, $config, $context) + { + // Flag for subclasses + $this->whitespace = false; + + // if there are no tokens, delete parent node + if (empty($children)) { + return false; + } + + // the new set of children + $result = array(); + + // whether or not parsed character data is allowed + // this controls whether or not we silently drop a tag + // or generate escaped HTML from it + $pcdata_allowed = isset($this->elements['#PCDATA']); + + // a little sanity check to make sure it's not ALL whitespace + $all_whitespace = true; + + $stack = array_reverse($children); + while (!empty($stack)) { + $node = array_pop($stack); + if (!empty($node->is_whitespace)) { + $result[] = $node; + continue; + } + $all_whitespace = false; // phew, we're not talking about whitespace + + if (!isset($this->elements[$node->name])) { + // special case text + // XXX One of these ought to be redundant or something + if ($pcdata_allowed && $node instanceof HTMLPurifier_Node_Text) { + $result[] = $node; + continue; + } + // spill the child contents in + // ToDo: Make configurable + if ($node instanceof HTMLPurifier_Node_Element) { + for ($i = count($node->children) - 1; $i >= 0; $i--) { + $stack[] = $node->children[$i]; + } + continue; + } + continue; + } + $result[] = $node; + } + if (empty($result)) { + return false; + } + if ($all_whitespace) { + $this->whitespace = true; + return false; + } + return $result; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ChildDef/StrictBlockquote.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ChildDef/StrictBlockquote.php new file mode 100644 index 0000000..3270a46 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ChildDef/StrictBlockquote.php @@ -0,0 +1,110 @@ +init($config); + return $this->fake_elements; + } + + /** + * @param array $children + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return array + */ + public function validateChildren($children, $config, $context) + { + $this->init($config); + + // trick the parent class into thinking it allows more + $this->elements = $this->fake_elements; + $result = parent::validateChildren($children, $config, $context); + $this->elements = $this->real_elements; + + if ($result === false) { + return array(); + } + if ($result === true) { + $result = $children; + } + + $def = $config->getHTMLDefinition(); + $block_wrap_name = $def->info_block_wrapper; + $block_wrap = false; + $ret = array(); + + foreach ($result as $node) { + if ($block_wrap === false) { + if (($node instanceof HTMLPurifier_Node_Text && !$node->is_whitespace) || + ($node instanceof HTMLPurifier_Node_Element && !isset($this->elements[$node->name]))) { + $block_wrap = new HTMLPurifier_Node_Element($def->info_block_wrapper); + $ret[] = $block_wrap; + } + } else { + if ($node instanceof HTMLPurifier_Node_Element && isset($this->elements[$node->name])) { + $block_wrap = false; + + } + } + if ($block_wrap) { + $block_wrap->children[] = $node; + } else { + $ret[] = $node; + } + } + return $ret; + } + + /** + * @param HTMLPurifier_Config $config + */ + private function init($config) + { + if (!$this->init) { + $def = $config->getHTMLDefinition(); + // allow all inline elements + $this->real_elements = $this->elements; + $this->fake_elements = $def->info_content_sets['Flow']; + $this->fake_elements['#PCDATA'] = true; + $this->init = true; + } + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ChildDef/Table.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ChildDef/Table.php new file mode 100644 index 0000000..d92205b --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ChildDef/Table.php @@ -0,0 +1,227 @@ + true, + 'tbody' => true, + 'thead' => true, + 'tfoot' => true, + 'caption' => true, + 'colgroup' => true, + 'col' => true + ); + + public function __construct() + { + } + + /** + * @param array $children + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return array + */ + public function validateChildren($children, $config, $context) + { + if (empty($children)) { + return false; + } + + // only one of these elements is allowed in a table + $caption = false; + $thead = false; + $tfoot = false; + + // whitespace + $initial_ws = array(); + $after_caption_ws = array(); + $after_thead_ws = array(); + $after_tfoot_ws = array(); + + // as many of these as you want + $cols = array(); + $content = array(); + + $tbody_mode = false; // if true, then we need to wrap any stray + // s with a . + + $ws_accum =& $initial_ws; + + foreach ($children as $node) { + if ($node instanceof HTMLPurifier_Node_Comment) { + $ws_accum[] = $node; + continue; + } + switch ($node->name) { + case 'tbody': + $tbody_mode = true; + // fall through + case 'tr': + $content[] = $node; + $ws_accum =& $content; + break; + case 'caption': + // there can only be one caption! + if ($caption !== false) break; + $caption = $node; + $ws_accum =& $after_caption_ws; + break; + case 'thead': + $tbody_mode = true; + // XXX This breaks rendering properties with + // Firefox, which never floats a to + // the top. Ever. (Our scheme will float the + // first to the top.) So maybe + // s that are not first should be + // turned into ? Very tricky, indeed. + if ($thead === false) { + $thead = $node; + $ws_accum =& $after_thead_ws; + } else { + // Oops, there's a second one! What + // should we do? Current behavior is to + // transmutate the first and last entries into + // tbody tags, and then put into content. + // Maybe a better idea is to *attach + // it* to the existing thead or tfoot? + // We don't do this, because Firefox + // doesn't float an extra tfoot to the + // bottom like it does for the first one. + $node->name = 'tbody'; + $content[] = $node; + $ws_accum =& $content; + } + break; + case 'tfoot': + // see above for some aveats + $tbody_mode = true; + if ($tfoot === false) { + $tfoot = $node; + $ws_accum =& $after_tfoot_ws; + } else { + $node->name = 'tbody'; + $content[] = $node; + $ws_accum =& $content; + } + break; + case 'colgroup': + case 'col': + $cols[] = $node; + $ws_accum =& $cols; + break; + case '#PCDATA': + // How is whitespace handled? We treat is as sticky to + // the *end* of the previous element. So all of the + // nonsense we have worked on is to keep things + // together. + if (!empty($node->is_whitespace)) { + $ws_accum[] = $node; + } + break; + } + } + + if (empty($content) && $thead === false && $tfoot === false) { + return false; + } + + $ret = $initial_ws; + if ($caption !== false) { + $ret[] = $caption; + $ret = array_merge($ret, $after_caption_ws); + } + if ($cols !== false) { + $ret = array_merge($ret, $cols); + } + if ($thead !== false) { + $ret[] = $thead; + $ret = array_merge($ret, $after_thead_ws); + } + if ($tfoot !== false) { + $ret[] = $tfoot; + $ret = array_merge($ret, $after_tfoot_ws); + } + + if ($tbody_mode) { + // we have to shuffle tr into tbody + $current_tr_tbody = null; + + foreach($content as $node) { + if (!isset($node->name)) { + continue; + } + switch ($node->name) { + case 'tbody': + $current_tr_tbody = null; + $ret[] = $node; + break; + case 'tr': + if ($current_tr_tbody === null) { + $current_tr_tbody = new HTMLPurifier_Node_Element('tbody'); + $ret[] = $current_tr_tbody; + } + $current_tr_tbody->children[] = $node; + break; + case '#PCDATA': + //assert($node->is_whitespace); + if ($current_tr_tbody === null) { + $ret[] = $node; + } else { + $current_tr_tbody->children[] = $node; + } + break; + } + } + } else { + $ret = array_merge($ret, $content); + } + + return $ret; + + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Config.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Config.php new file mode 100644 index 0000000..e6566e8 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Config.php @@ -0,0 +1,920 @@ +defaultPlist; + $this->plist = new HTMLPurifier_PropertyList($parent); + $this->def = $definition; // keep a copy around for checking + $this->parser = new HTMLPurifier_VarParser_Flexible(); + } + + /** + * Convenience constructor that creates a config object based on a mixed var + * @param mixed $config Variable that defines the state of the config + * object. Can be: a HTMLPurifier_Config() object, + * an array of directives based on loadArray(), + * or a string filename of an ini file. + * @param HTMLPurifier_ConfigSchema $schema Schema object + * @return HTMLPurifier_Config Configured object + */ + public static function create($config, $schema = null) + { + if ($config instanceof HTMLPurifier_Config) { + // pass-through + return $config; + } + if (!$schema) { + $ret = HTMLPurifier_Config::createDefault(); + } else { + $ret = new HTMLPurifier_Config($schema); + } + if (is_string($config)) { + $ret->loadIni($config); + } elseif (is_array($config)) $ret->loadArray($config); + return $ret; + } + + /** + * Creates a new config object that inherits from a previous one. + * @param HTMLPurifier_Config $config Configuration object to inherit from. + * @return HTMLPurifier_Config object with $config as its parent. + */ + public static function inherit(HTMLPurifier_Config $config) + { + return new HTMLPurifier_Config($config->def, $config->plist); + } + + /** + * Convenience constructor that creates a default configuration object. + * @return HTMLPurifier_Config default object. + */ + public static function createDefault() + { + $definition = HTMLPurifier_ConfigSchema::instance(); + $config = new HTMLPurifier_Config($definition); + return $config; + } + + /** + * Retrieves a value from the configuration. + * + * @param string $key String key + * @param mixed $a + * + * @return mixed + */ + public function get($key, $a = null) + { + if ($a !== null) { + $this->triggerError( + "Using deprecated API: use \$config->get('$key.$a') instead", + E_USER_WARNING + ); + $key = "$key.$a"; + } + if (!$this->finalized) { + $this->autoFinalize(); + } + if (!isset($this->def->info[$key])) { + // can't add % due to SimpleTest bug + $this->triggerError( + 'Cannot retrieve value of undefined directive ' . htmlspecialchars($key), + E_USER_WARNING + ); + return; + } + if (isset($this->def->info[$key]->isAlias)) { + $d = $this->def->info[$key]; + $this->triggerError( + 'Cannot get value from aliased directive, use real name ' . $d->key, + E_USER_ERROR + ); + return; + } + if ($this->lock) { + list($ns) = explode('.', $key); + if ($ns !== $this->lock) { + $this->triggerError( + 'Cannot get value of namespace ' . $ns . ' when lock for ' . + $this->lock . + ' is active, this probably indicates a Definition setup method ' . + 'is accessing directives that are not within its namespace', + E_USER_ERROR + ); + return; + } + } + return $this->plist->get($key); + } + + /** + * Retrieves an array of directives to values from a given namespace + * + * @param string $namespace String namespace + * + * @return array + */ + public function getBatch($namespace) + { + if (!$this->finalized) { + $this->autoFinalize(); + } + $full = $this->getAll(); + if (!isset($full[$namespace])) { + $this->triggerError( + 'Cannot retrieve undefined namespace ' . + htmlspecialchars($namespace), + E_USER_WARNING + ); + return; + } + return $full[$namespace]; + } + + /** + * Returns a SHA-1 signature of a segment of the configuration object + * that uniquely identifies that particular configuration + * + * @param string $namespace Namespace to get serial for + * + * @return string + * @note Revision is handled specially and is removed from the batch + * before processing! + */ + public function getBatchSerial($namespace) + { + if (empty($this->serials[$namespace])) { + $batch = $this->getBatch($namespace); + unset($batch['DefinitionRev']); + $this->serials[$namespace] = sha1(serialize($batch)); + } + return $this->serials[$namespace]; + } + + /** + * Returns a SHA-1 signature for the entire configuration object + * that uniquely identifies that particular configuration + * + * @return string + */ + public function getSerial() + { + if (empty($this->serial)) { + $this->serial = sha1(serialize($this->getAll())); + } + return $this->serial; + } + + /** + * Retrieves all directives, organized by namespace + * + * @warning This is a pretty inefficient function, avoid if you can + */ + public function getAll() + { + if (!$this->finalized) { + $this->autoFinalize(); + } + $ret = array(); + foreach ($this->plist->squash() as $name => $value) { + list($ns, $key) = explode('.', $name, 2); + $ret[$ns][$key] = $value; + } + return $ret; + } + + /** + * Sets a value to configuration. + * + * @param string $key key + * @param mixed $value value + * @param mixed $a + */ + public function set($key, $value, $a = null) + { + if (strpos($key, '.') === false) { + $namespace = $key; + $directive = $value; + $value = $a; + $key = "$key.$directive"; + $this->triggerError("Using deprecated API: use \$config->set('$key', ...) instead", E_USER_NOTICE); + } else { + list($namespace) = explode('.', $key); + } + if ($this->isFinalized('Cannot set directive after finalization')) { + return; + } + if (!isset($this->def->info[$key])) { + $this->triggerError( + 'Cannot set undefined directive ' . htmlspecialchars($key) . ' to value', + E_USER_WARNING + ); + return; + } + $def = $this->def->info[$key]; + + if (isset($def->isAlias)) { + if ($this->aliasMode) { + $this->triggerError( + 'Double-aliases not allowed, please fix '. + 'ConfigSchema bug with' . $key, + E_USER_ERROR + ); + return; + } + $this->aliasMode = true; + $this->set($def->key, $value); + $this->aliasMode = false; + $this->triggerError("$key is an alias, preferred directive name is {$def->key}", E_USER_NOTICE); + return; + } + + // Raw type might be negative when using the fully optimized form + // of stdClass, which indicates allow_null == true + $rtype = is_int($def) ? $def : $def->type; + if ($rtype < 0) { + $type = -$rtype; + $allow_null = true; + } else { + $type = $rtype; + $allow_null = isset($def->allow_null); + } + + try { + $value = $this->parser->parse($value, $type, $allow_null); + } catch (HTMLPurifier_VarParserException $e) { + $this->triggerError( + 'Value for ' . $key . ' is of invalid type, should be ' . + HTMLPurifier_VarParser::getTypeName($type), + E_USER_WARNING + ); + return; + } + if (is_string($value) && is_object($def)) { + // resolve value alias if defined + if (isset($def->aliases[$value])) { + $value = $def->aliases[$value]; + } + // check to see if the value is allowed + if (isset($def->allowed) && !isset($def->allowed[$value])) { + $this->triggerError( + 'Value not supported, valid values are: ' . + $this->_listify($def->allowed), + E_USER_WARNING + ); + return; + } + } + $this->plist->set($key, $value); + + // reset definitions if the directives they depend on changed + // this is a very costly process, so it's discouraged + // with finalization + if ($namespace == 'HTML' || $namespace == 'CSS' || $namespace == 'URI') { + $this->definitions[$namespace] = null; + } + + $this->serials[$namespace] = false; + } + + /** + * Convenience function for error reporting + * + * @param array $lookup + * + * @return string + */ + private function _listify($lookup) + { + $list = array(); + foreach ($lookup as $name => $b) { + $list[] = $name; + } + return implode(', ', $list); + } + + /** + * Retrieves object reference to the HTML definition. + * + * @param bool $raw Return a copy that has not been setup yet. Must be + * called before it's been setup, otherwise won't work. + * @param bool $optimized If true, this method may return null, to + * indicate that a cached version of the modified + * definition object is available and no further edits + * are necessary. Consider using + * maybeGetRawHTMLDefinition, which is more explicitly + * named, instead. + * + * @return HTMLPurifier_HTMLDefinition|null + */ + public function getHTMLDefinition($raw = false, $optimized = false) + { + return $this->getDefinition('HTML', $raw, $optimized); + } + + /** + * Retrieves object reference to the CSS definition + * + * @param bool $raw Return a copy that has not been setup yet. Must be + * called before it's been setup, otherwise won't work. + * @param bool $optimized If true, this method may return null, to + * indicate that a cached version of the modified + * definition object is available and no further edits + * are necessary. Consider using + * maybeGetRawCSSDefinition, which is more explicitly + * named, instead. + * + * @return HTMLPurifier_CSSDefinition|null + */ + public function getCSSDefinition($raw = false, $optimized = false) + { + return $this->getDefinition('CSS', $raw, $optimized); + } + + /** + * Retrieves object reference to the URI definition + * + * @param bool $raw Return a copy that has not been setup yet. Must be + * called before it's been setup, otherwise won't work. + * @param bool $optimized If true, this method may return null, to + * indicate that a cached version of the modified + * definition object is available and no further edits + * are necessary. Consider using + * maybeGetRawURIDefinition, which is more explicitly + * named, instead. + * + * @return HTMLPurifier_URIDefinition|null + */ + public function getURIDefinition($raw = false, $optimized = false) + { + return $this->getDefinition('URI', $raw, $optimized); + } + + /** + * Retrieves a definition + * + * @param string $type Type of definition: HTML, CSS, etc + * @param bool $raw Whether or not definition should be returned raw + * @param bool $optimized Only has an effect when $raw is true. Whether + * or not to return null if the result is already present in + * the cache. This is off by default for backwards + * compatibility reasons, but you need to do things this + * way in order to ensure that caching is done properly. + * Check out enduser-customize.html for more details. + * We probably won't ever change this default, as much as the + * maybe semantics is the "right thing to do." + * + * @throws HTMLPurifier_Exception + * @return HTMLPurifier_Definition|null + */ + public function getDefinition($type, $raw = false, $optimized = false) + { + if ($optimized && !$raw) { + throw new HTMLPurifier_Exception("Cannot set optimized = true when raw = false"); + } + if (!$this->finalized) { + $this->autoFinalize(); + } + // temporarily suspend locks, so we can handle recursive definition calls + $lock = $this->lock; + $this->lock = null; + $factory = HTMLPurifier_DefinitionCacheFactory::instance(); + $cache = $factory->create($type, $this); + $this->lock = $lock; + if (!$raw) { + // full definition + // --------------- + // check if definition is in memory + if (!empty($this->definitions[$type])) { + $def = $this->definitions[$type]; + // check if the definition is setup + if ($def->setup) { + return $def; + } else { + $def->setup($this); + if ($def->optimized) { + $cache->add($def, $this); + } + return $def; + } + } + // check if definition is in cache + $def = $cache->get($this); + if ($def) { + // definition in cache, save to memory and return it + $this->definitions[$type] = $def; + return $def; + } + // initialize it + $def = $this->initDefinition($type); + // set it up + $this->lock = $type; + $def->setup($this); + $this->lock = null; + // save in cache + $cache->add($def, $this); + // return it + return $def; + } else { + // raw definition + // -------------- + // check preconditions + $def = null; + if ($optimized) { + if (is_null($this->get($type . '.DefinitionID'))) { + // fatally error out if definition ID not set + throw new HTMLPurifier_Exception( + "Cannot retrieve raw version without specifying %$type.DefinitionID" + ); + } + } + if (!empty($this->definitions[$type])) { + $def = $this->definitions[$type]; + if ($def->setup && !$optimized) { + $extra = $this->chatty ? + " (try moving this code block earlier in your initialization)" : + ""; + throw new HTMLPurifier_Exception( + "Cannot retrieve raw definition after it has already been setup" . + $extra + ); + } + if ($def->optimized === null) { + $extra = $this->chatty ? " (try flushing your cache)" : ""; + throw new HTMLPurifier_Exception( + "Optimization status of definition is unknown" . $extra + ); + } + if ($def->optimized !== $optimized) { + $msg = $optimized ? "optimized" : "unoptimized"; + $extra = $this->chatty ? + " (this backtrace is for the first inconsistent call, which was for a $msg raw definition)" + : ""; + throw new HTMLPurifier_Exception( + "Inconsistent use of optimized and unoptimized raw definition retrievals" . $extra + ); + } + } + // check if definition was in memory + if ($def) { + if ($def->setup) { + // invariant: $optimized === true (checked above) + return null; + } else { + return $def; + } + } + // if optimized, check if definition was in cache + // (because we do the memory check first, this formulation + // is prone to cache slamming, but I think + // guaranteeing that either /all/ of the raw + // setup code or /none/ of it is run is more important.) + if ($optimized) { + // This code path only gets run once; once we put + // something in $definitions (which is guaranteed by the + // trailing code), we always short-circuit above. + $def = $cache->get($this); + if ($def) { + // save the full definition for later, but don't + // return it yet + $this->definitions[$type] = $def; + return null; + } + } + // check invariants for creation + if (!$optimized) { + if (!is_null($this->get($type . '.DefinitionID'))) { + if ($this->chatty) { + $this->triggerError( + 'Due to a documentation error in previous version of HTML Purifier, your ' . + 'definitions are not being cached. If this is OK, you can remove the ' . + '%$type.DefinitionRev and %$type.DefinitionID declaration. Otherwise, ' . + 'modify your code to use maybeGetRawDefinition, and test if the returned ' . + 'value is null before making any edits (if it is null, that means that a ' . + 'cached version is available, and no raw operations are necessary). See ' . + '' . + 'Customize for more details', + E_USER_WARNING + ); + } else { + $this->triggerError( + "Useless DefinitionID declaration", + E_USER_WARNING + ); + } + } + } + // initialize it + $def = $this->initDefinition($type); + $def->optimized = $optimized; + return $def; + } + throw new HTMLPurifier_Exception("The impossible happened!"); + } + + /** + * Initialise definition + * + * @param string $type What type of definition to create + * + * @return HTMLPurifier_CSSDefinition|HTMLPurifier_HTMLDefinition|HTMLPurifier_URIDefinition + * @throws HTMLPurifier_Exception + */ + private function initDefinition($type) + { + // quick checks failed, let's create the object + if ($type == 'HTML') { + $def = new HTMLPurifier_HTMLDefinition(); + } elseif ($type == 'CSS') { + $def = new HTMLPurifier_CSSDefinition(); + } elseif ($type == 'URI') { + $def = new HTMLPurifier_URIDefinition(); + } else { + throw new HTMLPurifier_Exception( + "Definition of $type type not supported" + ); + } + $this->definitions[$type] = $def; + return $def; + } + + public function maybeGetRawDefinition($name) + { + return $this->getDefinition($name, true, true); + } + + /** + * @return HTMLPurifier_HTMLDefinition|null + */ + public function maybeGetRawHTMLDefinition() + { + return $this->getDefinition('HTML', true, true); + } + + /** + * @return HTMLPurifier_CSSDefinition|null + */ + public function maybeGetRawCSSDefinition() + { + return $this->getDefinition('CSS', true, true); + } + + /** + * @return HTMLPurifier_URIDefinition|null + */ + public function maybeGetRawURIDefinition() + { + return $this->getDefinition('URI', true, true); + } + + /** + * Loads configuration values from an array with the following structure: + * Namespace.Directive => Value + * + * @param array $config_array Configuration associative array + */ + public function loadArray($config_array) + { + if ($this->isFinalized('Cannot load directives after finalization')) { + return; + } + foreach ($config_array as $key => $value) { + $key = str_replace('_', '.', $key); + if (strpos($key, '.') !== false) { + $this->set($key, $value); + } else { + $namespace = $key; + $namespace_values = $value; + foreach ($namespace_values as $directive => $value2) { + $this->set($namespace .'.'. $directive, $value2); + } + } + } + } + + /** + * Returns a list of array(namespace, directive) for all directives + * that are allowed in a web-form context as per an allowed + * namespaces/directives list. + * + * @param array $allowed List of allowed namespaces/directives + * @param HTMLPurifier_ConfigSchema $schema Schema to use, if not global copy + * + * @return array + */ + public static function getAllowedDirectivesForForm($allowed, $schema = null) + { + if (!$schema) { + $schema = HTMLPurifier_ConfigSchema::instance(); + } + if ($allowed !== true) { + if (is_string($allowed)) { + $allowed = array($allowed); + } + $allowed_ns = array(); + $allowed_directives = array(); + $blacklisted_directives = array(); + foreach ($allowed as $ns_or_directive) { + if (strpos($ns_or_directive, '.') !== false) { + // directive + if ($ns_or_directive[0] == '-') { + $blacklisted_directives[substr($ns_or_directive, 1)] = true; + } else { + $allowed_directives[$ns_or_directive] = true; + } + } else { + // namespace + $allowed_ns[$ns_or_directive] = true; + } + } + } + $ret = array(); + foreach ($schema->info as $key => $def) { + list($ns, $directive) = explode('.', $key, 2); + if ($allowed !== true) { + if (isset($blacklisted_directives["$ns.$directive"])) { + continue; + } + if (!isset($allowed_directives["$ns.$directive"]) && !isset($allowed_ns[$ns])) { + continue; + } + } + if (isset($def->isAlias)) { + continue; + } + if ($directive == 'DefinitionID' || $directive == 'DefinitionRev') { + continue; + } + $ret[] = array($ns, $directive); + } + return $ret; + } + + /** + * Loads configuration values from $_GET/$_POST that were posted + * via ConfigForm + * + * @param array $array $_GET or $_POST array to import + * @param string|bool $index Index/name that the config variables are in + * @param array|bool $allowed List of allowed namespaces/directives + * @param bool $mq_fix Boolean whether or not to enable magic quotes fix + * @param HTMLPurifier_ConfigSchema $schema Schema to use, if not global copy + * + * @return mixed + */ + public static function loadArrayFromForm($array, $index = false, $allowed = true, $mq_fix = true, $schema = null) + { + $ret = HTMLPurifier_Config::prepareArrayFromForm($array, $index, $allowed, $mq_fix, $schema); + $config = HTMLPurifier_Config::create($ret, $schema); + return $config; + } + + /** + * Merges in configuration values from $_GET/$_POST to object. NOT STATIC. + * + * @param array $array $_GET or $_POST array to import + * @param string|bool $index Index/name that the config variables are in + * @param array|bool $allowed List of allowed namespaces/directives + * @param bool $mq_fix Boolean whether or not to enable magic quotes fix + */ + public function mergeArrayFromForm($array, $index = false, $allowed = true, $mq_fix = true) + { + $ret = HTMLPurifier_Config::prepareArrayFromForm($array, $index, $allowed, $mq_fix, $this->def); + $this->loadArray($ret); + } + + /** + * Prepares an array from a form into something usable for the more + * strict parts of HTMLPurifier_Config + * + * @param array $array $_GET or $_POST array to import + * @param string|bool $index Index/name that the config variables are in + * @param array|bool $allowed List of allowed namespaces/directives + * @param bool $mq_fix Boolean whether or not to enable magic quotes fix + * @param HTMLPurifier_ConfigSchema $schema Schema to use, if not global copy + * + * @return array + */ + public static function prepareArrayFromForm($array, $index = false, $allowed = true, $mq_fix = true, $schema = null) + { + if ($index !== false) { + $array = (isset($array[$index]) && is_array($array[$index])) ? $array[$index] : array(); + } + $mq = $mq_fix && version_compare(PHP_VERSION, '7.4.0', '<') && function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc(); + + $allowed = HTMLPurifier_Config::getAllowedDirectivesForForm($allowed, $schema); + $ret = array(); + foreach ($allowed as $key) { + list($ns, $directive) = $key; + $skey = "$ns.$directive"; + if (!empty($array["Null_$skey"])) { + $ret[$ns][$directive] = null; + continue; + } + if (!isset($array[$skey])) { + continue; + } + $value = $mq ? stripslashes($array[$skey]) : $array[$skey]; + $ret[$ns][$directive] = $value; + } + return $ret; + } + + /** + * Loads configuration values from an ini file + * + * @param string $filename Name of ini file + */ + public function loadIni($filename) + { + if ($this->isFinalized('Cannot load directives after finalization')) { + return; + } + $array = parse_ini_file($filename, true); + $this->loadArray($array); + } + + /** + * Checks whether or not the configuration object is finalized. + * + * @param string|bool $error String error message, or false for no error + * + * @return bool + */ + public function isFinalized($error = false) + { + if ($this->finalized && $error) { + $this->triggerError($error, E_USER_ERROR); + } + return $this->finalized; + } + + /** + * Finalizes configuration only if auto finalize is on and not + * already finalized + */ + public function autoFinalize() + { + if ($this->autoFinalize) { + $this->finalize(); + } else { + $this->plist->squash(true); + } + } + + /** + * Finalizes a configuration object, prohibiting further change + */ + public function finalize() + { + $this->finalized = true; + $this->parser = null; + } + + /** + * Produces a nicely formatted error message by supplying the + * stack frame information OUTSIDE of HTMLPurifier_Config. + * + * @param string $msg An error message + * @param int $no An error number + */ + protected function triggerError($msg, $no) + { + // determine previous stack frame + $extra = ''; + if ($this->chatty) { + $trace = debug_backtrace(); + // zip(tail(trace), trace) -- but PHP is not Haskell har har + for ($i = 0, $c = count($trace); $i < $c - 1; $i++) { + // XXX this is not correct on some versions of HTML Purifier + if (isset($trace[$i + 1]['class']) && $trace[$i + 1]['class'] === 'HTMLPurifier_Config') { + continue; + } + $frame = $trace[$i]; + $extra = " invoked on line {$frame['line']} in file {$frame['file']}"; + break; + } + } + trigger_error($msg . $extra, $no); + } + + /** + * Returns a serialized form of the configuration object that can + * be reconstituted. + * + * @return string + */ + public function serialize() + { + $this->getDefinition('HTML'); + $this->getDefinition('CSS'); + $this->getDefinition('URI'); + return serialize($this); + } + +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema.php new file mode 100644 index 0000000..c3fe8cd --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema.php @@ -0,0 +1,176 @@ + array( + * 'Directive' => new stdClass(), + * ) + * ) + * + * The stdClass may have the following properties: + * + * - If isAlias isn't set: + * - type: Integer type of directive, see HTMLPurifier_VarParser for definitions + * - allow_null: If set, this directive allows null values + * - aliases: If set, an associative array of value aliases to real values + * - allowed: If set, a lookup array of allowed (string) values + * - If isAlias is set: + * - namespace: Namespace this directive aliases to + * - name: Directive name this directive aliases to + * + * In certain degenerate cases, stdClass will actually be an integer. In + * that case, the value is equivalent to an stdClass with the type + * property set to the integer. If the integer is negative, type is + * equal to the absolute value of integer, and allow_null is true. + * + * This class is friendly with HTMLPurifier_Config. If you need introspection + * about the schema, you're better of using the ConfigSchema_Interchange, + * which uses more memory but has much richer information. + * @type array + */ + public $info = array(); + + /** + * Application-wide singleton + * @type HTMLPurifier_ConfigSchema + */ + protected static $singleton; + + public function __construct() + { + $this->defaultPlist = new HTMLPurifier_PropertyList(); + } + + /** + * Unserializes the default ConfigSchema. + * @return HTMLPurifier_ConfigSchema + */ + public static function makeFromSerial() + { + $contents = file_get_contents(HTMLPURIFIER_PREFIX . '/HTMLPurifier/ConfigSchema/schema.ser'); + $r = unserialize($contents); + if (!$r) { + $hash = sha1($contents); + trigger_error("Unserialization of configuration schema failed, sha1 of file was $hash", E_USER_ERROR); + } + return $r; + } + + /** + * Retrieves an instance of the application-wide configuration definition. + * @param HTMLPurifier_ConfigSchema $prototype + * @return HTMLPurifier_ConfigSchema + */ + public static function instance($prototype = null) + { + if ($prototype !== null) { + HTMLPurifier_ConfigSchema::$singleton = $prototype; + } elseif (HTMLPurifier_ConfigSchema::$singleton === null || $prototype === true) { + HTMLPurifier_ConfigSchema::$singleton = HTMLPurifier_ConfigSchema::makeFromSerial(); + } + return HTMLPurifier_ConfigSchema::$singleton; + } + + /** + * Defines a directive for configuration + * @warning Will fail of directive's namespace is defined. + * @warning This method's signature is slightly different from the legacy + * define() static method! Beware! + * @param string $key Name of directive + * @param mixed $default Default value of directive + * @param string $type Allowed type of the directive. See + * HTMLPurifier_VarParser::$types for allowed values + * @param bool $allow_null Whether or not to allow null values + */ + public function add($key, $default, $type, $allow_null) + { + $obj = new stdClass(); + $obj->type = is_int($type) ? $type : HTMLPurifier_VarParser::$types[$type]; + if ($allow_null) { + $obj->allow_null = true; + } + $this->info[$key] = $obj; + $this->defaults[$key] = $default; + $this->defaultPlist->set($key, $default); + } + + /** + * Defines a directive value alias. + * + * Directive value aliases are convenient for developers because it lets + * them set a directive to several values and get the same result. + * @param string $key Name of Directive + * @param array $aliases Hash of aliased values to the real alias + */ + public function addValueAliases($key, $aliases) + { + if (!isset($this->info[$key]->aliases)) { + $this->info[$key]->aliases = array(); + } + foreach ($aliases as $alias => $real) { + $this->info[$key]->aliases[$alias] = $real; + } + } + + /** + * Defines a set of allowed values for a directive. + * @warning This is slightly different from the corresponding static + * method definition. + * @param string $key Name of directive + * @param array $allowed Lookup array of allowed values + */ + public function addAllowedValues($key, $allowed) + { + $this->info[$key]->allowed = $allowed; + } + + /** + * Defines a directive alias for backwards compatibility + * @param string $key Directive that will be aliased + * @param string $new_key Directive that the alias will be to + */ + public function addAlias($key, $new_key) + { + $obj = new stdClass; + $obj->key = $new_key; + $obj->isAlias = true; + $this->info[$key] = $obj; + } + + /** + * Replaces any stdClass that only has the type property with type integer. + */ + public function postProcess() + { + foreach ($this->info as $key => $v) { + if (count((array) $v) == 1) { + $this->info[$key] = $v->type; + } elseif (count((array) $v) == 2 && isset($v->allow_null)) { + $this->info[$key] = -$v->type; + } + } + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/Builder/ConfigSchema.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/Builder/ConfigSchema.php new file mode 100644 index 0000000..d5906cd --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/Builder/ConfigSchema.php @@ -0,0 +1,48 @@ +directives as $d) { + $schema->add( + $d->id->key, + $d->default, + $d->type, + $d->typeAllowsNull + ); + if ($d->allowed !== null) { + $schema->addAllowedValues( + $d->id->key, + $d->allowed + ); + } + foreach ($d->aliases as $alias) { + $schema->addAlias( + $alias->key, + $d->id->key + ); + } + if ($d->valueAliases !== null) { + $schema->addValueAliases( + $d->id->key, + $d->valueAliases + ); + } + } + $schema->postProcess(); + return $schema; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/Builder/Xml.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/Builder/Xml.php new file mode 100644 index 0000000..5fa56f7 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/Builder/Xml.php @@ -0,0 +1,144 @@ +startElement('div'); + + $purifier = HTMLPurifier::getInstance(); + $html = $purifier->purify($html); + $this->writeAttribute('xmlns', 'http://www.w3.org/1999/xhtml'); + $this->writeRaw($html); + + $this->endElement(); // div + } + + /** + * @param mixed $var + * @return string + */ + protected function export($var) + { + if ($var === array()) { + return 'array()'; + } + return var_export($var, true); + } + + /** + * @param HTMLPurifier_ConfigSchema_Interchange $interchange + */ + public function build($interchange) + { + // global access, only use as last resort + $this->interchange = $interchange; + + $this->setIndent(true); + $this->startDocument('1.0', 'UTF-8'); + $this->startElement('configdoc'); + $this->writeElement('title', $interchange->name); + + foreach ($interchange->directives as $directive) { + $this->buildDirective($directive); + } + + if ($this->namespace) { + $this->endElement(); + } // namespace + + $this->endElement(); // configdoc + $this->flush(); + } + + /** + * @param HTMLPurifier_ConfigSchema_Interchange_Directive $directive + */ + public function buildDirective($directive) + { + // Kludge, although I suppose having a notion of a "root namespace" + // certainly makes things look nicer when documentation is built. + // Depends on things being sorted. + if (!$this->namespace || $this->namespace !== $directive->id->getRootNamespace()) { + if ($this->namespace) { + $this->endElement(); + } // namespace + $this->namespace = $directive->id->getRootNamespace(); + $this->startElement('namespace'); + $this->writeAttribute('id', $this->namespace); + $this->writeElement('name', $this->namespace); + } + + $this->startElement('directive'); + $this->writeAttribute('id', $directive->id->toString()); + + $this->writeElement('name', $directive->id->getDirective()); + + $this->startElement('aliases'); + foreach ($directive->aliases as $alias) { + $this->writeElement('alias', $alias->toString()); + } + $this->endElement(); // aliases + + $this->startElement('constraints'); + if ($directive->version) { + $this->writeElement('version', $directive->version); + } + $this->startElement('type'); + if ($directive->typeAllowsNull) { + $this->writeAttribute('allow-null', 'yes'); + } + $this->text($directive->type); + $this->endElement(); // type + if ($directive->allowed) { + $this->startElement('allowed'); + foreach ($directive->allowed as $value => $x) { + $this->writeElement('value', $value); + } + $this->endElement(); // allowed + } + $this->writeElement('default', $this->export($directive->default)); + $this->writeAttribute('xml:space', 'preserve'); + if ($directive->external) { + $this->startElement('external'); + foreach ($directive->external as $project) { + $this->writeElement('project', $project); + } + $this->endElement(); + } + $this->endElement(); // constraints + + if ($directive->deprecatedVersion) { + $this->startElement('deprecated'); + $this->writeElement('version', $directive->deprecatedVersion); + $this->writeElement('use', $directive->deprecatedUse->toString()); + $this->endElement(); // deprecated + } + + $this->startElement('description'); + $this->writeHTMLDiv($directive->description); + $this->endElement(); // description + + $this->endElement(); // directive + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/Exception.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/Exception.php new file mode 100644 index 0000000..2671516 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/Exception.php @@ -0,0 +1,11 @@ + array(directive info) + * @type HTMLPurifier_ConfigSchema_Interchange_Directive[] + */ + public $directives = array(); + + /** + * Adds a directive array to $directives + * @param HTMLPurifier_ConfigSchema_Interchange_Directive $directive + * @throws HTMLPurifier_ConfigSchema_Exception + */ + public function addDirective($directive) + { + if (isset($this->directives[$i = $directive->id->toString()])) { + throw new HTMLPurifier_ConfigSchema_Exception("Cannot redefine directive '$i'"); + } + $this->directives[$i] = $directive; + } + + /** + * Convenience function to perform standard validation. Throws exception + * on failed validation. + */ + public function validate() + { + $validator = new HTMLPurifier_ConfigSchema_Validator(); + return $validator->validate($this); + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/Interchange/Directive.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/Interchange/Directive.php new file mode 100644 index 0000000..127a39a --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/Interchange/Directive.php @@ -0,0 +1,89 @@ + true). + * Null if all values are allowed. + * @type array + */ + public $allowed; + + /** + * List of aliases for the directive. + * e.g. array(new HTMLPurifier_ConfigSchema_Interchange_Id('Ns', 'Dir'))). + * @type HTMLPurifier_ConfigSchema_Interchange_Id[] + */ + public $aliases = array(); + + /** + * Hash of value aliases, e.g. array('alt' => 'real'). Null if value + * aliasing is disabled (necessary for non-scalar types). + * @type array + */ + public $valueAliases; + + /** + * Version of HTML Purifier the directive was introduced, e.g. '1.3.1'. + * Null if the directive has always existed. + * @type string + */ + public $version; + + /** + * ID of directive that supercedes this old directive. + * Null if not deprecated. + * @type HTMLPurifier_ConfigSchema_Interchange_Id + */ + public $deprecatedUse; + + /** + * Version of HTML Purifier this directive was deprecated. Null if not + * deprecated. + * @type string + */ + public $deprecatedVersion; + + /** + * List of external projects this directive depends on, e.g. array('CSSTidy'). + * @type array + */ + public $external = array(); +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/Interchange/Id.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/Interchange/Id.php new file mode 100644 index 0000000..126f09d --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/Interchange/Id.php @@ -0,0 +1,58 @@ +key = $key; + } + + /** + * @return string + * @warning This is NOT magic, to ensure that people don't abuse SPL and + * cause problems for PHP 5.0 support. + */ + public function toString() + { + return $this->key; + } + + /** + * @return string + */ + public function getRootNamespace() + { + return substr($this->key, 0, strpos($this->key, ".")); + } + + /** + * @return string + */ + public function getDirective() + { + return substr($this->key, strpos($this->key, ".") + 1); + } + + /** + * @param string $id + * @return HTMLPurifier_ConfigSchema_Interchange_Id + */ + public static function make($id) + { + return new HTMLPurifier_ConfigSchema_Interchange_Id($id); + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/InterchangeBuilder.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/InterchangeBuilder.php new file mode 100644 index 0000000..655e6dd --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/InterchangeBuilder.php @@ -0,0 +1,226 @@ +varParser = $varParser ? $varParser : new HTMLPurifier_VarParser_Native(); + } + + /** + * @param string $dir + * @return HTMLPurifier_ConfigSchema_Interchange + */ + public static function buildFromDirectory($dir = null) + { + $builder = new HTMLPurifier_ConfigSchema_InterchangeBuilder(); + $interchange = new HTMLPurifier_ConfigSchema_Interchange(); + return $builder->buildDir($interchange, $dir); + } + + /** + * @param HTMLPurifier_ConfigSchema_Interchange $interchange + * @param string $dir + * @return HTMLPurifier_ConfigSchema_Interchange + */ + public function buildDir($interchange, $dir = null) + { + if (!$dir) { + $dir = HTMLPURIFIER_PREFIX . '/HTMLPurifier/ConfigSchema/schema'; + } + if (file_exists($dir . '/info.ini')) { + $info = parse_ini_file($dir . '/info.ini'); + $interchange->name = $info['name']; + } + + $files = array(); + $dh = opendir($dir); + while (false !== ($file = readdir($dh))) { + if (!$file || $file[0] == '.' || strrchr($file, '.') !== '.txt') { + continue; + } + $files[] = $file; + } + closedir($dh); + + sort($files); + foreach ($files as $file) { + $this->buildFile($interchange, $dir . '/' . $file); + } + return $interchange; + } + + /** + * @param HTMLPurifier_ConfigSchema_Interchange $interchange + * @param string $file + */ + public function buildFile($interchange, $file) + { + $parser = new HTMLPurifier_StringHashParser(); + $this->build( + $interchange, + new HTMLPurifier_StringHash($parser->parseFile($file)) + ); + } + + /** + * Builds an interchange object based on a hash. + * @param HTMLPurifier_ConfigSchema_Interchange $interchange HTMLPurifier_ConfigSchema_Interchange object to build + * @param HTMLPurifier_StringHash $hash source data + * @throws HTMLPurifier_ConfigSchema_Exception + */ + public function build($interchange, $hash) + { + if (!$hash instanceof HTMLPurifier_StringHash) { + $hash = new HTMLPurifier_StringHash($hash); + } + if (!isset($hash['ID'])) { + throw new HTMLPurifier_ConfigSchema_Exception('Hash does not have any ID'); + } + if (strpos($hash['ID'], '.') === false) { + if (count($hash) == 2 && isset($hash['DESCRIPTION'])) { + $hash->offsetGet('DESCRIPTION'); // prevent complaining + } else { + throw new HTMLPurifier_ConfigSchema_Exception('All directives must have a namespace'); + } + } else { + $this->buildDirective($interchange, $hash); + } + $this->_findUnused($hash); + } + + /** + * @param HTMLPurifier_ConfigSchema_Interchange $interchange + * @param HTMLPurifier_StringHash $hash + * @throws HTMLPurifier_ConfigSchema_Exception + */ + public function buildDirective($interchange, $hash) + { + $directive = new HTMLPurifier_ConfigSchema_Interchange_Directive(); + + // These are required elements: + $directive->id = $this->id($hash->offsetGet('ID')); + $id = $directive->id->toString(); // convenience + + if (isset($hash['TYPE'])) { + $type = explode('/', $hash->offsetGet('TYPE')); + if (isset($type[1])) { + $directive->typeAllowsNull = true; + } + $directive->type = $type[0]; + } else { + throw new HTMLPurifier_ConfigSchema_Exception("TYPE in directive hash '$id' not defined"); + } + + if (isset($hash['DEFAULT'])) { + try { + $directive->default = $this->varParser->parse( + $hash->offsetGet('DEFAULT'), + $directive->type, + $directive->typeAllowsNull + ); + } catch (HTMLPurifier_VarParserException $e) { + throw new HTMLPurifier_ConfigSchema_Exception($e->getMessage() . " in DEFAULT in directive hash '$id'"); + } + } + + if (isset($hash['DESCRIPTION'])) { + $directive->description = $hash->offsetGet('DESCRIPTION'); + } + + if (isset($hash['ALLOWED'])) { + $directive->allowed = $this->lookup($this->evalArray($hash->offsetGet('ALLOWED'))); + } + + if (isset($hash['VALUE-ALIASES'])) { + $directive->valueAliases = $this->evalArray($hash->offsetGet('VALUE-ALIASES')); + } + + if (isset($hash['ALIASES'])) { + $raw_aliases = trim($hash->offsetGet('ALIASES')); + $aliases = preg_split('/\s*,\s*/', $raw_aliases); + foreach ($aliases as $alias) { + $directive->aliases[] = $this->id($alias); + } + } + + if (isset($hash['VERSION'])) { + $directive->version = $hash->offsetGet('VERSION'); + } + + if (isset($hash['DEPRECATED-USE'])) { + $directive->deprecatedUse = $this->id($hash->offsetGet('DEPRECATED-USE')); + } + + if (isset($hash['DEPRECATED-VERSION'])) { + $directive->deprecatedVersion = $hash->offsetGet('DEPRECATED-VERSION'); + } + + if (isset($hash['EXTERNAL'])) { + $directive->external = preg_split('/\s*,\s*/', trim($hash->offsetGet('EXTERNAL'))); + } + + $interchange->addDirective($directive); + } + + /** + * Evaluates an array PHP code string without array() wrapper + * @param string $contents + */ + protected function evalArray($contents) + { + return eval('return array(' . $contents . ');'); + } + + /** + * Converts an array list into a lookup array. + * @param array $array + * @return array + */ + protected function lookup($array) + { + $ret = array(); + foreach ($array as $val) { + $ret[$val] = true; + } + return $ret; + } + + /** + * Convenience function that creates an HTMLPurifier_ConfigSchema_Interchange_Id + * object based on a string Id. + * @param string $id + * @return HTMLPurifier_ConfigSchema_Interchange_Id + */ + protected function id($id) + { + return HTMLPurifier_ConfigSchema_Interchange_Id::make($id); + } + + /** + * Triggers errors for any unused keys passed in the hash; such keys + * may indicate typos, missing values, etc. + * @param HTMLPurifier_StringHash $hash Hash to check. + */ + protected function _findUnused($hash) + { + $accessed = $hash->getAccessed(); + foreach ($hash as $k => $v) { + if (!isset($accessed[$k])) { + trigger_error("String hash key '$k' not used by builder", E_USER_NOTICE); + } + } + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/Validator.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/Validator.php new file mode 100644 index 0000000..fb31277 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/Validator.php @@ -0,0 +1,248 @@ +parser = new HTMLPurifier_VarParser(); + } + + /** + * Validates a fully-formed interchange object. + * @param HTMLPurifier_ConfigSchema_Interchange $interchange + * @return bool + */ + public function validate($interchange) + { + $this->interchange = $interchange; + $this->aliases = array(); + // PHP is a bit lax with integer <=> string conversions in + // arrays, so we don't use the identical !== comparison + foreach ($interchange->directives as $i => $directive) { + $id = $directive->id->toString(); + if ($i != $id) { + $this->error(false, "Integrity violation: key '$i' does not match internal id '$id'"); + } + $this->validateDirective($directive); + } + return true; + } + + /** + * Validates a HTMLPurifier_ConfigSchema_Interchange_Id object. + * @param HTMLPurifier_ConfigSchema_Interchange_Id $id + */ + public function validateId($id) + { + $id_string = $id->toString(); + $this->context[] = "id '$id_string'"; + if (!$id instanceof HTMLPurifier_ConfigSchema_Interchange_Id) { + // handled by InterchangeBuilder + $this->error(false, 'is not an instance of HTMLPurifier_ConfigSchema_Interchange_Id'); + } + // keys are now unconstrained (we might want to narrow down to A-Za-z0-9.) + // we probably should check that it has at least one namespace + $this->with($id, 'key') + ->assertNotEmpty() + ->assertIsString(); // implicit assertIsString handled by InterchangeBuilder + array_pop($this->context); + } + + /** + * Validates a HTMLPurifier_ConfigSchema_Interchange_Directive object. + * @param HTMLPurifier_ConfigSchema_Interchange_Directive $d + */ + public function validateDirective($d) + { + $id = $d->id->toString(); + $this->context[] = "directive '$id'"; + $this->validateId($d->id); + + $this->with($d, 'description') + ->assertNotEmpty(); + + // BEGIN - handled by InterchangeBuilder + $this->with($d, 'type') + ->assertNotEmpty(); + $this->with($d, 'typeAllowsNull') + ->assertIsBool(); + try { + // This also tests validity of $d->type + $this->parser->parse($d->default, $d->type, $d->typeAllowsNull); + } catch (HTMLPurifier_VarParserException $e) { + $this->error('default', 'had error: ' . $e->getMessage()); + } + // END - handled by InterchangeBuilder + + if (!is_null($d->allowed) || !empty($d->valueAliases)) { + // allowed and valueAliases require that we be dealing with + // strings, so check for that early. + $d_int = HTMLPurifier_VarParser::$types[$d->type]; + if (!isset(HTMLPurifier_VarParser::$stringTypes[$d_int])) { + $this->error('type', 'must be a string type when used with allowed or value aliases'); + } + } + + $this->validateDirectiveAllowed($d); + $this->validateDirectiveValueAliases($d); + $this->validateDirectiveAliases($d); + + array_pop($this->context); + } + + /** + * Extra validation if $allowed member variable of + * HTMLPurifier_ConfigSchema_Interchange_Directive is defined. + * @param HTMLPurifier_ConfigSchema_Interchange_Directive $d + */ + public function validateDirectiveAllowed($d) + { + if (is_null($d->allowed)) { + return; + } + $this->with($d, 'allowed') + ->assertNotEmpty() + ->assertIsLookup(); // handled by InterchangeBuilder + if (is_string($d->default) && !isset($d->allowed[$d->default])) { + $this->error('default', 'must be an allowed value'); + } + $this->context[] = 'allowed'; + foreach ($d->allowed as $val => $x) { + if (!is_string($val)) { + $this->error("value $val", 'must be a string'); + } + } + array_pop($this->context); + } + + /** + * Extra validation if $valueAliases member variable of + * HTMLPurifier_ConfigSchema_Interchange_Directive is defined. + * @param HTMLPurifier_ConfigSchema_Interchange_Directive $d + */ + public function validateDirectiveValueAliases($d) + { + if (is_null($d->valueAliases)) { + return; + } + $this->with($d, 'valueAliases') + ->assertIsArray(); // handled by InterchangeBuilder + $this->context[] = 'valueAliases'; + foreach ($d->valueAliases as $alias => $real) { + if (!is_string($alias)) { + $this->error("alias $alias", 'must be a string'); + } + if (!is_string($real)) { + $this->error("alias target $real from alias '$alias'", 'must be a string'); + } + if ($alias === $real) { + $this->error("alias '$alias'", "must not be an alias to itself"); + } + } + if (!is_null($d->allowed)) { + foreach ($d->valueAliases as $alias => $real) { + if (isset($d->allowed[$alias])) { + $this->error("alias '$alias'", 'must not be an allowed value'); + } elseif (!isset($d->allowed[$real])) { + $this->error("alias '$alias'", 'must be an alias to an allowed value'); + } + } + } + array_pop($this->context); + } + + /** + * Extra validation if $aliases member variable of + * HTMLPurifier_ConfigSchema_Interchange_Directive is defined. + * @param HTMLPurifier_ConfigSchema_Interchange_Directive $d + */ + public function validateDirectiveAliases($d) + { + $this->with($d, 'aliases') + ->assertIsArray(); // handled by InterchangeBuilder + $this->context[] = 'aliases'; + foreach ($d->aliases as $alias) { + $this->validateId($alias); + $s = $alias->toString(); + if (isset($this->interchange->directives[$s])) { + $this->error("alias '$s'", 'collides with another directive'); + } + if (isset($this->aliases[$s])) { + $other_directive = $this->aliases[$s]; + $this->error("alias '$s'", "collides with alias for directive '$other_directive'"); + } + $this->aliases[$s] = $d->id->toString(); + } + array_pop($this->context); + } + + // protected helper functions + + /** + * Convenience function for generating HTMLPurifier_ConfigSchema_ValidatorAtom + * for validating simple member variables of objects. + * @param $obj + * @param $member + * @return HTMLPurifier_ConfigSchema_ValidatorAtom + */ + protected function with($obj, $member) + { + return new HTMLPurifier_ConfigSchema_ValidatorAtom($this->getFormattedContext(), $obj, $member); + } + + /** + * Emits an error, providing helpful context. + * @throws HTMLPurifier_ConfigSchema_Exception + */ + protected function error($target, $msg) + { + if ($target !== false) { + $prefix = ucfirst($target) . ' in ' . $this->getFormattedContext(); + } else { + $prefix = ucfirst($this->getFormattedContext()); + } + throw new HTMLPurifier_ConfigSchema_Exception(trim($prefix . ' ' . $msg)); + } + + /** + * Returns a formatted context string. + * @return string + */ + protected function getFormattedContext() + { + return implode(' in ', array_reverse($this->context)); + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/ValidatorAtom.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/ValidatorAtom.php new file mode 100644 index 0000000..c9aa364 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/ValidatorAtom.php @@ -0,0 +1,130 @@ +context = $context; + $this->obj = $obj; + $this->member = $member; + $this->contents =& $obj->$member; + } + + /** + * @return HTMLPurifier_ConfigSchema_ValidatorAtom + */ + public function assertIsString() + { + if (!is_string($this->contents)) { + $this->error('must be a string'); + } + return $this; + } + + /** + * @return HTMLPurifier_ConfigSchema_ValidatorAtom + */ + public function assertIsBool() + { + if (!is_bool($this->contents)) { + $this->error('must be a boolean'); + } + return $this; + } + + /** + * @return HTMLPurifier_ConfigSchema_ValidatorAtom + */ + public function assertIsArray() + { + if (!is_array($this->contents)) { + $this->error('must be an array'); + } + return $this; + } + + /** + * @return HTMLPurifier_ConfigSchema_ValidatorAtom + */ + public function assertNotNull() + { + if ($this->contents === null) { + $this->error('must not be null'); + } + return $this; + } + + /** + * @return HTMLPurifier_ConfigSchema_ValidatorAtom + */ + public function assertAlnum() + { + $this->assertIsString(); + if (!ctype_alnum($this->contents)) { + $this->error('must be alphanumeric'); + } + return $this; + } + + /** + * @return HTMLPurifier_ConfigSchema_ValidatorAtom + */ + public function assertNotEmpty() + { + if (empty($this->contents)) { + $this->error('must not be empty'); + } + return $this; + } + + /** + * @return HTMLPurifier_ConfigSchema_ValidatorAtom + */ + public function assertIsLookup() + { + $this->assertIsArray(); + foreach ($this->contents as $v) { + if ($v !== true) { + $this->error('must be a lookup array'); + } + } + return $this; + } + + /** + * @param string $msg + * @throws HTMLPurifier_ConfigSchema_Exception + */ + protected function error($msg) + { + throw new HTMLPurifier_ConfigSchema_Exception(ucfirst($this->member) . ' in ' . $this->context . ' ' . $msg); + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema.ser b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema.ser new file mode 100644 index 0000000..3cd756b --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema.ser @@ -0,0 +1 @@ +O:25:"HTMLPurifier_ConfigSchema":3:{s:8:"defaults";a:128:{s:19:"Attr.AllowedClasses";N;s:24:"Attr.AllowedFrameTargets";a:0:{}s:15:"Attr.AllowedRel";a:0:{}s:15:"Attr.AllowedRev";a:0:{}s:18:"Attr.ClassUseCDATA";N;s:20:"Attr.DefaultImageAlt";N;s:24:"Attr.DefaultInvalidImage";s:0:"";s:27:"Attr.DefaultInvalidImageAlt";s:13:"Invalid image";s:19:"Attr.DefaultTextDir";s:3:"ltr";s:13:"Attr.EnableID";b:0;s:21:"Attr.ForbiddenClasses";a:0:{}s:13:"Attr.ID.HTML5";N;s:16:"Attr.IDBlacklist";a:0:{}s:22:"Attr.IDBlacklistRegexp";N;s:13:"Attr.IDPrefix";s:0:"";s:18:"Attr.IDPrefixLocal";s:0:"";s:24:"AutoFormat.AutoParagraph";b:0;s:17:"AutoFormat.Custom";a:0:{}s:25:"AutoFormat.DisplayLinkURI";b:0;s:18:"AutoFormat.Linkify";b:0;s:33:"AutoFormat.PurifierLinkify.DocURL";s:3:"#%s";s:26:"AutoFormat.PurifierLinkify";b:0;s:32:"AutoFormat.RemoveEmpty.Predicate";a:4:{s:8:"colgroup";a:0:{}s:2:"th";a:0:{}s:2:"td";a:0:{}s:6:"iframe";a:1:{i:0;s:3:"src";}}s:44:"AutoFormat.RemoveEmpty.RemoveNbsp.Exceptions";a:2:{s:2:"td";b:1;s:2:"th";b:1;}s:33:"AutoFormat.RemoveEmpty.RemoveNbsp";b:0;s:22:"AutoFormat.RemoveEmpty";b:0;s:39:"AutoFormat.RemoveSpansWithoutAttributes";b:0;s:19:"CSS.AllowDuplicates";b:0;s:18:"CSS.AllowImportant";b:0;s:15:"CSS.AllowTricky";b:0;s:16:"CSS.AllowedFonts";N;s:21:"CSS.AllowedProperties";N;s:17:"CSS.DefinitionRev";i:1;s:23:"CSS.ForbiddenProperties";a:0:{}s:16:"CSS.MaxImgLength";s:6:"1200px";s:15:"CSS.Proprietary";b:0;s:11:"CSS.Trusted";b:0;s:20:"Cache.DefinitionImpl";s:10:"Serializer";s:20:"Cache.SerializerPath";N;s:27:"Cache.SerializerPermissions";i:493;s:22:"Core.AggressivelyFixLt";b:1;s:29:"Core.AggressivelyRemoveScript";b:1;s:28:"Core.AllowHostnameUnderscore";b:0;s:23:"Core.AllowParseManyTags";b:0;s:18:"Core.CollectErrors";b:0;s:18:"Core.ColorKeywords";a:148:{s:9:"aliceblue";s:7:"#F0F8FF";s:12:"antiquewhite";s:7:"#FAEBD7";s:4:"aqua";s:7:"#00FFFF";s:10:"aquamarine";s:7:"#7FFFD4";s:5:"azure";s:7:"#F0FFFF";s:5:"beige";s:7:"#F5F5DC";s:6:"bisque";s:7:"#FFE4C4";s:5:"black";s:7:"#000000";s:14:"blanchedalmond";s:7:"#FFEBCD";s:4:"blue";s:7:"#0000FF";s:10:"blueviolet";s:7:"#8A2BE2";s:5:"brown";s:7:"#A52A2A";s:9:"burlywood";s:7:"#DEB887";s:9:"cadetblue";s:7:"#5F9EA0";s:10:"chartreuse";s:7:"#7FFF00";s:9:"chocolate";s:7:"#D2691E";s:5:"coral";s:7:"#FF7F50";s:14:"cornflowerblue";s:7:"#6495ED";s:8:"cornsilk";s:7:"#FFF8DC";s:7:"crimson";s:7:"#DC143C";s:4:"cyan";s:7:"#00FFFF";s:8:"darkblue";s:7:"#00008B";s:8:"darkcyan";s:7:"#008B8B";s:13:"darkgoldenrod";s:7:"#B8860B";s:8:"darkgray";s:7:"#A9A9A9";s:8:"darkgrey";s:7:"#A9A9A9";s:9:"darkgreen";s:7:"#006400";s:9:"darkkhaki";s:7:"#BDB76B";s:11:"darkmagenta";s:7:"#8B008B";s:14:"darkolivegreen";s:7:"#556B2F";s:10:"darkorange";s:7:"#FF8C00";s:10:"darkorchid";s:7:"#9932CC";s:7:"darkred";s:7:"#8B0000";s:10:"darksalmon";s:7:"#E9967A";s:12:"darkseagreen";s:7:"#8FBC8F";s:13:"darkslateblue";s:7:"#483D8B";s:13:"darkslategray";s:7:"#2F4F4F";s:13:"darkslategrey";s:7:"#2F4F4F";s:13:"darkturquoise";s:7:"#00CED1";s:10:"darkviolet";s:7:"#9400D3";s:8:"deeppink";s:7:"#FF1493";s:11:"deepskyblue";s:7:"#00BFFF";s:7:"dimgray";s:7:"#696969";s:7:"dimgrey";s:7:"#696969";s:10:"dodgerblue";s:7:"#1E90FF";s:9:"firebrick";s:7:"#B22222";s:11:"floralwhite";s:7:"#FFFAF0";s:11:"forestgreen";s:7:"#228B22";s:7:"fuchsia";s:7:"#FF00FF";s:9:"gainsboro";s:7:"#DCDCDC";s:10:"ghostwhite";s:7:"#F8F8FF";s:4:"gold";s:7:"#FFD700";s:9:"goldenrod";s:7:"#DAA520";s:4:"gray";s:7:"#808080";s:4:"grey";s:7:"#808080";s:5:"green";s:7:"#008000";s:11:"greenyellow";s:7:"#ADFF2F";s:8:"honeydew";s:7:"#F0FFF0";s:7:"hotpink";s:7:"#FF69B4";s:9:"indianred";s:7:"#CD5C5C";s:6:"indigo";s:7:"#4B0082";s:5:"ivory";s:7:"#FFFFF0";s:5:"khaki";s:7:"#F0E68C";s:8:"lavender";s:7:"#E6E6FA";s:13:"lavenderblush";s:7:"#FFF0F5";s:9:"lawngreen";s:7:"#7CFC00";s:12:"lemonchiffon";s:7:"#FFFACD";s:9:"lightblue";s:7:"#ADD8E6";s:10:"lightcoral";s:7:"#F08080";s:9:"lightcyan";s:7:"#E0FFFF";s:20:"lightgoldenrodyellow";s:7:"#FAFAD2";s:9:"lightgray";s:7:"#D3D3D3";s:9:"lightgrey";s:7:"#D3D3D3";s:10:"lightgreen";s:7:"#90EE90";s:9:"lightpink";s:7:"#FFB6C1";s:11:"lightsalmon";s:7:"#FFA07A";s:13:"lightseagreen";s:7:"#20B2AA";s:12:"lightskyblue";s:7:"#87CEFA";s:14:"lightslategray";s:7:"#778899";s:14:"lightslategrey";s:7:"#778899";s:14:"lightsteelblue";s:7:"#B0C4DE";s:11:"lightyellow";s:7:"#FFFFE0";s:4:"lime";s:7:"#00FF00";s:9:"limegreen";s:7:"#32CD32";s:5:"linen";s:7:"#FAF0E6";s:7:"magenta";s:7:"#FF00FF";s:6:"maroon";s:7:"#800000";s:16:"mediumaquamarine";s:7:"#66CDAA";s:10:"mediumblue";s:7:"#0000CD";s:12:"mediumorchid";s:7:"#BA55D3";s:12:"mediumpurple";s:7:"#9370DB";s:14:"mediumseagreen";s:7:"#3CB371";s:15:"mediumslateblue";s:7:"#7B68EE";s:17:"mediumspringgreen";s:7:"#00FA9A";s:15:"mediumturquoise";s:7:"#48D1CC";s:15:"mediumvioletred";s:7:"#C71585";s:12:"midnightblue";s:7:"#191970";s:9:"mintcream";s:7:"#F5FFFA";s:9:"mistyrose";s:7:"#FFE4E1";s:8:"moccasin";s:7:"#FFE4B5";s:11:"navajowhite";s:7:"#FFDEAD";s:4:"navy";s:7:"#000080";s:7:"oldlace";s:7:"#FDF5E6";s:5:"olive";s:7:"#808000";s:9:"olivedrab";s:7:"#6B8E23";s:6:"orange";s:7:"#FFA500";s:9:"orangered";s:7:"#FF4500";s:6:"orchid";s:7:"#DA70D6";s:13:"palegoldenrod";s:7:"#EEE8AA";s:9:"palegreen";s:7:"#98FB98";s:13:"paleturquoise";s:7:"#AFEEEE";s:13:"palevioletred";s:7:"#DB7093";s:10:"papayawhip";s:7:"#FFEFD5";s:9:"peachpuff";s:7:"#FFDAB9";s:4:"peru";s:7:"#CD853F";s:4:"pink";s:7:"#FFC0CB";s:4:"plum";s:7:"#DDA0DD";s:10:"powderblue";s:7:"#B0E0E6";s:6:"purple";s:7:"#800080";s:13:"rebeccapurple";s:7:"#663399";s:3:"red";s:7:"#FF0000";s:9:"rosybrown";s:7:"#BC8F8F";s:9:"royalblue";s:7:"#4169E1";s:11:"saddlebrown";s:7:"#8B4513";s:6:"salmon";s:7:"#FA8072";s:10:"sandybrown";s:7:"#F4A460";s:8:"seagreen";s:7:"#2E8B57";s:8:"seashell";s:7:"#FFF5EE";s:6:"sienna";s:7:"#A0522D";s:6:"silver";s:7:"#C0C0C0";s:7:"skyblue";s:7:"#87CEEB";s:9:"slateblue";s:7:"#6A5ACD";s:9:"slategray";s:7:"#708090";s:9:"slategrey";s:7:"#708090";s:4:"snow";s:7:"#FFFAFA";s:11:"springgreen";s:7:"#00FF7F";s:9:"steelblue";s:7:"#4682B4";s:3:"tan";s:7:"#D2B48C";s:4:"teal";s:7:"#008080";s:7:"thistle";s:7:"#D8BFD8";s:6:"tomato";s:7:"#FF6347";s:9:"turquoise";s:7:"#40E0D0";s:6:"violet";s:7:"#EE82EE";s:5:"wheat";s:7:"#F5DEB3";s:5:"white";s:7:"#FFFFFF";s:10:"whitesmoke";s:7:"#F5F5F5";s:6:"yellow";s:7:"#FFFF00";s:11:"yellowgreen";s:7:"#9ACD32";}s:30:"Core.ConvertDocumentToFragment";b:1;s:36:"Core.DirectLexLineNumberSyncInterval";i:0;s:20:"Core.DisableExcludes";b:0;s:15:"Core.EnableIDNA";b:0;s:13:"Core.Encoding";s:5:"utf-8";s:26:"Core.EscapeInvalidChildren";b:0;s:22:"Core.EscapeInvalidTags";b:0;s:29:"Core.EscapeNonASCIICharacters";b:0;s:19:"Core.HiddenElements";a:2:{s:6:"script";b:1;s:5:"style";b:1;}s:13:"Core.Language";s:2:"en";s:24:"Core.LegacyEntityDecoder";b:0;s:14:"Core.LexerImpl";N;s:24:"Core.MaintainLineNumbers";N;s:22:"Core.NormalizeNewlines";b:1;s:17:"Core.RemoveBlanks";b:0;s:21:"Core.RemoveInvalidImg";b:1;s:33:"Core.RemoveProcessingInstructions";b:0;s:25:"Core.RemoveScriptContents";N;s:13:"Filter.Custom";a:0:{}s:34:"Filter.ExtractStyleBlocks.Escaping";b:1;s:31:"Filter.ExtractStyleBlocks.Scope";N;s:34:"Filter.ExtractStyleBlocks.TidyImpl";N;s:25:"Filter.ExtractStyleBlocks";b:0;s:14:"Filter.YouTube";b:0;s:12:"HTML.Allowed";N;s:22:"HTML.AllowedAttributes";N;s:20:"HTML.AllowedComments";a:0:{}s:26:"HTML.AllowedCommentsRegexp";N;s:20:"HTML.AllowedElements";N;s:19:"HTML.AllowedModules";N;s:23:"HTML.Attr.Name.UseCDATA";b:0;s:17:"HTML.BlockWrapper";s:1:"p";s:16:"HTML.CoreModules";a:7:{s:9:"Structure";b:1;s:4:"Text";b:1;s:9:"Hypertext";b:1;s:4:"List";b:1;s:22:"NonXMLCommonAttributes";b:1;s:19:"XMLCommonAttributes";b:1;s:16:"CommonAttributes";b:1;}s:18:"HTML.CustomDoctype";N;s:17:"HTML.DefinitionID";N;s:18:"HTML.DefinitionRev";i:1;s:12:"HTML.Doctype";N;s:25:"HTML.FlashAllowFullScreen";b:0;s:24:"HTML.ForbiddenAttributes";a:0:{}s:22:"HTML.ForbiddenElements";a:0:{}s:10:"HTML.Forms";b:0;s:17:"HTML.MaxImgLength";i:1200;s:13:"HTML.Nofollow";b:0;s:11:"HTML.Parent";s:3:"div";s:16:"HTML.Proprietary";b:0;s:14:"HTML.SafeEmbed";b:0;s:15:"HTML.SafeIframe";b:0;s:15:"HTML.SafeObject";b:0;s:18:"HTML.SafeScripting";a:0:{}s:11:"HTML.Strict";b:0;s:16:"HTML.TargetBlank";b:0;s:19:"HTML.TargetNoopener";b:1;s:21:"HTML.TargetNoreferrer";b:1;s:12:"HTML.TidyAdd";a:0:{}s:14:"HTML.TidyLevel";s:6:"medium";s:15:"HTML.TidyRemove";a:0:{}s:12:"HTML.Trusted";b:0;s:10:"HTML.XHTML";b:1;s:28:"Output.CommentScriptContents";b:1;s:19:"Output.FixInnerHTML";b:1;s:18:"Output.FlashCompat";b:0;s:14:"Output.Newline";N;s:15:"Output.SortAttr";b:0;s:17:"Output.TidyFormat";b:0;s:17:"Test.ForceNoIconv";b:0;s:18:"URI.AllowedSchemes";a:7:{s:4:"http";b:1;s:5:"https";b:1;s:6:"mailto";b:1;s:3:"ftp";b:1;s:4:"nntp";b:1;s:4:"news";b:1;s:3:"tel";b:1;}s:8:"URI.Base";N;s:17:"URI.DefaultScheme";s:4:"http";s:16:"URI.DefinitionID";N;s:17:"URI.DefinitionRev";i:1;s:11:"URI.Disable";b:0;s:19:"URI.DisableExternal";b:0;s:28:"URI.DisableExternalResources";b:0;s:20:"URI.DisableResources";b:0;s:8:"URI.Host";N;s:17:"URI.HostBlacklist";a:0:{}s:16:"URI.MakeAbsolute";b:0;s:9:"URI.Munge";N;s:18:"URI.MungeResources";b:0;s:18:"URI.MungeSecretKey";N;s:26:"URI.OverrideAllowedSchemes";b:1;s:20:"URI.SafeIframeRegexp";N;}s:12:"defaultPlist";O:25:"HTMLPurifier_PropertyList":3:{s:7:"*data";a:128:{s:19:"Attr.AllowedClasses";N;s:24:"Attr.AllowedFrameTargets";a:0:{}s:15:"Attr.AllowedRel";a:0:{}s:15:"Attr.AllowedRev";a:0:{}s:18:"Attr.ClassUseCDATA";N;s:20:"Attr.DefaultImageAlt";N;s:24:"Attr.DefaultInvalidImage";s:0:"";s:27:"Attr.DefaultInvalidImageAlt";s:13:"Invalid image";s:19:"Attr.DefaultTextDir";s:3:"ltr";s:13:"Attr.EnableID";b:0;s:21:"Attr.ForbiddenClasses";a:0:{}s:13:"Attr.ID.HTML5";N;s:16:"Attr.IDBlacklist";a:0:{}s:22:"Attr.IDBlacklistRegexp";N;s:13:"Attr.IDPrefix";s:0:"";s:18:"Attr.IDPrefixLocal";s:0:"";s:24:"AutoFormat.AutoParagraph";b:0;s:17:"AutoFormat.Custom";a:0:{}s:25:"AutoFormat.DisplayLinkURI";b:0;s:18:"AutoFormat.Linkify";b:0;s:33:"AutoFormat.PurifierLinkify.DocURL";s:3:"#%s";s:26:"AutoFormat.PurifierLinkify";b:0;s:32:"AutoFormat.RemoveEmpty.Predicate";a:4:{s:8:"colgroup";a:0:{}s:2:"th";a:0:{}s:2:"td";a:0:{}s:6:"iframe";a:1:{i:0;s:3:"src";}}s:44:"AutoFormat.RemoveEmpty.RemoveNbsp.Exceptions";a:2:{s:2:"td";b:1;s:2:"th";b:1;}s:33:"AutoFormat.RemoveEmpty.RemoveNbsp";b:0;s:22:"AutoFormat.RemoveEmpty";b:0;s:39:"AutoFormat.RemoveSpansWithoutAttributes";b:0;s:19:"CSS.AllowDuplicates";b:0;s:18:"CSS.AllowImportant";b:0;s:15:"CSS.AllowTricky";b:0;s:16:"CSS.AllowedFonts";N;s:21:"CSS.AllowedProperties";N;s:17:"CSS.DefinitionRev";i:1;s:23:"CSS.ForbiddenProperties";a:0:{}s:16:"CSS.MaxImgLength";s:6:"1200px";s:15:"CSS.Proprietary";b:0;s:11:"CSS.Trusted";b:0;s:20:"Cache.DefinitionImpl";s:10:"Serializer";s:20:"Cache.SerializerPath";N;s:27:"Cache.SerializerPermissions";i:493;s:22:"Core.AggressivelyFixLt";b:1;s:29:"Core.AggressivelyRemoveScript";b:1;s:28:"Core.AllowHostnameUnderscore";b:0;s:23:"Core.AllowParseManyTags";b:0;s:18:"Core.CollectErrors";b:0;s:18:"Core.ColorKeywords";a:148:{s:9:"aliceblue";s:7:"#F0F8FF";s:12:"antiquewhite";s:7:"#FAEBD7";s:4:"aqua";s:7:"#00FFFF";s:10:"aquamarine";s:7:"#7FFFD4";s:5:"azure";s:7:"#F0FFFF";s:5:"beige";s:7:"#F5F5DC";s:6:"bisque";s:7:"#FFE4C4";s:5:"black";s:7:"#000000";s:14:"blanchedalmond";s:7:"#FFEBCD";s:4:"blue";s:7:"#0000FF";s:10:"blueviolet";s:7:"#8A2BE2";s:5:"brown";s:7:"#A52A2A";s:9:"burlywood";s:7:"#DEB887";s:9:"cadetblue";s:7:"#5F9EA0";s:10:"chartreuse";s:7:"#7FFF00";s:9:"chocolate";s:7:"#D2691E";s:5:"coral";s:7:"#FF7F50";s:14:"cornflowerblue";s:7:"#6495ED";s:8:"cornsilk";s:7:"#FFF8DC";s:7:"crimson";s:7:"#DC143C";s:4:"cyan";s:7:"#00FFFF";s:8:"darkblue";s:7:"#00008B";s:8:"darkcyan";s:7:"#008B8B";s:13:"darkgoldenrod";s:7:"#B8860B";s:8:"darkgray";s:7:"#A9A9A9";s:8:"darkgrey";s:7:"#A9A9A9";s:9:"darkgreen";s:7:"#006400";s:9:"darkkhaki";s:7:"#BDB76B";s:11:"darkmagenta";s:7:"#8B008B";s:14:"darkolivegreen";s:7:"#556B2F";s:10:"darkorange";s:7:"#FF8C00";s:10:"darkorchid";s:7:"#9932CC";s:7:"darkred";s:7:"#8B0000";s:10:"darksalmon";s:7:"#E9967A";s:12:"darkseagreen";s:7:"#8FBC8F";s:13:"darkslateblue";s:7:"#483D8B";s:13:"darkslategray";s:7:"#2F4F4F";s:13:"darkslategrey";s:7:"#2F4F4F";s:13:"darkturquoise";s:7:"#00CED1";s:10:"darkviolet";s:7:"#9400D3";s:8:"deeppink";s:7:"#FF1493";s:11:"deepskyblue";s:7:"#00BFFF";s:7:"dimgray";s:7:"#696969";s:7:"dimgrey";s:7:"#696969";s:10:"dodgerblue";s:7:"#1E90FF";s:9:"firebrick";s:7:"#B22222";s:11:"floralwhite";s:7:"#FFFAF0";s:11:"forestgreen";s:7:"#228B22";s:7:"fuchsia";s:7:"#FF00FF";s:9:"gainsboro";s:7:"#DCDCDC";s:10:"ghostwhite";s:7:"#F8F8FF";s:4:"gold";s:7:"#FFD700";s:9:"goldenrod";s:7:"#DAA520";s:4:"gray";s:7:"#808080";s:4:"grey";s:7:"#808080";s:5:"green";s:7:"#008000";s:11:"greenyellow";s:7:"#ADFF2F";s:8:"honeydew";s:7:"#F0FFF0";s:7:"hotpink";s:7:"#FF69B4";s:9:"indianred";s:7:"#CD5C5C";s:6:"indigo";s:7:"#4B0082";s:5:"ivory";s:7:"#FFFFF0";s:5:"khaki";s:7:"#F0E68C";s:8:"lavender";s:7:"#E6E6FA";s:13:"lavenderblush";s:7:"#FFF0F5";s:9:"lawngreen";s:7:"#7CFC00";s:12:"lemonchiffon";s:7:"#FFFACD";s:9:"lightblue";s:7:"#ADD8E6";s:10:"lightcoral";s:7:"#F08080";s:9:"lightcyan";s:7:"#E0FFFF";s:20:"lightgoldenrodyellow";s:7:"#FAFAD2";s:9:"lightgray";s:7:"#D3D3D3";s:9:"lightgrey";s:7:"#D3D3D3";s:10:"lightgreen";s:7:"#90EE90";s:9:"lightpink";s:7:"#FFB6C1";s:11:"lightsalmon";s:7:"#FFA07A";s:13:"lightseagreen";s:7:"#20B2AA";s:12:"lightskyblue";s:7:"#87CEFA";s:14:"lightslategray";s:7:"#778899";s:14:"lightslategrey";s:7:"#778899";s:14:"lightsteelblue";s:7:"#B0C4DE";s:11:"lightyellow";s:7:"#FFFFE0";s:4:"lime";s:7:"#00FF00";s:9:"limegreen";s:7:"#32CD32";s:5:"linen";s:7:"#FAF0E6";s:7:"magenta";s:7:"#FF00FF";s:6:"maroon";s:7:"#800000";s:16:"mediumaquamarine";s:7:"#66CDAA";s:10:"mediumblue";s:7:"#0000CD";s:12:"mediumorchid";s:7:"#BA55D3";s:12:"mediumpurple";s:7:"#9370DB";s:14:"mediumseagreen";s:7:"#3CB371";s:15:"mediumslateblue";s:7:"#7B68EE";s:17:"mediumspringgreen";s:7:"#00FA9A";s:15:"mediumturquoise";s:7:"#48D1CC";s:15:"mediumvioletred";s:7:"#C71585";s:12:"midnightblue";s:7:"#191970";s:9:"mintcream";s:7:"#F5FFFA";s:9:"mistyrose";s:7:"#FFE4E1";s:8:"moccasin";s:7:"#FFE4B5";s:11:"navajowhite";s:7:"#FFDEAD";s:4:"navy";s:7:"#000080";s:7:"oldlace";s:7:"#FDF5E6";s:5:"olive";s:7:"#808000";s:9:"olivedrab";s:7:"#6B8E23";s:6:"orange";s:7:"#FFA500";s:9:"orangered";s:7:"#FF4500";s:6:"orchid";s:7:"#DA70D6";s:13:"palegoldenrod";s:7:"#EEE8AA";s:9:"palegreen";s:7:"#98FB98";s:13:"paleturquoise";s:7:"#AFEEEE";s:13:"palevioletred";s:7:"#DB7093";s:10:"papayawhip";s:7:"#FFEFD5";s:9:"peachpuff";s:7:"#FFDAB9";s:4:"peru";s:7:"#CD853F";s:4:"pink";s:7:"#FFC0CB";s:4:"plum";s:7:"#DDA0DD";s:10:"powderblue";s:7:"#B0E0E6";s:6:"purple";s:7:"#800080";s:13:"rebeccapurple";s:7:"#663399";s:3:"red";s:7:"#FF0000";s:9:"rosybrown";s:7:"#BC8F8F";s:9:"royalblue";s:7:"#4169E1";s:11:"saddlebrown";s:7:"#8B4513";s:6:"salmon";s:7:"#FA8072";s:10:"sandybrown";s:7:"#F4A460";s:8:"seagreen";s:7:"#2E8B57";s:8:"seashell";s:7:"#FFF5EE";s:6:"sienna";s:7:"#A0522D";s:6:"silver";s:7:"#C0C0C0";s:7:"skyblue";s:7:"#87CEEB";s:9:"slateblue";s:7:"#6A5ACD";s:9:"slategray";s:7:"#708090";s:9:"slategrey";s:7:"#708090";s:4:"snow";s:7:"#FFFAFA";s:11:"springgreen";s:7:"#00FF7F";s:9:"steelblue";s:7:"#4682B4";s:3:"tan";s:7:"#D2B48C";s:4:"teal";s:7:"#008080";s:7:"thistle";s:7:"#D8BFD8";s:6:"tomato";s:7:"#FF6347";s:9:"turquoise";s:7:"#40E0D0";s:6:"violet";s:7:"#EE82EE";s:5:"wheat";s:7:"#F5DEB3";s:5:"white";s:7:"#FFFFFF";s:10:"whitesmoke";s:7:"#F5F5F5";s:6:"yellow";s:7:"#FFFF00";s:11:"yellowgreen";s:7:"#9ACD32";}s:30:"Core.ConvertDocumentToFragment";b:1;s:36:"Core.DirectLexLineNumberSyncInterval";i:0;s:20:"Core.DisableExcludes";b:0;s:15:"Core.EnableIDNA";b:0;s:13:"Core.Encoding";s:5:"utf-8";s:26:"Core.EscapeInvalidChildren";b:0;s:22:"Core.EscapeInvalidTags";b:0;s:29:"Core.EscapeNonASCIICharacters";b:0;s:19:"Core.HiddenElements";a:2:{s:6:"script";b:1;s:5:"style";b:1;}s:13:"Core.Language";s:2:"en";s:24:"Core.LegacyEntityDecoder";b:0;s:14:"Core.LexerImpl";N;s:24:"Core.MaintainLineNumbers";N;s:22:"Core.NormalizeNewlines";b:1;s:17:"Core.RemoveBlanks";b:0;s:21:"Core.RemoveInvalidImg";b:1;s:33:"Core.RemoveProcessingInstructions";b:0;s:25:"Core.RemoveScriptContents";N;s:13:"Filter.Custom";a:0:{}s:34:"Filter.ExtractStyleBlocks.Escaping";b:1;s:31:"Filter.ExtractStyleBlocks.Scope";N;s:34:"Filter.ExtractStyleBlocks.TidyImpl";N;s:25:"Filter.ExtractStyleBlocks";b:0;s:14:"Filter.YouTube";b:0;s:12:"HTML.Allowed";N;s:22:"HTML.AllowedAttributes";N;s:20:"HTML.AllowedComments";a:0:{}s:26:"HTML.AllowedCommentsRegexp";N;s:20:"HTML.AllowedElements";N;s:19:"HTML.AllowedModules";N;s:23:"HTML.Attr.Name.UseCDATA";b:0;s:17:"HTML.BlockWrapper";s:1:"p";s:16:"HTML.CoreModules";a:7:{s:9:"Structure";b:1;s:4:"Text";b:1;s:9:"Hypertext";b:1;s:4:"List";b:1;s:22:"NonXMLCommonAttributes";b:1;s:19:"XMLCommonAttributes";b:1;s:16:"CommonAttributes";b:1;}s:18:"HTML.CustomDoctype";N;s:17:"HTML.DefinitionID";N;s:18:"HTML.DefinitionRev";i:1;s:12:"HTML.Doctype";N;s:25:"HTML.FlashAllowFullScreen";b:0;s:24:"HTML.ForbiddenAttributes";a:0:{}s:22:"HTML.ForbiddenElements";a:0:{}s:10:"HTML.Forms";b:0;s:17:"HTML.MaxImgLength";i:1200;s:13:"HTML.Nofollow";b:0;s:11:"HTML.Parent";s:3:"div";s:16:"HTML.Proprietary";b:0;s:14:"HTML.SafeEmbed";b:0;s:15:"HTML.SafeIframe";b:0;s:15:"HTML.SafeObject";b:0;s:18:"HTML.SafeScripting";a:0:{}s:11:"HTML.Strict";b:0;s:16:"HTML.TargetBlank";b:0;s:19:"HTML.TargetNoopener";b:1;s:21:"HTML.TargetNoreferrer";b:1;s:12:"HTML.TidyAdd";a:0:{}s:14:"HTML.TidyLevel";s:6:"medium";s:15:"HTML.TidyRemove";a:0:{}s:12:"HTML.Trusted";b:0;s:10:"HTML.XHTML";b:1;s:28:"Output.CommentScriptContents";b:1;s:19:"Output.FixInnerHTML";b:1;s:18:"Output.FlashCompat";b:0;s:14:"Output.Newline";N;s:15:"Output.SortAttr";b:0;s:17:"Output.TidyFormat";b:0;s:17:"Test.ForceNoIconv";b:0;s:18:"URI.AllowedSchemes";a:7:{s:4:"http";b:1;s:5:"https";b:1;s:6:"mailto";b:1;s:3:"ftp";b:1;s:4:"nntp";b:1;s:4:"news";b:1;s:3:"tel";b:1;}s:8:"URI.Base";N;s:17:"URI.DefaultScheme";s:4:"http";s:16:"URI.DefinitionID";N;s:17:"URI.DefinitionRev";i:1;s:11:"URI.Disable";b:0;s:19:"URI.DisableExternal";b:0;s:28:"URI.DisableExternalResources";b:0;s:20:"URI.DisableResources";b:0;s:8:"URI.Host";N;s:17:"URI.HostBlacklist";a:0:{}s:16:"URI.MakeAbsolute";b:0;s:9:"URI.Munge";N;s:18:"URI.MungeResources";b:0;s:18:"URI.MungeSecretKey";N;s:26:"URI.OverrideAllowedSchemes";b:1;s:20:"URI.SafeIframeRegexp";N;}s:9:"*parent";N;s:8:"*cache";N;}s:4:"info";a:141:{s:19:"Attr.AllowedClasses";i:-8;s:24:"Attr.AllowedFrameTargets";i:8;s:15:"Attr.AllowedRel";i:8;s:15:"Attr.AllowedRev";i:8;s:18:"Attr.ClassUseCDATA";i:-7;s:20:"Attr.DefaultImageAlt";i:-1;s:24:"Attr.DefaultInvalidImage";i:1;s:27:"Attr.DefaultInvalidImageAlt";i:1;s:19:"Attr.DefaultTextDir";O:8:"stdClass":2:{s:4:"type";i:1;s:7:"allowed";a:2:{s:3:"ltr";b:1;s:3:"rtl";b:1;}}s:13:"Attr.EnableID";i:7;s:17:"HTML.EnableAttrID";O:8:"stdClass":2:{s:3:"key";s:13:"Attr.EnableID";s:7:"isAlias";b:1;}s:21:"Attr.ForbiddenClasses";i:8;s:13:"Attr.ID.HTML5";i:-7;s:16:"Attr.IDBlacklist";i:9;s:22:"Attr.IDBlacklistRegexp";i:-1;s:13:"Attr.IDPrefix";i:1;s:18:"Attr.IDPrefixLocal";i:1;s:24:"AutoFormat.AutoParagraph";i:7;s:17:"AutoFormat.Custom";i:9;s:25:"AutoFormat.DisplayLinkURI";i:7;s:18:"AutoFormat.Linkify";i:7;s:33:"AutoFormat.PurifierLinkify.DocURL";i:1;s:37:"AutoFormatParam.PurifierLinkifyDocURL";O:8:"stdClass":2:{s:3:"key";s:33:"AutoFormat.PurifierLinkify.DocURL";s:7:"isAlias";b:1;}s:26:"AutoFormat.PurifierLinkify";i:7;s:32:"AutoFormat.RemoveEmpty.Predicate";i:10;s:44:"AutoFormat.RemoveEmpty.RemoveNbsp.Exceptions";i:8;s:33:"AutoFormat.RemoveEmpty.RemoveNbsp";i:7;s:22:"AutoFormat.RemoveEmpty";i:7;s:39:"AutoFormat.RemoveSpansWithoutAttributes";i:7;s:19:"CSS.AllowDuplicates";i:7;s:18:"CSS.AllowImportant";i:7;s:15:"CSS.AllowTricky";i:7;s:16:"CSS.AllowedFonts";i:-8;s:21:"CSS.AllowedProperties";i:-8;s:17:"CSS.DefinitionRev";i:5;s:23:"CSS.ForbiddenProperties";i:8;s:16:"CSS.MaxImgLength";i:-1;s:15:"CSS.Proprietary";i:7;s:11:"CSS.Trusted";i:7;s:20:"Cache.DefinitionImpl";i:-1;s:20:"Core.DefinitionCache";O:8:"stdClass":2:{s:3:"key";s:20:"Cache.DefinitionImpl";s:7:"isAlias";b:1;}s:20:"Cache.SerializerPath";i:-1;s:27:"Cache.SerializerPermissions";i:-5;s:22:"Core.AggressivelyFixLt";i:7;s:29:"Core.AggressivelyRemoveScript";i:7;s:28:"Core.AllowHostnameUnderscore";i:7;s:23:"Core.AllowParseManyTags";i:7;s:18:"Core.CollectErrors";i:7;s:18:"Core.ColorKeywords";i:10;s:30:"Core.ConvertDocumentToFragment";i:7;s:24:"Core.AcceptFullDocuments";O:8:"stdClass":2:{s:3:"key";s:30:"Core.ConvertDocumentToFragment";s:7:"isAlias";b:1;}s:36:"Core.DirectLexLineNumberSyncInterval";i:5;s:20:"Core.DisableExcludes";i:7;s:15:"Core.EnableIDNA";i:7;s:13:"Core.Encoding";i:2;s:26:"Core.EscapeInvalidChildren";i:7;s:22:"Core.EscapeInvalidTags";i:7;s:29:"Core.EscapeNonASCIICharacters";i:7;s:19:"Core.HiddenElements";i:8;s:13:"Core.Language";i:1;s:24:"Core.LegacyEntityDecoder";i:7;s:14:"Core.LexerImpl";i:-11;s:24:"Core.MaintainLineNumbers";i:-7;s:22:"Core.NormalizeNewlines";i:7;s:17:"Core.RemoveBlanks";i:7;s:21:"Core.RemoveInvalidImg";i:7;s:33:"Core.RemoveProcessingInstructions";i:7;s:25:"Core.RemoveScriptContents";i:-7;s:13:"Filter.Custom";i:9;s:34:"Filter.ExtractStyleBlocks.Escaping";i:7;s:33:"Filter.ExtractStyleBlocksEscaping";O:8:"stdClass":2:{s:3:"key";s:34:"Filter.ExtractStyleBlocks.Escaping";s:7:"isAlias";b:1;}s:38:"FilterParam.ExtractStyleBlocksEscaping";O:8:"stdClass":2:{s:3:"key";s:34:"Filter.ExtractStyleBlocks.Escaping";s:7:"isAlias";b:1;}s:31:"Filter.ExtractStyleBlocks.Scope";i:-1;s:30:"Filter.ExtractStyleBlocksScope";O:8:"stdClass":2:{s:3:"key";s:31:"Filter.ExtractStyleBlocks.Scope";s:7:"isAlias";b:1;}s:35:"FilterParam.ExtractStyleBlocksScope";O:8:"stdClass":2:{s:3:"key";s:31:"Filter.ExtractStyleBlocks.Scope";s:7:"isAlias";b:1;}s:34:"Filter.ExtractStyleBlocks.TidyImpl";i:-11;s:38:"FilterParam.ExtractStyleBlocksTidyImpl";O:8:"stdClass":2:{s:3:"key";s:34:"Filter.ExtractStyleBlocks.TidyImpl";s:7:"isAlias";b:1;}s:25:"Filter.ExtractStyleBlocks";i:7;s:14:"Filter.YouTube";i:7;s:12:"HTML.Allowed";i:-4;s:22:"HTML.AllowedAttributes";i:-8;s:20:"HTML.AllowedComments";i:8;s:26:"HTML.AllowedCommentsRegexp";i:-1;s:20:"HTML.AllowedElements";i:-8;s:19:"HTML.AllowedModules";i:-8;s:23:"HTML.Attr.Name.UseCDATA";i:7;s:17:"HTML.BlockWrapper";i:1;s:16:"HTML.CoreModules";i:8;s:18:"HTML.CustomDoctype";i:-1;s:17:"HTML.DefinitionID";i:-1;s:18:"HTML.DefinitionRev";i:5;s:12:"HTML.Doctype";O:8:"stdClass":3:{s:4:"type";i:1;s:10:"allow_null";b:1;s:7:"allowed";a:5:{s:22:"HTML 4.01 Transitional";b:1;s:16:"HTML 4.01 Strict";b:1;s:22:"XHTML 1.0 Transitional";b:1;s:16:"XHTML 1.0 Strict";b:1;s:9:"XHTML 1.1";b:1;}}s:25:"HTML.FlashAllowFullScreen";i:7;s:24:"HTML.ForbiddenAttributes";i:8;s:22:"HTML.ForbiddenElements";i:8;s:10:"HTML.Forms";i:7;s:17:"HTML.MaxImgLength";i:-5;s:13:"HTML.Nofollow";i:7;s:11:"HTML.Parent";i:1;s:16:"HTML.Proprietary";i:7;s:14:"HTML.SafeEmbed";i:7;s:15:"HTML.SafeIframe";i:7;s:15:"HTML.SafeObject";i:7;s:18:"HTML.SafeScripting";i:8;s:11:"HTML.Strict";i:7;s:16:"HTML.TargetBlank";i:7;s:19:"HTML.TargetNoopener";i:7;s:21:"HTML.TargetNoreferrer";i:7;s:12:"HTML.TidyAdd";i:8;s:14:"HTML.TidyLevel";O:8:"stdClass":2:{s:4:"type";i:1;s:7:"allowed";a:4:{s:4:"none";b:1;s:5:"light";b:1;s:6:"medium";b:1;s:5:"heavy";b:1;}}s:15:"HTML.TidyRemove";i:8;s:12:"HTML.Trusted";i:7;s:10:"HTML.XHTML";i:7;s:10:"Core.XHTML";O:8:"stdClass":2:{s:3:"key";s:10:"HTML.XHTML";s:7:"isAlias";b:1;}s:28:"Output.CommentScriptContents";i:7;s:26:"Core.CommentScriptContents";O:8:"stdClass":2:{s:3:"key";s:28:"Output.CommentScriptContents";s:7:"isAlias";b:1;}s:19:"Output.FixInnerHTML";i:7;s:18:"Output.FlashCompat";i:7;s:14:"Output.Newline";i:-1;s:15:"Output.SortAttr";i:7;s:17:"Output.TidyFormat";i:7;s:15:"Core.TidyFormat";O:8:"stdClass":2:{s:3:"key";s:17:"Output.TidyFormat";s:7:"isAlias";b:1;}s:17:"Test.ForceNoIconv";i:7;s:18:"URI.AllowedSchemes";i:8;s:8:"URI.Base";i:-1;s:17:"URI.DefaultScheme";i:-1;s:16:"URI.DefinitionID";i:-1;s:17:"URI.DefinitionRev";i:5;s:11:"URI.Disable";i:7;s:15:"Attr.DisableURI";O:8:"stdClass":2:{s:3:"key";s:11:"URI.Disable";s:7:"isAlias";b:1;}s:19:"URI.DisableExternal";i:7;s:28:"URI.DisableExternalResources";i:7;s:20:"URI.DisableResources";i:7;s:8:"URI.Host";i:-1;s:17:"URI.HostBlacklist";i:9;s:16:"URI.MakeAbsolute";i:7;s:9:"URI.Munge";i:-1;s:18:"URI.MungeResources";i:7;s:18:"URI.MungeSecretKey";i:-1;s:26:"URI.OverrideAllowedSchemes";i:7;s:20:"URI.SafeIframeRegexp";i:-1;}} \ No newline at end of file diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.AllowedClasses.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.AllowedClasses.txt new file mode 100644 index 0000000..0517fed --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.AllowedClasses.txt @@ -0,0 +1,8 @@ +Attr.AllowedClasses +TYPE: lookup/null +VERSION: 4.0.0 +DEFAULT: null +--DESCRIPTION-- +List of allowed class values in the class attribute. By default, this is null, +which means all classes are allowed. +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.AllowedFrameTargets.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.AllowedFrameTargets.txt new file mode 100644 index 0000000..249edd6 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.AllowedFrameTargets.txt @@ -0,0 +1,12 @@ +Attr.AllowedFrameTargets +TYPE: lookup +DEFAULT: array() +--DESCRIPTION-- +Lookup table of all allowed link frame targets. Some commonly used link +targets include _blank, _self, _parent and _top. Values should be +lowercase, as validation will be done in a case-sensitive manner despite +W3C's recommendation. XHTML 1.0 Strict does not permit the target attribute +so this directive will have no effect in that doctype. XHTML 1.1 does not +enable the Target module by default, you will have to manually enable it +(see the module documentation for more details.) +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.AllowedRel.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.AllowedRel.txt new file mode 100644 index 0000000..9a8fa6a --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.AllowedRel.txt @@ -0,0 +1,9 @@ +Attr.AllowedRel +TYPE: lookup +VERSION: 1.6.0 +DEFAULT: array() +--DESCRIPTION-- +List of allowed forward document relationships in the rel attribute. Common +values may be nofollow or print. By default, this is empty, meaning that no +document relationships are allowed. +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.AllowedRev.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.AllowedRev.txt new file mode 100644 index 0000000..b017883 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.AllowedRev.txt @@ -0,0 +1,9 @@ +Attr.AllowedRev +TYPE: lookup +VERSION: 1.6.0 +DEFAULT: array() +--DESCRIPTION-- +List of allowed reverse document relationships in the rev attribute. This +attribute is a bit of an edge-case; if you don't know what it is for, stay +away. +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.ClassUseCDATA.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.ClassUseCDATA.txt new file mode 100644 index 0000000..e774b82 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.ClassUseCDATA.txt @@ -0,0 +1,19 @@ +Attr.ClassUseCDATA +TYPE: bool/null +DEFAULT: null +VERSION: 4.0.0 +--DESCRIPTION-- +If null, class will auto-detect the doctype and, if matching XHTML 1.1 or +XHTML 2.0, will use the restrictive NMTOKENS specification of class. Otherwise, +it will use a relaxed CDATA definition. If true, the relaxed CDATA definition +is forced; if false, the NMTOKENS definition is forced. To get behavior +of HTML Purifier prior to 4.0.0, set this directive to false. + +Some rational behind the auto-detection: +in previous versions of HTML Purifier, it was assumed that the form of +class was NMTOKENS, as specified by the XHTML Modularization (representing +XHTML 1.1 and XHTML 2.0). The DTDs for HTML 4.01 and XHTML 1.0, however +specify class as CDATA. HTML 5 effectively defines it as CDATA, but +with the additional constraint that each name should be unique (this is not +explicitly outlined in previous specifications). +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.DefaultImageAlt.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.DefaultImageAlt.txt new file mode 100644 index 0000000..533165e --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.DefaultImageAlt.txt @@ -0,0 +1,11 @@ +Attr.DefaultImageAlt +TYPE: string/null +DEFAULT: null +VERSION: 3.2.0 +--DESCRIPTION-- +This is the content of the alt tag of an image if the user had not +previously specified an alt attribute. This applies to all images without +a valid alt attribute, as opposed to %Attr.DefaultInvalidImageAlt, which +only applies to invalid images, and overrides in the case of an invalid image. +Default behavior with null is to use the basename of the src tag for the alt. +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.DefaultInvalidImage.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.DefaultInvalidImage.txt new file mode 100644 index 0000000..9eb7e38 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.DefaultInvalidImage.txt @@ -0,0 +1,9 @@ +Attr.DefaultInvalidImage +TYPE: string +DEFAULT: '' +--DESCRIPTION-- +This is the default image an img tag will be pointed to if it does not have +a valid src attribute. In future versions, we may allow the image tag to +be removed completely, but due to design issues, this is not possible right +now. +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.DefaultInvalidImageAlt.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.DefaultInvalidImageAlt.txt new file mode 100644 index 0000000..2f17bf4 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.DefaultInvalidImageAlt.txt @@ -0,0 +1,8 @@ +Attr.DefaultInvalidImageAlt +TYPE: string +DEFAULT: 'Invalid image' +--DESCRIPTION-- +This is the content of the alt tag of an invalid image if the user had not +previously specified an alt attribute. It has no effect when the image is +valid but there was no alt attribute present. +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.DefaultTextDir.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.DefaultTextDir.txt new file mode 100644 index 0000000..52654b5 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.DefaultTextDir.txt @@ -0,0 +1,10 @@ +Attr.DefaultTextDir +TYPE: string +DEFAULT: 'ltr' +--DESCRIPTION-- +Defines the default text direction (ltr or rtl) of the document being +parsed. This generally is the same as the value of the dir attribute in +HTML, or ltr if that is not specified. +--ALLOWED-- +'ltr', 'rtl' +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.EnableID.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.EnableID.txt new file mode 100644 index 0000000..6440d21 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.EnableID.txt @@ -0,0 +1,16 @@ +Attr.EnableID +TYPE: bool +DEFAULT: false +VERSION: 1.2.0 +--DESCRIPTION-- +Allows the ID attribute in HTML. This is disabled by default due to the +fact that without proper configuration user input can easily break the +validation of a webpage by specifying an ID that is already on the +surrounding HTML. If you don't mind throwing caution to the wind, enable +this directive, but I strongly recommend you also consider blacklisting IDs +you use (%Attr.IDBlacklist) or prefixing all user supplied IDs +(%Attr.IDPrefix). When set to true HTML Purifier reverts to the behavior of +pre-1.2.0 versions. +--ALIASES-- +HTML.EnableAttrID +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.ForbiddenClasses.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.ForbiddenClasses.txt new file mode 100644 index 0000000..f31d226 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.ForbiddenClasses.txt @@ -0,0 +1,8 @@ +Attr.ForbiddenClasses +TYPE: lookup +VERSION: 4.0.0 +DEFAULT: array() +--DESCRIPTION-- +List of forbidden class values in the class attribute. By default, this is +empty, which means that no classes are forbidden. See also %Attr.AllowedClasses. +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.ID.HTML5.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.ID.HTML5.txt new file mode 100644 index 0000000..735d4b7 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.ID.HTML5.txt @@ -0,0 +1,10 @@ +Attr.ID.HTML5 +TYPE: bool/null +DEFAULT: null +VERSION: 4.8.0 +--DESCRIPTION-- +In HTML5, restrictions on the format of the id attribute have been significantly +relaxed, such that any string is valid so long as it contains no spaces and +is at least one character. In lieu of a general HTML5 compatibility flag, +set this configuration directive to true to use the relaxed rules. +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.IDBlacklist.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.IDBlacklist.txt new file mode 100644 index 0000000..5f2b5e3 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.IDBlacklist.txt @@ -0,0 +1,5 @@ +Attr.IDBlacklist +TYPE: list +DEFAULT: array() +DESCRIPTION: Array of IDs not allowed in the document. +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.IDBlacklistRegexp.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.IDBlacklistRegexp.txt new file mode 100644 index 0000000..6f58245 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.IDBlacklistRegexp.txt @@ -0,0 +1,9 @@ +Attr.IDBlacklistRegexp +TYPE: string/null +VERSION: 1.6.0 +DEFAULT: NULL +--DESCRIPTION-- +PCRE regular expression to be matched against all IDs. If the expression is +matches, the ID is rejected. Use this with care: may cause significant +degradation. ID matching is done after all other validation. +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.IDPrefix.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.IDPrefix.txt new file mode 100644 index 0000000..cc49d43 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.IDPrefix.txt @@ -0,0 +1,12 @@ +Attr.IDPrefix +TYPE: string +VERSION: 1.2.0 +DEFAULT: '' +--DESCRIPTION-- +String to prefix to IDs. If you have no idea what IDs your pages may use, +you may opt to simply add a prefix to all user-submitted ID attributes so +that they are still usable, but will not conflict with core page IDs. +Example: setting the directive to 'user_' will result in a user submitted +'foo' to become 'user_foo' Be sure to set %HTML.EnableAttrID to true +before using this. +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.IDPrefixLocal.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.IDPrefixLocal.txt new file mode 100644 index 0000000..2c5924a --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.IDPrefixLocal.txt @@ -0,0 +1,14 @@ +Attr.IDPrefixLocal +TYPE: string +VERSION: 1.2.0 +DEFAULT: '' +--DESCRIPTION-- +Temporary prefix for IDs used in conjunction with %Attr.IDPrefix. If you +need to allow multiple sets of user content on web page, you may need to +have a seperate prefix that changes with each iteration. This way, +seperately submitted user content displayed on the same page doesn't +clobber each other. Ideal values are unique identifiers for the content it +represents (i.e. the id of the row in the database). Be sure to add a +seperator (like an underscore) at the end. Warning: this directive will +not work unless %Attr.IDPrefix is set to a non-empty value! +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.AutoParagraph.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.AutoParagraph.txt new file mode 100644 index 0000000..d5caa1b --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.AutoParagraph.txt @@ -0,0 +1,31 @@ +AutoFormat.AutoParagraph +TYPE: bool +VERSION: 2.0.1 +DEFAULT: false +--DESCRIPTION-- + +

    + This directive turns on auto-paragraphing, where double newlines are + converted in to paragraphs whenever possible. Auto-paragraphing: +

    +
      +
    • Always applies to inline elements or text in the root node,
    • +
    • Applies to inline elements or text with double newlines in nodes + that allow paragraph tags,
    • +
    • Applies to double newlines in paragraph tags
    • +
    +

    + p tags must be allowed for this directive to take effect. + We do not use br tags for paragraphing, as that is + semantically incorrect. +

    +

    + To prevent auto-paragraphing as a content-producer, refrain from using + double-newlines except to specify a new paragraph or in contexts where + it has special meaning (whitespace usually has no meaning except in + tags like pre, so this should not be difficult.) To prevent + the paragraphing of inline text adjacent to block elements, wrap them + in div tags (the behavior is slightly different outside of + the root node.) +

    +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.Custom.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.Custom.txt new file mode 100644 index 0000000..2a47648 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.Custom.txt @@ -0,0 +1,12 @@ +AutoFormat.Custom +TYPE: list +VERSION: 2.0.1 +DEFAULT: array() +--DESCRIPTION-- + +

    + This directive can be used to add custom auto-format injectors. + Specify an array of injector names (class name minus the prefix) + or concrete implementations. Injector class must exist. +

    +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.DisplayLinkURI.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.DisplayLinkURI.txt new file mode 100644 index 0000000..663064a --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.DisplayLinkURI.txt @@ -0,0 +1,11 @@ +AutoFormat.DisplayLinkURI +TYPE: bool +VERSION: 3.2.0 +DEFAULT: false +--DESCRIPTION-- +

    + This directive turns on the in-text display of URIs in <a> tags, and disables + those links. For example, example becomes + example (http://example.com). +

    +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.Linkify.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.Linkify.txt new file mode 100644 index 0000000..3a48ba9 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.Linkify.txt @@ -0,0 +1,12 @@ +AutoFormat.Linkify +TYPE: bool +VERSION: 2.0.1 +DEFAULT: false +--DESCRIPTION-- + +

    + This directive turns on linkification, auto-linking http, ftp and + https URLs. a tags with the href attribute + must be allowed. +

    +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.PurifierLinkify.DocURL.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.PurifierLinkify.DocURL.txt new file mode 100644 index 0000000..db58b13 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.PurifierLinkify.DocURL.txt @@ -0,0 +1,12 @@ +AutoFormat.PurifierLinkify.DocURL +TYPE: string +VERSION: 2.0.1 +DEFAULT: '#%s' +ALIASES: AutoFormatParam.PurifierLinkifyDocURL +--DESCRIPTION-- +

    + Location of configuration documentation to link to, let %s substitute + into the configuration's namespace and directive names sans the percent + sign. +

    +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.PurifierLinkify.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.PurifierLinkify.txt new file mode 100644 index 0000000..7996488 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.PurifierLinkify.txt @@ -0,0 +1,12 @@ +AutoFormat.PurifierLinkify +TYPE: bool +VERSION: 2.0.1 +DEFAULT: false +--DESCRIPTION-- + +

    + Internal auto-formatter that converts configuration directives in + syntax %Namespace.Directive to links. a tags + with the href attribute must be allowed. +

    +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.RemoveEmpty.Predicate.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.RemoveEmpty.Predicate.txt new file mode 100644 index 0000000..6367fe2 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.RemoveEmpty.Predicate.txt @@ -0,0 +1,14 @@ +AutoFormat.RemoveEmpty.Predicate +TYPE: hash +VERSION: 4.7.0 +DEFAULT: array('colgroup' => array(), 'th' => array(), 'td' => array(), 'iframe' => array('src')) +--DESCRIPTION-- +

    + Given that an element has no contents, it will be removed by default, unless + this predicate dictates otherwise. The predicate can either be an associative + map from tag name to list of attributes that must be present for the element + to be considered preserved: thus, the default always preserves colgroup, + th and td, and also iframe if it + has a src. +

    +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.RemoveEmpty.RemoveNbsp.Exceptions.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.RemoveEmpty.RemoveNbsp.Exceptions.txt new file mode 100644 index 0000000..35c393b --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.RemoveEmpty.RemoveNbsp.Exceptions.txt @@ -0,0 +1,11 @@ +AutoFormat.RemoveEmpty.RemoveNbsp.Exceptions +TYPE: lookup +VERSION: 4.0.0 +DEFAULT: array('td' => true, 'th' => true) +--DESCRIPTION-- +

    + When %AutoFormat.RemoveEmpty and %AutoFormat.RemoveEmpty.RemoveNbsp + are enabled, this directive defines what HTML elements should not be + removede if they have only a non-breaking space in them. +

    +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.RemoveEmpty.RemoveNbsp.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.RemoveEmpty.RemoveNbsp.txt new file mode 100644 index 0000000..9228dee --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.RemoveEmpty.RemoveNbsp.txt @@ -0,0 +1,15 @@ +AutoFormat.RemoveEmpty.RemoveNbsp +TYPE: bool +VERSION: 4.0.0 +DEFAULT: false +--DESCRIPTION-- +

    + When enabled, HTML Purifier will treat any elements that contain only + non-breaking spaces as well as regular whitespace as empty, and remove + them when %AutoFormat.RemoveEmpty is enabled. +

    +

    + See %AutoFormat.RemoveEmpty.RemoveNbsp.Exceptions for a list of elements + that don't have this behavior applied to them. +

    +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.RemoveEmpty.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.RemoveEmpty.txt new file mode 100644 index 0000000..34657ba --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.RemoveEmpty.txt @@ -0,0 +1,46 @@ +AutoFormat.RemoveEmpty +TYPE: bool +VERSION: 3.2.0 +DEFAULT: false +--DESCRIPTION-- +

    + When enabled, HTML Purifier will attempt to remove empty elements that + contribute no semantic information to the document. The following types + of nodes will be removed: +

    +
    • + Tags with no attributes and no content, and that are not empty + elements (remove <a></a> but not + <br />), and +
    • +
    • + Tags with no content, except for:
        +
      • The colgroup element, or
      • +
      • + Elements with the id or name attribute, + when those attributes are permitted on those elements. +
      • +
    • +
    +

    + Please be very careful when using this functionality; while it may not + seem that empty elements contain useful information, they can alter the + layout of a document given appropriate styling. This directive is most + useful when you are processing machine-generated HTML, please avoid using + it on regular user HTML. +

    +

    + Elements that contain only whitespace will be treated as empty. Non-breaking + spaces, however, do not count as whitespace. See + %AutoFormat.RemoveEmpty.RemoveNbsp for alternate behavior. +

    +

    + This algorithm is not perfect; you may still notice some empty tags, + particularly if a node had elements, but those elements were later removed + because they were not permitted in that context, or tags that, after + being auto-closed by another tag, where empty. This is for safety reasons + to prevent clever code from breaking validation. The general rule of thumb: + if a tag looked empty on the way in, it will get removed; if HTML Purifier + made it empty, it will stay. +

    +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.RemoveSpansWithoutAttributes.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.RemoveSpansWithoutAttributes.txt new file mode 100644 index 0000000..dde990a --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.RemoveSpansWithoutAttributes.txt @@ -0,0 +1,11 @@ +AutoFormat.RemoveSpansWithoutAttributes +TYPE: bool +VERSION: 4.0.1 +DEFAULT: false +--DESCRIPTION-- +

    + This directive causes span tags without any attributes + to be removed. It will also remove spans that had all attributes + removed during processing. +

    +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/CSS.AllowDuplicates.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/CSS.AllowDuplicates.txt new file mode 100644 index 0000000..4d054b1 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/CSS.AllowDuplicates.txt @@ -0,0 +1,11 @@ +CSS.AllowDuplicates +TYPE: bool +DEFAULT: false +VERSION: 4.8.0 +--DESCRIPTION-- +

    + By default, HTML Purifier removes duplicate CSS properties, + like color:red; color:blue. If this is set to + true, duplicate properties are allowed. +

    +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/CSS.AllowImportant.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/CSS.AllowImportant.txt new file mode 100644 index 0000000..b324608 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/CSS.AllowImportant.txt @@ -0,0 +1,8 @@ +CSS.AllowImportant +TYPE: bool +DEFAULT: false +VERSION: 3.1.0 +--DESCRIPTION-- +This parameter determines whether or not !important cascade modifiers should +be allowed in user CSS. If false, !important will stripped. +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/CSS.AllowTricky.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/CSS.AllowTricky.txt new file mode 100644 index 0000000..748be0e --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/CSS.AllowTricky.txt @@ -0,0 +1,11 @@ +CSS.AllowTricky +TYPE: bool +DEFAULT: false +VERSION: 3.1.0 +--DESCRIPTION-- +This parameter determines whether or not to allow "tricky" CSS properties and +values. Tricky CSS properties/values can drastically modify page layout or +be used for deceptive practices but do not directly constitute a security risk. +For example, display:none; is considered a tricky property that +will only be allowed if this directive is set to true. +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/CSS.AllowedFonts.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/CSS.AllowedFonts.txt new file mode 100644 index 0000000..3fd4654 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/CSS.AllowedFonts.txt @@ -0,0 +1,12 @@ +CSS.AllowedFonts +TYPE: lookup/null +VERSION: 4.3.0 +DEFAULT: NULL +--DESCRIPTION-- +

    + Allows you to manually specify a set of allowed fonts. If + NULL, all fonts are allowed. This directive + affects generic names (serif, sans-serif, monospace, cursive, + fantasy) as well as specific font families. +

    +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/CSS.AllowedProperties.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/CSS.AllowedProperties.txt new file mode 100644 index 0000000..460112e --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/CSS.AllowedProperties.txt @@ -0,0 +1,18 @@ +CSS.AllowedProperties +TYPE: lookup/null +VERSION: 3.1.0 +DEFAULT: NULL +--DESCRIPTION-- + +

    + If HTML Purifier's style attributes set is unsatisfactory for your needs, + you can overload it with your own list of tags to allow. Note that this + method is subtractive: it does its job by taking away from HTML Purifier + usual feature set, so you cannot add an attribute that HTML Purifier never + supported in the first place. +

    +

    + Warning: If another directive conflicts with the + elements here, that directive will win and override. +

    +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/CSS.DefinitionRev.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/CSS.DefinitionRev.txt new file mode 100644 index 0000000..5cb7dda --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/CSS.DefinitionRev.txt @@ -0,0 +1,11 @@ +CSS.DefinitionRev +TYPE: int +VERSION: 2.0.0 +DEFAULT: 1 +--DESCRIPTION-- + +

    + Revision identifier for your custom definition. See + %HTML.DefinitionRev for details. +

    +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/CSS.ForbiddenProperties.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/CSS.ForbiddenProperties.txt new file mode 100644 index 0000000..f1f5c5f --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/CSS.ForbiddenProperties.txt @@ -0,0 +1,13 @@ +CSS.ForbiddenProperties +TYPE: lookup +VERSION: 4.2.0 +DEFAULT: array() +--DESCRIPTION-- +

    + This is the logical inverse of %CSS.AllowedProperties, and it will + override that directive or any other directive. If possible, + %CSS.AllowedProperties is recommended over this directive, + because it can sometimes be difficult to tell whether or not you've + forbidden all of the CSS properties you truly would like to disallow. +

    +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/CSS.MaxImgLength.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/CSS.MaxImgLength.txt new file mode 100644 index 0000000..7a32914 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/CSS.MaxImgLength.txt @@ -0,0 +1,16 @@ +CSS.MaxImgLength +TYPE: string/null +DEFAULT: '1200px' +VERSION: 3.1.1 +--DESCRIPTION-- +

    + This parameter sets the maximum allowed length on img tags, + effectively the width and height properties. + Only absolute units of measurement (in, pt, pc, mm, cm) and pixels (px) are allowed. This is + in place to prevent imagecrash attacks, disable with null at your own risk. + This directive is similar to %HTML.MaxImgLength, and both should be + concurrently edited, although there are + subtle differences in the input format (the CSS max is a number with + a unit). +

    +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/CSS.Proprietary.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/CSS.Proprietary.txt new file mode 100644 index 0000000..148eedb --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/CSS.Proprietary.txt @@ -0,0 +1,10 @@ +CSS.Proprietary +TYPE: bool +VERSION: 3.0.0 +DEFAULT: false +--DESCRIPTION-- + +

    + Whether or not to allow safe, proprietary CSS values. +

    +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/CSS.Trusted.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/CSS.Trusted.txt new file mode 100644 index 0000000..e733a61 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/CSS.Trusted.txt @@ -0,0 +1,9 @@ +CSS.Trusted +TYPE: bool +VERSION: 4.2.1 +DEFAULT: false +--DESCRIPTION-- +Indicates whether or not the user's CSS input is trusted or not. If the +input is trusted, a more expansive set of allowed properties. See +also %HTML.Trusted. +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Cache.DefinitionImpl.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Cache.DefinitionImpl.txt new file mode 100644 index 0000000..c486724 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Cache.DefinitionImpl.txt @@ -0,0 +1,14 @@ +Cache.DefinitionImpl +TYPE: string/null +VERSION: 2.0.0 +DEFAULT: 'Serializer' +--DESCRIPTION-- + +This directive defines which method to use when caching definitions, +the complex data-type that makes HTML Purifier tick. Set to null +to disable caching (not recommended, as you will see a definite +performance degradation). + +--ALIASES-- +Core.DefinitionCache +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Cache.SerializerPath.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Cache.SerializerPath.txt new file mode 100644 index 0000000..5403650 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Cache.SerializerPath.txt @@ -0,0 +1,13 @@ +Cache.SerializerPath +TYPE: string/null +VERSION: 2.0.0 +DEFAULT: NULL +--DESCRIPTION-- + +

    + Absolute path with no trailing slash to store serialized definitions in. + Default is within the + HTML Purifier library inside DefinitionCache/Serializer. This + path must be writable by the webserver. +

    +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Cache.SerializerPermissions.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Cache.SerializerPermissions.txt new file mode 100644 index 0000000..2e0cc81 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Cache.SerializerPermissions.txt @@ -0,0 +1,16 @@ +Cache.SerializerPermissions +TYPE: int/null +VERSION: 4.3.0 +DEFAULT: 0755 +--DESCRIPTION-- + +

    + Directory permissions of the files and directories created inside + the DefinitionCache/Serializer or other custom serializer path. +

    +

    + In HTML Purifier 4.8.0, this also supports NULL, + which means that no chmod'ing or directory creation shall + occur. +

    +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.AggressivelyFixLt.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.AggressivelyFixLt.txt new file mode 100644 index 0000000..568cbf3 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.AggressivelyFixLt.txt @@ -0,0 +1,18 @@ +Core.AggressivelyFixLt +TYPE: bool +VERSION: 2.1.0 +DEFAULT: true +--DESCRIPTION-- +

    + This directive enables aggressive pre-filter fixes HTML Purifier can + perform in order to ensure that open angled-brackets do not get killed + during parsing stage. Enabling this will result in two preg_replace_callback + calls and at least two preg_replace calls for every HTML document parsed; + if your users make very well-formed HTML, you can set this directive false. + This has no effect when DirectLex is used. +

    +

    + Notice: This directive's default turned from false to true + in HTML Purifier 3.2.0. +

    +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.AggressivelyRemoveScript.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.AggressivelyRemoveScript.txt new file mode 100644 index 0000000..b2b6ab1 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.AggressivelyRemoveScript.txt @@ -0,0 +1,16 @@ +Core.AggressivelyRemoveScript +TYPE: bool +VERSION: 4.9.0 +DEFAULT: true +--DESCRIPTION-- +

    + This directive enables aggressive pre-filter removal of + script tags. This is not necessary for security, + but it can help work around a bug in libxml where embedded + HTML elements inside script sections cause the parser to + choke. To revert to pre-4.9.0 behavior, set this to false. + This directive has no effect if %Core.Trusted is true, + %Core.RemoveScriptContents is false, or %Core.HiddenElements + does not contain script. +

    +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.AllowHostnameUnderscore.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.AllowHostnameUnderscore.txt new file mode 100644 index 0000000..2c910cc --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.AllowHostnameUnderscore.txt @@ -0,0 +1,16 @@ +Core.AllowHostnameUnderscore +TYPE: bool +VERSION: 4.6.0 +DEFAULT: false +--DESCRIPTION-- +

    + By RFC 1123, underscores are not permitted in host names. + (This is in contrast to the specification for DNS, RFC + 2181, which allows underscores.) + However, most browsers do the right thing when faced with + an underscore in the host name, and so some poorly written + websites are written with the expectation this should work. + Setting this parameter to true relaxes our allowed character + check so that underscores are permitted. +

    +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.AllowParseManyTags.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.AllowParseManyTags.txt new file mode 100644 index 0000000..06278f8 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.AllowParseManyTags.txt @@ -0,0 +1,12 @@ +Core.AllowParseManyTags +TYPE: bool +DEFAULT: false +VERSION: 4.10.1 +--DESCRIPTION-- +

    + This directive allows parsing of many nested tags. + If you set true, relaxes any hardcoded limit from the parser. + However, in that case it may cause a Dos attack. + Be careful when enabling it. +

    +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.CollectErrors.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.CollectErrors.txt new file mode 100644 index 0000000..d731791 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.CollectErrors.txt @@ -0,0 +1,12 @@ +Core.CollectErrors +TYPE: bool +VERSION: 2.0.0 +DEFAULT: false +--DESCRIPTION-- + +Whether or not to collect errors found while filtering the document. This +is a useful way to give feedback to your users. Warning: +Currently this feature is very patchy and experimental, with lots of +possible error messages not yet implemented. It will not cause any +problems, but it may not help your users either. +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.ColorKeywords.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.ColorKeywords.txt new file mode 100644 index 0000000..a75844c --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.ColorKeywords.txt @@ -0,0 +1,160 @@ +Core.ColorKeywords +TYPE: hash +VERSION: 2.0.0 +--DEFAULT-- +array ( + 'aliceblue' => '#F0F8FF', + 'antiquewhite' => '#FAEBD7', + 'aqua' => '#00FFFF', + 'aquamarine' => '#7FFFD4', + 'azure' => '#F0FFFF', + 'beige' => '#F5F5DC', + 'bisque' => '#FFE4C4', + 'black' => '#000000', + 'blanchedalmond' => '#FFEBCD', + 'blue' => '#0000FF', + 'blueviolet' => '#8A2BE2', + 'brown' => '#A52A2A', + 'burlywood' => '#DEB887', + 'cadetblue' => '#5F9EA0', + 'chartreuse' => '#7FFF00', + 'chocolate' => '#D2691E', + 'coral' => '#FF7F50', + 'cornflowerblue' => '#6495ED', + 'cornsilk' => '#FFF8DC', + 'crimson' => '#DC143C', + 'cyan' => '#00FFFF', + 'darkblue' => '#00008B', + 'darkcyan' => '#008B8B', + 'darkgoldenrod' => '#B8860B', + 'darkgray' => '#A9A9A9', + 'darkgrey' => '#A9A9A9', + 'darkgreen' => '#006400', + 'darkkhaki' => '#BDB76B', + 'darkmagenta' => '#8B008B', + 'darkolivegreen' => '#556B2F', + 'darkorange' => '#FF8C00', + 'darkorchid' => '#9932CC', + 'darkred' => '#8B0000', + 'darksalmon' => '#E9967A', + 'darkseagreen' => '#8FBC8F', + 'darkslateblue' => '#483D8B', + 'darkslategray' => '#2F4F4F', + 'darkslategrey' => '#2F4F4F', + 'darkturquoise' => '#00CED1', + 'darkviolet' => '#9400D3', + 'deeppink' => '#FF1493', + 'deepskyblue' => '#00BFFF', + 'dimgray' => '#696969', + 'dimgrey' => '#696969', + 'dodgerblue' => '#1E90FF', + 'firebrick' => '#B22222', + 'floralwhite' => '#FFFAF0', + 'forestgreen' => '#228B22', + 'fuchsia' => '#FF00FF', + 'gainsboro' => '#DCDCDC', + 'ghostwhite' => '#F8F8FF', + 'gold' => '#FFD700', + 'goldenrod' => '#DAA520', + 'gray' => '#808080', + 'grey' => '#808080', + 'green' => '#008000', + 'greenyellow' => '#ADFF2F', + 'honeydew' => '#F0FFF0', + 'hotpink' => '#FF69B4', + 'indianred' => '#CD5C5C', + 'indigo' => '#4B0082', + 'ivory' => '#FFFFF0', + 'khaki' => '#F0E68C', + 'lavender' => '#E6E6FA', + 'lavenderblush' => '#FFF0F5', + 'lawngreen' => '#7CFC00', + 'lemonchiffon' => '#FFFACD', + 'lightblue' => '#ADD8E6', + 'lightcoral' => '#F08080', + 'lightcyan' => '#E0FFFF', + 'lightgoldenrodyellow' => '#FAFAD2', + 'lightgray' => '#D3D3D3', + 'lightgrey' => '#D3D3D3', + 'lightgreen' => '#90EE90', + 'lightpink' => '#FFB6C1', + 'lightsalmon' => '#FFA07A', + 'lightseagreen' => '#20B2AA', + 'lightskyblue' => '#87CEFA', + 'lightslategray' => '#778899', + 'lightslategrey' => '#778899', + 'lightsteelblue' => '#B0C4DE', + 'lightyellow' => '#FFFFE0', + 'lime' => '#00FF00', + 'limegreen' => '#32CD32', + 'linen' => '#FAF0E6', + 'magenta' => '#FF00FF', + 'maroon' => '#800000', + 'mediumaquamarine' => '#66CDAA', + 'mediumblue' => '#0000CD', + 'mediumorchid' => '#BA55D3', + 'mediumpurple' => '#9370DB', + 'mediumseagreen' => '#3CB371', + 'mediumslateblue' => '#7B68EE', + 'mediumspringgreen' => '#00FA9A', + 'mediumturquoise' => '#48D1CC', + 'mediumvioletred' => '#C71585', + 'midnightblue' => '#191970', + 'mintcream' => '#F5FFFA', + 'mistyrose' => '#FFE4E1', + 'moccasin' => '#FFE4B5', + 'navajowhite' => '#FFDEAD', + 'navy' => '#000080', + 'oldlace' => '#FDF5E6', + 'olive' => '#808000', + 'olivedrab' => '#6B8E23', + 'orange' => '#FFA500', + 'orangered' => '#FF4500', + 'orchid' => '#DA70D6', + 'palegoldenrod' => '#EEE8AA', + 'palegreen' => '#98FB98', + 'paleturquoise' => '#AFEEEE', + 'palevioletred' => '#DB7093', + 'papayawhip' => '#FFEFD5', + 'peachpuff' => '#FFDAB9', + 'peru' => '#CD853F', + 'pink' => '#FFC0CB', + 'plum' => '#DDA0DD', + 'powderblue' => '#B0E0E6', + 'purple' => '#800080', + 'rebeccapurple' => '#663399', + 'red' => '#FF0000', + 'rosybrown' => '#BC8F8F', + 'royalblue' => '#4169E1', + 'saddlebrown' => '#8B4513', + 'salmon' => '#FA8072', + 'sandybrown' => '#F4A460', + 'seagreen' => '#2E8B57', + 'seashell' => '#FFF5EE', + 'sienna' => '#A0522D', + 'silver' => '#C0C0C0', + 'skyblue' => '#87CEEB', + 'slateblue' => '#6A5ACD', + 'slategray' => '#708090', + 'slategrey' => '#708090', + 'snow' => '#FFFAFA', + 'springgreen' => '#00FF7F', + 'steelblue' => '#4682B4', + 'tan' => '#D2B48C', + 'teal' => '#008080', + 'thistle' => '#D8BFD8', + 'tomato' => '#FF6347', + 'turquoise' => '#40E0D0', + 'violet' => '#EE82EE', + 'wheat' => '#F5DEB3', + 'white' => '#FFFFFF', + 'whitesmoke' => '#F5F5F5', + 'yellow' => '#FFFF00', + 'yellowgreen' => '#9ACD32' +) +--DESCRIPTION-- + +Lookup array of color names to six digit hexadecimal number corresponding +to color, with preceding hash mark. Used when parsing colors. The lookup +is done in a case-insensitive manner. +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.ConvertDocumentToFragment.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.ConvertDocumentToFragment.txt new file mode 100644 index 0000000..64b114f --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.ConvertDocumentToFragment.txt @@ -0,0 +1,14 @@ +Core.ConvertDocumentToFragment +TYPE: bool +DEFAULT: true +--DESCRIPTION-- + +This parameter determines whether or not the filter should convert +input that is a full document with html and body tags to a fragment +of just the contents of a body tag. This parameter is simply something +HTML Purifier can do during an edge-case: for most inputs, this +processing is not necessary. + +--ALIASES-- +Core.AcceptFullDocuments +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.DirectLexLineNumberSyncInterval.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.DirectLexLineNumberSyncInterval.txt new file mode 100644 index 0000000..36f16e0 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.DirectLexLineNumberSyncInterval.txt @@ -0,0 +1,17 @@ +Core.DirectLexLineNumberSyncInterval +TYPE: int +VERSION: 2.0.0 +DEFAULT: 0 +--DESCRIPTION-- + +

    + Specifies the number of tokens the DirectLex line number tracking + implementations should process before attempting to resyncronize the + current line count by manually counting all previous new-lines. When + at 0, this functionality is disabled. Lower values will decrease + performance, and this is only strictly necessary if the counting + algorithm is buggy (in which case you should report it as a bug). + This has no effect when %Core.MaintainLineNumbers is disabled or DirectLex is + not being used. +

    +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.DisableExcludes.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.DisableExcludes.txt new file mode 100644 index 0000000..1cd4c2c --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.DisableExcludes.txt @@ -0,0 +1,14 @@ +Core.DisableExcludes +TYPE: bool +DEFAULT: false +VERSION: 4.5.0 +--DESCRIPTION-- +

    + This directive disables SGML-style exclusions, e.g. the exclusion of + <object> in any descendant of a + <pre> tag. Disabling excludes will allow some + invalid documents to pass through HTML Purifier, but HTML Purifier + will also be less likely to accidentally remove large documents during + processing. +

    +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.EnableIDNA.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.EnableIDNA.txt new file mode 100644 index 0000000..ce243c3 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.EnableIDNA.txt @@ -0,0 +1,9 @@ +Core.EnableIDNA +TYPE: bool +DEFAULT: false +VERSION: 4.4.0 +--DESCRIPTION-- +Allows international domain names in URLs. This configuration option +requires the PEAR Net_IDNA2 module to be installed. It operates by +punycoding any internationalized host names for maximum portability. +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.Encoding.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.Encoding.txt new file mode 100644 index 0000000..8bfb47c --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.Encoding.txt @@ -0,0 +1,15 @@ +Core.Encoding +TYPE: istring +DEFAULT: 'utf-8' +--DESCRIPTION-- +If for some reason you are unable to convert all webpages to UTF-8, you can +use this directive as a stop-gap compatibility change to let HTML Purifier +deal with non UTF-8 input. This technique has notable deficiencies: +absolutely no characters outside of the selected character encoding will be +preserved, not even the ones that have been ampersand escaped (this is due +to a UTF-8 specific feature that automatically resolves all +entities), making it pretty useless for anything except the most I18N-blind +applications, although %Core.EscapeNonASCIICharacters offers fixes this +trouble with another tradeoff. This directive only accepts ISO-8859-1 if +iconv is not enabled. +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.EscapeInvalidChildren.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.EscapeInvalidChildren.txt new file mode 100644 index 0000000..a3881be --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.EscapeInvalidChildren.txt @@ -0,0 +1,12 @@ +Core.EscapeInvalidChildren +TYPE: bool +DEFAULT: false +--DESCRIPTION-- +

    Warning: this configuration option is no longer does anything as of 4.6.0.

    + +

    When true, a child is found that is not allowed in the context of the +parent element will be transformed into text as if it were ASCII. When +false, that element and all internal tags will be dropped, though text will +be preserved. There is no option for dropping the element but preserving +child nodes.

    +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.EscapeInvalidTags.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.EscapeInvalidTags.txt new file mode 100644 index 0000000..a7a5b24 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.EscapeInvalidTags.txt @@ -0,0 +1,7 @@ +Core.EscapeInvalidTags +TYPE: bool +DEFAULT: false +--DESCRIPTION-- +When true, invalid tags will be written back to the document as plain text. +Otherwise, they are silently dropped. +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.EscapeNonASCIICharacters.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.EscapeNonASCIICharacters.txt new file mode 100644 index 0000000..abb4999 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.EscapeNonASCIICharacters.txt @@ -0,0 +1,13 @@ +Core.EscapeNonASCIICharacters +TYPE: bool +VERSION: 1.4.0 +DEFAULT: false +--DESCRIPTION-- +This directive overcomes a deficiency in %Core.Encoding by blindly +converting all non-ASCII characters into decimal numeric entities before +converting it to its native encoding. This means that even characters that +can be expressed in the non-UTF-8 encoding will be entity-ized, which can +be a real downer for encodings like Big5. It also assumes that the ASCII +repetoire is available, although this is the case for almost all encodings. +Anyway, use UTF-8! +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.HiddenElements.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.HiddenElements.txt new file mode 100644 index 0000000..915391e --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.HiddenElements.txt @@ -0,0 +1,19 @@ +Core.HiddenElements +TYPE: lookup +--DEFAULT-- +array ( + 'script' => true, + 'style' => true, +) +--DESCRIPTION-- + +

    + This directive is a lookup array of elements which should have their + contents removed when they are not allowed by the HTML definition. + For example, the contents of a script tag are not + normally shown in a document, so if script tags are to be removed, + their contents should be removed to. This is opposed to a b + tag, which defines some presentational changes but does not hide its + contents. +

    +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.Language.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.Language.txt new file mode 100644 index 0000000..233fca1 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.Language.txt @@ -0,0 +1,10 @@ +Core.Language +TYPE: string +VERSION: 2.0.0 +DEFAULT: 'en' +--DESCRIPTION-- + +ISO 639 language code for localizable things in HTML Purifier to use, +which is mainly error reporting. There is currently only an English (en) +translation, so this directive is currently useless. +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.LegacyEntityDecoder.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.LegacyEntityDecoder.txt new file mode 100644 index 0000000..392b436 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.LegacyEntityDecoder.txt @@ -0,0 +1,36 @@ +Core.LegacyEntityDecoder +TYPE: bool +VERSION: 4.9.0 +DEFAULT: false +--DESCRIPTION-- +

    + Prior to HTML Purifier 4.9.0, entities were decoded by performing + a global search replace for all entities whose decoded versions + did not have special meanings under HTML, and replaced them with + their decoded versions. We would match all entities, even if they did + not have a trailing semicolon, but only if there weren't any trailing + alphanumeric characters. +

    + + + + + + +
    OriginalTextAttribute
    &yen;¥¥
    &yen¥¥
    &yena&yena&yena
    &yen=¥=¥=
    +

    + In HTML Purifier 4.9.0, we changed the behavior of entity parsing + to match entities that had missing trailing semicolons in less + cases, to more closely match HTML5 parsing behavior: +

    + + + + + + +
    OriginalTextAttribute
    &yen;¥¥
    &yen¥¥
    &yena¥a&yena
    &yen=¥=&yen=
    +

    + This flag reverts back to pre-HTML Purifier 4.9.0 behavior. +

    +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.LexerImpl.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.LexerImpl.txt new file mode 100644 index 0000000..8983e2c --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.LexerImpl.txt @@ -0,0 +1,34 @@ +Core.LexerImpl +TYPE: mixed/null +VERSION: 2.0.0 +DEFAULT: NULL +--DESCRIPTION-- + +

    + This parameter determines what lexer implementation can be used. The + valid values are: +

    +
    +
    null
    +
    + Recommended, the lexer implementation will be auto-detected based on + your PHP-version and configuration. +
    +
    string lexer identifier
    +
    + This is a slim way of manually overridding the implementation. + Currently recognized values are: DOMLex (the default PHP5 +implementation) + and DirectLex (the default PHP4 implementation). Only use this if + you know what you are doing: usually, the auto-detection will + manage things for cases you aren't even aware of. +
    +
    object lexer instance
    +
    + Super-advanced: you can specify your own, custom, implementation that + implements the interface defined by HTMLPurifier_Lexer. + I may remove this option simply because I don't expect anyone + to use it. +
    +
    +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.MaintainLineNumbers.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.MaintainLineNumbers.txt new file mode 100644 index 0000000..eb841a7 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.MaintainLineNumbers.txt @@ -0,0 +1,16 @@ +Core.MaintainLineNumbers +TYPE: bool/null +VERSION: 2.0.0 +DEFAULT: NULL +--DESCRIPTION-- + +

    + If true, HTML Purifier will add line number information to all tokens. + This is useful when error reporting is turned on, but can result in + significant performance degradation and should not be used when + unnecessary. This directive must be used with the DirectLex lexer, + as the DOMLex lexer does not (yet) support this functionality. + If the value is null, an appropriate value will be selected based + on other configuration. +

    +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.NormalizeNewlines.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.NormalizeNewlines.txt new file mode 100644 index 0000000..d77f536 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.NormalizeNewlines.txt @@ -0,0 +1,11 @@ +Core.NormalizeNewlines +TYPE: bool +VERSION: 4.2.0 +DEFAULT: true +--DESCRIPTION-- +

    + Whether or not to normalize newlines to the operating + system default. When false, HTML Purifier + will attempt to preserve mixed newline files. +

    +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.RemoveBlanks.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.RemoveBlanks.txt new file mode 100644 index 0000000..95e5285 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.RemoveBlanks.txt @@ -0,0 +1,10 @@ +Core.RemoveBlanks +TYPE: bool +DEFAULT: false +VERSION: 4.18 +--DESCRIPTION-- +

    + If set to true, blank nodes will be removed. This can be useful for maintaining + backwards compatibility when upgrading from previous versions of PHP. +

    +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.RemoveInvalidImg.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.RemoveInvalidImg.txt new file mode 100644 index 0000000..4070c2a --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.RemoveInvalidImg.txt @@ -0,0 +1,12 @@ +Core.RemoveInvalidImg +TYPE: bool +DEFAULT: true +VERSION: 1.3.0 +--DESCRIPTION-- + +

    + This directive enables pre-emptive URI checking in img + tags, as the attribute validation strategy is not authorized to + remove elements from the document. Revert to pre-1.3.0 behavior by setting to false. +

    +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.RemoveProcessingInstructions.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.RemoveProcessingInstructions.txt new file mode 100644 index 0000000..3397d9f --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.RemoveProcessingInstructions.txt @@ -0,0 +1,11 @@ +Core.RemoveProcessingInstructions +TYPE: bool +VERSION: 4.2.0 +DEFAULT: false +--DESCRIPTION-- +Instead of escaping processing instructions in the form <? ... +?>, remove it out-right. This may be useful if the HTML +you are validating contains XML processing instruction gunk, however, +it can also be user-unfriendly for people attempting to post PHP +snippets. +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.RemoveScriptContents.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.RemoveScriptContents.txt new file mode 100644 index 0000000..a4cd966 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.RemoveScriptContents.txt @@ -0,0 +1,12 @@ +Core.RemoveScriptContents +TYPE: bool/null +DEFAULT: NULL +VERSION: 2.0.0 +DEPRECATED-VERSION: 2.1.0 +DEPRECATED-USE: Core.HiddenElements +--DESCRIPTION-- +

    + This directive enables HTML Purifier to remove not only script tags + but all of their contents. +

    +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Filter.Custom.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Filter.Custom.txt new file mode 100644 index 0000000..3db50ef --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Filter.Custom.txt @@ -0,0 +1,11 @@ +Filter.Custom +TYPE: list +VERSION: 3.1.0 +DEFAULT: array() +--DESCRIPTION-- +

    + This directive can be used to add custom filters; it is nearly the + equivalent of the now deprecated HTMLPurifier->addFilter() + method. Specify an array of concrete implementations. +

    +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Filter.ExtractStyleBlocks.Escaping.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Filter.ExtractStyleBlocks.Escaping.txt new file mode 100644 index 0000000..16829bc --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Filter.ExtractStyleBlocks.Escaping.txt @@ -0,0 +1,14 @@ +Filter.ExtractStyleBlocks.Escaping +TYPE: bool +VERSION: 3.0.0 +DEFAULT: true +ALIASES: Filter.ExtractStyleBlocksEscaping, FilterParam.ExtractStyleBlocksEscaping +--DESCRIPTION-- + +

    + Whether or not to escape the dangerous characters <, > and & + as \3C, \3E and \26, respectively. This is can be safely set to false + if the contents of StyleBlocks will be placed in an external stylesheet, + where there is no risk of it being interpreted as HTML. +

    +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Filter.ExtractStyleBlocks.Scope.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Filter.ExtractStyleBlocks.Scope.txt new file mode 100644 index 0000000..7f95f54 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Filter.ExtractStyleBlocks.Scope.txt @@ -0,0 +1,29 @@ +Filter.ExtractStyleBlocks.Scope +TYPE: string/null +VERSION: 3.0.0 +DEFAULT: NULL +ALIASES: Filter.ExtractStyleBlocksScope, FilterParam.ExtractStyleBlocksScope +--DESCRIPTION-- + +

    + If you would like users to be able to define external stylesheets, but + only allow them to specify CSS declarations for a specific node and + prevent them from fiddling with other elements, use this directive. + It accepts any valid CSS selector, and will prepend this to any + CSS declaration extracted from the document. For example, if this + directive is set to #user-content and a user uses the + selector a:hover, the final selector will be + #user-content a:hover. +

    +

    + The comma shorthand may be used; consider the above example, with + #user-content, #user-content2, the final selector will + be #user-content a:hover, #user-content2 a:hover. +

    +

    + Warning: It is possible for users to bypass this measure + using a naughty + selector. This is a bug in CSS Tidy 1.3, not HTML + Purifier, and I am working to get it fixed. Until then, HTML Purifier + performs a basic check to prevent this. +

    +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Filter.ExtractStyleBlocks.TidyImpl.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Filter.ExtractStyleBlocks.TidyImpl.txt new file mode 100644 index 0000000..6c231b2 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Filter.ExtractStyleBlocks.TidyImpl.txt @@ -0,0 +1,16 @@ +Filter.ExtractStyleBlocks.TidyImpl +TYPE: mixed/null +VERSION: 3.1.0 +DEFAULT: NULL +ALIASES: FilterParam.ExtractStyleBlocksTidyImpl +--DESCRIPTION-- +

    + If left NULL, HTML Purifier will attempt to instantiate a csstidy + class to use for internal cleaning. This will usually be good enough. +

    +

    + However, for trusted user input, you can set this to false to + disable cleaning. In addition, you can supply your own concrete implementation + of Tidy's interface to use, although I don't know why you'd want to do that. +

    +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Filter.ExtractStyleBlocks.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Filter.ExtractStyleBlocks.txt new file mode 100644 index 0000000..078d087 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Filter.ExtractStyleBlocks.txt @@ -0,0 +1,74 @@ +Filter.ExtractStyleBlocks +TYPE: bool +VERSION: 3.1.0 +DEFAULT: false +EXTERNAL: CSSTidy +--DESCRIPTION-- +

    + This directive turns on the style block extraction filter, which removes + style blocks from input HTML, cleans them up with CSSTidy, + and places them in the StyleBlocks context variable, for further + use by you, usually to be placed in an external stylesheet, or a + style block in the head of your document. +

    +

    + Sample usage: +

    +
    ';
    +?>
    +
    +
    +
    +  Filter.ExtractStyleBlocks
    +body {color:#F00;} Some text';
    +
    +    $config = HTMLPurifier_Config::createDefault();
    +    $config->set('Filter', 'ExtractStyleBlocks', true);
    +    $purifier = new HTMLPurifier($config);
    +
    +    $html = $purifier->purify($dirty);
    +
    +    // This implementation writes the stylesheets to the styles/ directory.
    +    // You can also echo the styles inside the document, but it's a bit
    +    // more difficult to make sure they get interpreted properly by
    +    // browsers; try the usual CSS armoring techniques.
    +    $styles = $purifier->context->get('StyleBlocks');
    +    $dir = 'styles/';
    +    if (!is_dir($dir)) mkdir($dir);
    +    $hash = sha1($_GET['html']);
    +    foreach ($styles as $i => $style) {
    +        file_put_contents($name = $dir . $hash . "_$i");
    +        echo '';
    +    }
    +?>
    +
    +
    +  
    + +
    + + +]]>
    +

    + Warning: It is possible for a user to mount an + imagecrash attack using this CSS. Counter-measures are difficult; + it is not simply enough to limit the range of CSS lengths (using + relative lengths with many nesting levels allows for large values + to be attained without actually specifying them in the stylesheet), + and the flexible nature of selectors makes it difficult to selectively + disable lengths on image tags (HTML Purifier, however, does disable + CSS width and height in inline styling). There are probably two effective + counter measures: an explicit width and height set to auto in all + images in your document (unlikely) or the disabling of width and + height (somewhat reasonable). Whether or not these measures should be + used is left to the reader. +

    +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Filter.YouTube.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Filter.YouTube.txt new file mode 100644 index 0000000..321eaa2 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Filter.YouTube.txt @@ -0,0 +1,16 @@ +Filter.YouTube +TYPE: bool +VERSION: 3.1.0 +DEFAULT: false +--DESCRIPTION-- +

    + Warning: Deprecated in favor of %HTML.SafeObject and + %Output.FlashCompat (turn both on to allow YouTube videos and other + Flash content). +

    +

    + This directive enables YouTube video embedding in HTML Purifier. Check + this document + on embedding videos for more information on what this filter does. +

    +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.Allowed.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.Allowed.txt new file mode 100644 index 0000000..0b2c106 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.Allowed.txt @@ -0,0 +1,25 @@ +HTML.Allowed +TYPE: itext/null +VERSION: 2.0.0 +DEFAULT: NULL +--DESCRIPTION-- + +

    + This is a preferred convenience directive that combines + %HTML.AllowedElements and %HTML.AllowedAttributes. + Specify elements and attributes that are allowed using: + element1[attr1|attr2],element2.... For example, + if you would like to only allow paragraphs and links, specify + a[href],p. You can specify attributes that apply + to all elements using an asterisk, e.g. *[lang]. + You can also use newlines instead of commas to separate elements. +

    +

    + Warning: + All of the constraints on the component directives are still enforced. + The syntax is a subset of TinyMCE's valid_elements + whitelist: directly copy-pasting it here will probably result in + broken whitelists. If %HTML.AllowedElements or %HTML.AllowedAttributes + are set, this directive has no effect. +

    +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.AllowedAttributes.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.AllowedAttributes.txt new file mode 100644 index 0000000..fcf093f --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.AllowedAttributes.txt @@ -0,0 +1,19 @@ +HTML.AllowedAttributes +TYPE: lookup/null +VERSION: 1.3.0 +DEFAULT: NULL +--DESCRIPTION-- + +

    + If HTML Purifier's attribute set is unsatisfactory, overload it! + The syntax is "tag.attr" or "*.attr" for the global attributes + (style, id, class, dir, lang, xml:lang). +

    +

    + Warning: If another directive conflicts with the + elements here, that directive will win and override. For + example, %HTML.EnableAttrID will take precedence over *.id in this + directive. You must set that directive to true before you can use + IDs at all. +

    +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.AllowedComments.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.AllowedComments.txt new file mode 100644 index 0000000..140e214 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.AllowedComments.txt @@ -0,0 +1,10 @@ +HTML.AllowedComments +TYPE: lookup +VERSION: 4.4.0 +DEFAULT: array() +--DESCRIPTION-- +A whitelist which indicates what explicit comment bodies should be +allowed, modulo leading and trailing whitespace. See also %HTML.AllowedCommentsRegexp +(these directives are union'ed together, so a comment is considered +valid if any directive deems it valid.) +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.AllowedCommentsRegexp.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.AllowedCommentsRegexp.txt new file mode 100644 index 0000000..f22e977 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.AllowedCommentsRegexp.txt @@ -0,0 +1,15 @@ +HTML.AllowedCommentsRegexp +TYPE: string/null +VERSION: 4.4.0 +DEFAULT: NULL +--DESCRIPTION-- +A regexp, which if it matches the body of a comment, indicates that +it should be allowed. Trailing and leading spaces are removed prior +to running this regular expression. +Warning: Make sure you specify +correct anchor metacharacters ^regex$, otherwise you may accept +comments that you did not mean to! In particular, the regex /foo|bar/ +is probably not sufficiently strict, since it also allows foobar. +See also %HTML.AllowedComments (these directives are union'ed together, +so a comment is considered valid if any directive deems it valid.) +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.AllowedElements.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.AllowedElements.txt new file mode 100644 index 0000000..1d3fa79 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.AllowedElements.txt @@ -0,0 +1,23 @@ +HTML.AllowedElements +TYPE: lookup/null +VERSION: 1.3.0 +DEFAULT: NULL +--DESCRIPTION-- +

    + If HTML Purifier's tag set is unsatisfactory for your needs, you can + overload it with your own list of tags to allow. If you change + this, you probably also want to change %HTML.AllowedAttributes; see + also %HTML.Allowed which lets you set allowed elements and + attributes at the same time. +

    +

    + If you attempt to allow an element that HTML Purifier does not know + about, HTML Purifier will raise an error. You will need to manually + tell HTML Purifier about this element by using the + advanced customization features. +

    +

    + Warning: If another directive conflicts with the + elements here, that directive will win and override. +

    +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.AllowedModules.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.AllowedModules.txt new file mode 100644 index 0000000..5a59a55 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.AllowedModules.txt @@ -0,0 +1,20 @@ +HTML.AllowedModules +TYPE: lookup/null +VERSION: 2.0.0 +DEFAULT: NULL +--DESCRIPTION-- + +

    + A doctype comes with a set of usual modules to use. Without having + to mucking about with the doctypes, you can quickly activate or + disable these modules by specifying which modules you wish to allow + with this directive. This is most useful for unit testing specific + modules, although end users may find it useful for their own ends. +

    +

    + If you specify a module that does not exist, the manager will silently + fail to use it, so be careful! User-defined modules are not affected + by this directive. Modules defined in %HTML.CoreModules are not + affected by this directive. +

    +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.Attr.Name.UseCDATA.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.Attr.Name.UseCDATA.txt new file mode 100644 index 0000000..151fb7b --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.Attr.Name.UseCDATA.txt @@ -0,0 +1,11 @@ +HTML.Attr.Name.UseCDATA +TYPE: bool +DEFAULT: false +VERSION: 4.0.0 +--DESCRIPTION-- +The W3C specification DTD defines the name attribute to be CDATA, not ID, due +to limitations of DTD. In certain documents, this relaxed behavior is desired, +whether it is to specify duplicate names, or to specify names that would be +illegal IDs (for example, names that begin with a digit.) Set this configuration +directive to true to use the relaxed parsing rules. +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.BlockWrapper.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.BlockWrapper.txt new file mode 100644 index 0000000..45ae469 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.BlockWrapper.txt @@ -0,0 +1,18 @@ +HTML.BlockWrapper +TYPE: string +VERSION: 1.3.0 +DEFAULT: 'p' +--DESCRIPTION-- + +

    + String name of element to wrap inline elements that are inside a block + context. This only occurs in the children of blockquote in strict mode. +

    +

    + Example: by default value, + <blockquote>Foo</blockquote> would become + <blockquote><p>Foo</p></blockquote>. + The <p> tags can be replaced with whatever you desire, + as long as it is a block level element. +

    +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.CoreModules.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.CoreModules.txt new file mode 100644 index 0000000..5246188 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.CoreModules.txt @@ -0,0 +1,23 @@ +HTML.CoreModules +TYPE: lookup +VERSION: 2.0.0 +--DEFAULT-- +array ( + 'Structure' => true, + 'Text' => true, + 'Hypertext' => true, + 'List' => true, + 'NonXMLCommonAttributes' => true, + 'XMLCommonAttributes' => true, + 'CommonAttributes' => true, +) +--DESCRIPTION-- + +

    + Certain modularized doctypes (XHTML, namely), have certain modules + that must be included for the doctype to be an conforming document + type: put those modules here. By default, XHTML's core modules + are used. You can set this to a blank array to disable core module + protection, but this is not recommended. +

    +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.CustomDoctype.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.CustomDoctype.txt new file mode 100644 index 0000000..6ed70b5 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.CustomDoctype.txt @@ -0,0 +1,9 @@ +HTML.CustomDoctype +TYPE: string/null +VERSION: 2.0.1 +DEFAULT: NULL +--DESCRIPTION-- + +A custom doctype for power-users who defined their own document +type. This directive only applies when %HTML.Doctype is blank. +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.DefinitionID.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.DefinitionID.txt new file mode 100644 index 0000000..103db75 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.DefinitionID.txt @@ -0,0 +1,33 @@ +HTML.DefinitionID +TYPE: string/null +DEFAULT: NULL +VERSION: 2.0.0 +--DESCRIPTION-- + +

    + Unique identifier for a custom-built HTML definition. If you edit + the raw version of the HTMLDefinition, introducing changes that the + configuration object does not reflect, you must specify this variable. + If you change your custom edits, you should change this directive, or + clear your cache. Example: +

    +
    +$config = HTMLPurifier_Config::createDefault();
    +$config->set('HTML', 'DefinitionID', '1');
    +$def = $config->getHTMLDefinition();
    +$def->addAttribute('a', 'tabindex', 'Number');
    +
    +

    + In the above example, the configuration is still at the defaults, but + using the advanced API, an extra attribute has been added. The + configuration object normally has no way of knowing that this change + has taken place, so it needs an extra directive: %HTML.DefinitionID. + If someone else attempts to use the default configuration, these two + pieces of code will not clobber each other in the cache, since one has + an extra directive attached to it. +

    +

    + You must specify a value to this directive to use the + advanced API features. +

    +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.DefinitionRev.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.DefinitionRev.txt new file mode 100644 index 0000000..229ae02 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.DefinitionRev.txt @@ -0,0 +1,16 @@ +HTML.DefinitionRev +TYPE: int +VERSION: 2.0.0 +DEFAULT: 1 +--DESCRIPTION-- + +

    + Revision identifier for your custom definition specified in + %HTML.DefinitionID. This serves the same purpose: uniquely identifying + your custom definition, but this one does so in a chronological + context: revision 3 is more up-to-date then revision 2. Thus, when + this gets incremented, the cache handling is smart enough to clean + up any older revisions of your definition as well as flush the + cache. +

    +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.Doctype.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.Doctype.txt new file mode 100644 index 0000000..9dab497 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.Doctype.txt @@ -0,0 +1,11 @@ +HTML.Doctype +TYPE: string/null +DEFAULT: NULL +--DESCRIPTION-- +Doctype to use during filtering. Technically speaking this is not actually +a doctype (as it does not identify a corresponding DTD), but we are using +this name for sake of simplicity. When non-blank, this will override any +older directives like %HTML.XHTML or %HTML.Strict. +--ALLOWED-- +'HTML 4.01 Transitional', 'HTML 4.01 Strict', 'XHTML 1.0 Transitional', 'XHTML 1.0 Strict', 'XHTML 1.1' +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.FlashAllowFullScreen.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.FlashAllowFullScreen.txt new file mode 100644 index 0000000..7878dc0 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.FlashAllowFullScreen.txt @@ -0,0 +1,11 @@ +HTML.FlashAllowFullScreen +TYPE: bool +VERSION: 4.2.0 +DEFAULT: false +--DESCRIPTION-- +

    + Whether or not to permit embedded Flash content from + %HTML.SafeObject to expand to the full screen. Corresponds to + the allowFullScreen parameter. +

    +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.ForbiddenAttributes.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.ForbiddenAttributes.txt new file mode 100644 index 0000000..57358f9 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.ForbiddenAttributes.txt @@ -0,0 +1,21 @@ +HTML.ForbiddenAttributes +TYPE: lookup +VERSION: 3.1.0 +DEFAULT: array() +--DESCRIPTION-- +

    + While this directive is similar to %HTML.AllowedAttributes, for + forwards-compatibility with XML, this attribute has a different syntax. Instead of + tag.attr, use tag@attr. To disallow href + attributes in a tags, set this directive to + a@href. You can also disallow an attribute globally with + attr or *@attr (either syntax is fine; the latter + is provided for consistency with %HTML.AllowedAttributes). +

    +

    + Warning: This directive complements %HTML.ForbiddenElements, + accordingly, check + out that directive for a discussion of why you + should think twice before using this directive. +

    +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.ForbiddenElements.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.ForbiddenElements.txt new file mode 100644 index 0000000..93a53e1 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.ForbiddenElements.txt @@ -0,0 +1,20 @@ +HTML.ForbiddenElements +TYPE: lookup +VERSION: 3.1.0 +DEFAULT: array() +--DESCRIPTION-- +

    + This was, perhaps, the most requested feature ever in HTML + Purifier. Please don't abuse it! This is the logical inverse of + %HTML.AllowedElements, and it will override that directive, or any + other directive. +

    +

    + If possible, %HTML.Allowed is recommended over this directive, because it + can sometimes be difficult to tell whether or not you've forbidden all of + the behavior you would like to disallow. If you forbid img + with the expectation of preventing images on your site, you'll be in for + a nasty surprise when people start using the background-image + CSS property. +

    +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.Forms.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.Forms.txt new file mode 100644 index 0000000..4a432d8 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.Forms.txt @@ -0,0 +1,11 @@ +HTML.Forms +TYPE: bool +VERSION: 4.13.0 +DEFAULT: false +--DESCRIPTION-- +

    + Whether or not to permit form elements in the user input, regardless of + %HTML.Trusted value. Please be very careful when using this functionality, as + enabling forms in untrusted documents may allow for phishing attacks. +

    +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.MaxImgLength.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.MaxImgLength.txt new file mode 100644 index 0000000..e424c38 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.MaxImgLength.txt @@ -0,0 +1,14 @@ +HTML.MaxImgLength +TYPE: int/null +DEFAULT: 1200 +VERSION: 3.1.1 +--DESCRIPTION-- +

    + This directive controls the maximum number of pixels in the width and + height attributes in img tags. This is + in place to prevent imagecrash attacks, disable with null at your own risk. + This directive is similar to %CSS.MaxImgLength, and both should be + concurrently edited, although there are + subtle differences in the input format (the HTML max is an integer). +

    +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.Nofollow.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.Nofollow.txt new file mode 100644 index 0000000..700b309 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.Nofollow.txt @@ -0,0 +1,7 @@ +HTML.Nofollow +TYPE: bool +VERSION: 4.3.0 +DEFAULT: FALSE +--DESCRIPTION-- +If enabled, nofollow rel attributes are added to all outgoing links. +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.Parent.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.Parent.txt new file mode 100644 index 0000000..62e8e16 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.Parent.txt @@ -0,0 +1,12 @@ +HTML.Parent +TYPE: string +VERSION: 1.3.0 +DEFAULT: 'div' +--DESCRIPTION-- + +

    + String name of element that HTML fragment passed to library will be + inserted in. An interesting variation would be using span as the + parent element, meaning that only inline tags would be allowed. +

    +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.Proprietary.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.Proprietary.txt new file mode 100644 index 0000000..dfb7204 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.Proprietary.txt @@ -0,0 +1,12 @@ +HTML.Proprietary +TYPE: bool +VERSION: 3.1.0 +DEFAULT: false +--DESCRIPTION-- +

    + Whether or not to allow proprietary elements and attributes in your + documents, as per HTMLPurifier_HTMLModule_Proprietary. + Warning: This can cause your documents to stop + validating! +

    +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.SafeEmbed.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.SafeEmbed.txt new file mode 100644 index 0000000..cdda09a --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.SafeEmbed.txt @@ -0,0 +1,13 @@ +HTML.SafeEmbed +TYPE: bool +VERSION: 3.1.1 +DEFAULT: false +--DESCRIPTION-- +

    + Whether or not to permit embed tags in documents, with a number of extra + security features added to prevent script execution. This is similar to + what websites like MySpace do to embed tags. Embed is a proprietary + element and will cause your website to stop validating; you should + see if you can use %Output.FlashCompat with %HTML.SafeObject instead + first.

    +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.SafeIframe.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.SafeIframe.txt new file mode 100644 index 0000000..5eb6ec2 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.SafeIframe.txt @@ -0,0 +1,13 @@ +HTML.SafeIframe +TYPE: bool +VERSION: 4.4.0 +DEFAULT: false +--DESCRIPTION-- +

    + Whether or not to permit iframe tags in untrusted documents. This + directive must be accompanied by a whitelist of permitted iframes, + such as %URI.SafeIframeRegexp, otherwise it will fatally error. + This directive has no effect on strict doctypes, as iframes are not + valid. +

    +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.SafeObject.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.SafeObject.txt new file mode 100644 index 0000000..ceb342e --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.SafeObject.txt @@ -0,0 +1,13 @@ +HTML.SafeObject +TYPE: bool +VERSION: 3.1.1 +DEFAULT: false +--DESCRIPTION-- +

    + Whether or not to permit object tags in documents, with a number of extra + security features added to prevent script execution. This is similar to + what websites like MySpace do to object tags. You should also enable + %Output.FlashCompat in order to generate Internet Explorer + compatibility code for your object tags. +

    +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.SafeScripting.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.SafeScripting.txt new file mode 100644 index 0000000..5ebc7a1 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.SafeScripting.txt @@ -0,0 +1,10 @@ +HTML.SafeScripting +TYPE: lookup +VERSION: 4.5.0 +DEFAULT: array() +--DESCRIPTION-- +

    + Whether or not to permit script tags to external scripts in documents. + Inline scripting is not allowed, and the script must match an explicit whitelist. +

    +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.Strict.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.Strict.txt new file mode 100644 index 0000000..a8b1de5 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.Strict.txt @@ -0,0 +1,9 @@ +HTML.Strict +TYPE: bool +VERSION: 1.3.0 +DEFAULT: false +DEPRECATED-VERSION: 1.7.0 +DEPRECATED-USE: HTML.Doctype +--DESCRIPTION-- +Determines whether or not to use Transitional (loose) or Strict rulesets. +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.TargetBlank.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.TargetBlank.txt new file mode 100644 index 0000000..587a167 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.TargetBlank.txt @@ -0,0 +1,8 @@ +HTML.TargetBlank +TYPE: bool +VERSION: 4.4.0 +DEFAULT: FALSE +--DESCRIPTION-- +If enabled, target=blank attributes are added to all outgoing links. +(This includes links from an HTTPS version of a page to an HTTP version.) +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.TargetNoopener.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.TargetNoopener.txt new file mode 100644 index 0000000..dd514c0 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.TargetNoopener.txt @@ -0,0 +1,10 @@ +--# vim: et sw=4 sts=4 +HTML.TargetNoopener +TYPE: bool +VERSION: 4.8.0 +DEFAULT: TRUE +--DESCRIPTION-- +If enabled, noopener rel attributes are added to links which have +a target attribute associated with them. This prevents malicious +destinations from overwriting the original window. +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.TargetNoreferrer.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.TargetNoreferrer.txt new file mode 100644 index 0000000..cb5a0b0 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.TargetNoreferrer.txt @@ -0,0 +1,9 @@ +HTML.TargetNoreferrer +TYPE: bool +VERSION: 4.8.0 +DEFAULT: TRUE +--DESCRIPTION-- +If enabled, noreferrer rel attributes are added to links which have +a target attribute associated with them. This prevents malicious +destinations from overwriting the original window. +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.TidyAdd.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.TidyAdd.txt new file mode 100644 index 0000000..b4c271b --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.TidyAdd.txt @@ -0,0 +1,8 @@ +HTML.TidyAdd +TYPE: lookup +VERSION: 2.0.0 +DEFAULT: array() +--DESCRIPTION-- + +Fixes to add to the default set of Tidy fixes as per your level. +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.TidyLevel.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.TidyLevel.txt new file mode 100644 index 0000000..4186ccd --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.TidyLevel.txt @@ -0,0 +1,24 @@ +HTML.TidyLevel +TYPE: string +VERSION: 2.0.0 +DEFAULT: 'medium' +--DESCRIPTION-- + +

    General level of cleanliness the Tidy module should enforce. +There are four allowed values:

    +
    +
    none
    +
    No extra tidying should be done
    +
    light
    +
    Only fix elements that would be discarded otherwise due to + lack of support in doctype
    +
    medium
    +
    Enforce best practices
    +
    heavy
    +
    Transform all deprecated elements and attributes to standards + compliant equivalents
    +
    + +--ALLOWED-- +'none', 'light', 'medium', 'heavy' +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.TidyRemove.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.TidyRemove.txt new file mode 100644 index 0000000..996762b --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.TidyRemove.txt @@ -0,0 +1,8 @@ +HTML.TidyRemove +TYPE: lookup +VERSION: 2.0.0 +DEFAULT: array() +--DESCRIPTION-- + +Fixes to remove from the default set of Tidy fixes as per your level. +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.Trusted.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.Trusted.txt new file mode 100644 index 0000000..1db9237 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.Trusted.txt @@ -0,0 +1,9 @@ +HTML.Trusted +TYPE: bool +VERSION: 2.0.0 +DEFAULT: false +--DESCRIPTION-- +Indicates whether or not the user input is trusted or not. If the input is +trusted, a more expansive set of allowed tags and attributes will be used. +See also %CSS.Trusted. +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.XHTML.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.XHTML.txt new file mode 100644 index 0000000..2a47e38 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.XHTML.txt @@ -0,0 +1,11 @@ +HTML.XHTML +TYPE: bool +DEFAULT: true +VERSION: 1.1.0 +DEPRECATED-VERSION: 1.7.0 +DEPRECATED-USE: HTML.Doctype +--DESCRIPTION-- +Determines whether or not output is XHTML 1.0 or HTML 4.01 flavor. +--ALIASES-- +Core.XHTML +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Output.CommentScriptContents.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Output.CommentScriptContents.txt new file mode 100644 index 0000000..08921fd --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Output.CommentScriptContents.txt @@ -0,0 +1,10 @@ +Output.CommentScriptContents +TYPE: bool +VERSION: 2.0.0 +DEFAULT: true +--DESCRIPTION-- +Determines whether or not HTML Purifier should attempt to fix up the +contents of script tags for legacy browsers with comments. +--ALIASES-- +Core.CommentScriptContents +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Output.FixInnerHTML.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Output.FixInnerHTML.txt new file mode 100644 index 0000000..d6f0d9f --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Output.FixInnerHTML.txt @@ -0,0 +1,15 @@ +Output.FixInnerHTML +TYPE: bool +VERSION: 4.3.0 +DEFAULT: true +--DESCRIPTION-- +

    + If true, HTML Purifier will protect against Internet Explorer's + mishandling of the innerHTML attribute by appending + a space to any attribute that does not contain angled brackets, spaces + or quotes, but contains a backtick. This slightly changes the + semantics of any given attribute, so if this is unacceptable and + you do not use innerHTML on any of your pages, you can + turn this directive off. +

    +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Output.FlashCompat.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Output.FlashCompat.txt new file mode 100644 index 0000000..93398e8 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Output.FlashCompat.txt @@ -0,0 +1,11 @@ +Output.FlashCompat +TYPE: bool +VERSION: 4.1.0 +DEFAULT: false +--DESCRIPTION-- +

    + If true, HTML Purifier will generate Internet Explorer compatibility + code for all object code. This is highly recommended if you enable + %HTML.SafeObject. +

    +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Output.Newline.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Output.Newline.txt new file mode 100644 index 0000000..79f8ad8 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Output.Newline.txt @@ -0,0 +1,13 @@ +Output.Newline +TYPE: string/null +VERSION: 2.0.1 +DEFAULT: NULL +--DESCRIPTION-- + +

    + Newline string to format final output with. If left null, HTML Purifier + will auto-detect the default newline type of the system and use that; + you can manually override it here. Remember, \r\n is Windows, \r + is Mac, and \n is Unix. +

    +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Output.SortAttr.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Output.SortAttr.txt new file mode 100644 index 0000000..232b023 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Output.SortAttr.txt @@ -0,0 +1,14 @@ +Output.SortAttr +TYPE: bool +VERSION: 3.2.0 +DEFAULT: false +--DESCRIPTION-- +

    + If true, HTML Purifier will sort attributes by name before writing them back + to the document, converting a tag like: <el b="" a="" c="" /> + to <el a="" b="" c="" />. This is a workaround for + a bug in FCKeditor which causes it to swap attributes order, adding noise + to text diffs. If you're not seeing this bug, chances are, you don't need + this directive. +

    +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Output.TidyFormat.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Output.TidyFormat.txt new file mode 100644 index 0000000..06bab00 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Output.TidyFormat.txt @@ -0,0 +1,25 @@ +Output.TidyFormat +TYPE: bool +VERSION: 1.1.1 +DEFAULT: false +--DESCRIPTION-- +

    + Determines whether or not to run Tidy on the final output for pretty + formatting reasons, such as indentation and wrap. +

    +

    + This can greatly improve readability for editors who are hand-editing + the HTML, but is by no means necessary as HTML Purifier has already + fixed all major errors the HTML may have had. Tidy is a non-default + extension, and this directive will silently fail if Tidy is not + available. +

    +

    + If you are looking to make the overall look of your page's source + better, I recommend running Tidy on the entire page rather than just + user-content (after all, the indentation relative to the containing + blocks will be incorrect). +

    +--ALIASES-- +Core.TidyFormat +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Test.ForceNoIconv.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Test.ForceNoIconv.txt new file mode 100644 index 0000000..071bc02 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Test.ForceNoIconv.txt @@ -0,0 +1,7 @@ +Test.ForceNoIconv +TYPE: bool +DEFAULT: false +--DESCRIPTION-- +When set to true, HTMLPurifier_Encoder will act as if iconv does not exist +and use only pure PHP implementations. +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.AllowedSchemes.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.AllowedSchemes.txt new file mode 100644 index 0000000..eb97307 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.AllowedSchemes.txt @@ -0,0 +1,18 @@ +URI.AllowedSchemes +TYPE: lookup +--DEFAULT-- +array ( + 'http' => true, + 'https' => true, + 'mailto' => true, + 'ftp' => true, + 'nntp' => true, + 'news' => true, + 'tel' => true, +) +--DESCRIPTION-- +Whitelist that defines the schemes that a URI is allowed to have. This +prevents XSS attacks from using pseudo-schemes like javascript or mocha. +There is also support for the data and file +URI schemes, but they are not enabled by default. +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.Base.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.Base.txt new file mode 100644 index 0000000..876f068 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.Base.txt @@ -0,0 +1,17 @@ +URI.Base +TYPE: string/null +VERSION: 2.1.0 +DEFAULT: NULL +--DESCRIPTION-- + +

    + The base URI is the URI of the document this purified HTML will be + inserted into. This information is important if HTML Purifier needs + to calculate absolute URIs from relative URIs, such as when %URI.MakeAbsolute + is on. You may use a non-absolute URI for this value, but behavior + may vary (%URI.MakeAbsolute deals nicely with both absolute and + relative paths, but forwards-compatibility is not guaranteed). + Warning: If set, the scheme on this URI + overrides the one specified by %URI.DefaultScheme. +

    +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.DefaultScheme.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.DefaultScheme.txt new file mode 100644 index 0000000..834bc08 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.DefaultScheme.txt @@ -0,0 +1,15 @@ +URI.DefaultScheme +TYPE: string/null +DEFAULT: 'http' +--DESCRIPTION-- + +

    + Defines through what scheme the output will be served, in order to + select the proper object validator when no scheme information is present. +

    + +

    + Starting with HTML Purifier 4.9.0, the default scheme can be null, in + which case we reject all URIs which do not have explicit schemes. +

    +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.DefinitionID.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.DefinitionID.txt new file mode 100644 index 0000000..f05312b --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.DefinitionID.txt @@ -0,0 +1,11 @@ +URI.DefinitionID +TYPE: string/null +VERSION: 2.1.0 +DEFAULT: NULL +--DESCRIPTION-- + +

    + Unique identifier for a custom-built URI definition. If you want + to add custom URIFilters, you must specify this value. +

    +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.DefinitionRev.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.DefinitionRev.txt new file mode 100644 index 0000000..80cfea9 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.DefinitionRev.txt @@ -0,0 +1,11 @@ +URI.DefinitionRev +TYPE: int +VERSION: 2.1.0 +DEFAULT: 1 +--DESCRIPTION-- + +

    + Revision identifier for your custom definition. See + %HTML.DefinitionRev for details. +

    +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.Disable.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.Disable.txt new file mode 100644 index 0000000..71ce025 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.Disable.txt @@ -0,0 +1,14 @@ +URI.Disable +TYPE: bool +VERSION: 1.3.0 +DEFAULT: false +--DESCRIPTION-- + +

    + Disables all URIs in all forms. Not sure why you'd want to do that + (after all, the Internet's founded on the notion of a hyperlink). +

    + +--ALIASES-- +Attr.DisableURI +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.DisableExternal.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.DisableExternal.txt new file mode 100644 index 0000000..13c122c --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.DisableExternal.txt @@ -0,0 +1,11 @@ +URI.DisableExternal +TYPE: bool +VERSION: 1.2.0 +DEFAULT: false +--DESCRIPTION-- +Disables links to external websites. This is a highly effective anti-spam +and anti-pagerank-leech measure, but comes at a hefty price: nolinks or +images outside of your domain will be allowed. Non-linkified URIs will +still be preserved. If you want to be able to link to subdomains or use +absolute URIs, specify %URI.Host for your website. +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.DisableExternalResources.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.DisableExternalResources.txt new file mode 100644 index 0000000..abcc1ef --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.DisableExternalResources.txt @@ -0,0 +1,13 @@ +URI.DisableExternalResources +TYPE: bool +VERSION: 1.3.0 +DEFAULT: false +--DESCRIPTION-- +Disables the embedding of external resources, preventing users from +embedding things like images from other hosts. This prevents access +tracking (good for email viewers), bandwidth leeching, cross-site request +forging, goatse.cx posting, and other nasties, but also results in a loss +of end-user functionality (they can't directly post a pic they posted from +Flickr anymore). Use it if you don't have a robust user-content moderation +team. +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.DisableResources.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.DisableResources.txt new file mode 100644 index 0000000..f891de4 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.DisableResources.txt @@ -0,0 +1,15 @@ +URI.DisableResources +TYPE: bool +VERSION: 4.2.0 +DEFAULT: false +--DESCRIPTION-- +

    + Disables embedding resources, essentially meaning no pictures. You can + still link to them though. See %URI.DisableExternalResources for why + this might be a good idea. +

    +

    + Note: While this directive has been available since 1.3.0, + it didn't actually start doing anything until 4.2.0. +

    +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.Host.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.Host.txt new file mode 100644 index 0000000..ee83b12 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.Host.txt @@ -0,0 +1,19 @@ +URI.Host +TYPE: string/null +VERSION: 1.2.0 +DEFAULT: NULL +--DESCRIPTION-- + +

    + Defines the domain name of the server, so we can determine whether or + an absolute URI is from your website or not. Not strictly necessary, + as users should be using relative URIs to reference resources on your + website. It will, however, let you use absolute URIs to link to + subdomains of the domain you post here: i.e. example.com will allow + sub.example.com. However, higher up domains will still be excluded: + if you set %URI.Host to sub.example.com, example.com will be blocked. + Note: This directive overrides %URI.Base because + a given page may be on a sub-domain, but you wish HTML Purifier to be + more relaxed and allow some of the parent domains too. +

    +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.HostBlacklist.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.HostBlacklist.txt new file mode 100644 index 0000000..0b6df76 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.HostBlacklist.txt @@ -0,0 +1,9 @@ +URI.HostBlacklist +TYPE: list +VERSION: 1.3.0 +DEFAULT: array() +--DESCRIPTION-- +List of strings that are forbidden in the host of any URI. Use it to kill +domain names of spam, etc. Note that it will catch anything in the domain, +so moo.com will catch moo.com.example.com. +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.MakeAbsolute.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.MakeAbsolute.txt new file mode 100644 index 0000000..4214900 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.MakeAbsolute.txt @@ -0,0 +1,13 @@ +URI.MakeAbsolute +TYPE: bool +VERSION: 2.1.0 +DEFAULT: false +--DESCRIPTION-- + +

    + Converts all URIs into absolute forms. This is useful when the HTML + being filtered assumes a specific base path, but will actually be + viewed in a different context (and setting an alternate base URI is + not possible). %URI.Base must be set for this directive to work. +

    +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.Munge.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.Munge.txt new file mode 100644 index 0000000..58c81dc --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.Munge.txt @@ -0,0 +1,83 @@ +URI.Munge +TYPE: string/null +VERSION: 1.3.0 +DEFAULT: NULL +--DESCRIPTION-- + +

    + Munges all browsable (usually http, https and ftp) + absolute URIs into another URI, usually a URI redirection service. + This directive accepts a URI, formatted with a %s where + the url-encoded original URI should be inserted (sample: + http://www.google.com/url?q=%s). +

    +

    + Uses for this directive: +

    +
      +
    • + Prevent PageRank leaks, while being fairly transparent + to users (you may also want to add some client side JavaScript to + override the text in the statusbar). Notice: + Many security experts believe that this form of protection does not deter spam-bots. +
    • +
    • + Redirect users to a splash page telling them they are leaving your + website. While this is poor usability practice, it is often mandated + in corporate environments. +
    • +
    +

    + Prior to HTML Purifier 3.1.1, this directive also enabled the munging + of browsable external resources, which could break things if your redirection + script was a splash page or used meta tags. To revert to + previous behavior, please use %URI.MungeResources. +

    +

    + You may want to also use %URI.MungeSecretKey along with this directive + in order to enforce what URIs your redirector script allows. Open + redirector scripts can be a security risk and negatively affect the + reputation of your domain name. +

    +

    + Starting with HTML Purifier 3.1.1, there is also these substitutions: +

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    KeyDescriptionExample <a href="">
    %r1 - The URI embeds a resource
    (blank) - The URI is merely a link
    %nThe name of the tag this URI came froma
    %mThe name of the attribute this URI came fromhref
    %pThe name of the CSS property this URI came from, or blank if irrelevant
    +

    + Admittedly, these letters are somewhat arbitrary; the only stipulation + was that they couldn't be a through f. r is for resource (I would have preferred + e, but you take what you can get), n is for name, m + was picked because it came after n (and I couldn't use a), p is for + property. +

    +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.MungeResources.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.MungeResources.txt new file mode 100644 index 0000000..6fce0fd --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.MungeResources.txt @@ -0,0 +1,17 @@ +URI.MungeResources +TYPE: bool +VERSION: 3.1.1 +DEFAULT: false +--DESCRIPTION-- +

    + If true, any URI munging directives like %URI.Munge + will also apply to embedded resources, such as <img src="">. + Be careful enabling this directive if you have a redirector script + that does not use the Location HTTP header; all of your images + and other embedded resources will break. +

    +

    + Warning: It is strongly advised you use this in conjunction + %URI.MungeSecretKey to mitigate the security risk of an open redirector. +

    +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.MungeSecretKey.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.MungeSecretKey.txt new file mode 100644 index 0000000..1e17c1d --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.MungeSecretKey.txt @@ -0,0 +1,30 @@ +URI.MungeSecretKey +TYPE: string/null +VERSION: 3.1.1 +DEFAULT: NULL +--DESCRIPTION-- +

    + This directive enables secure checksum generation along with %URI.Munge. + It should be set to a secure key that is not shared with anyone else. + The checksum can be placed in the URI using %t. Use of this checksum + affords an additional level of protection by allowing a redirector + to check if a URI has passed through HTML Purifier with this line: +

    + +
    $checksum === hash_hmac("sha256", $url, $secret_key)
    + +

    + If the output is TRUE, the redirector script should accept the URI. +

    + +

    + Please note that it would still be possible for an attacker to procure + secure hashes en-mass by abusing your website's Preview feature or the + like, but this service affords an additional level of protection + that should be combined with website blacklisting. +

    + +

    + Remember this has no effect if %URI.Munge is not on. +

    +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.OverrideAllowedSchemes.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.OverrideAllowedSchemes.txt new file mode 100644 index 0000000..23331a4 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.OverrideAllowedSchemes.txt @@ -0,0 +1,9 @@ +URI.OverrideAllowedSchemes +TYPE: bool +DEFAULT: true +--DESCRIPTION-- +If this is set to true (which it is by default), you can override +%URI.AllowedSchemes by simply registering a HTMLPurifier_URIScheme to the +registry. If false, you will also have to update that directive in order +to add more schemes. +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.SafeIframeRegexp.txt b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.SafeIframeRegexp.txt new file mode 100644 index 0000000..7908483 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.SafeIframeRegexp.txt @@ -0,0 +1,22 @@ +URI.SafeIframeRegexp +TYPE: string/null +VERSION: 4.4.0 +DEFAULT: NULL +--DESCRIPTION-- +

    + A PCRE regular expression that will be matched against an iframe URI. This is + a relatively inflexible scheme, but works well enough for the most common + use-case of iframes: embedded video. This directive only has an effect if + %HTML.SafeIframe is enabled. Here are some example values: +

    +
      +
    • %^http://www.youtube.com/embed/% - Allow YouTube videos
    • +
    • %^http://player.vimeo.com/video/% - Allow Vimeo videos
    • +
    • %^http://(www.youtube.com/embed/|player.vimeo.com/video/)% - Allow both
    • +
    +

    + Note that this directive does not give you enough granularity to, say, disable + all autoplay videos. Pipe up on the HTML Purifier forums if this + is a capability you want. +

    +--# vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/info.ini b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/info.ini new file mode 100644 index 0000000..5de4505 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/info.ini @@ -0,0 +1,3 @@ +name = "HTML Purifier" + +; vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ContentSets.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ContentSets.php new file mode 100644 index 0000000..543e3f8 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ContentSets.php @@ -0,0 +1,170 @@ + true) indexed by name. + * @type array + * @note This is in HTMLPurifier_HTMLDefinition->info_content_sets + */ + public $lookup = array(); + + /** + * Synchronized list of defined content sets (keys of info). + * @type array + */ + protected $keys = array(); + /** + * Synchronized list of defined content values (values of info). + * @type array + */ + protected $values = array(); + + /** + * Merges in module's content sets, expands identifiers in the content + * sets and populates the keys, values and lookup member variables. + * @param HTMLPurifier_HTMLModule[] $modules List of HTMLPurifier_HTMLModule + */ + public function __construct($modules) + { + if (!is_array($modules)) { + $modules = array($modules); + } + // populate content_sets based on module hints + // sorry, no way of overloading + foreach ($modules as $module) { + foreach ($module->content_sets as $key => $value) { + $temp = $this->convertToLookup($value); + if (isset($this->lookup[$key])) { + // add it into the existing content set + $this->lookup[$key] = array_merge($this->lookup[$key], $temp); + } else { + $this->lookup[$key] = $temp; + } + } + } + $old_lookup = false; + while ($old_lookup !== $this->lookup) { + $old_lookup = $this->lookup; + foreach ($this->lookup as $i => $set) { + $add = array(); + foreach ($set as $element => $x) { + if (isset($this->lookup[$element])) { + $add += $this->lookup[$element]; + unset($this->lookup[$i][$element]); + } + } + $this->lookup[$i] += $add; + } + } + + foreach ($this->lookup as $key => $lookup) { + $this->info[$key] = implode(' | ', array_keys($lookup)); + } + $this->keys = array_keys($this->info); + $this->values = array_values($this->info); + } + + /** + * Accepts a definition; generates and assigns a ChildDef for it + * @param HTMLPurifier_ElementDef $def HTMLPurifier_ElementDef reference + * @param HTMLPurifier_HTMLModule $module Module that defined the ElementDef + */ + public function generateChildDef(&$def, $module) + { + if (!empty($def->child)) { // already done! + return; + } + $content_model = $def->content_model; + if (is_string($content_model)) { + // Assume that $this->keys is alphanumeric + $def->content_model = preg_replace_callback( + '/\b(' . implode('|', $this->keys) . ')\b/', + array($this, 'generateChildDefCallback'), + $content_model + ); + //$def->content_model = str_replace( + // $this->keys, $this->values, $content_model); + } + $def->child = $this->getChildDef($def, $module); + } + + public function generateChildDefCallback($matches) + { + return $this->info[$matches[0]]; + } + + /** + * Instantiates a ChildDef based on content_model and content_model_type + * member variables in HTMLPurifier_ElementDef + * @note This will also defer to modules for custom HTMLPurifier_ChildDef + * subclasses that need content set expansion + * @param HTMLPurifier_ElementDef $def HTMLPurifier_ElementDef to have ChildDef extracted + * @param HTMLPurifier_HTMLModule $module Module that defined the ElementDef + * @return HTMLPurifier_ChildDef corresponding to ElementDef + */ + public function getChildDef($def, $module) + { + $value = $def->content_model; + if (is_object($value)) { + trigger_error( + 'Literal object child definitions should be stored in '. + 'ElementDef->child not ElementDef->content_model', + E_USER_NOTICE + ); + return $value; + } + switch ($def->content_model_type) { + case 'required': + return new HTMLPurifier_ChildDef_Required($value); + case 'optional': + return new HTMLPurifier_ChildDef_Optional($value); + case 'empty': + return new HTMLPurifier_ChildDef_Empty(); + case 'custom': + return new HTMLPurifier_ChildDef_Custom($value); + } + // defer to its module + $return = false; + if ($module->defines_child_def) { // save a func call + $return = $module->getChildDef($def); + } + if ($return !== false) { + return $return; + } + // error-out + trigger_error( + 'Could not determine which ChildDef class to instantiate', + E_USER_ERROR + ); + return false; + } + + /** + * Converts a string list of elements separated by pipes into + * a lookup array. + * @param string $string List of elements + * @return array Lookup array of elements + */ + protected function convertToLookup($string) + { + $array = explode('|', str_replace(' ', '', $string)); + $ret = array(); + foreach ($array as $k) { + $ret[$k] = true; + } + return $ret; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Context.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Context.php new file mode 100644 index 0000000..00e509c --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Context.php @@ -0,0 +1,95 @@ +_storage)) { + trigger_error( + "Name $name produces collision, cannot re-register", + E_USER_ERROR + ); + return; + } + $this->_storage[$name] =& $ref; + } + + /** + * Retrieves a variable reference from the context. + * @param string $name String name + * @param bool $ignore_error Boolean whether or not to ignore error + * @return mixed + */ + public function &get($name, $ignore_error = false) + { + if (!array_key_exists($name, $this->_storage)) { + if (!$ignore_error) { + trigger_error( + "Attempted to retrieve non-existent variable $name", + E_USER_ERROR + ); + } + $var = null; // so we can return by reference + return $var; + } + return $this->_storage[$name]; + } + + /** + * Destroys a variable in the context. + * @param string $name String name + */ + public function destroy($name) + { + if (!array_key_exists($name, $this->_storage)) { + trigger_error( + "Attempted to destroy non-existent variable $name", + E_USER_ERROR + ); + return; + } + unset($this->_storage[$name]); + } + + /** + * Checks whether or not the variable exists. + * @param string $name String name + * @return bool + */ + public function exists($name) + { + return array_key_exists($name, $this->_storage); + } + + /** + * Loads a series of variables from an associative array + * @param array $context_array Assoc array of variables to load + */ + public function loadArray($context_array) + { + foreach ($context_array as $key => $discard) { + $this->register($key, $context_array[$key]); + } + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Definition.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Definition.php new file mode 100644 index 0000000..bc6d433 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Definition.php @@ -0,0 +1,55 @@ +setup) { + return; + } + $this->setup = true; + $this->doSetup($config); + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache.php new file mode 100644 index 0000000..9aa8ff3 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache.php @@ -0,0 +1,129 @@ +type = $type; + } + + /** + * Generates a unique identifier for a particular configuration + * @param HTMLPurifier_Config $config Instance of HTMLPurifier_Config + * @return string + */ + public function generateKey($config) + { + return $config->version . ',' . // possibly replace with function calls + $config->getBatchSerial($this->type) . ',' . + $config->get($this->type . '.DefinitionRev'); + } + + /** + * Tests whether or not a key is old with respect to the configuration's + * version and revision number. + * @param string $key Key to test + * @param HTMLPurifier_Config $config Instance of HTMLPurifier_Config to test against + * @return bool + */ + public function isOld($key, $config) + { + if (substr_count($key, ',') < 2) { + return true; + } + list($version, $hash, $revision) = explode(',', $key, 3); + $compare = version_compare($version, $config->version); + // version mismatch, is always old + if ($compare != 0) { + return true; + } + // versions match, ids match, check revision number + if ($hash == $config->getBatchSerial($this->type) && + $revision < $config->get($this->type . '.DefinitionRev')) { + return true; + } + return false; + } + + /** + * Checks if a definition's type jives with the cache's type + * @note Throws an error on failure + * @param HTMLPurifier_Definition $def Definition object to check + * @return bool true if good, false if not + */ + public function checkDefType($def) + { + if ($def->type !== $this->type) { + trigger_error("Cannot use definition of type {$def->type} in cache for {$this->type}"); + return false; + } + return true; + } + + /** + * Adds a definition object to the cache + * @param HTMLPurifier_Definition $def + * @param HTMLPurifier_Config $config + */ + abstract public function add($def, $config); + + /** + * Unconditionally saves a definition object to the cache + * @param HTMLPurifier_Definition $def + * @param HTMLPurifier_Config $config + */ + abstract public function set($def, $config); + + /** + * Replace an object in the cache + * @param HTMLPurifier_Definition $def + * @param HTMLPurifier_Config $config + */ + abstract public function replace($def, $config); + + /** + * Retrieves a definition object from the cache + * @param HTMLPurifier_Config $config + */ + abstract public function get($config); + + /** + * Removes a definition object to the cache + * @param HTMLPurifier_Config $config + */ + abstract public function remove($config); + + /** + * Clears all objects from cache + * @param HTMLPurifier_Config $config + */ + abstract public function flush($config); + + /** + * Clears all expired (older version or revision) objects from cache + * @note Be careful implementing this method as flush. Flush must + * not interfere with other Definition types, and cleanup() + * should not be repeatedly called by userland code. + * @param HTMLPurifier_Config $config + */ + abstract public function cleanup($config); +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/Decorator.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/Decorator.php new file mode 100644 index 0000000..b57a51b --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/Decorator.php @@ -0,0 +1,112 @@ +copy(); + // reference is necessary for mocks in PHP 4 + $decorator->cache =& $cache; + $decorator->type = $cache->type; + return $decorator; + } + + /** + * Cross-compatible clone substitute + * @return HTMLPurifier_DefinitionCache_Decorator + */ + public function copy() + { + return new HTMLPurifier_DefinitionCache_Decorator(); + } + + /** + * @param HTMLPurifier_Definition $def + * @param HTMLPurifier_Config $config + * @return mixed + */ + public function add($def, $config) + { + return $this->cache->add($def, $config); + } + + /** + * @param HTMLPurifier_Definition $def + * @param HTMLPurifier_Config $config + * @return mixed + */ + public function set($def, $config) + { + return $this->cache->set($def, $config); + } + + /** + * @param HTMLPurifier_Definition $def + * @param HTMLPurifier_Config $config + * @return mixed + */ + public function replace($def, $config) + { + return $this->cache->replace($def, $config); + } + + /** + * @param HTMLPurifier_Config $config + * @return mixed + */ + public function get($config) + { + return $this->cache->get($config); + } + + /** + * @param HTMLPurifier_Config $config + * @return mixed + */ + public function remove($config) + { + return $this->cache->remove($config); + } + + /** + * @param HTMLPurifier_Config $config + * @return mixed + */ + public function flush($config) + { + return $this->cache->flush($config); + } + + /** + * @param HTMLPurifier_Config $config + * @return mixed + */ + public function cleanup($config) + { + return $this->cache->cleanup($config); + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/Decorator/Cleanup.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/Decorator/Cleanup.php new file mode 100644 index 0000000..4991777 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/Decorator/Cleanup.php @@ -0,0 +1,78 @@ +definitions[$this->generateKey($config)] = $def; + } + return $status; + } + + /** + * @param HTMLPurifier_Definition $def + * @param HTMLPurifier_Config $config + * @return mixed + */ + public function set($def, $config) + { + $status = parent::set($def, $config); + if ($status) { + $this->definitions[$this->generateKey($config)] = $def; + } + return $status; + } + + /** + * @param HTMLPurifier_Definition $def + * @param HTMLPurifier_Config $config + * @return mixed + */ + public function replace($def, $config) + { + $status = parent::replace($def, $config); + if ($status) { + $this->definitions[$this->generateKey($config)] = $def; + } + return $status; + } + + /** + * @param HTMLPurifier_Config $config + * @return mixed + */ + public function get($config) + { + $key = $this->generateKey($config); + if (isset($this->definitions[$key])) { + return $this->definitions[$key]; + } + $this->definitions[$key] = parent::get($config); + return $this->definitions[$key]; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/Decorator/Template.php.in b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/Decorator/Template.php.in new file mode 100644 index 0000000..b1fec8d --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/Decorator/Template.php.in @@ -0,0 +1,82 @@ +checkDefType($def)) { + return; + } + $file = $this->generateFilePath($config); + if (file_exists($file)) { + return false; + } + if (!$this->_prepareDir($config)) { + return false; + } + return $this->_write($file, serialize($def), $config); + } + + /** + * @param HTMLPurifier_Definition $def + * @param HTMLPurifier_Config $config + * @return int|bool + */ + public function set($def, $config) + { + if (!$this->checkDefType($def)) { + return; + } + $file = $this->generateFilePath($config); + if (!$this->_prepareDir($config)) { + return false; + } + return $this->_write($file, serialize($def), $config); + } + + /** + * @param HTMLPurifier_Definition $def + * @param HTMLPurifier_Config $config + * @return int|bool + */ + public function replace($def, $config) + { + if (!$this->checkDefType($def)) { + return; + } + $file = $this->generateFilePath($config); + if (!file_exists($file)) { + return false; + } + if (!$this->_prepareDir($config)) { + return false; + } + return $this->_write($file, serialize($def), $config); + } + + /** + * @param HTMLPurifier_Config $config + * @return bool|HTMLPurifier_Config + */ + public function get($config) + { + $file = $this->generateFilePath($config); + if (!file_exists($file)) { + return false; + } + return unserialize(file_get_contents($file)); + } + + /** + * @param HTMLPurifier_Config $config + * @return bool + */ + public function remove($config) + { + $file = $this->generateFilePath($config); + if (!file_exists($file)) { + return false; + } + return unlink($file); + } + + /** + * @param HTMLPurifier_Config $config + * @return bool + */ + public function flush($config) + { + if (!$this->_prepareDir($config)) { + return false; + } + $dir = $this->generateDirectoryPath($config); + $dh = opendir($dir); + // Apparently, on some versions of PHP, readdir will return + // an empty string if you pass an invalid argument to readdir. + // So you need this test. See #49. + if (false === $dh) { + return false; + } + while (false !== ($filename = readdir($dh))) { + if (empty($filename)) { + continue; + } + if ($filename[0] === '.') { + continue; + } + unlink($dir . '/' . $filename); + } + closedir($dh); + return true; + } + + /** + * @param HTMLPurifier_Config $config + * @return bool + */ + public function cleanup($config) + { + if (!$this->_prepareDir($config)) { + return false; + } + $dir = $this->generateDirectoryPath($config); + $dh = opendir($dir); + // See #49 (and above). + if (false === $dh) { + return false; + } + while (false !== ($filename = readdir($dh))) { + if (empty($filename)) { + continue; + } + if ($filename[0] === '.') { + continue; + } + $key = substr($filename, 0, strlen($filename) - 4); + if ($this->isOld($key, $config)) { + unlink($dir . '/' . $filename); + } + } + closedir($dh); + return true; + } + + /** + * Generates the file path to the serial file corresponding to + * the configuration and definition name + * @param HTMLPurifier_Config $config + * @return string + * @todo Make protected + */ + public function generateFilePath($config) + { + $key = $this->generateKey($config); + return $this->generateDirectoryPath($config) . '/' . $key . '.ser'; + } + + /** + * Generates the path to the directory contain this cache's serial files + * @param HTMLPurifier_Config $config + * @return string + * @note No trailing slash + * @todo Make protected + */ + public function generateDirectoryPath($config) + { + $base = $this->generateBaseDirectoryPath($config); + return $base . '/' . $this->type; + } + + /** + * Generates path to base directory that contains all definition type + * serials + * @param HTMLPurifier_Config $config + * @return mixed|string + * @todo Make protected + */ + public function generateBaseDirectoryPath($config) + { + $base = $config->get('Cache.SerializerPath'); + $base = is_null($base) ? HTMLPURIFIER_PREFIX . '/HTMLPurifier/DefinitionCache/Serializer' : $base; + return $base; + } + + /** + * Convenience wrapper function for file_put_contents + * @param string $file File name to write to + * @param string $data Data to write into file + * @param HTMLPurifier_Config $config + * @return int|bool Number of bytes written if success, or false if failure. + */ + private function _write($file, $data, $config) + { + $result = file_put_contents($file, $data); + if ($result !== false) { + // set permissions of the new file (no execute) + $chmod = $config->get('Cache.SerializerPermissions'); + if ($chmod !== null) { + chmod($file, $chmod & 0666); + } + } + return $result; + } + + /** + * Prepares the directory that this type stores the serials in + * @param HTMLPurifier_Config $config + * @return bool True if successful + */ + private function _prepareDir($config) + { + $directory = $this->generateDirectoryPath($config); + $chmod = $config->get('Cache.SerializerPermissions'); + if ($chmod === null) { + if (!@mkdir($directory) && !is_dir($directory)) { + trigger_error( + 'Could not create directory ' . $directory . '', + E_USER_WARNING + ); + return false; + } + return true; + } + if (!is_dir($directory)) { + $base = $this->generateBaseDirectoryPath($config); + if (!is_dir($base)) { + trigger_error( + 'Base directory ' . $base . ' does not exist, + please create or change using %Cache.SerializerPath', + E_USER_WARNING + ); + return false; + } elseif (!$this->_testPermissions($base, $chmod)) { + return false; + } + if (!@mkdir($directory, $chmod) && !is_dir($directory)) { + trigger_error( + 'Could not create directory ' . $directory . '', + E_USER_WARNING + ); + return false; + } + if (!$this->_testPermissions($directory, $chmod)) { + return false; + } + } elseif (!$this->_testPermissions($directory, $chmod)) { + return false; + } + return true; + } + + /** + * Tests permissions on a directory and throws out friendly + * error messages and attempts to chmod it itself if possible + * @param string $dir Directory path + * @param int $chmod Permissions + * @return bool True if directory is writable + */ + private function _testPermissions($dir, $chmod) + { + // early abort, if it is writable, everything is hunky-dory + if (is_writable($dir)) { + return true; + } + if (!is_dir($dir)) { + // generally, you'll want to handle this beforehand + // so a more specific error message can be given + trigger_error( + 'Directory ' . $dir . ' does not exist', + E_USER_WARNING + ); + return false; + } + if (function_exists('posix_getuid') && $chmod !== null) { + // POSIX system, we can give more specific advice + if (fileowner($dir) === posix_getuid()) { + // we can chmod it ourselves + $chmod = $chmod | 0700; + if (chmod($dir, $chmod)) { + return true; + } + } elseif (filegroup($dir) === posix_getgid()) { + $chmod = $chmod | 0070; + } else { + // PHP's probably running as nobody, it is + // not obvious how to fix this (777 is probably + // bad if you are multi-user), let the user figure it out + $chmod = null; + } + trigger_error( + 'Directory ' . $dir . ' not writable. ' . + ($chmod === null ? '' : 'Please chmod to ' . decoct($chmod)), + E_USER_WARNING + ); + } else { + // generic error message + trigger_error( + 'Directory ' . $dir . ' not writable, ' . + 'please alter file permissions', + E_USER_WARNING + ); + } + return false; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/Serializer/HTML/4.18.0,f474c0a322b208e83d22d3aef33ecb184bc71d31,1.ser b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/Serializer/HTML/4.18.0,f474c0a322b208e83d22d3aef33ecb184bc71d31,1.ser new file mode 100644 index 0000000000000000000000000000000000000000..931f16a0e9fa0bf0f0ce14432031f31c3f98f5b6 GIT binary patch literal 95522 zcmeHQYje}cww<3c<@4=UogsGK<`YAh8mbteAh+)M=8`QX=|Pr^Boi_m{`*~P_d`wm!L4^~;mqaF_Ms&3nK6&o5QIs?hL>1gYeSVujge|-@xf{VN#jtyI6Lu!FtXsTt#nYT-{OXI~TJj zO4IyuluT#URbzoxS2MIOD=PQT*do>iSGf$t9$wC_XTb!!ywUa1q{y?YX`{Z0sign8 z{y728GJg@J4`W%uyoMM0=&zuY%4jO_cL-s}!2Yea$Ol6B@%6h!<*UFwV@&@uK!87mZfF+q-l2KhgXTl% zGF+Vd=Wx-S711in( zCSm*)n-rTAn?z2aLZ>YeIzc)IF=;o*bnIlfVV8&e?UT6Bdh%`i7WX*5mkkyP8l)f} z>ZpU^7c<;Dl9h>rV|TE>;}81&VBimS{lT6;*!Kqq{@~CZ9QaEI{?b9Xt_KJqmm`I?V>%}2iG zBVY5euld;DbL{Uq_V@I6{7wBG-+q6`zd(P-zd?V;ze0bx6t45P4ss{ z8~xBmKeW*gZ9u$9IUMvl{m@1~v;hI9zZ%-;hc+PXbXNzVjX`Jw!cTj3&sVqSYdiL5 z`U89F>sLyn?Icd7<0LNMC1pOxZ00WdK1wADYOS(U<+`eOk{Kw%RnON8>3EZ%TO4)8gBKiQnw-H`FnH>U zeWepf^EiS)yCm61W~js|k@z zP_*Hz>{aEG9wAiC=EBfm^5h|$4hr*TAr1u$I-|Du34*;KBA%sjnS}T?n0Q+q&t{Wb zJ->20WSh{vTjTQ}B8N*8R~Nz=VlpfhY`g@doC8!4JqKbI7ZWZ^&ZA}^G3yWVPf|$S zCK)8>sFc?c$0+5vTg0)h1r-_wjC)=U1EyiXTujK-VZaW#(t&=Bz-uTq;=BRITCv^0 zp0sHlPDHa=TGJJwJazmvfK7WWu;SMZJ4VI{Y~7EH(un$aZexR>=a-`N8scYE6$H+N zW{jEVAI*>wXn^|P^RhB$2#2`6LTJTy#db#SYvYONPc+0MU=>}{U5H0wEq2X{wLWYt zI^=px-esyj#ahvE0;x2du5)q@VjygkG@NcN_u6XlgZO2G7v4lTU1BYSl8Uv8wUU=0 z7*}ZMaxOzG4-H)|N@-Z4)LH`d(q1QYIk6TxAH`b5TE$v`D;RZ66QME$pZlS683I)5 zinWThinWTho_W2dA%avy`Pz_t=OMZ=SS%^lD%L92D%L92()X#(Y1S!U3yKAqzCx`+ ztwOCrtwQY@Pz#5pFE)>)x2(6GvezA%tjFwv!4ed6V(?C5CF|Zs^Lm8DM+p*M+Cjs0 z2L<3h)~GXlHa@E)EvU`#5Z5h~o8ggtkk-@&=_X-KfnCZiSuo`#(5w;yB?OO32-K-X zmZLhgY&QRL+t3$C`e=rCfNXVY>Dq!1qz#FvyCF{Sf&L?z=Y*qwnDeKXv>$qj&uZ}iG!A5O1k zNa=0^uvq7;OtRL4w}qGLvoy^wllUE@Kit(P%e60@ZD;MHw!62FkKQ8ZIY6E5QkQrh zyOAm?>@k0YaZI1wt91KMIV+sl6FH3Sej-w61MOY^T9D5BdXy=N9aSDR){#SxJx5 z(QACs`>SlyvuVmOR3<)gL;-X8=Dv7&;%2GyEG!ZIXHw62F*_FnRsj*xcGWTlEYe#Y~AD`WDphHvBQJ^&xm>WDyv zUYW9TA~`^k_rt+q$_sY%o1yn)bBC3cqEEQaM26Z5Ea7+OSi9sZFE0>P4Q7K(1^JrY z#(pEGIdakcZ0JW+8Q+-x|2sufoR%f=X^`NI^Kt0)e(4z1Y5y_>?`^< zOtke^s7yml>hj|}Vx&sDR8etk%86gCR0Wt~lFIeL%B6V^rVGtS}q;WBk; zT226iXO$>-SejJYbh9)iZk?`7S(!xaE~oa*d!KhM;)J6-XtYUV2HgCTAbg@a7sXLzv$*-4PN9vbc=kkQ{Y0tF6j(yQVeX2EvTFjX3$kv5d$M zyDrNp1kuwiDxzC-?ZBR>3EAOFLiX)=%$rwx$F7O0;*=SqDo#~#YTP~%*2;Rg#R7+f zUL>-E>*C-SX@a#>Q83NjDR>X=TOr=a;wY71`<4j-8$qt0hN7Ac9Ks~4qqx4E4}Ilj z2_W_PtTK5PiC*a%ucu(HU``!oBaR$qR1hwKX>7%m!z!-At^kk4Ylf;)q#(WJ<;s}Nxr zH%v6uhP6dr6Tj{f_j_{~2b9(TO|{~H5!<_gCRl)g9o;%P&W{v%R5XxTUS348h^7|A z7+z<1s~R;_vZ&>wR0fRig7FrRur&YJcEQ@TRCKL&-P@#G9|D1%MxU)l?QSZ? zc3|(_m94!>vU3Cgx9Z}xTI*Vr{4*vM10Pn-5d^RsC{Zp)xty9Q`hH(rm+878Q^Q1tpB<;>)M5`u7w;SF2(Z;SYD(_ zp7mh<2pdT3y#3B|<3W|K8_A2uhMG7#HmBa06YRusyAv0Uw&VrYlRug;W~HwMdUc%U zlMgiiTQErttK?BUYZs?G_BI!NuP=v5aEe1Q%DK9aY+On*E1 z+K=+CPSh<6&LLJ(A;~+GChzf zWXB)${ej=!?)%;CzTe#L@B4cW{K26+IPjMa{H23%$v3L;z+Go)Jn%aPj@&M1K@}GS zlA_`QS;{g$A0?v0U3Ph!<2A4i?b;)Hph;sUqG!0P@?Hl>?e*IT`ZSQWcP z#RV!E6ukw!wlcrf#cclGT!M9}lcoH+ZQ_D)oOdNIkU#}qEC&e$)@@5g=;LDC62o62 zr=XgY5&LX-aFmJ)avlb1B{v1>C*o*KqB0qkNmiQ5d=kCE-GhNY>UIm7iqF$@m`3zf zD~5w(h;{+vjq=0xR|s|JviP857P`1jkn?+-pBR@G2Q6YeCYs&GLnsDBy$98M@R9v< z#IG4}HHjpWW>-+Vg~9KEF5N_z0;W|t;+R5_V{n)zVq}3Ou?h2*2QG&T4*KF)w+r>x*>yp0bBHivm@z7 z2?l2Ki&(LZ^CG6D3Cw!1{aRqV5QTcglcO#ozR?h1lBDSj_BP^$ep{mt5Bz4W57;Qf zgKVr(43~@5wEm94n>ByR4Gc0Z-9Ww3IOn#&k`0u{36fWNx&gX!Q5s~f;)z`_=-hE! zNNLZO3R`k{9X^Gdnb!d~k8?!vGs8oaghtuPVTMN?5h3B%i+Rd7T)%6?1QR4PlW^#P zq@EY~d?p{urHSiBekn!fM-$E%F$?RCflUfatCOVNXY&P)sGLuyQE|2M<4%*$$Z;kc z!flL|_^6vmOtBc7H|`%fD7Wt^aZ9z|y?Gjs10fv&&{cR7os5iZ8$r zE|7`(X%E@bwv}l3q|S|M0L!qkq_m?fnU$A$?;4jWPwF$?(p|#_-5iheRID#;=+Fg2 zw1s?3HJM$oP!oa)5=r@uRipCeaUNr_*X4^O66<+y`+1h79fc8S&a?J|G5$XJ2V{UVrb710H7#15>vI}@hP3zYQxnHF zjU(4N8mc$*j;e7}WCIg)JVmxBxjZI)pln>gFb`{?_$Ih}^nI4wR6A%6G-ZJ_g&oX| zDTf<%+&xq_;OElBh)R9y>QEc_on#8G^<&-R3)CbQb!eCey#yHw%%!FTq{t>c{l~ z0a&QVhi4Ih&T76@^IVT&zNLCy%b@~Ax)PU>yV^kPFrO~lLbLL!VSmvvBl2L@N_kb; zDM|`*#Ir;$Li>s2dwVZvVK`tFFjz;{ zb5H7>40KT&M1ZSh_#mI2`(se0cFGZK!@O*A>s%H)Rqbw?R~6krC%mf2-9a&xJ#&id zhl^iCsHLLB4YOz8mC);5@^Nko1WvM9sG%ch1~-s3>C`6{Wm$mekOh7x7+OfUFE5aV zlx7M7#sWb=<5uK^1%(wA6uxa%wN*~rqR8sVUd3y07qvjO7jF<+5}xQMEgp93LeHADzep*wA0YOTN`sVOdM( ztAGaTMRq72;df3;uE++(gJMDz&&n+h``;CyZA_IZnp$sPvYPeVD)hr>IyoM;+C}=SKLzE z`bo`;$&`R6yzT+Q0NfEm#D2kLM(M82SihystKt@M3p}KmA~r}zs3n0{ARKPE9)W3H zuxSpm=$kxL;mI-BA-B`Lvt4IRVy36a0S?E_iS!>NX-hv;GuTjWq8V&_h+oZMQ`Fkh zd#vxRVb29MqZB@Z!37R5S{4ce`yu?aMy3V{0|m3t*WdAhzWX~014&%IOUiuiV1PQt zJHUWgU4X_~&tzB?Q+|kTS2qG_EZ}>&3pUhd?mdDVdUvr2z({Q})Cc)CXUcM$8{kb$ z)a$#AWw4*$SaY{+P3TCBj|NY-z{AxJcrT~t^{&AwyjSSqVM4@ei{aibg80)p87*MO zu4sXN_3y8;NzZPVaI=ZQEDL|R?A-z*{qm%t#D`rHJXsO(hw%%nsQwNM41+=qKH3bi z`EGX6-x9k4*TpqOwl3hF9OHA)Ysu$HI+yq=kqeH1-iYQ^K1uUZ_NLaP0&CiOrE(T? zr^*~2*vv`<8gWrVWp(7FZnjL~tjs>Q(I$dVE?(wLtjYq9fioo%{WZ9bhHho${8oz* zbkFUh3;grJMYHvIVA`SXnI1A_zrNxvFTlndeT%#HBIqU|_CHf6Dt@#x8-q`(vn_DkvOyU2AI>nJ+#oz{JCoB(zpcr2 zDns)Hvux4JcRZdb%vr3R^U$y6c>Fa}THDL3eNIdA4!F6V*9;-Z`8XuHZ zl*JJ&jDz$K@)EBs`H{1(;WL{N3DAkbw2EWj(9+xB{*aosLg91Ja1J_vhj@gs7Km_{ z`!cAiTpT&leDdMrJa5UTHGlfgDQ4H;+m@aJdF~#3o04`HqHQ$I<3uz?d!!o|{a^q4 z>&1XSyZqVX&pv++@Pk}zMN*bH8izHA0@faX@gEcjzZV65M6`^*b_axmEDwj)+zIEP zCdV(O@%Tft68^EOC>&7*g+EX|;TI|={C>oLs+jNxswMm;Q=X}qY7qy_XUj5zbmEV# zj^+7Se)$-WAf>{u;khYdrr~c@;RhYT)0uo=ob!0f8|@s!fj7d#A=RSz!&|MC0|)#F z%hcc?XI*pt#QY(9%|9kd<1*o+!tLO%HJQXgg*VvKZjGrB%0_l1bX-F5mSSL@@=BTu-Rt4@s>T z4G%=aswQJt(_Vgz-cge=N1lPPYBFX?mTXgIbL?Kime69MKLOP6nCMS|3%A(lPoNUP zNL#jI=a-pHrxXo$+o{6>sZ?_Z-+utADvSX4kYomIKMCXl<3ed1=Z%v1@75zXDa)-amnn+Z?a*;!atFx zP<#hrE1blVGBr+dc*#$VVnsfl2NH5kAIL z!P}9=7Jk8G%z;gh7;kHeE{*evW!fNpzHZBT;;y0V(b@PapA(b(+<(Z`{M!F*=U3ro zOl9)S8hW8tu<|xrE}|X)_-v9w3X-1Z(`lZO2QolUoAH-24OA`(X5l2nTy$_x`SS{l z89}#^-p`H>)BEAG@D6XW2Y}EiV%xlp`GHZ>3*_QpkhRIah&0+V-z{E(t>#Cp+=i5 z6gTk2(F?DV^JpS@3;Qmm@o7|?C-TygJOuZ=bg7u}6!RL>%j!RWy;|CT{16Vw>pWX} z3nu~C(8|PDf7Js6*l^>50XxODQF|cKFx$nXkc%?j>bIE%I4m66_X28b-XR zT(TdHwlM^srvb~+7#tRnXi#`oD@Vd3aTULvk5dB|VmyK6@$V;3{%`mBlP4#qC%-PA zYfqlMc+I=*)9fF&{#*17 zZtDJqSLjh)49mpcFD;&(1qdfiCb#}FijczD_GIrVU8OL@e&>Tj-YxF|1}mv*0|mS% O?IEXdVM0T2r}}>`?yTnk literal 0 HcmV?d00001 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/Serializer/README b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/Serializer/README new file mode 100644 index 0000000..2e35c1c --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/Serializer/README @@ -0,0 +1,3 @@ +This is a dummy file to prevent Git from ignoring this empty directory. + + vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCacheFactory.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCacheFactory.php new file mode 100644 index 0000000..3a0f461 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCacheFactory.php @@ -0,0 +1,106 @@ + array()); + + /** + * @type array + */ + protected $implementations = array(); + + /** + * @type HTMLPurifier_DefinitionCache_Decorator[] + */ + protected $decorators = array(); + + /** + * Initialize default decorators + */ + public function setup() + { + $this->addDecorator('Cleanup'); + } + + /** + * Retrieves an instance of global definition cache factory. + * @param HTMLPurifier_DefinitionCacheFactory $prototype + * @return HTMLPurifier_DefinitionCacheFactory + */ + public static function instance($prototype = null) + { + static $instance; + if ($prototype !== null) { + $instance = $prototype; + } elseif ($instance === null || $prototype === true) { + $instance = new HTMLPurifier_DefinitionCacheFactory(); + $instance->setup(); + } + return $instance; + } + + /** + * Registers a new definition cache object + * @param string $short Short name of cache object, for reference + * @param string $long Full class name of cache object, for construction + */ + public function register($short, $long) + { + $this->implementations[$short] = $long; + } + + /** + * Factory method that creates a cache object based on configuration + * @param string $type Name of definitions handled by cache + * @param HTMLPurifier_Config $config Config instance + * @return mixed + */ + public function create($type, $config) + { + $method = $config->get('Cache.DefinitionImpl'); + if ($method === null) { + return new HTMLPurifier_DefinitionCache_Null($type); + } + if (!empty($this->caches[$method][$type])) { + return $this->caches[$method][$type]; + } + if (isset($this->implementations[$method]) && + class_exists($class = $this->implementations[$method])) { + $cache = new $class($type); + } else { + if ($method != 'Serializer') { + trigger_error("Unrecognized DefinitionCache $method, using Serializer instead", E_USER_WARNING); + } + $cache = new HTMLPurifier_DefinitionCache_Serializer($type); + } + foreach ($this->decorators as $decorator) { + $new_cache = $decorator->decorate($cache); + // prevent infinite recursion in PHP 4 + unset($cache); + $cache = $new_cache; + } + $this->caches[$method][$type] = $cache; + return $this->caches[$method][$type]; + } + + /** + * Registers a decorator to add to all new cache objects + * @param HTMLPurifier_DefinitionCache_Decorator|string $decorator An instance or the name of a decorator + */ + public function addDecorator($decorator) + { + if (is_string($decorator)) { + $class = "HTMLPurifier_DefinitionCache_Decorator_$decorator"; + $decorator = new $class; + } + $this->decorators[$decorator->name] = $decorator; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Doctype.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Doctype.php new file mode 100644 index 0000000..4acd06e --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Doctype.php @@ -0,0 +1,73 @@ +renderDoctype. + * If structure changes, please update that function. + */ +class HTMLPurifier_Doctype +{ + /** + * Full name of doctype + * @type string + */ + public $name; + + /** + * List of standard modules (string identifiers or literal objects) + * that this doctype uses + * @type array + */ + public $modules = array(); + + /** + * List of modules to use for tidying up code + * @type array + */ + public $tidyModules = array(); + + /** + * Is the language derived from XML (i.e. XHTML)? + * @type bool + */ + public $xml = true; + + /** + * List of aliases for this doctype + * @type array + */ + public $aliases = array(); + + /** + * Public DTD identifier + * @type string + */ + public $dtdPublic; + + /** + * System DTD identifier + * @type string + */ + public $dtdSystem; + + public function __construct( + $name = null, + $xml = true, + $modules = array(), + $tidyModules = array(), + $aliases = array(), + $dtd_public = null, + $dtd_system = null + ) { + $this->name = $name; + $this->xml = $xml; + $this->modules = $modules; + $this->tidyModules = $tidyModules; + $this->aliases = $aliases; + $this->dtdPublic = $dtd_public; + $this->dtdSystem = $dtd_system; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DoctypeRegistry.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DoctypeRegistry.php new file mode 100644 index 0000000..acc1d64 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DoctypeRegistry.php @@ -0,0 +1,142 @@ +doctypes[$doctype->name] = $doctype; + $name = $doctype->name; + // hookup aliases + foreach ($doctype->aliases as $alias) { + if (isset($this->doctypes[$alias])) { + continue; + } + $this->aliases[$alias] = $name; + } + // remove old aliases + if (isset($this->aliases[$name])) { + unset($this->aliases[$name]); + } + return $doctype; + } + + /** + * Retrieves reference to a doctype of a certain name + * @note This function resolves aliases + * @note When possible, use the more fully-featured make() + * @param string $doctype Name of doctype + * @return HTMLPurifier_Doctype Editable doctype object + */ + public function get($doctype) + { + if (isset($this->aliases[$doctype])) { + $doctype = $this->aliases[$doctype]; + } + if (!isset($this->doctypes[$doctype])) { + trigger_error('Doctype ' . htmlspecialchars($doctype) . ' does not exist', E_USER_ERROR); + $anon = new HTMLPurifier_Doctype($doctype); + return $anon; + } + return $this->doctypes[$doctype]; + } + + /** + * Creates a doctype based on a configuration object, + * will perform initialization on the doctype + * @note Use this function to get a copy of doctype that config + * can hold on to (this is necessary in order to tell + * Generator whether or not the current document is XML + * based or not). + * @param HTMLPurifier_Config $config + * @return HTMLPurifier_Doctype + */ + public function make($config) + { + return clone $this->get($this->getDoctypeFromConfig($config)); + } + + /** + * Retrieves the doctype from the configuration object + * @param HTMLPurifier_Config $config + * @return string + */ + public function getDoctypeFromConfig($config) + { + // recommended test + $doctype = $config->get('HTML.Doctype'); + if (!empty($doctype)) { + return $doctype; + } + $doctype = $config->get('HTML.CustomDoctype'); + if (!empty($doctype)) { + return $doctype; + } + // backwards-compatibility + if ($config->get('HTML.XHTML')) { + $doctype = 'XHTML 1.0'; + } else { + $doctype = 'HTML 4.01'; + } + if ($config->get('HTML.Strict')) { + $doctype .= ' Strict'; + } else { + $doctype .= ' Transitional'; + } + return $doctype; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ElementDef.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ElementDef.php new file mode 100644 index 0000000..57cfd2b --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ElementDef.php @@ -0,0 +1,216 @@ +setup(), this array may also + * contain an array at index 0 that indicates which attribute + * collections to load into the full array. It may also + * contain string indentifiers in lieu of HTMLPurifier_AttrDef, + * see HTMLPurifier_AttrTypes on how they are expanded during + * HTMLPurifier_HTMLDefinition->setup() processing. + */ + public $attr = array(); + + // XXX: Design note: currently, it's not possible to override + // previously defined AttrTransforms without messing around with + // the final generated config. This is by design; a previous version + // used an associated list of attr_transform, but it was extremely + // easy to accidentally override other attribute transforms by + // forgetting to specify an index (and just using 0.) While we + // could check this by checking the index number and complaining, + // there is a second problem which is that it is not at all easy to + // tell when something is getting overridden. Combine this with a + // codebase where this isn't really being used, and it's perfect for + // nuking. + + /** + * List of tags HTMLPurifier_AttrTransform to be done before validation. + * @type array + */ + public $attr_transform_pre = array(); + + /** + * List of tags HTMLPurifier_AttrTransform to be done after validation. + * @type array + */ + public $attr_transform_post = array(); + + /** + * HTMLPurifier_ChildDef of this tag. + * @type HTMLPurifier_ChildDef + */ + public $child; + + /** + * Abstract string representation of internal ChildDef rules. + * @see HTMLPurifier_ContentSets for how this is parsed and then transformed + * into an HTMLPurifier_ChildDef. + * @warning This is a temporary variable that is not available after + * being processed by HTMLDefinition + * @type string + */ + public $content_model; + + /** + * Value of $child->type, used to determine which ChildDef to use, + * used in combination with $content_model. + * @warning This must be lowercase + * @warning This is a temporary variable that is not available after + * being processed by HTMLDefinition + * @type string + */ + public $content_model_type; + + /** + * Does the element have a content model (#PCDATA | Inline)*? This + * is important for chameleon ins and del processing in + * HTMLPurifier_ChildDef_Chameleon. Dynamically set: modules don't + * have to worry about this one. + * @type bool + */ + public $descendants_are_inline = false; + + /** + * List of the names of required attributes this element has. + * Dynamically populated by HTMLPurifier_HTMLDefinition::getElement() + * @type array + */ + public $required_attr = array(); + + /** + * Lookup table of tags excluded from all descendants of this tag. + * @type array + * @note SGML permits exclusions for all descendants, but this is + * not possible with DTDs or XML Schemas. W3C has elected to + * use complicated compositions of content_models to simulate + * exclusion for children, but we go the simpler, SGML-style + * route of flat-out exclusions, which correctly apply to + * all descendants and not just children. Note that the XHTML + * Modularization Abstract Modules are blithely unaware of such + * distinctions. + */ + public $excludes = array(); + + /** + * This tag is explicitly auto-closed by the following tags. + * @type array + */ + public $autoclose = array(); + + /** + * If a foreign element is found in this element, test if it is + * allowed by this sub-element; if it is, instead of closing the + * current element, place it inside this element. + * @type string + */ + public $wrap; + + /** + * Whether or not this is a formatting element affected by the + * "Active Formatting Elements" algorithm. + * @type bool + */ + public $formatting; + + /** + * Low-level factory constructor for creating new standalone element defs + */ + public static function create($content_model, $content_model_type, $attr) + { + $def = new HTMLPurifier_ElementDef(); + $def->content_model = $content_model; + $def->content_model_type = $content_model_type; + $def->attr = $attr; + return $def; + } + + /** + * Merges the values of another element definition into this one. + * Values from the new element def take precedence if a value is + * not mergeable. + * @param HTMLPurifier_ElementDef $def + */ + public function mergeIn($def) + { + // later keys takes precedence + foreach ($def->attr as $k => $v) { + if ($k === 0) { + // merge in the includes + // sorry, no way to override an include + foreach ($v as $v2) { + $this->attr[0][] = $v2; + } + continue; + } + if ($v === false) { + if (isset($this->attr[$k])) { + unset($this->attr[$k]); + } + continue; + } + $this->attr[$k] = $v; + } + $this->_mergeAssocArray($this->excludes, $def->excludes); + $this->attr_transform_pre = array_merge($this->attr_transform_pre, $def->attr_transform_pre); + $this->attr_transform_post = array_merge($this->attr_transform_post, $def->attr_transform_post); + + if (!empty($def->content_model)) { + $this->content_model = + str_replace("#SUPER", (string)$this->content_model, $def->content_model); + $this->child = false; + } + if (!empty($def->content_model_type)) { + $this->content_model_type = $def->content_model_type; + $this->child = false; + } + if (!is_null($def->child)) { + $this->child = $def->child; + } + if (!is_null($def->formatting)) { + $this->formatting = $def->formatting; + } + if ($def->descendants_are_inline) { + $this->descendants_are_inline = $def->descendants_are_inline; + } + } + + /** + * Merges one array into another, removes values which equal false + * @param $a1 Array by reference that is merged into + * @param $a2 Array that merges into $a1 + */ + private function _mergeAssocArray(&$a1, $a2) + { + foreach ($a2 as $k => $v) { + if ($v === false) { + if (isset($a1[$k])) { + unset($a1[$k]); + } + continue; + } + $a1[$k] = $v; + } + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Encoder.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Encoder.php new file mode 100644 index 0000000..d4791cc --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Encoder.php @@ -0,0 +1,617 @@ += $c) { + $r .= self::unsafeIconv($in, $out, substr($text, $i)); + break; + } + // wibble the boundary + if (0x80 != (0xC0 & ord($text[$i + $max_chunk_size]))) { + $chunk_size = $max_chunk_size; + } elseif (0x80 != (0xC0 & ord($text[$i + $max_chunk_size - 1]))) { + $chunk_size = $max_chunk_size - 1; + } elseif (0x80 != (0xC0 & ord($text[$i + $max_chunk_size - 2]))) { + $chunk_size = $max_chunk_size - 2; + } elseif (0x80 != (0xC0 & ord($text[$i + $max_chunk_size - 3]))) { + $chunk_size = $max_chunk_size - 3; + } else { + return false; // rather confusing UTF-8... + } + $chunk = substr($text, $i, $chunk_size); // substr doesn't mind overlong lengths + $r .= self::unsafeIconv($in, $out, $chunk); + $i += $chunk_size; + } + return $r; + } else { + return false; + } + } else { + return false; + } + } + + /** + * Cleans a UTF-8 string for well-formedness and SGML validity + * + * It will parse according to UTF-8 and return a valid UTF8 string, with + * non-SGML codepoints excluded. + * + * Specifically, it will permit: + * \x{9}\x{A}\x{D}\x{20}-\x{7E}\x{A0}-\x{D7FF}\x{E000}-\x{FFFD}\x{10000}-\x{10FFFF} + * Source: https://www.w3.org/TR/REC-xml/#NT-Char + * Arguably this function should be modernized to the HTML5 set + * of allowed characters: + * https://www.w3.org/TR/html5/syntax.html#preprocessing-the-input-stream + * which simultaneously expand and restrict the set of allowed characters. + * + * @param string $str The string to clean + * @param bool $force_php + * @return string + * + * @note Just for reference, the non-SGML code points are 0 to 31 and + * 127 to 159, inclusive. However, we allow code points 9, 10 + * and 13, which are the tab, line feed and carriage return + * respectively. 128 and above the code points map to multibyte + * UTF-8 representations. + * + * @note Fallback code adapted from utf8ToUnicode by Henri Sivonen and + * hsivonen@iki.fi at under the + * LGPL license. Notes on what changed are inside, but in general, + * the original code transformed UTF-8 text into an array of integer + * Unicode codepoints. Understandably, transforming that back to + * a string would be somewhat expensive, so the function was modded to + * directly operate on the string. However, this discourages code + * reuse, and the logic enumerated here would be useful for any + * function that needs to be able to understand UTF-8 characters. + * As of right now, only smart lossless character encoding converters + * would need that, and I'm probably not going to implement them. + */ + public static function cleanUTF8($str, $force_php = false) + { + // UTF-8 validity is checked since PHP 4.3.5 + // This is an optimization: if the string is already valid UTF-8, no + // need to do PHP stuff. 99% of the time, this will be the case. + if (preg_match( + '/^[\x{9}\x{A}\x{D}\x{20}-\x{7E}\x{A0}-\x{D7FF}\x{E000}-\x{FFFD}\x{10000}-\x{10FFFF}]*$/Du', + $str + )) { + return $str; + } + + $mState = 0; // cached expected number of octets after the current octet + // until the beginning of the next UTF8 character sequence + $mUcs4 = 0; // cached Unicode character + $mBytes = 1; // cached expected number of octets in the current sequence + + // original code involved an $out that was an array of Unicode + // codepoints. Instead of having to convert back into UTF-8, we've + // decided to directly append valid UTF-8 characters onto a string + // $out once they're done. $char accumulates raw bytes, while $mUcs4 + // turns into the Unicode code point, so there's some redundancy. + + $out = ''; + $char = ''; + + $len = strlen($str); + for ($i = 0; $i < $len; $i++) { + $in = ord($str[$i]); + $char .= $str[$i]; // append byte to char + if (0 == $mState) { + // When mState is zero we expect either a US-ASCII character + // or a multi-octet sequence. + if (0 == (0x80 & ($in))) { + // US-ASCII, pass straight through. + if (($in <= 31 || $in == 127) && + !($in == 9 || $in == 13 || $in == 10) // save \r\t\n + ) { + // control characters, remove + } else { + $out .= $char; + } + // reset + $char = ''; + $mBytes = 1; + } elseif (0xC0 == (0xE0 & ($in))) { + // First octet of 2 octet sequence + $mUcs4 = ($in); + $mUcs4 = ($mUcs4 & 0x1F) << 6; + $mState = 1; + $mBytes = 2; + } elseif (0xE0 == (0xF0 & ($in))) { + // First octet of 3 octet sequence + $mUcs4 = ($in); + $mUcs4 = ($mUcs4 & 0x0F) << 12; + $mState = 2; + $mBytes = 3; + } elseif (0xF0 == (0xF8 & ($in))) { + // First octet of 4 octet sequence + $mUcs4 = ($in); + $mUcs4 = ($mUcs4 & 0x07) << 18; + $mState = 3; + $mBytes = 4; + } elseif (0xF8 == (0xFC & ($in))) { + // First octet of 5 octet sequence. + // + // This is illegal because the encoded codepoint must be + // either: + // (a) not the shortest form or + // (b) outside the Unicode range of 0-0x10FFFF. + // Rather than trying to resynchronize, we will carry on + // until the end of the sequence and let the later error + // handling code catch it. + $mUcs4 = ($in); + $mUcs4 = ($mUcs4 & 0x03) << 24; + $mState = 4; + $mBytes = 5; + } elseif (0xFC == (0xFE & ($in))) { + // First octet of 6 octet sequence, see comments for 5 + // octet sequence. + $mUcs4 = ($in); + $mUcs4 = ($mUcs4 & 1) << 30; + $mState = 5; + $mBytes = 6; + } else { + // Current octet is neither in the US-ASCII range nor a + // legal first octet of a multi-octet sequence. + $mState = 0; + $mUcs4 = 0; + $mBytes = 1; + $char = ''; + } + } else { + // When mState is non-zero, we expect a continuation of the + // multi-octet sequence + if (0x80 == (0xC0 & ($in))) { + // Legal continuation. + $shift = ($mState - 1) * 6; + $tmp = $in; + $tmp = ($tmp & 0x0000003F) << $shift; + $mUcs4 |= $tmp; + + if (0 == --$mState) { + // End of the multi-octet sequence. mUcs4 now contains + // the final Unicode codepoint to be output + + // Check for illegal sequences and codepoints. + + // From Unicode 3.1, non-shortest form is illegal + if (((2 == $mBytes) && ($mUcs4 < 0x0080)) || + ((3 == $mBytes) && ($mUcs4 < 0x0800)) || + ((4 == $mBytes) && ($mUcs4 < 0x10000)) || + (4 < $mBytes) || + // From Unicode 3.2, surrogate characters = illegal + (($mUcs4 & 0xFFFFF800) == 0xD800) || + // Codepoints outside the Unicode range are illegal + ($mUcs4 > 0x10FFFF) + ) { + + } elseif (0xFEFF != $mUcs4 && // omit BOM + // check for valid Char unicode codepoints + ( + 0x9 == $mUcs4 || + 0xA == $mUcs4 || + 0xD == $mUcs4 || + (0x20 <= $mUcs4 && 0x7E >= $mUcs4) || + // 7F-9F is not strictly prohibited by XML, + // but it is non-SGML, and thus we don't allow it + (0xA0 <= $mUcs4 && 0xD7FF >= $mUcs4) || + (0xE000 <= $mUcs4 && 0xFFFD >= $mUcs4) || + (0x10000 <= $mUcs4 && 0x10FFFF >= $mUcs4) + ) + ) { + $out .= $char; + } + // initialize UTF8 cache (reset) + $mState = 0; + $mUcs4 = 0; + $mBytes = 1; + $char = ''; + } + } else { + // ((0xC0 & (*in) != 0x80) && (mState != 0)) + // Incomplete multi-octet sequence. + // used to result in complete fail, but we'll reset + $mState = 0; + $mUcs4 = 0; + $mBytes = 1; + $char =''; + } + } + } + return $out; + } + + /** + * Translates a Unicode codepoint into its corresponding UTF-8 character. + * @note Based on Feyd's function at + * , + * which is in public domain. + * @note While we're going to do code point parsing anyway, a good + * optimization would be to refuse to translate code points that + * are non-SGML characters. However, this could lead to duplication. + * @note This is very similar to the unichr function in + * maintenance/generate-entity-file.php (although this is superior, + * due to its sanity checks). + */ + + // +----------+----------+----------+----------+ + // | 33222222 | 22221111 | 111111 | | + // | 10987654 | 32109876 | 54321098 | 76543210 | bit + // +----------+----------+----------+----------+ + // | | | | 0xxxxxxx | 1 byte 0x00000000..0x0000007F + // | | | 110yyyyy | 10xxxxxx | 2 byte 0x00000080..0x000007FF + // | | 1110zzzz | 10yyyyyy | 10xxxxxx | 3 byte 0x00000800..0x0000FFFF + // | 11110www | 10wwzzzz | 10yyyyyy | 10xxxxxx | 4 byte 0x00010000..0x0010FFFF + // +----------+----------+----------+----------+ + // | 00000000 | 00011111 | 11111111 | 11111111 | Theoretical upper limit of legal scalars: 2097151 (0x001FFFFF) + // | 00000000 | 00010000 | 11111111 | 11111111 | Defined upper limit of legal scalar codes + // +----------+----------+----------+----------+ + + public static function unichr($code) + { + if ($code > 1114111 or $code < 0 or + ($code >= 55296 and $code <= 57343) ) { + // bits are set outside the "valid" range as defined + // by UNICODE 4.1.0 + return ''; + } + + $x = $y = $z = $w = 0; + if ($code < 128) { + // regular ASCII character + $x = $code; + } else { + // set up bits for UTF-8 + $x = ($code & 63) | 128; + if ($code < 2048) { + $y = (($code & 2047) >> 6) | 192; + } else { + $y = (($code & 4032) >> 6) | 128; + if ($code < 65536) { + $z = (($code >> 12) & 15) | 224; + } else { + $z = (($code >> 12) & 63) | 128; + $w = (($code >> 18) & 7) | 240; + } + } + } + // set up the actual character + $ret = ''; + if ($w) { + $ret .= chr($w); + } + if ($z) { + $ret .= chr($z); + } + if ($y) { + $ret .= chr($y); + } + $ret .= chr($x); + + return $ret; + } + + /** + * @return bool + */ + public static function iconvAvailable() + { + static $iconv = null; + if ($iconv === null) { + $iconv = function_exists('iconv') && self::testIconvTruncateBug() != self::ICONV_UNUSABLE; + } + return $iconv; + } + + /** + * Convert a string to UTF-8 based on configuration. + * @param string $str The string to convert + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return string + */ + public static function convertToUTF8($str, $config, $context) + { + $encoding = $config->get('Core.Encoding'); + if ($encoding === 'utf-8') { + return $str; + } + static $iconv = null; + if ($iconv === null) { + $iconv = self::iconvAvailable(); + } + if ($iconv && !$config->get('Test.ForceNoIconv')) { + // unaffected by bugs, since UTF-8 support all characters + $str = self::unsafeIconv($encoding, 'utf-8//IGNORE', $str); + if ($str === false) { + // $encoding is not a valid encoding + trigger_error('Invalid encoding ' . $encoding, E_USER_ERROR); + return ''; + } + // If the string is bjorked by Shift_JIS or a similar encoding + // that doesn't support all of ASCII, convert the naughty + // characters to their true byte-wise ASCII/UTF-8 equivalents. + $str = strtr($str, self::testEncodingSupportsASCII($encoding)); + return $str; + } elseif ($encoding === 'iso-8859-1' && function_exists('mb_convert_encoding')) { + $str = mb_convert_encoding($str, 'UTF-8', 'ISO-8859-1'); + return $str; + } + $bug = HTMLPurifier_Encoder::testIconvTruncateBug(); + if ($bug == self::ICONV_OK) { + trigger_error('Encoding not supported, please install iconv', E_USER_ERROR); + } else { + trigger_error( + 'You have a buggy version of iconv, see https://bugs.php.net/bug.php?id=48147 ' . + 'and http://sourceware.org/bugzilla/show_bug.cgi?id=13541', + E_USER_ERROR + ); + } + } + + /** + * Converts a string from UTF-8 based on configuration. + * @param string $str The string to convert + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return string + * @note Currently, this is a lossy conversion, with unexpressable + * characters being omitted. + */ + public static function convertFromUTF8($str, $config, $context) + { + $encoding = $config->get('Core.Encoding'); + if ($escape = $config->get('Core.EscapeNonASCIICharacters')) { + $str = self::convertToASCIIDumbLossless($str); + } + if ($encoding === 'utf-8') { + return $str; + } + static $iconv = null; + if ($iconv === null) { + $iconv = self::iconvAvailable(); + } + if ($iconv && !$config->get('Test.ForceNoIconv')) { + // Undo our previous fix in convertToUTF8, otherwise iconv will barf + $ascii_fix = self::testEncodingSupportsASCII($encoding); + if (!$escape && !empty($ascii_fix)) { + $clear_fix = array(); + foreach ($ascii_fix as $utf8 => $native) { + $clear_fix[$utf8] = ''; + } + $str = strtr($str, $clear_fix); + } + $str = strtr($str, array_flip($ascii_fix)); + // Normal stuff + $str = self::iconv('utf-8', $encoding . '//IGNORE', $str); + return $str; + } elseif ($encoding === 'iso-8859-1' && function_exists('mb_convert_encoding')) { + $str = mb_convert_encoding($str, 'ISO-8859-1', 'UTF-8'); + return $str; + } + trigger_error('Encoding not supported', E_USER_ERROR); + // You might be tempted to assume that the ASCII representation + // might be OK, however, this is *not* universally true over all + // encodings. So we take the conservative route here, rather + // than forcibly turn on %Core.EscapeNonASCIICharacters + } + + /** + * Lossless (character-wise) conversion of HTML to ASCII + * @param string $str UTF-8 string to be converted to ASCII + * @return string ASCII encoded string with non-ASCII character entity-ized + * @warning Adapted from MediaWiki, claiming fair use: this is a common + * algorithm. If you disagree with this license fudgery, + * implement it yourself. + * @note Uses decimal numeric entities since they are best supported. + * @note This is a DUMB function: it has no concept of keeping + * character entities that the projected character encoding + * can allow. We could possibly implement a smart version + * but that would require it to also know which Unicode + * codepoints the charset supported (not an easy task). + * @note Sort of with cleanUTF8() but it assumes that $str is + * well-formed UTF-8 + */ + public static function convertToASCIIDumbLossless($str) + { + $bytesleft = 0; + $result = ''; + $working = 0; + $len = strlen($str); + for ($i = 0; $i < $len; $i++) { + $bytevalue = ord($str[$i]); + if ($bytevalue <= 0x7F) { //0xxx xxxx + $result .= chr($bytevalue); + $bytesleft = 0; + } elseif ($bytevalue <= 0xBF) { //10xx xxxx + $working = $working << 6; + $working += ($bytevalue & 0x3F); + $bytesleft--; + if ($bytesleft <= 0) { + $result .= "&#" . $working . ";"; + } + } elseif ($bytevalue <= 0xDF) { //110x xxxx + $working = $bytevalue & 0x1F; + $bytesleft = 1; + } elseif ($bytevalue <= 0xEF) { //1110 xxxx + $working = $bytevalue & 0x0F; + $bytesleft = 2; + } else { //1111 0xxx + $working = $bytevalue & 0x07; + $bytesleft = 3; + } + } + return $result; + } + + /** No bugs detected in iconv. */ + const ICONV_OK = 0; + + /** Iconv truncates output if converting from UTF-8 to another + * character set with //IGNORE, and a non-encodable character is found */ + const ICONV_TRUNCATES = 1; + + /** Iconv does not support //IGNORE, making it unusable for + * transcoding purposes */ + const ICONV_UNUSABLE = 2; + + /** + * glibc iconv has a known bug where it doesn't handle the magic + * //IGNORE stanza correctly. In particular, rather than ignore + * characters, it will return an EILSEQ after consuming some number + * of characters, and expect you to restart iconv as if it were + * an E2BIG. Old versions of PHP did not respect the errno, and + * returned the fragment, so as a result you would see iconv + * mysteriously truncating output. We can work around this by + * manually chopping our input into segments of about 8000 + * characters, as long as PHP ignores the error code. If PHP starts + * paying attention to the error code, iconv becomes unusable. + * + * @return int Error code indicating severity of bug. + */ + public static function testIconvTruncateBug() + { + static $code = null; + if ($code === null) { + // better not use iconv, otherwise infinite loop! + $r = self::unsafeIconv('utf-8', 'ascii//IGNORE', "\xCE\xB1" . str_repeat('a', 9000)); + if ($r === false) { + $code = self::ICONV_UNUSABLE; + } elseif (($c = strlen($r)) < 9000) { + $code = self::ICONV_TRUNCATES; + } elseif ($c > 9000) { + trigger_error( + 'Your copy of iconv is extremely buggy. Please notify HTML Purifier maintainers: ' . + 'include your iconv version as per phpversion()', + E_USER_ERROR + ); + } else { + $code = self::ICONV_OK; + } + } + return $code; + } + + /** + * This expensive function tests whether or not a given character + * encoding supports ASCII. 7/8-bit encodings like Shift_JIS will + * fail this test, and require special processing. Variable width + * encodings shouldn't ever fail. + * + * @param string $encoding Encoding name to test, as per iconv format + * @param bool $bypass Whether or not to bypass the precompiled arrays. + * @return Array of UTF-8 characters to their corresponding ASCII, + * which can be used to "undo" any overzealous iconv action. + */ + public static function testEncodingSupportsASCII($encoding, $bypass = false) + { + // All calls to iconv here are unsafe, proof by case analysis: + // If ICONV_OK, no difference. + // If ICONV_TRUNCATE, all calls involve one character inputs, + // so bug is not triggered. + // If ICONV_UNUSABLE, this call is irrelevant + static $encodings = array(); + if (!$bypass) { + if (isset($encodings[$encoding])) { + return $encodings[$encoding]; + } + $lenc = strtolower($encoding); + switch ($lenc) { + case 'shift_jis': + return array("\xC2\xA5" => '\\', "\xE2\x80\xBE" => '~'); + case 'johab': + return array("\xE2\x82\xA9" => '\\'); + } + if (strpos($lenc, 'iso-8859-') === 0) { + return array(); + } + } + $ret = array(); + if (self::unsafeIconv('UTF-8', $encoding, 'a') === false) { + return false; + } + for ($i = 0x20; $i <= 0x7E; $i++) { // all printable ASCII chars + $c = chr($i); // UTF-8 char + $r = self::unsafeIconv('UTF-8', "$encoding//IGNORE", $c); // initial conversion + if ($r === '' || + // This line is needed for iconv implementations that do not + // omit characters that do not exist in the target character set + ($r === $c && self::unsafeIconv($encoding, 'UTF-8//IGNORE', $r) !== $c) + ) { + // Reverse engineer: what's the UTF-8 equiv of this byte + // sequence? This assumes that there's no variable width + // encoding that doesn't support ASCII. + $ret[self::unsafeIconv($encoding, 'UTF-8//IGNORE', $c)] = $c; + } + } + $encodings[$encoding] = $ret; + return $ret; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/EntityLookup.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/EntityLookup.php new file mode 100644 index 0000000..f12ff13 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/EntityLookup.php @@ -0,0 +1,48 @@ +table = unserialize(file_get_contents($file)); + } + + /** + * Retrieves sole instance of the object. + * @param bool|HTMLPurifier_EntityLookup $prototype Optional prototype of custom lookup table to overload with. + * @return HTMLPurifier_EntityLookup + */ + public static function instance($prototype = false) + { + // no references, since PHP doesn't copy unless modified + static $instance = null; + if ($prototype) { + $instance = $prototype; + } elseif (!$instance) { + $instance = new HTMLPurifier_EntityLookup(); + $instance->setup(); + } + return $instance; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/EntityLookup/entities.ser b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/EntityLookup/entities.ser new file mode 100644 index 0000000..e8b0812 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/EntityLookup/entities.ser @@ -0,0 +1 @@ +a:253:{s:4:"fnof";s:2:"ƒ";s:5:"Alpha";s:2:"Α";s:4:"Beta";s:2:"Β";s:5:"Gamma";s:2:"Γ";s:5:"Delta";s:2:"Δ";s:7:"Epsilon";s:2:"Ε";s:4:"Zeta";s:2:"Ζ";s:3:"Eta";s:2:"Η";s:5:"Theta";s:2:"Θ";s:4:"Iota";s:2:"Ι";s:5:"Kappa";s:2:"Κ";s:6:"Lambda";s:2:"Λ";s:2:"Mu";s:2:"Μ";s:2:"Nu";s:2:"Ν";s:2:"Xi";s:2:"Ξ";s:7:"Omicron";s:2:"Ο";s:2:"Pi";s:2:"Π";s:3:"Rho";s:2:"Ρ";s:5:"Sigma";s:2:"Σ";s:3:"Tau";s:2:"Τ";s:7:"Upsilon";s:2:"Υ";s:3:"Phi";s:2:"Φ";s:3:"Chi";s:2:"Χ";s:3:"Psi";s:2:"Ψ";s:5:"Omega";s:2:"Ω";s:5:"alpha";s:2:"α";s:4:"beta";s:2:"β";s:5:"gamma";s:2:"γ";s:5:"delta";s:2:"δ";s:7:"epsilon";s:2:"ε";s:4:"zeta";s:2:"ζ";s:3:"eta";s:2:"η";s:5:"theta";s:2:"θ";s:4:"iota";s:2:"ι";s:5:"kappa";s:2:"κ";s:6:"lambda";s:2:"λ";s:2:"mu";s:2:"μ";s:2:"nu";s:2:"ν";s:2:"xi";s:2:"ξ";s:7:"omicron";s:2:"ο";s:2:"pi";s:2:"π";s:3:"rho";s:2:"ρ";s:6:"sigmaf";s:2:"ς";s:5:"sigma";s:2:"σ";s:3:"tau";s:2:"τ";s:7:"upsilon";s:2:"υ";s:3:"phi";s:2:"φ";s:3:"chi";s:2:"χ";s:3:"psi";s:2:"ψ";s:5:"omega";s:2:"ω";s:8:"thetasym";s:2:"ϑ";s:5:"upsih";s:2:"ϒ";s:3:"piv";s:2:"ϖ";s:4:"bull";s:3:"•";s:6:"hellip";s:3:"…";s:5:"prime";s:3:"′";s:5:"Prime";s:3:"″";s:5:"oline";s:3:"‾";s:5:"frasl";s:3:"⁄";s:6:"weierp";s:3:"℘";s:5:"image";s:3:"ℑ";s:4:"real";s:3:"ℜ";s:5:"trade";s:3:"™";s:7:"alefsym";s:3:"ℵ";s:4:"larr";s:3:"←";s:4:"uarr";s:3:"↑";s:4:"rarr";s:3:"→";s:4:"darr";s:3:"↓";s:4:"harr";s:3:"↔";s:5:"crarr";s:3:"↵";s:4:"lArr";s:3:"⇐";s:4:"uArr";s:3:"⇑";s:4:"rArr";s:3:"⇒";s:4:"dArr";s:3:"⇓";s:4:"hArr";s:3:"⇔";s:6:"forall";s:3:"∀";s:4:"part";s:3:"∂";s:5:"exist";s:3:"∃";s:5:"empty";s:3:"∅";s:5:"nabla";s:3:"∇";s:4:"isin";s:3:"∈";s:5:"notin";s:3:"∉";s:2:"ni";s:3:"∋";s:4:"prod";s:3:"∏";s:3:"sum";s:3:"∑";s:5:"minus";s:3:"−";s:6:"lowast";s:3:"∗";s:5:"radic";s:3:"√";s:4:"prop";s:3:"∝";s:5:"infin";s:3:"∞";s:3:"ang";s:3:"∠";s:3:"and";s:3:"∧";s:2:"or";s:3:"∨";s:3:"cap";s:3:"∩";s:3:"cup";s:3:"∪";s:3:"int";s:3:"∫";s:6:"there4";s:3:"∴";s:3:"sim";s:3:"∼";s:4:"cong";s:3:"≅";s:5:"asymp";s:3:"≈";s:2:"ne";s:3:"≠";s:5:"equiv";s:3:"≡";s:2:"le";s:3:"≤";s:2:"ge";s:3:"≥";s:3:"sub";s:3:"⊂";s:3:"sup";s:3:"⊃";s:4:"nsub";s:3:"⊄";s:4:"sube";s:3:"⊆";s:4:"supe";s:3:"⊇";s:5:"oplus";s:3:"⊕";s:6:"otimes";s:3:"⊗";s:4:"perp";s:3:"⊥";s:4:"sdot";s:3:"⋅";s:5:"lceil";s:3:"⌈";s:5:"rceil";s:3:"⌉";s:6:"lfloor";s:3:"⌊";s:6:"rfloor";s:3:"⌋";s:4:"lang";s:3:"〈";s:4:"rang";s:3:"〉";s:3:"loz";s:3:"◊";s:6:"spades";s:3:"♠";s:5:"clubs";s:3:"♣";s:6:"hearts";s:3:"♥";s:5:"diams";s:3:"♦";s:4:"quot";s:1:""";s:3:"amp";s:1:"&";s:2:"lt";s:1:"<";s:2:"gt";s:1:">";s:4:"apos";s:1:"'";s:5:"OElig";s:2:"Œ";s:5:"oelig";s:2:"œ";s:6:"Scaron";s:2:"Š";s:6:"scaron";s:2:"š";s:4:"Yuml";s:2:"Ÿ";s:4:"circ";s:2:"ˆ";s:5:"tilde";s:2:"˜";s:4:"ensp";s:3:" ";s:4:"emsp";s:3:" ";s:6:"thinsp";s:3:" ";s:4:"zwnj";s:3:"‌";s:3:"zwj";s:3:"‍";s:3:"lrm";s:3:"‎";s:3:"rlm";s:3:"‏";s:5:"ndash";s:3:"–";s:5:"mdash";s:3:"—";s:5:"lsquo";s:3:"‘";s:5:"rsquo";s:3:"’";s:5:"sbquo";s:3:"‚";s:5:"ldquo";s:3:"“";s:5:"rdquo";s:3:"”";s:5:"bdquo";s:3:"„";s:6:"dagger";s:3:"†";s:6:"Dagger";s:3:"‡";s:6:"permil";s:3:"‰";s:6:"lsaquo";s:3:"‹";s:6:"rsaquo";s:3:"›";s:4:"euro";s:3:"€";s:4:"nbsp";s:2:" ";s:5:"iexcl";s:2:"¡";s:4:"cent";s:2:"¢";s:5:"pound";s:2:"£";s:6:"curren";s:2:"¤";s:3:"yen";s:2:"¥";s:6:"brvbar";s:2:"¦";s:4:"sect";s:2:"§";s:3:"uml";s:2:"¨";s:4:"copy";s:2:"©";s:4:"ordf";s:2:"ª";s:5:"laquo";s:2:"«";s:3:"not";s:2:"¬";s:3:"shy";s:2:"­";s:3:"reg";s:2:"®";s:4:"macr";s:2:"¯";s:3:"deg";s:2:"°";s:6:"plusmn";s:2:"±";s:4:"sup2";s:2:"²";s:4:"sup3";s:2:"³";s:5:"acute";s:2:"´";s:5:"micro";s:2:"µ";s:4:"para";s:2:"¶";s:6:"middot";s:2:"·";s:5:"cedil";s:2:"¸";s:4:"sup1";s:2:"¹";s:4:"ordm";s:2:"º";s:5:"raquo";s:2:"»";s:6:"frac14";s:2:"¼";s:6:"frac12";s:2:"½";s:6:"frac34";s:2:"¾";s:6:"iquest";s:2:"¿";s:6:"Agrave";s:2:"À";s:6:"Aacute";s:2:"Á";s:5:"Acirc";s:2:"Â";s:6:"Atilde";s:2:"Ã";s:4:"Auml";s:2:"Ä";s:5:"Aring";s:2:"Å";s:5:"AElig";s:2:"Æ";s:6:"Ccedil";s:2:"Ç";s:6:"Egrave";s:2:"È";s:6:"Eacute";s:2:"É";s:5:"Ecirc";s:2:"Ê";s:4:"Euml";s:2:"Ë";s:6:"Igrave";s:2:"Ì";s:6:"Iacute";s:2:"Í";s:5:"Icirc";s:2:"Î";s:4:"Iuml";s:2:"Ï";s:3:"ETH";s:2:"Ð";s:6:"Ntilde";s:2:"Ñ";s:6:"Ograve";s:2:"Ò";s:6:"Oacute";s:2:"Ó";s:5:"Ocirc";s:2:"Ô";s:6:"Otilde";s:2:"Õ";s:4:"Ouml";s:2:"Ö";s:5:"times";s:2:"×";s:6:"Oslash";s:2:"Ø";s:6:"Ugrave";s:2:"Ù";s:6:"Uacute";s:2:"Ú";s:5:"Ucirc";s:2:"Û";s:4:"Uuml";s:2:"Ü";s:6:"Yacute";s:2:"Ý";s:5:"THORN";s:2:"Þ";s:5:"szlig";s:2:"ß";s:6:"agrave";s:2:"à";s:6:"aacute";s:2:"á";s:5:"acirc";s:2:"â";s:6:"atilde";s:2:"ã";s:4:"auml";s:2:"ä";s:5:"aring";s:2:"å";s:5:"aelig";s:2:"æ";s:6:"ccedil";s:2:"ç";s:6:"egrave";s:2:"è";s:6:"eacute";s:2:"é";s:5:"ecirc";s:2:"ê";s:4:"euml";s:2:"ë";s:6:"igrave";s:2:"ì";s:6:"iacute";s:2:"í";s:5:"icirc";s:2:"î";s:4:"iuml";s:2:"ï";s:3:"eth";s:2:"ð";s:6:"ntilde";s:2:"ñ";s:6:"ograve";s:2:"ò";s:6:"oacute";s:2:"ó";s:5:"ocirc";s:2:"ô";s:6:"otilde";s:2:"õ";s:4:"ouml";s:2:"ö";s:6:"divide";s:2:"÷";s:6:"oslash";s:2:"ø";s:6:"ugrave";s:2:"ù";s:6:"uacute";s:2:"ú";s:5:"ucirc";s:2:"û";s:4:"uuml";s:2:"ü";s:6:"yacute";s:2:"ý";s:5:"thorn";s:2:"þ";s:4:"yuml";s:2:"ÿ";} \ No newline at end of file diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/EntityParser.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/EntityParser.php new file mode 100644 index 0000000..0f2b83d --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/EntityParser.php @@ -0,0 +1,285 @@ +_semiOptionalPrefixRegex = "/&()()()($semi_optional)/"; + + $this->_textEntitiesRegex = + '/&(?:'. + // hex + '[#]x([a-fA-F0-9]+);?|'. + // dec + '[#]0*(\d+);?|'. + // string (mandatory semicolon) + // NB: order matters: match semicolon preferentially + '([A-Za-z_:][A-Za-z0-9.\-_:]*);|'. + // string (optional semicolon) + "($semi_optional)". + ')/'; + + $this->_attrEntitiesRegex = + '/&(?:'. + // hex + '[#]x([a-fA-F0-9]+);?|'. + // dec + '[#]0*(\d+);?|'. + // string (mandatory semicolon) + // NB: order matters: match semicolon preferentially + '([A-Za-z_:][A-Za-z0-9.\-_:]*);|'. + // string (optional semicolon) + // don't match if trailing is equals or alphanumeric (URL + // like) + "($semi_optional)(?![=;A-Za-z0-9])". + ')/'; + + } + + /** + * Substitute entities with the parsed equivalents. Use this on + * textual data in an HTML document (as opposed to attributes.) + * + * @param string $string String to have entities parsed. + * @return string Parsed string. + */ + public function substituteTextEntities($string) + { + return preg_replace_callback( + $this->_textEntitiesRegex, + array($this, 'entityCallback'), + $string + ); + } + + /** + * Substitute entities with the parsed equivalents. Use this on + * attribute contents in documents. + * + * @param string $string String to have entities parsed. + * @return string Parsed string. + */ + public function substituteAttrEntities($string) + { + return preg_replace_callback( + $this->_attrEntitiesRegex, + array($this, 'entityCallback'), + $string + ); + } + + /** + * Callback function for substituteNonSpecialEntities() that does the work. + * + * @param array $matches PCRE matches array, with 0 the entire match, and + * either index 1, 2 or 3 set with a hex value, dec value, + * or string (respectively). + * @return string Replacement string. + */ + + protected function entityCallback($matches) + { + $entity = $matches[0]; + $hex_part = isset($matches[1]) ? $matches[1] : null; + $dec_part = isset($matches[2]) ? $matches[2] : null; + $named_part = empty($matches[3]) ? (empty($matches[4]) ? "" : $matches[4]) : $matches[3]; + if ($hex_part !== NULL && $hex_part !== "") { + return HTMLPurifier_Encoder::unichr(hexdec($hex_part)); + } elseif ($dec_part !== NULL && $dec_part !== "") { + return HTMLPurifier_Encoder::unichr((int) $dec_part); + } else { + if (!$this->_entity_lookup) { + $this->_entity_lookup = HTMLPurifier_EntityLookup::instance(); + } + if (isset($this->_entity_lookup->table[$named_part])) { + return $this->_entity_lookup->table[$named_part]; + } else { + // exact match didn't match anything, so test if + // any of the semicolon optional match the prefix. + // Test that this is an EXACT match is important to + // prevent infinite loop + if (!empty($matches[3])) { + return preg_replace_callback( + $this->_semiOptionalPrefixRegex, + array($this, 'entityCallback'), + $entity + ); + } + return $entity; + } + } + } + + // LEGACY CODE BELOW + + /** + * Callback regex string for parsing entities. + * @type string + */ + protected $_substituteEntitiesRegex = + '/&(?:[#]x([a-fA-F0-9]+)|[#]0*(\d+)|([A-Za-z_:][A-Za-z0-9.\-_:]*));?/'; + // 1. hex 2. dec 3. string (XML style) + + /** + * Decimal to parsed string conversion table for special entities. + * @type array + */ + protected $_special_dec2str = + array( + 34 => '"', + 38 => '&', + 39 => "'", + 60 => '<', + 62 => '>' + ); + + /** + * Stripped entity names to decimal conversion table for special entities. + * @type array + */ + protected $_special_ent2dec = + array( + 'quot' => 34, + 'amp' => 38, + 'lt' => 60, + 'gt' => 62 + ); + + /** + * Substitutes non-special entities with their parsed equivalents. Since + * running this whenever you have parsed character is t3h 5uck, we run + * it before everything else. + * + * @param string $string String to have non-special entities parsed. + * @return string Parsed string. + */ + public function substituteNonSpecialEntities($string) + { + // it will try to detect missing semicolons, but don't rely on it + return preg_replace_callback( + $this->_substituteEntitiesRegex, + array($this, 'nonSpecialEntityCallback'), + $string + ); + } + + /** + * Callback function for substituteNonSpecialEntities() that does the work. + * + * @param array $matches PCRE matches array, with 0 the entire match, and + * either index 1, 2 or 3 set with a hex value, dec value, + * or string (respectively). + * @return string Replacement string. + */ + + protected function nonSpecialEntityCallback($matches) + { + // replaces all but big five + $entity = $matches[0]; + $is_num = (@$matches[0][1] === '#'); + if ($is_num) { + $is_hex = (@$entity[2] === 'x'); + $code = $is_hex ? hexdec($matches[1]) : (int) $matches[2]; + // abort for special characters + if (isset($this->_special_dec2str[$code])) { + return $entity; + } + return HTMLPurifier_Encoder::unichr($code); + } else { + if (isset($this->_special_ent2dec[$matches[3]])) { + return $entity; + } + if (!$this->_entity_lookup) { + $this->_entity_lookup = HTMLPurifier_EntityLookup::instance(); + } + if (isset($this->_entity_lookup->table[$matches[3]])) { + return $this->_entity_lookup->table[$matches[3]]; + } else { + return $entity; + } + } + } + + /** + * Substitutes only special entities with their parsed equivalents. + * + * @notice We try to avoid calling this function because otherwise, it + * would have to be called a lot (for every parsed section). + * + * @param string $string String to have non-special entities parsed. + * @return string Parsed string. + */ + public function substituteSpecialEntities($string) + { + return preg_replace_callback( + $this->_substituteEntitiesRegex, + array($this, 'specialEntityCallback'), + $string + ); + } + + /** + * Callback function for substituteSpecialEntities() that does the work. + * + * This callback has same syntax as nonSpecialEntityCallback(). + * + * @param array $matches PCRE-style matches array, with 0 the entire match, and + * either index 1, 2 or 3 set with a hex value, dec value, + * or string (respectively). + * @return string Replacement string. + */ + protected function specialEntityCallback($matches) + { + $entity = $matches[0]; + $is_num = (@$matches[0][1] === '#'); + if ($is_num) { + $is_hex = (@$entity[2] === 'x'); + $int = $is_hex ? hexdec($matches[1]) : (int) $matches[2]; + return isset($this->_special_dec2str[$int]) ? + $this->_special_dec2str[$int] : + $entity; + } else { + return isset($this->_special_ent2dec[$matches[3]]) ? + $this->_special_dec2str[$this->_special_ent2dec[$matches[3]]] : + $entity; + } + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ErrorCollector.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ErrorCollector.php new file mode 100644 index 0000000..d47e3f2 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ErrorCollector.php @@ -0,0 +1,244 @@ +locale =& $context->get('Locale'); + $this->context = $context; + $this->_current =& $this->_stacks[0]; + $this->errors =& $this->_stacks[0]; + } + + /** + * Sends an error message to the collector for later use + * @param int $severity Error severity, PHP error style (don't use E_USER_) + * @param string $msg Error message text + */ + public function send($severity, $msg) + { + $args = array(); + if (func_num_args() > 2) { + $args = func_get_args(); + array_shift($args); + unset($args[0]); + } + + $token = $this->context->get('CurrentToken', true); + $line = $token ? $token->line : $this->context->get('CurrentLine', true); + $col = $token ? $token->col : $this->context->get('CurrentCol', true); + $attr = $this->context->get('CurrentAttr', true); + + // perform special substitutions, also add custom parameters + $subst = array(); + if (!is_null($token)) { + $args['CurrentToken'] = $token; + } + if (!is_null($attr)) { + $subst['$CurrentAttr.Name'] = $attr; + if (isset($token->attr[$attr])) { + $subst['$CurrentAttr.Value'] = $token->attr[$attr]; + } + } + + if (empty($args)) { + $msg = $this->locale->getMessage($msg); + } else { + $msg = $this->locale->formatMessage($msg, $args); + } + + if (!empty($subst)) { + $msg = strtr($msg, $subst); + } + + // (numerically indexed) + $error = array( + self::LINENO => $line, + self::SEVERITY => $severity, + self::MESSAGE => $msg, + self::CHILDREN => array() + ); + $this->_current[] = $error; + + // NEW CODE BELOW ... + // Top-level errors are either: + // TOKEN type, if $value is set appropriately, or + // "syntax" type, if $value is null + $new_struct = new HTMLPurifier_ErrorStruct(); + $new_struct->type = HTMLPurifier_ErrorStruct::TOKEN; + if ($token) { + $new_struct->value = clone $token; + } + if (is_int($line) && is_int($col)) { + if (isset($this->lines[$line][$col])) { + $struct = $this->lines[$line][$col]; + } else { + $struct = $this->lines[$line][$col] = $new_struct; + } + // These ksorts may present a performance problem + ksort($this->lines[$line], SORT_NUMERIC); + } else { + if (isset($this->lines[-1])) { + $struct = $this->lines[-1]; + } else { + $struct = $this->lines[-1] = $new_struct; + } + } + ksort($this->lines, SORT_NUMERIC); + + // Now, check if we need to operate on a lower structure + if (!empty($attr)) { + $struct = $struct->getChild(HTMLPurifier_ErrorStruct::ATTR, $attr); + if (!$struct->value) { + $struct->value = array($attr, 'PUT VALUE HERE'); + } + } + if (!empty($cssprop)) { + $struct = $struct->getChild(HTMLPurifier_ErrorStruct::CSSPROP, $cssprop); + if (!$struct->value) { + // if we tokenize CSS this might be a little more difficult to do + $struct->value = array($cssprop, 'PUT VALUE HERE'); + } + } + + // Ok, structs are all setup, now time to register the error + $struct->addError($severity, $msg); + } + + /** + * Retrieves raw error data for custom formatter to use + */ + public function getRaw() + { + return $this->errors; + } + + /** + * Default HTML formatting implementation for error messages + * @param HTMLPurifier_Config $config Configuration, vital for HTML output nature + * @param array $errors Errors array to display; used for recursion. + * @return string + */ + public function getHTMLFormatted($config, $errors = null) + { + $ret = array(); + + $this->generator = new HTMLPurifier_Generator($config, $this->context); + if ($errors === null) { + $errors = $this->errors; + } + + // 'At line' message needs to be removed + + // generation code for new structure goes here. It needs to be recursive. + foreach ($this->lines as $line => $col_array) { + if ($line == -1) { + continue; + } + foreach ($col_array as $col => $struct) { + $this->_renderStruct($ret, $struct, $line, $col); + } + } + if (isset($this->lines[-1])) { + $this->_renderStruct($ret, $this->lines[-1]); + } + + if (empty($errors)) { + return '

    ' . $this->locale->getMessage('ErrorCollector: No errors') . '

    '; + } else { + return '
    • ' . implode('
    • ', $ret) . '
    '; + } + + } + + private function _renderStruct(&$ret, $struct, $line = null, $col = null) + { + $stack = array($struct); + $context_stack = array(array()); + while ($current = array_pop($stack)) { + $context = array_pop($context_stack); + foreach ($current->errors as $error) { + list($severity, $msg) = $error; + $string = ''; + $string .= '
    '; + // W3C uses an icon to indicate the severity of the error. + $error = $this->locale->getErrorName($severity); + $string .= "$error "; + if (!is_null($line) && !is_null($col)) { + $string .= "Line $line, Column $col: "; + } else { + $string .= 'End of Document: '; + } + $string .= '' . $this->generator->escape($msg) . ' '; + $string .= '
    '; + // Here, have a marker for the character on the column appropriate. + // Be sure to clip extremely long lines. + //$string .= '
    ';
    +                //$string .= '';
    +                //$string .= '
    '; + $ret[] = $string; + } + foreach ($current->children as $array) { + $context[] = $current; + $stack = array_merge($stack, array_reverse($array, true)); + for ($i = count($array); $i > 0; $i--) { + $context_stack[] = $context; + } + } + } + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ErrorStruct.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ErrorStruct.php new file mode 100644 index 0000000..cf869d3 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ErrorStruct.php @@ -0,0 +1,74 @@ +children[$type][$id])) { + $this->children[$type][$id] = new HTMLPurifier_ErrorStruct(); + $this->children[$type][$id]->type = $type; + } + return $this->children[$type][$id]; + } + + /** + * @param int $severity + * @param string $message + */ + public function addError($severity, $message) + { + $this->errors[] = array($severity, $message); + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Exception.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Exception.php new file mode 100644 index 0000000..be85b4c --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Exception.php @@ -0,0 +1,12 @@ +preFilter, + * 2->preFilter, 3->preFilter, purify, 3->postFilter, 2->postFilter, + * 1->postFilter. + * + * @note Methods are not declared abstract as it is perfectly legitimate + * for an implementation not to want anything to happen on a step + */ + +class HTMLPurifier_Filter +{ + + /** + * Name of the filter for identification purposes. + * @type string + */ + public $name; + + /** + * Pre-processor function, handles HTML before HTML Purifier + * @param string $html + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return string + */ + public function preFilter($html, $config, $context) + { + return $html; + } + + /** + * Post-processor function, handles HTML after HTML Purifier + * @param string $html + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return string + */ + public function postFilter($html, $config, $context) + { + return $html; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Filter/ExtractStyleBlocks.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Filter/ExtractStyleBlocks.php new file mode 100644 index 0000000..e7e3cac --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Filter/ExtractStyleBlocks.php @@ -0,0 +1,362 @@ + blocks from input HTML, cleans them up + * using CSSTidy, and then places them in $purifier->context->get('StyleBlocks') + * so they can be used elsewhere in the document. + * + * @note + * See tests/HTMLPurifier/Filter/ExtractStyleBlocksTest.php for + * sample usage. + * + * @note + * This filter can also be used on stylesheets not included in the + * document--something purists would probably prefer. Just directly + * call HTMLPurifier_Filter_ExtractStyleBlocks->cleanCSS() + */ +class HTMLPurifier_Filter_ExtractStyleBlocks extends HTMLPurifier_Filter +{ + /** + * @type string + */ + public $name = 'ExtractStyleBlocks'; + + /** + * @type array + */ + private $_styleMatches = array(); + + /** + * @type csstidy + */ + private $_tidy; + + /** + * @type HTMLPurifier_AttrDef_HTML_ID + */ + private $_id_attrdef; + + /** + * @type HTMLPurifier_AttrDef_CSS_Ident + */ + private $_class_attrdef; + + /** + * @type HTMLPurifier_AttrDef_Enum + */ + private $_enum_attrdef; + + /** + * @type HTMLPurifier_AttrDef_Enum + */ + private $_universal_attrdef; + + public function __construct() + { + $this->_tidy = new csstidy(); + $this->_tidy->set_cfg('lowercase_s', false); + $this->_id_attrdef = new HTMLPurifier_AttrDef_HTML_ID(true); + $this->_class_attrdef = new HTMLPurifier_AttrDef_CSS_Ident(); + $this->_enum_attrdef = new HTMLPurifier_AttrDef_Enum( + array( + 'first-child', + 'link', + 'visited', + 'active', + 'hover', + 'focus' + ) + ); + $this->_universal_attrdef = new HTMLPurifier_AttrDef_Enum( + array( + 'initial', + 'inherit', + 'unset', + ) + ); + } + + /** + * Save the contents of CSS blocks to style matches + * @param array $matches preg_replace style $matches array + */ + protected function styleCallback($matches) + { + $this->_styleMatches[] = $matches[1]; + } + + /** + * Removes inline + // we must not grab foo in a font-family prop). + if ($config->get('Filter.ExtractStyleBlocks.Escaping')) { + $css = str_replace( + array('<', '>', '&'), + array('\3C ', '\3E ', '\26 '), + $css + ); + } + return $css; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Filter/YouTube.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Filter/YouTube.php new file mode 100644 index 0000000..276d836 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Filter/YouTube.php @@ -0,0 +1,65 @@ +]+>.+?' . + '(?:http:)?//www.youtube.com/((?:v|cp)/[A-Za-z0-9\-_=]+).+?#s'; + $pre_replace = '\1'; + return preg_replace($pre_regex, $pre_replace, $html); + } + + /** + * @param string $html + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return string + */ + public function postFilter($html, $config, $context) + { + $post_regex = '#((?:v|cp)/[A-Za-z0-9\-_=]+)#'; + return preg_replace_callback($post_regex, array($this, 'postFilterCallback'), $html); + } + + /** + * @param $url + * @return string + */ + protected function armorUrl($url) + { + return str_replace('--', '--', $url); + } + + /** + * @param array $matches + * @return string + */ + protected function postFilterCallback($matches) + { + $url = $this->armorUrl($matches[1]); + return '' . + '' . + '' . + ''; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Generator.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Generator.php new file mode 100644 index 0000000..eb56e2d --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Generator.php @@ -0,0 +1,286 @@ + tags. + * @type bool + */ + private $_scriptFix = false; + + /** + * Cache of HTMLDefinition during HTML output to determine whether or + * not attributes should be minimized. + * @type HTMLPurifier_HTMLDefinition + */ + private $_def; + + /** + * Cache of %Output.SortAttr. + * @type bool + */ + private $_sortAttr; + + /** + * Cache of %Output.FlashCompat. + * @type bool + */ + private $_flashCompat; + + /** + * Cache of %Output.FixInnerHTML. + * @type bool + */ + private $_innerHTMLFix; + + /** + * Stack for keeping track of object information when outputting IE + * compatibility code. + * @type array + */ + private $_flashStack = array(); + + /** + * Configuration for the generator + * @type HTMLPurifier_Config + */ + protected $config; + + /** + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + */ + public function __construct($config, $context) + { + $this->config = $config; + $this->_scriptFix = $config->get('Output.CommentScriptContents'); + $this->_innerHTMLFix = $config->get('Output.FixInnerHTML'); + $this->_sortAttr = $config->get('Output.SortAttr'); + $this->_flashCompat = $config->get('Output.FlashCompat'); + $this->_def = $config->getHTMLDefinition(); + $this->_xhtml = $this->_def->doctype->xml; + } + + /** + * Generates HTML from an array of tokens. + * @param HTMLPurifier_Token[] $tokens Array of HTMLPurifier_Token + * @return string Generated HTML + */ + public function generateFromTokens($tokens) + { + if (!$tokens) { + return ''; + } + + // Basic algorithm + $html = ''; + for ($i = 0, $size = count($tokens); $i < $size; $i++) { + if ($this->_scriptFix && $tokens[$i]->name === 'script' + && $i + 2 < $size && $tokens[$i+2] instanceof HTMLPurifier_Token_End) { + // script special case + // the contents of the script block must be ONE token + // for this to work. + $html .= $this->generateFromToken($tokens[$i++]); + $html .= $this->generateScriptFromToken($tokens[$i++]); + } + $html .= $this->generateFromToken($tokens[$i]); + } + + // Tidy cleanup + if (extension_loaded('tidy') && $this->config->get('Output.TidyFormat')) { + $tidy = new Tidy; + $tidy->parseString( + $html, + array( + 'indent'=> true, + 'output-xhtml' => $this->_xhtml, + 'show-body-only' => true, + 'indent-spaces' => 2, + 'wrap' => 68, + ), + 'utf8' + ); + $tidy->cleanRepair(); + $html = (string) $tidy; // explicit cast necessary + } + + // Normalize newlines to system defined value + if ($this->config->get('Core.NormalizeNewlines')) { + $nl = $this->config->get('Output.Newline'); + if ($nl === null) { + $nl = PHP_EOL; + } + if ($nl !== "\n") { + $html = str_replace("\n", $nl, $html); + } + } + return $html; + } + + /** + * Generates HTML from a single token. + * @param HTMLPurifier_Token $token HTMLPurifier_Token object. + * @return string Generated HTML + */ + public function generateFromToken($token) + { + if (!$token instanceof HTMLPurifier_Token) { + trigger_error('Cannot generate HTML from non-HTMLPurifier_Token object', E_USER_WARNING); + return ''; + + } elseif ($token instanceof HTMLPurifier_Token_Start) { + $attr = $this->generateAttributes($token->attr, $token->name); + if ($this->_flashCompat) { + if ($token->name == "object") { + $flash = new stdClass(); + $flash->attr = $token->attr; + $flash->param = array(); + $this->_flashStack[] = $flash; + } + } + return '<' . $token->name . ($attr ? ' ' : '') . $attr . '>'; + + } elseif ($token instanceof HTMLPurifier_Token_End) { + $_extra = ''; + if ($this->_flashCompat) { + if ($token->name == "object" && !empty($this->_flashStack)) { + // doesn't do anything for now + } + } + return $_extra . 'name . '>'; + + } elseif ($token instanceof HTMLPurifier_Token_Empty) { + if ($this->_flashCompat && $token->name == "param" && !empty($this->_flashStack)) { + $this->_flashStack[count($this->_flashStack)-1]->param[$token->attr['name']] = $token->attr['value']; + } + $attr = $this->generateAttributes($token->attr, $token->name); + return '<' . $token->name . ($attr ? ' ' : '') . $attr . + ( $this->_xhtml ? ' /': '' ) //
    v.
    + . '>'; + + } elseif ($token instanceof HTMLPurifier_Token_Text) { + return $this->escape($token->data, ENT_NOQUOTES); + + } elseif ($token instanceof HTMLPurifier_Token_Comment) { + return ''; + } else { + return ''; + + } + } + + /** + * Special case processor for the contents of script tags + * @param HTMLPurifier_Token $token HTMLPurifier_Token object. + * @return string + * @warning This runs into problems if there's already a literal + * --> somewhere inside the script contents. + */ + public function generateScriptFromToken($token) + { + if (!$token instanceof HTMLPurifier_Token_Text) { + return $this->generateFromToken($token); + } + // Thanks + $data = preg_replace('#//\s*$#', '', $token->data); + return ''; + } + + /** + * Generates attribute declarations from attribute array. + * @note This does not include the leading or trailing space. + * @param array $assoc_array_of_attributes Attribute array + * @param string $element Name of element attributes are for, used to check + * attribute minimization. + * @return string Generated HTML fragment for insertion. + */ + public function generateAttributes($assoc_array_of_attributes, $element = '') + { + $html = ''; + if ($this->_sortAttr) { + ksort($assoc_array_of_attributes); + } + foreach ($assoc_array_of_attributes as $key => $value) { + if (!$this->_xhtml) { + // Remove namespaced attributes + if (strpos($key, ':') !== false) { + continue; + } + // Check if we should minimize the attribute: val="val" -> val + if ($element && !empty($this->_def->info[$element]->attr[$key]->minimized)) { + $html .= $key . ' '; + continue; + } + } + // Workaround for Internet Explorer innerHTML bug. + // Essentially, Internet Explorer, when calculating + // innerHTML, omits quotes if there are no instances of + // angled brackets, quotes or spaces. However, when parsing + // HTML (for example, when you assign to innerHTML), it + // treats backticks as quotes. Thus, + // `` + // becomes + // `` + // becomes + // + // Fortunately, all we need to do is trigger an appropriate + // quoting style, which we do by adding an extra space. + // This also is consistent with the W3C spec, which states + // that user agents may ignore leading or trailing + // whitespace (in fact, most don't, at least for attributes + // like alt, but an extra space at the end is barely + // noticeable). Still, we have a configuration knob for + // this, since this transformation is not necesary if you + // don't process user input with innerHTML or you don't plan + // on supporting Internet Explorer. + if ($this->_innerHTMLFix) { + if (strpos($value, '`') !== false) { + // check if correct quoting style would not already be + // triggered + if (strcspn($value, '"\' <>') === strlen($value)) { + // protect! + $value .= ' '; + } + } + } + $html .= $key.'="'.$this->escape($value).'" '; + } + return rtrim($html); + } + + /** + * Escapes raw text data. + * @todo This really ought to be protected, but until we have a facility + * for properly generating HTML here w/o using tokens, it stays + * public. + * @param string $string String data to escape for HTML. + * @param int $quote Quoting style, like htmlspecialchars. ENT_NOQUOTES is + * permissible for non-attribute output. + * @return string escaped data. + */ + public function escape($string, $quote = null) + { + // Workaround for APC bug on Mac Leopard reported by sidepodcast + // http://htmlpurifier.org/phorum/read.php?3,4823,4846 + if ($quote === null) { + $quote = ENT_COMPAT; + } + return htmlspecialchars($string, $quote, 'UTF-8'); + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLDefinition.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLDefinition.php new file mode 100644 index 0000000..9b7b334 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLDefinition.php @@ -0,0 +1,493 @@ +getAnonymousModule(); + if (!isset($module->info[$element_name])) { + $element = $module->addBlankElement($element_name); + } else { + $element = $module->info[$element_name]; + } + $element->attr[$attr_name] = $def; + } + + /** + * Adds a custom element to your HTML definition + * @see HTMLPurifier_HTMLModule::addElement() for detailed + * parameter and return value descriptions. + */ + public function addElement($element_name, $type, $contents, $attr_collections, $attributes = array()) + { + $module = $this->getAnonymousModule(); + // assume that if the user is calling this, the element + // is safe. This may not be a good idea + $element = $module->addElement($element_name, $type, $contents, $attr_collections, $attributes); + return $element; + } + + /** + * Adds a blank element to your HTML definition, for overriding + * existing behavior + * @param string $element_name + * @return HTMLPurifier_ElementDef + * @see HTMLPurifier_HTMLModule::addBlankElement() for detailed + * parameter and return value descriptions. + */ + public function addBlankElement($element_name) + { + $module = $this->getAnonymousModule(); + $element = $module->addBlankElement($element_name); + return $element; + } + + /** + * Retrieves a reference to the anonymous module, so you can + * bust out advanced features without having to make your own + * module. + * @return HTMLPurifier_HTMLModule + */ + public function getAnonymousModule() + { + if (!$this->_anonModule) { + $this->_anonModule = new HTMLPurifier_HTMLModule(); + $this->_anonModule->name = 'Anonymous'; + } + return $this->_anonModule; + } + + private $_anonModule = null; + + // PUBLIC BUT INTERNAL VARIABLES -------------------------------------- + + /** + * @type string + */ + public $type = 'HTML'; + + /** + * @type HTMLPurifier_HTMLModuleManager + */ + public $manager; + + /** + * Performs low-cost, preliminary initialization. + */ + public function __construct() + { + $this->manager = new HTMLPurifier_HTMLModuleManager(); + } + + /** + * @param HTMLPurifier_Config $config + */ + protected function doSetup($config) + { + $this->processModules($config); + $this->setupConfigStuff($config); + unset($this->manager); + + // cleanup some of the element definitions + foreach ($this->info as $k => $v) { + unset($this->info[$k]->content_model); + unset($this->info[$k]->content_model_type); + } + } + + /** + * Extract out the information from the manager + * @param HTMLPurifier_Config $config + */ + protected function processModules($config) + { + if ($this->_anonModule) { + // for user specific changes + // this is late-loaded so we don't have to deal with PHP4 + // reference wonky-ness + $this->manager->addModule($this->_anonModule); + unset($this->_anonModule); + } + + $this->manager->setup($config); + $this->doctype = $this->manager->doctype; + + foreach ($this->manager->modules as $module) { + foreach ($module->info_tag_transform as $k => $v) { + if ($v === false) { + unset($this->info_tag_transform[$k]); + } else { + $this->info_tag_transform[$k] = $v; + } + } + foreach ($module->info_attr_transform_pre as $k => $v) { + if ($v === false) { + unset($this->info_attr_transform_pre[$k]); + } else { + $this->info_attr_transform_pre[$k] = $v; + } + } + foreach ($module->info_attr_transform_post as $k => $v) { + if ($v === false) { + unset($this->info_attr_transform_post[$k]); + } else { + $this->info_attr_transform_post[$k] = $v; + } + } + foreach ($module->info_injector as $k => $v) { + if ($v === false) { + unset($this->info_injector[$k]); + } else { + $this->info_injector[$k] = $v; + } + } + } + $this->info = $this->manager->getElements(); + $this->info_content_sets = $this->manager->contentSets->lookup; + } + + /** + * Sets up stuff based on config. We need a better way of doing this. + * @param HTMLPurifier_Config $config + */ + protected function setupConfigStuff($config) + { + $block_wrapper = $config->get('HTML.BlockWrapper'); + if (isset($this->info_content_sets['Block'][$block_wrapper])) { + $this->info_block_wrapper = $block_wrapper; + } else { + trigger_error( + 'Cannot use non-block element as block wrapper', + E_USER_ERROR + ); + } + + $parent = $config->get('HTML.Parent'); + $def = $this->manager->getElement($parent, true); + if ($def) { + $this->info_parent = $parent; + $this->info_parent_def = $def; + } else { + trigger_error( + 'Cannot use unrecognized element as parent', + E_USER_ERROR + ); + $this->info_parent_def = $this->manager->getElement($this->info_parent, true); + } + + // support template text + $support = "(for information on implementing this, see the support forums) "; + + // setup allowed elements ----------------------------------------- + + $allowed_elements = $config->get('HTML.AllowedElements'); + $allowed_attributes = $config->get('HTML.AllowedAttributes'); // retrieve early + + if (!is_array($allowed_elements) && !is_array($allowed_attributes)) { + $allowed = $config->get('HTML.Allowed'); + if (is_string($allowed)) { + list($allowed_elements, $allowed_attributes) = $this->parseTinyMCEAllowedList($allowed); + } + } + + if (is_array($allowed_elements)) { + foreach ($this->info as $name => $d) { + if (!isset($allowed_elements[$name])) { + unset($this->info[$name]); + } + unset($allowed_elements[$name]); + } + // emit errors + foreach ($allowed_elements as $element => $d) { + $element = htmlspecialchars($element); // PHP doesn't escape errors, be careful! + trigger_error("Element '$element' is not supported $support", E_USER_WARNING); + } + } + + // setup allowed attributes --------------------------------------- + + $allowed_attributes_mutable = $allowed_attributes; // by copy! + if (is_array($allowed_attributes)) { + // This actually doesn't do anything, since we went away from + // global attributes. It's possible that userland code uses + // it, but HTMLModuleManager doesn't! + foreach ($this->info_global_attr as $attr => $x) { + $keys = array($attr, "*@$attr", "*.$attr"); + $delete = true; + foreach ($keys as $key) { + if ($delete && isset($allowed_attributes[$key])) { + $delete = false; + } + if (isset($allowed_attributes_mutable[$key])) { + unset($allowed_attributes_mutable[$key]); + } + } + if ($delete) { + unset($this->info_global_attr[$attr]); + } + } + + foreach ($this->info as $tag => $info) { + foreach ($info->attr as $attr => $x) { + $keys = array("$tag@$attr", $attr, "*@$attr", "$tag.$attr", "*.$attr"); + $delete = true; + foreach ($keys as $key) { + if ($delete && isset($allowed_attributes[$key])) { + $delete = false; + } + if (isset($allowed_attributes_mutable[$key])) { + unset($allowed_attributes_mutable[$key]); + } + } + if ($delete) { + if ($this->info[$tag]->attr[$attr]->required) { + trigger_error( + "Required attribute '$attr' in element '$tag' " . + "was not allowed, which means '$tag' will not be allowed either", + E_USER_WARNING + ); + } + unset($this->info[$tag]->attr[$attr]); + } + } + } + // emit errors + foreach ($allowed_attributes_mutable as $elattr => $d) { + $bits = preg_split('/[.@]/', $elattr, 2); + $c = count($bits); + switch ($c) { + case 2: + if ($bits[0] !== '*') { + $element = htmlspecialchars($bits[0]); + $attribute = htmlspecialchars($bits[1]); + if (!isset($this->info[$element])) { + trigger_error( + "Cannot allow attribute '$attribute' if element " . + "'$element' is not allowed/supported $support" + ); + } else { + trigger_error( + "Attribute '$attribute' in element '$element' not supported $support", + E_USER_WARNING + ); + } + break; + } + // otherwise fall through + case 1: + $attribute = htmlspecialchars($bits[0]); + trigger_error( + "Global attribute '$attribute' is not ". + "supported in any elements $support", + E_USER_WARNING + ); + break; + } + } + } + + // setup forbidden elements --------------------------------------- + + $forbidden_elements = $config->get('HTML.ForbiddenElements'); + $forbidden_attributes = $config->get('HTML.ForbiddenAttributes'); + + foreach ($this->info as $tag => $info) { + if (isset($forbidden_elements[$tag])) { + unset($this->info[$tag]); + continue; + } + foreach ($info->attr as $attr => $x) { + if (isset($forbidden_attributes["$tag@$attr"]) || + isset($forbidden_attributes["*@$attr"]) || + isset($forbidden_attributes[$attr]) + ) { + unset($this->info[$tag]->attr[$attr]); + continue; + } elseif (isset($forbidden_attributes["$tag.$attr"])) { // this segment might get removed eventually + // $tag.$attr are not user supplied, so no worries! + trigger_error( + "Error with $tag.$attr: tag.attr syntax not supported for " . + "HTML.ForbiddenAttributes; use tag@attr instead", + E_USER_WARNING + ); + } + } + } + foreach ($forbidden_attributes as $key => $v) { + if (strlen($key) < 2) { + continue; + } + if ($key[0] != '*') { + continue; + } + if ($key[1] == '.') { + trigger_error( + "Error with $key: *.attr syntax not supported for HTML.ForbiddenAttributes; use attr instead", + E_USER_WARNING + ); + } + } + + // setup injectors ----------------------------------------------------- + foreach ($this->info_injector as $i => $injector) { + if ($injector->checkNeeded($config) !== false) { + // remove injector that does not have it's required + // elements/attributes present, and is thus not needed. + unset($this->info_injector[$i]); + } + } + } + + /** + * Parses a TinyMCE-flavored Allowed Elements and Attributes list into + * separate lists for processing. Format is element[attr1|attr2],element2... + * @warning Although it's largely drawn from TinyMCE's implementation, + * it is different, and you'll probably have to modify your lists + * @param array $list String list to parse + * @return array + * @todo Give this its own class, probably static interface + */ + public function parseTinyMCEAllowedList($list) + { + $list = str_replace(array(' ', "\t"), '', $list); + + $elements = array(); + $attributes = array(); + + $chunks = preg_split('/(,|[\n\r]+)/', $list); + foreach ($chunks as $chunk) { + if (empty($chunk)) { + continue; + } + // remove TinyMCE element control characters + if (!strpos($chunk, '[')) { + $element = $chunk; + $attr = false; + } else { + list($element, $attr) = explode('[', $chunk); + } + if ($element !== '*') { + $elements[$element] = true; + } + if (!$attr) { + continue; + } + $attr = substr($attr, 0, strlen($attr) - 1); // remove trailing ] + $attr = explode('|', $attr); + foreach ($attr as $key) { + $attributes["$element.$key"] = true; + } + } + return array($elements, $attributes); + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule.php new file mode 100644 index 0000000..9dbb987 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule.php @@ -0,0 +1,285 @@ +info, since the object's data is only info, + * with extra behavior associated with it. + * @type array + */ + public $attr_collections = array(); + + /** + * Associative array of deprecated tag name to HTMLPurifier_TagTransform. + * @type array + */ + public $info_tag_transform = array(); + + /** + * List of HTMLPurifier_AttrTransform to be performed before validation. + * @type array + */ + public $info_attr_transform_pre = array(); + + /** + * List of HTMLPurifier_AttrTransform to be performed after validation. + * @type array + */ + public $info_attr_transform_post = array(); + + /** + * List of HTMLPurifier_Injector to be performed during well-formedness fixing. + * An injector will only be invoked if all of it's pre-requisites are met; + * if an injector fails setup, there will be no error; it will simply be + * silently disabled. + * @type array + */ + public $info_injector = array(); + + /** + * Boolean flag that indicates whether or not getChildDef is implemented. + * For optimization reasons: may save a call to a function. Be sure + * to set it if you do implement getChildDef(), otherwise it will have + * no effect! + * @type bool + */ + public $defines_child_def = false; + + /** + * Boolean flag whether or not this module is safe. If it is not safe, all + * of its members are unsafe. Modules are safe by default (this might be + * slightly dangerous, but it doesn't make much sense to force HTML Purifier, + * which is based off of safe HTML, to explicitly say, "This is safe," even + * though there are modules which are "unsafe") + * + * @type bool + * @note Previously, safety could be applied at an element level granularity. + * We've removed this ability, so in order to add "unsafe" elements + * or attributes, a dedicated module with this property set to false + * must be used. + */ + public $safe = true; + + /** + * Retrieves a proper HTMLPurifier_ChildDef subclass based on + * content_model and content_model_type member variables of + * the HTMLPurifier_ElementDef class. There is a similar function + * in HTMLPurifier_HTMLDefinition. + * @param HTMLPurifier_ElementDef $def + * @return HTMLPurifier_ChildDef subclass + */ + public function getChildDef($def) + { + return false; + } + + // -- Convenience ----------------------------------------------------- + + /** + * Convenience function that sets up a new element + * @param string $element Name of element to add + * @param string|bool $type What content set should element be registered to? + * Set as false to skip this step. + * @param string|HTMLPurifier_ChildDef $contents Allowed children in form of: + * "$content_model_type: $content_model" + * @param array|string $attr_includes What attribute collections to register to + * element? + * @param array $attr What unique attributes does the element define? + * @see HTMLPurifier_ElementDef:: for in-depth descriptions of these parameters. + * @return HTMLPurifier_ElementDef Created element definition object, so you + * can set advanced parameters + */ + public function addElement($element, $type, $contents, $attr_includes = array(), $attr = array()) + { + $this->elements[] = $element; + // parse content_model + list($content_model_type, $content_model) = $this->parseContents($contents); + // merge in attribute inclusions + $this->mergeInAttrIncludes($attr, $attr_includes); + // add element to content sets + if ($type) { + $this->addElementToContentSet($element, $type); + } + // create element + $this->info[$element] = HTMLPurifier_ElementDef::create( + $content_model, + $content_model_type, + $attr + ); + // literal object $contents means direct child manipulation + if (!is_string($contents)) { + $this->info[$element]->child = $contents; + } + return $this->info[$element]; + } + + /** + * Convenience function that creates a totally blank, non-standalone + * element. + * @param string $element Name of element to create + * @return HTMLPurifier_ElementDef Created element + */ + public function addBlankElement($element) + { + if (!isset($this->info[$element])) { + $this->elements[] = $element; + $this->info[$element] = new HTMLPurifier_ElementDef(); + $this->info[$element]->standalone = false; + } else { + trigger_error("Definition for $element already exists in module, cannot redefine"); + } + return $this->info[$element]; + } + + /** + * Convenience function that registers an element to a content set + * @param string $element Element to register + * @param string $type Name content set (warning: case sensitive, usually upper-case + * first letter) + */ + public function addElementToContentSet($element, $type) + { + if (!isset($this->content_sets[$type])) { + $this->content_sets[$type] = ''; + } else { + $this->content_sets[$type] .= ' | '; + } + $this->content_sets[$type] .= $element; + } + + /** + * Convenience function that transforms single-string contents + * into separate content model and content model type + * @param string $contents Allowed children in form of: + * "$content_model_type: $content_model" + * @return array + * @note If contents is an object, an array of two nulls will be + * returned, and the callee needs to take the original $contents + * and use it directly. + */ + public function parseContents($contents) + { + if (!is_string($contents)) { + return array(null, null); + } // defer + switch ($contents) { + // check for shorthand content model forms + case 'Empty': + return array('empty', ''); + case 'Inline': + return array('optional', 'Inline | #PCDATA'); + case 'Flow': + return array('optional', 'Flow | #PCDATA'); + } + list($content_model_type, $content_model) = explode(':', $contents); + $content_model_type = strtolower(trim($content_model_type)); + $content_model = trim($content_model); + return array($content_model_type, $content_model); + } + + /** + * Convenience function that merges a list of attribute includes into + * an attribute array. + * @param array $attr Reference to attr array to modify + * @param array $attr_includes Array of includes / string include to merge in + */ + public function mergeInAttrIncludes(&$attr, $attr_includes) + { + if (!is_array($attr_includes)) { + if (empty($attr_includes)) { + $attr_includes = array(); + } else { + $attr_includes = array($attr_includes); + } + } + $attr[0] = $attr_includes; + } + + /** + * Convenience function that generates a lookup table with boolean + * true as value. + * @param string $list List of values to turn into a lookup + * @note You can also pass an arbitrary number of arguments in + * place of the regular argument + * @return array array equivalent of list + */ + public function makeLookup($list) + { + $args = func_get_args(); + if (is_string($list)) { + $list = $args; + } + $ret = array(); + foreach ($list as $value) { + if (is_null($value)) { + continue; + } + $ret[$value] = true; + } + return $ret; + } + + /** + * Lazy load construction of the module after determining whether + * or not it's needed, and also when a finalized configuration object + * is available. + * @param HTMLPurifier_Config $config + */ + public function setup($config) + { + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Bdo.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Bdo.php new file mode 100644 index 0000000..1e67c79 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Bdo.php @@ -0,0 +1,44 @@ + array('dir' => false) + ); + + /** + * @param HTMLPurifier_Config $config + */ + public function setup($config) + { + $bdo = $this->addElement( + 'bdo', + 'Inline', + 'Inline', + array('Core', 'Lang'), + array( + 'dir' => 'Enum#ltr,rtl', // required + // The Abstract Module specification has the attribute + // inclusions wrong for bdo: bdo allows Lang + ) + ); + $bdo->attr_transform_post[] = new HTMLPurifier_AttrTransform_BdoDir(); + + $this->attr_collections['I18N']['dir'] = 'Enum#ltr,rtl'; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/CommonAttributes.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/CommonAttributes.php new file mode 100644 index 0000000..7220c14 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/CommonAttributes.php @@ -0,0 +1,32 @@ + array( + 0 => array('Style'), + // 'xml:space' => false, + 'class' => 'Class', + 'id' => 'ID', + 'title' => 'CDATA', + 'contenteditable' => 'ContentEditable', + ), + 'Lang' => array(), + 'I18N' => array( + 0 => array('Lang'), // proprietary, for xml:lang/lang + ), + 'Common' => array( + 0 => array('Core', 'I18N') + ) + ); +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Edit.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Edit.php new file mode 100644 index 0000000..a9042a3 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Edit.php @@ -0,0 +1,55 @@ + 'URI', + // 'datetime' => 'Datetime', // not implemented + ); + $this->addElement('del', 'Inline', $contents, 'Common', $attr); + $this->addElement('ins', 'Inline', $contents, 'Common', $attr); + } + + // HTML 4.01 specifies that ins/del must not contain block + // elements when used in an inline context, chameleon is + // a complicated workaround to acheive this effect + + // Inline context ! Block context (exclamation mark is + // separator, see getChildDef for parsing) + + /** + * @type bool + */ + public $defines_child_def = true; + + /** + * @param HTMLPurifier_ElementDef $def + * @return HTMLPurifier_ChildDef_Chameleon + */ + public function getChildDef($def) + { + if ($def->content_model_type != 'chameleon') { + return false; + } + $value = explode('!', $def->content_model); + return new HTMLPurifier_ChildDef_Chameleon($value[0], $value[1]); + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Forms.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Forms.php new file mode 100644 index 0000000..eb0edcf --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Forms.php @@ -0,0 +1,194 @@ + 'Form', + 'Inline' => 'Formctrl', + ); + + /** + * @param HTMLPurifier_Config $config + */ + public function setup($config) + { + if ($config->get('HTML.Forms')) { + $this->safe = true; + } + + $form = $this->addElement( + 'form', + 'Form', + 'Required: Heading | List | Block | fieldset', + 'Common', + array( + 'accept' => 'ContentTypes', + 'accept-charset' => 'Charsets', + 'action*' => 'URI', + 'method' => 'Enum#get,post', + // really ContentType, but these two are the only ones used today + 'enctype' => 'Enum#application/x-www-form-urlencoded,multipart/form-data', + ) + ); + $form->excludes = array('form' => true); + + $input = $this->addElement( + 'input', + 'Formctrl', + 'Empty', + 'Common', + array( + 'accept' => 'ContentTypes', + 'accesskey' => 'Character', + 'alt' => 'Text', + 'checked' => 'Bool#checked', + 'disabled' => 'Bool#disabled', + 'maxlength' => 'Number', + 'name' => 'CDATA', + 'readonly' => 'Bool#readonly', + 'size' => 'Number', + 'src' => 'URI#embedded', + 'tabindex' => 'Number', + 'type' => 'Enum#text,password,checkbox,button,radio,submit,reset,file,hidden,image', + 'value' => 'CDATA', + ) + ); + $input->attr_transform_post[] = new HTMLPurifier_AttrTransform_Input(); + + $this->addElement( + 'select', + 'Formctrl', + 'Required: optgroup | option', + 'Common', + array( + 'disabled' => 'Bool#disabled', + 'multiple' => 'Bool#multiple', + 'name' => 'CDATA', + 'size' => 'Number', + 'tabindex' => 'Number', + ) + ); + + $this->addElement( + 'option', + false, + 'Optional: #PCDATA', + 'Common', + array( + 'disabled' => 'Bool#disabled', + 'label' => 'Text', + 'selected' => 'Bool#selected', + 'value' => 'CDATA', + ) + ); + // It's illegal for there to be more than one selected, but not + // be multiple. Also, no selected means undefined behavior. This might + // be difficult to implement; perhaps an injector, or a context variable. + + $textarea = $this->addElement( + 'textarea', + 'Formctrl', + 'Optional: #PCDATA', + 'Common', + array( + 'accesskey' => 'Character', + 'cols*' => 'Number', + 'disabled' => 'Bool#disabled', + 'name' => 'CDATA', + 'readonly' => 'Bool#readonly', + 'rows*' => 'Number', + 'tabindex' => 'Number', + ) + ); + $textarea->attr_transform_pre[] = new HTMLPurifier_AttrTransform_Textarea(); + + $button = $this->addElement( + 'button', + 'Formctrl', + 'Optional: #PCDATA | Heading | List | Block | Inline', + 'Common', + array( + 'accesskey' => 'Character', + 'disabled' => 'Bool#disabled', + 'name' => 'CDATA', + 'tabindex' => 'Number', + 'type' => 'Enum#button,submit,reset', + 'value' => 'CDATA', + ) + ); + + // For exclusions, ideally we'd specify content sets, not literal elements + $button->excludes = $this->makeLookup( + 'form', + 'fieldset', // Form + 'input', + 'select', + 'textarea', + 'label', + 'button', // Formctrl + 'a', // as per HTML 4.01 spec, this is omitted by modularization + 'isindex', + 'iframe' // legacy items + ); + + // Extra exclusion: img usemap="" is not permitted within this element. + // We'll omit this for now, since we don't have any good way of + // indicating it yet. + + // This is HIGHLY user-unfriendly; we need a custom child-def for this + $this->addElement('fieldset', 'Form', 'Custom: (#WS?,legend,(Flow|#PCDATA)*)', 'Common'); + + $label = $this->addElement( + 'label', + 'Formctrl', + 'Optional: #PCDATA | Inline', + 'Common', + array( + 'accesskey' => 'Character', + // 'for' => 'IDREF', // IDREF not implemented, cannot allow + ) + ); + $label->excludes = array('label' => true); + + $this->addElement( + 'legend', + false, + 'Optional: #PCDATA | Inline', + 'Common', + array( + 'accesskey' => 'Character', + ) + ); + + $this->addElement( + 'optgroup', + false, + 'Required: option', + 'Common', + array( + 'disabled' => 'Bool#disabled', + 'label*' => 'Text', + ) + ); + // Don't forget an injector for . This one's a little complex + // because it maps to multiple elements. + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Hypertext.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Hypertext.php new file mode 100644 index 0000000..72d7a31 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Hypertext.php @@ -0,0 +1,40 @@ +addElement( + 'a', + 'Inline', + 'Inline', + 'Common', + array( + // 'accesskey' => 'Character', + // 'charset' => 'Charset', + 'href' => 'URI', + // 'hreflang' => 'LanguageCode', + 'rel' => new HTMLPurifier_AttrDef_HTML_LinkTypes('rel'), + 'rev' => new HTMLPurifier_AttrDef_HTML_LinkTypes('rev'), + // 'tabindex' => 'Number', + // 'type' => 'ContentType', + ) + ); + $a->formatting = true; + $a->excludes = array('a' => true); + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Iframe.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Iframe.php new file mode 100644 index 0000000..71dfc77 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Iframe.php @@ -0,0 +1,57 @@ +get('HTML.SafeIframe')) { + $this->safe = true; + } + $attrs = array( + 'src' => 'URI#embedded', + 'width' => 'Length', + 'height' => 'Length', + 'name' => 'ID', + 'scrolling' => 'Enum#yes,no,auto', + 'frameborder' => 'Enum#0,1', + 'longdesc' => 'URI', + 'marginheight' => 'Pixels', + 'marginwidth' => 'Pixels', + ); + + if ($config->get('HTML.Trusted')) { + $attrs['allowfullscreen'] = 'Bool#allowfullscreen'; + } + + $this->addElement( + 'iframe', + 'Inline', + 'Flow', + 'Common', + $attrs + ); + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Image.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Image.php new file mode 100644 index 0000000..0f5fdb3 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Image.php @@ -0,0 +1,49 @@ +get('HTML.MaxImgLength'); + $img = $this->addElement( + 'img', + 'Inline', + 'Empty', + 'Common', + array( + 'alt*' => 'Text', + // According to the spec, it's Length, but percents can + // be abused, so we allow only Pixels. + 'height' => 'Pixels#' . $max, + 'width' => 'Pixels#' . $max, + 'longdesc' => 'URI', + 'src*' => new HTMLPurifier_AttrDef_URI(true), // embedded + ) + ); + if ($max === null || $config->get('HTML.Trusted')) { + $img->attr['height'] = + $img->attr['width'] = 'Length'; + } + + // kind of strange, but splitting things up would be inefficient + $img->attr_transform_pre[] = + $img->attr_transform_post[] = + new HTMLPurifier_AttrTransform_ImgRequired(); + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Legacy.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Legacy.php new file mode 100644 index 0000000..86b5299 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Legacy.php @@ -0,0 +1,186 @@ +addElement( + 'basefont', + 'Inline', + 'Empty', + null, + array( + 'color' => 'Color', + 'face' => 'Text', // extremely broad, we should + 'size' => 'Text', // tighten it + 'id' => 'ID' + ) + ); + $this->addElement('center', 'Block', 'Flow', 'Common'); + $this->addElement( + 'dir', + 'Block', + 'Required: li', + 'Common', + array( + 'compact' => 'Bool#compact' + ) + ); + $this->addElement( + 'font', + 'Inline', + 'Inline', + array('Core', 'I18N'), + array( + 'color' => 'Color', + 'face' => 'Text', // extremely broad, we should + 'size' => 'Text', // tighten it + ) + ); + $this->addElement( + 'menu', + 'Block', + 'Required: li', + 'Common', + array( + 'compact' => 'Bool#compact' + ) + ); + + $s = $this->addElement('s', 'Inline', 'Inline', 'Common'); + $s->formatting = true; + + $strike = $this->addElement('strike', 'Inline', 'Inline', 'Common'); + $strike->formatting = true; + + $u = $this->addElement('u', 'Inline', 'Inline', 'Common'); + $u->formatting = true; + + // setup modifications to old elements + + $align = 'Enum#left,right,center,justify'; + + $address = $this->addBlankElement('address'); + $address->content_model = 'Inline | #PCDATA | p'; + $address->content_model_type = 'optional'; + $address->child = false; + + $blockquote = $this->addBlankElement('blockquote'); + $blockquote->content_model = 'Flow | #PCDATA'; + $blockquote->content_model_type = 'optional'; + $blockquote->child = false; + + $br = $this->addBlankElement('br'); + $br->attr['clear'] = 'Enum#left,all,right,none'; + + $caption = $this->addBlankElement('caption'); + $caption->attr['align'] = 'Enum#top,bottom,left,right'; + + $div = $this->addBlankElement('div'); + $div->attr['align'] = $align; + + $dl = $this->addBlankElement('dl'); + $dl->attr['compact'] = 'Bool#compact'; + + for ($i = 1; $i <= 6; $i++) { + $h = $this->addBlankElement("h$i"); + $h->attr['align'] = $align; + } + + $hr = $this->addBlankElement('hr'); + $hr->attr['align'] = $align; + $hr->attr['noshade'] = 'Bool#noshade'; + $hr->attr['size'] = 'Pixels'; + $hr->attr['width'] = 'Length'; + + $img = $this->addBlankElement('img'); + $img->attr['align'] = 'IAlign'; + $img->attr['border'] = 'Pixels'; + $img->attr['hspace'] = 'Pixels'; + $img->attr['vspace'] = 'Pixels'; + + // figure out this integer business + + $li = $this->addBlankElement('li'); + $li->attr['value'] = new HTMLPurifier_AttrDef_Integer(); + $li->attr['type'] = 'Enum#s:1,i,I,a,A,disc,square,circle'; + + $ol = $this->addBlankElement('ol'); + $ol->attr['compact'] = 'Bool#compact'; + $ol->attr['start'] = new HTMLPurifier_AttrDef_Integer(); + $ol->attr['type'] = 'Enum#s:1,i,I,a,A'; + + $p = $this->addBlankElement('p'); + $p->attr['align'] = $align; + + $pre = $this->addBlankElement('pre'); + $pre->attr['width'] = 'Number'; + + // script omitted + + $table = $this->addBlankElement('table'); + $table->attr['align'] = 'Enum#left,center,right'; + $table->attr['bgcolor'] = 'Color'; + + $tr = $this->addBlankElement('tr'); + $tr->attr['bgcolor'] = 'Color'; + + $th = $this->addBlankElement('th'); + $th->attr['bgcolor'] = 'Color'; + $th->attr['height'] = 'Length'; + $th->attr['nowrap'] = 'Bool#nowrap'; + $th->attr['width'] = 'Length'; + + $td = $this->addBlankElement('td'); + $td->attr['bgcolor'] = 'Color'; + $td->attr['height'] = 'Length'; + $td->attr['nowrap'] = 'Bool#nowrap'; + $td->attr['width'] = 'Length'; + + $ul = $this->addBlankElement('ul'); + $ul->attr['compact'] = 'Bool#compact'; + $ul->attr['type'] = 'Enum#square,disc,circle'; + + // "safe" modifications to "unsafe" elements + // WARNING: If you want to add support for an unsafe, legacy + // attribute, make a new TrustedLegacy module with the trusted + // bit set appropriately + + $form = $this->addBlankElement('form'); + $form->content_model = 'Flow | #PCDATA'; + $form->content_model_type = 'optional'; + $form->attr['target'] = 'FrameTarget'; + + $input = $this->addBlankElement('input'); + $input->attr['align'] = 'IAlign'; + + $legend = $this->addBlankElement('legend'); + $legend->attr['align'] = 'LAlign'; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/List.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/List.php new file mode 100644 index 0000000..7a20ff7 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/List.php @@ -0,0 +1,51 @@ + 'List'); + + /** + * @param HTMLPurifier_Config $config + */ + public function setup($config) + { + $ol = $this->addElement('ol', 'List', new HTMLPurifier_ChildDef_List(), 'Common'); + $ul = $this->addElement('ul', 'List', new HTMLPurifier_ChildDef_List(), 'Common'); + // XXX The wrap attribute is handled by MakeWellFormed. This is all + // quite unsatisfactory, because we generated this + // *specifically* for lists, and now a big chunk of the handling + // is done properly by the List ChildDef. So actually, we just + // want enough information to make autoclosing work properly, + // and then hand off the tricky stuff to the ChildDef. + $ol->wrap = 'li'; + $ul->wrap = 'li'; + $this->addElement('dl', 'List', 'Required: dt | dd', 'Common'); + + $this->addElement('li', false, 'Flow', 'Common'); + + $this->addElement('dd', false, 'Flow', 'Common'); + $this->addElement('dt', false, 'Inline', 'Common'); + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Name.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Name.php new file mode 100644 index 0000000..60c0545 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Name.php @@ -0,0 +1,26 @@ +addBlankElement($name); + $element->attr['name'] = 'CDATA'; + if (!$config->get('HTML.Attr.Name.UseCDATA')) { + $element->attr_transform_post[] = new HTMLPurifier_AttrTransform_NameSync(); + } + } + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Nofollow.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Nofollow.php new file mode 100644 index 0000000..dc9410a --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Nofollow.php @@ -0,0 +1,25 @@ +addBlankElement('a'); + $a->attr_transform_post[] = new HTMLPurifier_AttrTransform_Nofollow(); + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/NonXMLCommonAttributes.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/NonXMLCommonAttributes.php new file mode 100644 index 0000000..da72225 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/NonXMLCommonAttributes.php @@ -0,0 +1,20 @@ + array( + 'lang' => 'LanguageCode', + ) + ); +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Object.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Object.php new file mode 100644 index 0000000..2f9efc5 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Object.php @@ -0,0 +1,62 @@ + to cater to legacy browsers: this + * module does not allow this sort of behavior + */ +class HTMLPurifier_HTMLModule_Object extends HTMLPurifier_HTMLModule +{ + /** + * @type string + */ + public $name = 'Object'; + + /** + * @type bool + */ + public $safe = false; + + /** + * @param HTMLPurifier_Config $config + */ + public function setup($config) + { + $this->addElement( + 'object', + 'Inline', + 'Optional: #PCDATA | Flow | param', + 'Common', + array( + 'archive' => 'URI', + 'classid' => 'URI', + 'codebase' => 'URI', + 'codetype' => 'Text', + 'data' => 'URI', + 'declare' => 'Bool#declare', + 'height' => 'Length', + 'name' => 'CDATA', + 'standby' => 'Text', + 'tabindex' => 'Number', + 'type' => 'ContentType', + 'width' => 'Length' + ) + ); + + $this->addElement( + 'param', + false, + 'Empty', + null, + array( + 'id' => 'ID', + 'name*' => 'Text', + 'type' => 'Text', + 'value' => 'Text', + 'valuetype' => 'Enum#data,ref,object' + ) + ); + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Presentation.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Presentation.php new file mode 100644 index 0000000..6458ce9 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Presentation.php @@ -0,0 +1,42 @@ +addElement('hr', 'Block', 'Empty', 'Common'); + $this->addElement('sub', 'Inline', 'Inline', 'Common'); + $this->addElement('sup', 'Inline', 'Inline', 'Common'); + $b = $this->addElement('b', 'Inline', 'Inline', 'Common'); + $b->formatting = true; + $big = $this->addElement('big', 'Inline', 'Inline', 'Common'); + $big->formatting = true; + $i = $this->addElement('i', 'Inline', 'Inline', 'Common'); + $i->formatting = true; + $small = $this->addElement('small', 'Inline', 'Inline', 'Common'); + $small->formatting = true; + $tt = $this->addElement('tt', 'Inline', 'Inline', 'Common'); + $tt->formatting = true; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Proprietary.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Proprietary.php new file mode 100644 index 0000000..5ee3c8e --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Proprietary.php @@ -0,0 +1,40 @@ +addElement( + 'marquee', + 'Inline', + 'Flow', + 'Common', + array( + 'direction' => 'Enum#left,right,up,down', + 'behavior' => 'Enum#alternate', + 'width' => 'Length', + 'height' => 'Length', + 'scrolldelay' => 'Number', + 'scrollamount' => 'Number', + 'loop' => 'Number', + 'bgcolor' => 'Color', + 'hspace' => 'Pixels', + 'vspace' => 'Pixels', + ) + ); + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Ruby.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Ruby.php new file mode 100644 index 0000000..a0d4892 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Ruby.php @@ -0,0 +1,36 @@ +addElement( + 'ruby', + 'Inline', + 'Custom: ((rb, (rt | (rp, rt, rp))) | (rbc, rtc, rtc?))', + 'Common' + ); + $this->addElement('rbc', false, 'Required: rb', 'Common'); + $this->addElement('rtc', false, 'Required: rt', 'Common'); + $rb = $this->addElement('rb', false, 'Inline', 'Common'); + $rb->excludes = array('ruby' => true); + $rt = $this->addElement('rt', false, 'Inline', 'Common', array('rbspan' => 'Number')); + $rt->excludes = array('ruby' => true); + $this->addElement('rp', false, 'Optional: #PCDATA', 'Common'); + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/SafeEmbed.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/SafeEmbed.php new file mode 100644 index 0000000..04e6689 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/SafeEmbed.php @@ -0,0 +1,40 @@ +get('HTML.MaxImgLength'); + $embed = $this->addElement( + 'embed', + 'Inline', + 'Empty', + 'Common', + array( + 'src*' => 'URI#embedded', + 'type' => 'Enum#application/x-shockwave-flash', + 'width' => 'Pixels#' . $max, + 'height' => 'Pixels#' . $max, + 'allowscriptaccess' => 'Enum#never', + 'allownetworking' => 'Enum#internal', + 'flashvars' => 'Text', + 'wmode' => 'Enum#window,transparent,opaque', + 'name' => 'ID', + ) + ); + $embed->attr_transform_post[] = new HTMLPurifier_AttrTransform_SafeEmbed(); + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/SafeObject.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/SafeObject.php new file mode 100644 index 0000000..1297f80 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/SafeObject.php @@ -0,0 +1,62 @@ +get('HTML.MaxImgLength'); + $object = $this->addElement( + 'object', + 'Inline', + 'Optional: param | Flow | #PCDATA', + 'Common', + array( + // While technically not required by the spec, we're forcing + // it to this value. + 'type' => 'Enum#application/x-shockwave-flash', + 'width' => 'Pixels#' . $max, + 'height' => 'Pixels#' . $max, + 'data' => 'URI#embedded', + 'codebase' => new HTMLPurifier_AttrDef_Enum( + array( + 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0' + ) + ), + ) + ); + $object->attr_transform_post[] = new HTMLPurifier_AttrTransform_SafeObject(); + + $param = $this->addElement( + 'param', + false, + 'Empty', + false, + array( + 'id' => 'ID', + 'name*' => 'Text', + 'value' => 'Text' + ) + ); + $param->attr_transform_post[] = new HTMLPurifier_AttrTransform_SafeParam(); + $this->info_injector[] = 'SafeObject'; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/SafeScripting.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/SafeScripting.php new file mode 100644 index 0000000..aea7584 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/SafeScripting.php @@ -0,0 +1,40 @@ +get('HTML.SafeScripting'); + $script = $this->addElement( + 'script', + 'Inline', + 'Optional:', // Not `Empty` to not allow to autoclose the #i', '', $html); + } + + return $html; + } + + /** + * Takes a string of HTML (fragment or document) and returns the content + * @todo Consider making protected + */ + public function extractBody($html) + { + $matches = array(); + $result = preg_match('|(.*?)]*>(.*)|is', $html, $matches); + if ($result) { + // Make sure it's not in a comment + $comment_start = strrpos($matches[1], ''); + if ($comment_start === false || + ($comment_end !== false && $comment_end > $comment_start)) { + return $matches[2]; + } + } + return $html; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Lexer/DOMLex.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Lexer/DOMLex.php new file mode 100644 index 0000000..7d57983 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Lexer/DOMLex.php @@ -0,0 +1,340 @@ +factory = new HTMLPurifier_TokenFactory(); + } + + /** + * @param string $html + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return HTMLPurifier_Token[] + */ + public function tokenizeHTML($html, $config, $context) + { + $html = $this->normalize($html, $config, $context); + + // attempt to armor stray angled brackets that cannot possibly + // form tags and thus are probably being used as emoticons + if ($config->get('Core.AggressivelyFixLt')) { + $char = '[^a-z!\/]'; + $comment = "/|\z)/is"; + $html = preg_replace_callback($comment, array($this, 'callbackArmorCommentEntities'), $html); + do { + $old = $html; + $html = preg_replace("/<($char)/i", '<\\1', $html); + } while ($html !== $old); + $html = preg_replace_callback($comment, array($this, 'callbackUndoCommentSubst'), $html); // fix comments + } + + // preprocess html, essential for UTF-8 + $html = $this->wrapHTML($html, $config, $context); + + $doc = new DOMDocument(); + $doc->encoding = 'UTF-8'; // theoretically, the above has this covered + + $options = 0; + if ($config->get('Core.AllowParseManyTags') && defined('LIBXML_PARSEHUGE')) { + $options |= LIBXML_PARSEHUGE; + } + if ($config->get('Core.RemoveBlanks') && defined('LIBXML_NOBLANKS')) { + $options |= LIBXML_NOBLANKS; + } + + set_error_handler(array($this, 'muteErrorHandler')); + // loadHTML() fails on PHP 5.3 when second parameter is given + if ($options) { + $doc->loadHTML($html, $options); + } else { + $doc->loadHTML($html); + } + restore_error_handler(); + + $body = $doc->getElementsByTagName('html')->item(0)-> // + getElementsByTagName('body')->item(0); // + + $div = $body->getElementsByTagName('div')->item(0); //
    + $tokens = array(); + $this->tokenizeDOM($div, $tokens, $config); + // If the div has a sibling, that means we tripped across + // a premature
    tag. So remove the div we parsed, + // and then tokenize the rest of body. We can't tokenize + // the sibling directly as we'll lose the tags in that case. + if ($div->nextSibling) { + $body->removeChild($div); + $this->tokenizeDOM($body, $tokens, $config); + } + return $tokens; + } + + /** + * Iterative function that tokenizes a node, putting it into an accumulator. + * To iterate is human, to recurse divine - L. Peter Deutsch + * @param DOMNode $node DOMNode to be tokenized. + * @param HTMLPurifier_Token[] $tokens Array-list of already tokenized tokens. + */ + protected function tokenizeDOM($node, &$tokens, $config) + { + $level = 0; + $nodes = array($level => new HTMLPurifier_Queue(array($node))); + $closingNodes = array(); + do { + while (!$nodes[$level]->isEmpty()) { + $node = $nodes[$level]->shift(); // FIFO + $collect = $level > 0 ? true : false; + $needEndingTag = $this->createStartNode($node, $tokens, $collect, $config); + if ($needEndingTag) { + $closingNodes[$level][] = $node; + } + if ($node->childNodes && $node->childNodes->length) { + $level++; + $nodes[$level] = new HTMLPurifier_Queue(); + foreach ($node->childNodes as $childNode) { + $nodes[$level]->push($childNode); + } + } + } + $level--; + if ($level && isset($closingNodes[$level])) { + while ($node = array_pop($closingNodes[$level])) { + $this->createEndNode($node, $tokens); + } + } + } while ($level > 0); + } + + /** + * Portably retrieve the tag name of a node; deals with older versions + * of libxml like 2.7.6 + * @param DOMNode $node + */ + protected function getTagName($node) + { + if (isset($node->tagName)) { + return $node->tagName; + } else if (isset($node->nodeName)) { + return $node->nodeName; + } else if (isset($node->localName)) { + return $node->localName; + } + return null; + } + + /** + * Portably retrieve the data of a node; deals with older versions + * of libxml like 2.7.6 + * @param DOMNode $node + */ + protected function getData($node) + { + if (isset($node->data)) { + return $node->data; + } else if (isset($node->nodeValue)) { + return $node->nodeValue; + } else if (isset($node->textContent)) { + return $node->textContent; + } + return null; + } + + + /** + * @param DOMNode $node DOMNode to be tokenized. + * @param HTMLPurifier_Token[] $tokens Array-list of already tokenized tokens. + * @param bool $collect Says whether or start and close are collected, set to + * false at first recursion because it's the implicit DIV + * tag you're dealing with. + * @return bool if the token needs an endtoken + * @todo data and tagName properties don't seem to exist in DOMNode? + */ + protected function createStartNode($node, &$tokens, $collect, $config) + { + // intercept non element nodes. WE MUST catch all of them, + // but we're not getting the character reference nodes because + // those should have been preprocessed + if ($node->nodeType === XML_TEXT_NODE) { + $data = $this->getData($node); // Handle variable data property + if ($data !== null) { + $tokens[] = $this->factory->createText($data); + } + return false; + } elseif ($node->nodeType === XML_CDATA_SECTION_NODE) { + // undo libxml's special treatment of )#si', + array($this, 'scriptCallback'), + $html + ); + } + + $html = $this->normalize($html, $config, $context); + + $cursor = 0; // our location in the text + $inside_tag = false; // whether or not we're parsing the inside of a tag + $array = array(); // result array + + // This is also treated to mean maintain *column* numbers too + $maintain_line_numbers = $config->get('Core.MaintainLineNumbers'); + + if ($maintain_line_numbers === null) { + // automatically determine line numbering by checking + // if error collection is on + $maintain_line_numbers = $config->get('Core.CollectErrors'); + } + + if ($maintain_line_numbers) { + $current_line = 1; + $current_col = 0; + $length = strlen($html); + } else { + $current_line = false; + $current_col = false; + $length = false; + } + $context->register('CurrentLine', $current_line); + $context->register('CurrentCol', $current_col); + $nl = "\n"; + // how often to manually recalculate. This will ALWAYS be right, + // but it's pretty wasteful. Set to 0 to turn off + $synchronize_interval = $config->get('Core.DirectLexLineNumberSyncInterval'); + + $e = false; + if ($config->get('Core.CollectErrors')) { + $e =& $context->get('ErrorCollector'); + } + + // for testing synchronization + $loops = 0; + + while (++$loops) { + // $cursor is either at the start of a token, or inside of + // a tag (i.e. there was a < immediately before it), as indicated + // by $inside_tag + + if ($maintain_line_numbers) { + // $rcursor, however, is always at the start of a token. + $rcursor = $cursor - (int)$inside_tag; + + // Column number is cheap, so we calculate it every round. + // We're interested at the *end* of the newline string, so + // we need to add strlen($nl) == 1 to $nl_pos before subtracting it + // from our "rcursor" position. + $nl_pos = strrpos($html, $nl, $rcursor - $length); + $current_col = $rcursor - (is_bool($nl_pos) ? 0 : $nl_pos + 1); + + // recalculate lines + if ($synchronize_interval && // synchronization is on + $cursor > 0 && // cursor is further than zero + $loops % $synchronize_interval === 0) { // time to synchronize! + $current_line = 1 + $this->substrCount($html, $nl, 0, $cursor); + } + } + + $position_next_lt = strpos($html, '<', $cursor); + $position_next_gt = strpos($html, '>', $cursor); + + // triggers on "asdf" but not "asdf " + // special case to set up context + if ($position_next_lt === $cursor) { + $inside_tag = true; + $cursor++; + } + + if (!$inside_tag && $position_next_lt !== false) { + // We are not inside tag and there still is another tag to parse + $token = new + HTMLPurifier_Token_Text( + $this->parseText( + substr( + $html, + $cursor, + $position_next_lt - $cursor + ), $config + ) + ); + if ($maintain_line_numbers) { + $token->rawPosition($current_line, $current_col); + $current_line += $this->substrCount($html, $nl, $cursor, $position_next_lt - $cursor); + } + $array[] = $token; + $cursor = $position_next_lt + 1; + $inside_tag = true; + continue; + } elseif (!$inside_tag) { + // We are not inside tag but there are no more tags + // If we're already at the end, break + if ($cursor === strlen($html)) { + break; + } + // Create Text of rest of string + $token = new + HTMLPurifier_Token_Text( + $this->parseText( + substr( + $html, + $cursor + ), $config + ) + ); + if ($maintain_line_numbers) { + $token->rawPosition($current_line, $current_col); + } + $array[] = $token; + break; + } elseif ($inside_tag && $position_next_gt !== false) { + // We are in tag and it is well formed + // Grab the internals of the tag + $strlen_segment = $position_next_gt - $cursor; + + if ($strlen_segment < 1) { + // there's nothing to process! + $token = new HTMLPurifier_Token_Text('<'); + $cursor++; + continue; + } + + $segment = substr($html, $cursor, $strlen_segment); + + if ($segment === false) { + // somehow, we attempted to access beyond the end of + // the string, defense-in-depth, reported by Nate Abele + break; + } + + // Check if it's a comment + if (substr($segment, 0, 3) === '!--') { + // re-determine segment length, looking for --> + $position_comment_end = strpos($html, '-->', $cursor); + if ($position_comment_end === false) { + // uh oh, we have a comment that extends to + // infinity. Can't be helped: set comment + // end position to end of string + if ($e) { + $e->send(E_WARNING, 'Lexer: Unclosed comment'); + } + $position_comment_end = strlen($html); + $end = true; + } else { + $end = false; + } + $strlen_segment = $position_comment_end - $cursor; + $segment = substr($html, $cursor, $strlen_segment); + $token = new + HTMLPurifier_Token_Comment( + substr( + $segment, + 3, + $strlen_segment - 3 + ) + ); + if ($maintain_line_numbers) { + $token->rawPosition($current_line, $current_col); + $current_line += $this->substrCount($html, $nl, $cursor, $strlen_segment); + } + $array[] = $token; + $cursor = $end ? $position_comment_end : $position_comment_end + 3; + $inside_tag = false; + continue; + } + + // Check if it's an end tag + $is_end_tag = (strpos($segment, '/') === 0); + if ($is_end_tag) { + $type = substr($segment, 1); + $token = new HTMLPurifier_Token_End($type); + if ($maintain_line_numbers) { + $token->rawPosition($current_line, $current_col); + $current_line += $this->substrCount($html, $nl, $cursor, $position_next_gt - $cursor); + } + $array[] = $token; + $inside_tag = false; + $cursor = $position_next_gt + 1; + continue; + } + + // Check leading character is alnum, if not, we may + // have accidently grabbed an emoticon. Translate into + // text and go our merry way + if (!ctype_alpha($segment[0])) { + // XML: $segment[0] !== '_' && $segment[0] !== ':' + if ($e) { + $e->send(E_NOTICE, 'Lexer: Unescaped lt'); + } + $token = new HTMLPurifier_Token_Text('<'); + if ($maintain_line_numbers) { + $token->rawPosition($current_line, $current_col); + $current_line += $this->substrCount($html, $nl, $cursor, $position_next_gt - $cursor); + } + $array[] = $token; + $inside_tag = false; + continue; + } + + // Check if it is explicitly self closing, if so, remove + // trailing slash. Remember, we could have a tag like
    , so + // any later token processing scripts must convert improperly + // classified EmptyTags from StartTags. + $is_self_closing = (strrpos($segment, '/') === $strlen_segment - 1); + if ($is_self_closing) { + $strlen_segment--; + $segment = substr($segment, 0, $strlen_segment); + } + + // Check if there are any attributes + $position_first_space = strcspn($segment, $this->_whitespace); + + if ($position_first_space >= $strlen_segment) { + if ($is_self_closing) { + $token = new HTMLPurifier_Token_Empty($segment); + } else { + $token = new HTMLPurifier_Token_Start($segment); + } + if ($maintain_line_numbers) { + $token->rawPosition($current_line, $current_col); + $current_line += $this->substrCount($html, $nl, $cursor, $position_next_gt - $cursor); + } + $array[] = $token; + $inside_tag = false; + $cursor = $position_next_gt + 1; + continue; + } + + // Grab out all the data + $type = substr($segment, 0, $position_first_space); + $attribute_string = + trim( + substr( + $segment, + $position_first_space + ) + ); + if ($attribute_string) { + $attr = $this->parseAttributeString( + $attribute_string, + $config, + $context + ); + } else { + $attr = array(); + } + + if ($is_self_closing) { + $token = new HTMLPurifier_Token_Empty($type, $attr); + } else { + $token = new HTMLPurifier_Token_Start($type, $attr); + } + if ($maintain_line_numbers) { + $token->rawPosition($current_line, $current_col); + $current_line += $this->substrCount($html, $nl, $cursor, $position_next_gt - $cursor); + } + $array[] = $token; + $cursor = $position_next_gt + 1; + $inside_tag = false; + continue; + } else { + // inside tag, but there's no ending > sign + if ($e) { + $e->send(E_WARNING, 'Lexer: Missing gt'); + } + $token = new + HTMLPurifier_Token_Text( + '<' . + $this->parseText( + substr($html, $cursor), $config + ) + ); + if ($maintain_line_numbers) { + $token->rawPosition($current_line, $current_col); + } + // no cursor scroll? Hmm... + $array[] = $token; + break; + } + break; + } + + $context->destroy('CurrentLine'); + $context->destroy('CurrentCol'); + return $array; + } + + /** + * PHP 5.0.x compatible substr_count that implements offset and length + * @param string $haystack + * @param string $needle + * @param int $offset + * @param int $length + * @return int + */ + protected function substrCount($haystack, $needle, $offset, $length) + { + static $oldVersion; + if ($oldVersion === null) { + $oldVersion = version_compare(PHP_VERSION, '5.1', '<'); + } + if ($oldVersion) { + $haystack = substr($haystack, $offset, $length); + return substr_count($haystack, $needle); + } else { + return substr_count($haystack, $needle, $offset, $length); + } + } + + /** + * Takes the inside of an HTML tag and makes an assoc array of attributes. + * + * @param string $string Inside of tag excluding name. + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return array Assoc array of attributes. + */ + public function parseAttributeString($string, $config, $context) + { + $string = (string)$string; // quick typecast + + if ($string == '') { + return array(); + } // no attributes + + $e = false; + if ($config->get('Core.CollectErrors')) { + $e =& $context->get('ErrorCollector'); + } + + // let's see if we can abort as quickly as possible + // one equal sign, no spaces => one attribute + $num_equal = substr_count($string, '='); + $has_space = strpos($string, ' '); + if ($num_equal === 0 && !$has_space) { + // bool attribute + return array($string => $string); + } elseif ($num_equal === 1 && !$has_space) { + // only one attribute + list($key, $quoted_value) = explode('=', $string); + $quoted_value = trim($quoted_value); + if (!$key) { + if ($e) { + $e->send(E_ERROR, 'Lexer: Missing attribute key'); + } + return array(); + } + if (!$quoted_value) { + return array($key => ''); + } + $first_char = @$quoted_value[0]; + $last_char = @$quoted_value[strlen($quoted_value) - 1]; + + $same_quote = ($first_char == $last_char); + $open_quote = ($first_char == '"' || $first_char == "'"); + + if ($same_quote && $open_quote) { + // well behaved + $value = substr($quoted_value, 1, strlen($quoted_value) - 2); + } else { + // not well behaved + if ($open_quote) { + if ($e) { + $e->send(E_ERROR, 'Lexer: Missing end quote'); + } + $value = substr($quoted_value, 1); + } else { + $value = $quoted_value; + } + } + if ($value === false) { + $value = ''; + } + return array($key => $this->parseAttr($value, $config)); + } + + // setup loop environment + $array = array(); // return assoc array of attributes + $cursor = 0; // current position in string (moves forward) + $size = strlen($string); // size of the string (stays the same) + + // if we have unquoted attributes, the parser expects a terminating + // space, so let's guarantee that there's always a terminating space. + $string .= ' '; + + $old_cursor = -1; + while ($cursor < $size) { + if ($old_cursor >= $cursor) { + throw new Exception("Infinite loop detected"); + } + $old_cursor = $cursor; + + $cursor += ($value = strspn($string, $this->_whitespace, $cursor)); + // grab the key + + $key_begin = $cursor; //we're currently at the start of the key + + // scroll past all characters that are the key (not whitespace or =) + $cursor += strcspn($string, $this->_whitespace . '=', $cursor); + + $key_end = $cursor; // now at the end of the key + + $key = substr($string, $key_begin, $key_end - $key_begin); + + if (!$key) { + if ($e) { + $e->send(E_ERROR, 'Lexer: Missing attribute key'); + } + $cursor += 1 + strcspn($string, $this->_whitespace, $cursor + 1); // prevent infinite loop + continue; // empty key + } + + // scroll past all whitespace + $cursor += strspn($string, $this->_whitespace, $cursor); + + if ($cursor >= $size) { + $array[$key] = $key; + break; + } + + // if the next character is an equal sign, we've got a regular + // pair, otherwise, it's a bool attribute + $first_char = @$string[$cursor]; + + if ($first_char == '=') { + // key="value" + + $cursor++; + $cursor += strspn($string, $this->_whitespace, $cursor); + + if ($cursor === false) { + $array[$key] = ''; + break; + } + + // we might be in front of a quote right now + + $char = @$string[$cursor]; + + if ($char == '"' || $char == "'") { + // it's quoted, end bound is $char + $cursor++; + $value_begin = $cursor; + $cursor = strpos($string, $char, $cursor); + $value_end = $cursor; + } else { + // it's not quoted, end bound is whitespace + $value_begin = $cursor; + $cursor += strcspn($string, $this->_whitespace, $cursor); + $value_end = $cursor; + } + + // we reached a premature end + if ($cursor === false) { + $cursor = $size; + $value_end = $cursor; + } + + $value = substr($string, $value_begin, $value_end - $value_begin); + if ($value === false) { + $value = ''; + } + $array[$key] = $this->parseAttr($value, $config); + $cursor++; + } else { + // boolattr + if ($key !== '') { + $array[$key] = $key; + } else { + // purely theoretical + if ($e) { + $e->send(E_ERROR, 'Lexer: Missing attribute key'); + } + } + } + } + return $array; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Lexer/PH5P.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Lexer/PH5P.php new file mode 100644 index 0000000..1564f28 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Lexer/PH5P.php @@ -0,0 +1,4788 @@ +normalize($html, $config, $context); + $new_html = $this->wrapHTML($new_html, $config, $context, false /* no div */); + try { + $parser = new HTML5($new_html); + $doc = $parser->save(); + } catch (DOMException $e) { + // Uh oh, it failed. Punt to DirectLex. + $lexer = new HTMLPurifier_Lexer_DirectLex(); + $context->register('PH5PError', $e); // save the error, so we can detect it + return $lexer->tokenizeHTML($html, $config, $context); // use original HTML + } + $tokens = array(); + $this->tokenizeDOM( + $doc->getElementsByTagName('html')->item(0)-> // + getElementsByTagName('body')->item(0) // + , + $tokens, $config + ); + return $tokens; + } +} + +/* + +Copyright 2007 Jeroen van der Meer + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +*/ + +class HTML5 +{ + private $data; + private $char; + private $EOF; + private $state; + private $tree; + private $token; + private $content_model; + private $escape = false; + private $entities = array( + 'AElig;', + 'AElig', + 'AMP;', + 'AMP', + 'Aacute;', + 'Aacute', + 'Acirc;', + 'Acirc', + 'Agrave;', + 'Agrave', + 'Alpha;', + 'Aring;', + 'Aring', + 'Atilde;', + 'Atilde', + 'Auml;', + 'Auml', + 'Beta;', + 'COPY;', + 'COPY', + 'Ccedil;', + 'Ccedil', + 'Chi;', + 'Dagger;', + 'Delta;', + 'ETH;', + 'ETH', + 'Eacute;', + 'Eacute', + 'Ecirc;', + 'Ecirc', + 'Egrave;', + 'Egrave', + 'Epsilon;', + 'Eta;', + 'Euml;', + 'Euml', + 'GT;', + 'GT', + 'Gamma;', + 'Iacute;', + 'Iacute', + 'Icirc;', + 'Icirc', + 'Igrave;', + 'Igrave', + 'Iota;', + 'Iuml;', + 'Iuml', + 'Kappa;', + 'LT;', + 'LT', + 'Lambda;', + 'Mu;', + 'Ntilde;', + 'Ntilde', + 'Nu;', + 'OElig;', + 'Oacute;', + 'Oacute', + 'Ocirc;', + 'Ocirc', + 'Ograve;', + 'Ograve', + 'Omega;', + 'Omicron;', + 'Oslash;', + 'Oslash', + 'Otilde;', + 'Otilde', + 'Ouml;', + 'Ouml', + 'Phi;', + 'Pi;', + 'Prime;', + 'Psi;', + 'QUOT;', + 'QUOT', + 'REG;', + 'REG', + 'Rho;', + 'Scaron;', + 'Sigma;', + 'THORN;', + 'THORN', + 'TRADE;', + 'Tau;', + 'Theta;', + 'Uacute;', + 'Uacute', + 'Ucirc;', + 'Ucirc', + 'Ugrave;', + 'Ugrave', + 'Upsilon;', + 'Uuml;', + 'Uuml', + 'Xi;', + 'Yacute;', + 'Yacute', + 'Yuml;', + 'Zeta;', + 'aacute;', + 'aacute', + 'acirc;', + 'acirc', + 'acute;', + 'acute', + 'aelig;', + 'aelig', + 'agrave;', + 'agrave', + 'alefsym;', + 'alpha;', + 'amp;', + 'amp', + 'and;', + 'ang;', + 'apos;', + 'aring;', + 'aring', + 'asymp;', + 'atilde;', + 'atilde', + 'auml;', + 'auml', + 'bdquo;', + 'beta;', + 'brvbar;', + 'brvbar', + 'bull;', + 'cap;', + 'ccedil;', + 'ccedil', + 'cedil;', + 'cedil', + 'cent;', + 'cent', + 'chi;', + 'circ;', + 'clubs;', + 'cong;', + 'copy;', + 'copy', + 'crarr;', + 'cup;', + 'curren;', + 'curren', + 'dArr;', + 'dagger;', + 'darr;', + 'deg;', + 'deg', + 'delta;', + 'diams;', + 'divide;', + 'divide', + 'eacute;', + 'eacute', + 'ecirc;', + 'ecirc', + 'egrave;', + 'egrave', + 'empty;', + 'emsp;', + 'ensp;', + 'epsilon;', + 'equiv;', + 'eta;', + 'eth;', + 'eth', + 'euml;', + 'euml', + 'euro;', + 'exist;', + 'fnof;', + 'forall;', + 'frac12;', + 'frac12', + 'frac14;', + 'frac14', + 'frac34;', + 'frac34', + 'frasl;', + 'gamma;', + 'ge;', + 'gt;', + 'gt', + 'hArr;', + 'harr;', + 'hearts;', + 'hellip;', + 'iacute;', + 'iacute', + 'icirc;', + 'icirc', + 'iexcl;', + 'iexcl', + 'igrave;', + 'igrave', + 'image;', + 'infin;', + 'int;', + 'iota;', + 'iquest;', + 'iquest', + 'isin;', + 'iuml;', + 'iuml', + 'kappa;', + 'lArr;', + 'lambda;', + 'lang;', + 'laquo;', + 'laquo', + 'larr;', + 'lceil;', + 'ldquo;', + 'le;', + 'lfloor;', + 'lowast;', + 'loz;', + 'lrm;', + 'lsaquo;', + 'lsquo;', + 'lt;', + 'lt', + 'macr;', + 'macr', + 'mdash;', + 'micro;', + 'micro', + 'middot;', + 'middot', + 'minus;', + 'mu;', + 'nabla;', + 'nbsp;', + 'nbsp', + 'ndash;', + 'ne;', + 'ni;', + 'not;', + 'not', + 'notin;', + 'nsub;', + 'ntilde;', + 'ntilde', + 'nu;', + 'oacute;', + 'oacute', + 'ocirc;', + 'ocirc', + 'oelig;', + 'ograve;', + 'ograve', + 'oline;', + 'omega;', + 'omicron;', + 'oplus;', + 'or;', + 'ordf;', + 'ordf', + 'ordm;', + 'ordm', + 'oslash;', + 'oslash', + 'otilde;', + 'otilde', + 'otimes;', + 'ouml;', + 'ouml', + 'para;', + 'para', + 'part;', + 'permil;', + 'perp;', + 'phi;', + 'pi;', + 'piv;', + 'plusmn;', + 'plusmn', + 'pound;', + 'pound', + 'prime;', + 'prod;', + 'prop;', + 'psi;', + 'quot;', + 'quot', + 'rArr;', + 'radic;', + 'rang;', + 'raquo;', + 'raquo', + 'rarr;', + 'rceil;', + 'rdquo;', + 'real;', + 'reg;', + 'reg', + 'rfloor;', + 'rho;', + 'rlm;', + 'rsaquo;', + 'rsquo;', + 'sbquo;', + 'scaron;', + 'sdot;', + 'sect;', + 'sect', + 'shy;', + 'shy', + 'sigma;', + 'sigmaf;', + 'sim;', + 'spades;', + 'sub;', + 'sube;', + 'sum;', + 'sup1;', + 'sup1', + 'sup2;', + 'sup2', + 'sup3;', + 'sup3', + 'sup;', + 'supe;', + 'szlig;', + 'szlig', + 'tau;', + 'there4;', + 'theta;', + 'thetasym;', + 'thinsp;', + 'thorn;', + 'thorn', + 'tilde;', + 'times;', + 'times', + 'trade;', + 'uArr;', + 'uacute;', + 'uacute', + 'uarr;', + 'ucirc;', + 'ucirc', + 'ugrave;', + 'ugrave', + 'uml;', + 'uml', + 'upsih;', + 'upsilon;', + 'uuml;', + 'uuml', + 'weierp;', + 'xi;', + 'yacute;', + 'yacute', + 'yen;', + 'yen', + 'yuml;', + 'yuml', + 'zeta;', + 'zwj;', + 'zwnj;' + ); + + const PCDATA = 0; + const RCDATA = 1; + const CDATA = 2; + const PLAINTEXT = 3; + + const DOCTYPE = 0; + const STARTTAG = 1; + const ENDTAG = 2; + const COMMENT = 3; + const CHARACTR = 4; + const EOF = 5; + + public function __construct($data) + { + $this->data = $data; + $this->char = -1; + $this->EOF = strlen($data); + $this->tree = new HTML5TreeConstructer; + $this->content_model = self::PCDATA; + + $this->state = 'data'; + + while ($this->state !== null) { + $this->{$this->state . 'State'}(); + } + } + + public function save() + { + return $this->tree->save(); + } + + private function char() + { + return ($this->char < $this->EOF) + ? $this->data[$this->char] + : false; + } + + private function character($s, $l = 0) + { + if ($s + $l < $this->EOF) { + if ($l === 0) { + return $this->data[$s]; + } else { + return substr($this->data, $s, $l); + } + } + } + + private function characters($char_class, $start) + { + return preg_replace('#^([' . $char_class . ']+).*#s', '\\1', substr($this->data, $start)); + } + + private function dataState() + { + // Consume the next input character + $this->char++; + $char = $this->char(); + + if ($char === '&' && ($this->content_model === self::PCDATA || $this->content_model === self::RCDATA)) { + /* U+0026 AMPERSAND (&) + When the content model flag is set to one of the PCDATA or RCDATA + states: switch to the entity data state. Otherwise: treat it as per + the "anything else" entry below. */ + $this->state = 'entityData'; + + } elseif ($char === '-') { + /* If the content model flag is set to either the RCDATA state or + the CDATA state, and the escape flag is false, and there are at + least three characters before this one in the input stream, and the + last four characters in the input stream, including this one, are + U+003C LESS-THAN SIGN, U+0021 EXCLAMATION MARK, U+002D HYPHEN-MINUS, + and U+002D HYPHEN-MINUS (""), + set the escape flag to false. */ + if (($this->content_model === self::RCDATA || + $this->content_model === self::CDATA) && $this->escape === true && + $this->character($this->char, 3) === '-->' + ) { + $this->escape = false; + } + + /* In any case, emit the input character as a character token. + Stay in the data state. */ + $this->emitToken( + array( + 'type' => self::CHARACTR, + 'data' => $char + ) + ); + + } elseif ($this->char === $this->EOF) { + /* EOF + Emit an end-of-file token. */ + $this->EOF(); + + } elseif ($this->content_model === self::PLAINTEXT) { + /* When the content model flag is set to the PLAINTEXT state + THIS DIFFERS GREATLY FROM THE SPEC: Get the remaining characters of + the text and emit it as a character token. */ + $this->emitToken( + array( + 'type' => self::CHARACTR, + 'data' => substr($this->data, $this->char) + ) + ); + + $this->EOF(); + + } else { + /* Anything else + THIS DIFFERS GREATLY FROM THE SPEC: Get as many character that + otherwise would also be treated as a character token and emit it + as a single character token. Stay in the data state. */ + $len = strcspn($this->data, '<&', $this->char); + $char = substr($this->data, $this->char, $len); + $this->char += $len - 1; + + $this->emitToken( + array( + 'type' => self::CHARACTR, + 'data' => $char + ) + ); + + $this->state = 'data'; + } + } + + private function entityDataState() + { + // Attempt to consume an entity. + $entity = $this->entity(); + + // If nothing is returned, emit a U+0026 AMPERSAND character token. + // Otherwise, emit the character token that was returned. + $char = (!$entity) ? '&' : $entity; + $this->emitToken( + array( + 'type' => self::CHARACTR, + 'data' => $char + ) + ); + + // Finally, switch to the data state. + $this->state = 'data'; + } + + private function tagOpenState() + { + switch ($this->content_model) { + case self::RCDATA: + case self::CDATA: + /* If the next input character is a U+002F SOLIDUS (/) character, + consume it and switch to the close tag open state. If the next + input character is not a U+002F SOLIDUS (/) character, emit a + U+003C LESS-THAN SIGN character token and switch to the data + state to process the next input character. */ + if ($this->character($this->char + 1) === '/') { + $this->char++; + $this->state = 'closeTagOpen'; + + } else { + $this->emitToken( + array( + 'type' => self::CHARACTR, + 'data' => '<' + ) + ); + + $this->state = 'data'; + } + break; + + case self::PCDATA: + // If the content model flag is set to the PCDATA state + // Consume the next input character: + $this->char++; + $char = $this->char(); + + if ($char === '!') { + /* U+0021 EXCLAMATION MARK (!) + Switch to the markup declaration open state. */ + $this->state = 'markupDeclarationOpen'; + + } elseif ($char === '/') { + /* U+002F SOLIDUS (/) + Switch to the close tag open state. */ + $this->state = 'closeTagOpen'; + + } elseif (preg_match('/^[A-Za-z]$/', $char)) { + /* U+0041 LATIN LETTER A through to U+005A LATIN LETTER Z + Create a new start tag token, set its tag name to the lowercase + version of the input character (add 0x0020 to the character's code + point), then switch to the tag name state. (Don't emit the token + yet; further details will be filled in before it is emitted.) */ + $this->token = array( + 'name' => strtolower($char), + 'type' => self::STARTTAG, + 'attr' => array() + ); + + $this->state = 'tagName'; + + } elseif ($char === '>') { + /* U+003E GREATER-THAN SIGN (>) + Parse error. Emit a U+003C LESS-THAN SIGN character token and a + U+003E GREATER-THAN SIGN character token. Switch to the data state. */ + $this->emitToken( + array( + 'type' => self::CHARACTR, + 'data' => '<>' + ) + ); + + $this->state = 'data'; + + } elseif ($char === '?') { + /* U+003F QUESTION MARK (?) + Parse error. Switch to the bogus comment state. */ + $this->state = 'bogusComment'; + + } else { + /* Anything else + Parse error. Emit a U+003C LESS-THAN SIGN character token and + reconsume the current input character in the data state. */ + $this->emitToken( + array( + 'type' => self::CHARACTR, + 'data' => '<' + ) + ); + + $this->char--; + $this->state = 'data'; + } + break; + } + } + + private function closeTagOpenState() + { + $next_node = strtolower($this->characters('A-Za-z', $this->char + 1)); + $the_same = count($this->tree->stack) > 0 && $next_node === end($this->tree->stack)->nodeName; + + if (($this->content_model === self::RCDATA || $this->content_model === self::CDATA) && + (!$the_same || ($the_same && (!preg_match( + '/[\t\n\x0b\x0c >\/]/', + $this->character($this->char + 1 + strlen($next_node)) + ) || $this->EOF === $this->char))) + ) { + /* If the content model flag is set to the RCDATA or CDATA states then + examine the next few characters. If they do not match the tag name of + the last start tag token emitted (case insensitively), or if they do but + they are not immediately followed by one of the following characters: + * U+0009 CHARACTER TABULATION + * U+000A LINE FEED (LF) + * U+000B LINE TABULATION + * U+000C FORM FEED (FF) + * U+0020 SPACE + * U+003E GREATER-THAN SIGN (>) + * U+002F SOLIDUS (/) + * EOF + ...then there is a parse error. Emit a U+003C LESS-THAN SIGN character + token, a U+002F SOLIDUS character token, and switch to the data state + to process the next input character. */ + $this->emitToken( + array( + 'type' => self::CHARACTR, + 'data' => 'state = 'data'; + + } else { + /* Otherwise, if the content model flag is set to the PCDATA state, + or if the next few characters do match that tag name, consume the + next input character: */ + $this->char++; + $char = $this->char(); + + if (preg_match('/^[A-Za-z]$/', $char)) { + /* U+0041 LATIN LETTER A through to U+005A LATIN LETTER Z + Create a new end tag token, set its tag name to the lowercase version + of the input character (add 0x0020 to the character's code point), then + switch to the tag name state. (Don't emit the token yet; further details + will be filled in before it is emitted.) */ + $this->token = array( + 'name' => strtolower($char), + 'type' => self::ENDTAG + ); + + $this->state = 'tagName'; + + } elseif ($char === '>') { + /* U+003E GREATER-THAN SIGN (>) + Parse error. Switch to the data state. */ + $this->state = 'data'; + + } elseif ($this->char === $this->EOF) { + /* EOF + Parse error. Emit a U+003C LESS-THAN SIGN character token and a U+002F + SOLIDUS character token. Reconsume the EOF character in the data state. */ + $this->emitToken( + array( + 'type' => self::CHARACTR, + 'data' => 'char--; + $this->state = 'data'; + + } else { + /* Parse error. Switch to the bogus comment state. */ + $this->state = 'bogusComment'; + } + } + } + + private function tagNameState() + { + // Consume the next input character: + $this->char++; + $char = $this->character($this->char); + + if (preg_match('/^[\t\n\x0b\x0c ]$/', $char)) { + /* U+0009 CHARACTER TABULATION + U+000A LINE FEED (LF) + U+000B LINE TABULATION + U+000C FORM FEED (FF) + U+0020 SPACE + Switch to the before attribute name state. */ + $this->state = 'beforeAttributeName'; + + } elseif ($char === '>') { + /* U+003E GREATER-THAN SIGN (>) + Emit the current tag token. Switch to the data state. */ + $this->emitToken($this->token); + $this->state = 'data'; + + } elseif ($this->char === $this->EOF) { + /* EOF + Parse error. Emit the current tag token. Reconsume the EOF + character in the data state. */ + $this->emitToken($this->token); + + $this->char--; + $this->state = 'data'; + + } elseif ($char === '/') { + /* U+002F SOLIDUS (/) + Parse error unless this is a permitted slash. Switch to the before + attribute name state. */ + $this->state = 'beforeAttributeName'; + + } else { + /* Anything else + Append the current input character to the current tag token's tag name. + Stay in the tag name state. */ + $this->token['name'] .= strtolower($char); + $this->state = 'tagName'; + } + } + + private function beforeAttributeNameState() + { + // Consume the next input character: + $this->char++; + $char = $this->character($this->char); + + if (preg_match('/^[\t\n\x0b\x0c ]$/', $char)) { + /* U+0009 CHARACTER TABULATION + U+000A LINE FEED (LF) + U+000B LINE TABULATION + U+000C FORM FEED (FF) + U+0020 SPACE + Stay in the before attribute name state. */ + $this->state = 'beforeAttributeName'; + + } elseif ($char === '>') { + /* U+003E GREATER-THAN SIGN (>) + Emit the current tag token. Switch to the data state. */ + $this->emitToken($this->token); + $this->state = 'data'; + + } elseif ($char === '/') { + /* U+002F SOLIDUS (/) + Parse error unless this is a permitted slash. Stay in the before + attribute name state. */ + $this->state = 'beforeAttributeName'; + + } elseif ($this->char === $this->EOF) { + /* EOF + Parse error. Emit the current tag token. Reconsume the EOF + character in the data state. */ + $this->emitToken($this->token); + + $this->char--; + $this->state = 'data'; + + } else { + /* Anything else + Start a new attribute in the current tag token. Set that attribute's + name to the current input character, and its value to the empty string. + Switch to the attribute name state. */ + $this->token['attr'][] = array( + 'name' => strtolower($char), + 'value' => null + ); + + $this->state = 'attributeName'; + } + } + + private function attributeNameState() + { + // Consume the next input character: + $this->char++; + $char = $this->character($this->char); + + if (preg_match('/^[\t\n\x0b\x0c ]$/', $char)) { + /* U+0009 CHARACTER TABULATION + U+000A LINE FEED (LF) + U+000B LINE TABULATION + U+000C FORM FEED (FF) + U+0020 SPACE + Stay in the before attribute name state. */ + $this->state = 'afterAttributeName'; + + } elseif ($char === '=') { + /* U+003D EQUALS SIGN (=) + Switch to the before attribute value state. */ + $this->state = 'beforeAttributeValue'; + + } elseif ($char === '>') { + /* U+003E GREATER-THAN SIGN (>) + Emit the current tag token. Switch to the data state. */ + $this->emitToken($this->token); + $this->state = 'data'; + + } elseif ($char === '/' && $this->character($this->char + 1) !== '>') { + /* U+002F SOLIDUS (/) + Parse error unless this is a permitted slash. Switch to the before + attribute name state. */ + $this->state = 'beforeAttributeName'; + + } elseif ($this->char === $this->EOF) { + /* EOF + Parse error. Emit the current tag token. Reconsume the EOF + character in the data state. */ + $this->emitToken($this->token); + + $this->char--; + $this->state = 'data'; + + } else { + /* Anything else + Append the current input character to the current attribute's name. + Stay in the attribute name state. */ + $last = count($this->token['attr']) - 1; + $this->token['attr'][$last]['name'] .= strtolower($char); + + $this->state = 'attributeName'; + } + } + + private function afterAttributeNameState() + { + // Consume the next input character: + $this->char++; + $char = $this->character($this->char); + + if (preg_match('/^[\t\n\x0b\x0c ]$/', $char)) { + /* U+0009 CHARACTER TABULATION + U+000A LINE FEED (LF) + U+000B LINE TABULATION + U+000C FORM FEED (FF) + U+0020 SPACE + Stay in the after attribute name state. */ + $this->state = 'afterAttributeName'; + + } elseif ($char === '=') { + /* U+003D EQUALS SIGN (=) + Switch to the before attribute value state. */ + $this->state = 'beforeAttributeValue'; + + } elseif ($char === '>') { + /* U+003E GREATER-THAN SIGN (>) + Emit the current tag token. Switch to the data state. */ + $this->emitToken($this->token); + $this->state = 'data'; + + } elseif ($char === '/' && $this->character($this->char + 1) !== '>') { + /* U+002F SOLIDUS (/) + Parse error unless this is a permitted slash. Switch to the + before attribute name state. */ + $this->state = 'beforeAttributeName'; + + } elseif ($this->char === $this->EOF) { + /* EOF + Parse error. Emit the current tag token. Reconsume the EOF + character in the data state. */ + $this->emitToken($this->token); + + $this->char--; + $this->state = 'data'; + + } else { + /* Anything else + Start a new attribute in the current tag token. Set that attribute's + name to the current input character, and its value to the empty string. + Switch to the attribute name state. */ + $this->token['attr'][] = array( + 'name' => strtolower($char), + 'value' => null + ); + + $this->state = 'attributeName'; + } + } + + private function beforeAttributeValueState() + { + // Consume the next input character: + $this->char++; + $char = $this->character($this->char); + + if (preg_match('/^[\t\n\x0b\x0c ]$/', $char)) { + /* U+0009 CHARACTER TABULATION + U+000A LINE FEED (LF) + U+000B LINE TABULATION + U+000C FORM FEED (FF) + U+0020 SPACE + Stay in the before attribute value state. */ + $this->state = 'beforeAttributeValue'; + + } elseif ($char === '"') { + /* U+0022 QUOTATION MARK (") + Switch to the attribute value (double-quoted) state. */ + $this->state = 'attributeValueDoubleQuoted'; + + } elseif ($char === '&') { + /* U+0026 AMPERSAND (&) + Switch to the attribute value (unquoted) state and reconsume + this input character. */ + $this->char--; + $this->state = 'attributeValueUnquoted'; + + } elseif ($char === '\'') { + /* U+0027 APOSTROPHE (') + Switch to the attribute value (single-quoted) state. */ + $this->state = 'attributeValueSingleQuoted'; + + } elseif ($char === '>') { + /* U+003E GREATER-THAN SIGN (>) + Emit the current tag token. Switch to the data state. */ + $this->emitToken($this->token); + $this->state = 'data'; + + } else { + /* Anything else + Append the current input character to the current attribute's value. + Switch to the attribute value (unquoted) state. */ + $last = count($this->token['attr']) - 1; + $this->token['attr'][$last]['value'] .= $char; + + $this->state = 'attributeValueUnquoted'; + } + } + + private function attributeValueDoubleQuotedState() + { + // Consume the next input character: + $this->char++; + $char = $this->character($this->char); + + if ($char === '"') { + /* U+0022 QUOTATION MARK (") + Switch to the before attribute name state. */ + $this->state = 'beforeAttributeName'; + + } elseif ($char === '&') { + /* U+0026 AMPERSAND (&) + Switch to the entity in attribute value state. */ + $this->entityInAttributeValueState('double'); + + } elseif ($this->char === $this->EOF) { + /* EOF + Parse error. Emit the current tag token. Reconsume the character + in the data state. */ + $this->emitToken($this->token); + + $this->char--; + $this->state = 'data'; + + } else { + /* Anything else + Append the current input character to the current attribute's value. + Stay in the attribute value (double-quoted) state. */ + $last = count($this->token['attr']) - 1; + $this->token['attr'][$last]['value'] .= $char; + + $this->state = 'attributeValueDoubleQuoted'; + } + } + + private function attributeValueSingleQuotedState() + { + // Consume the next input character: + $this->char++; + $char = $this->character($this->char); + + if ($char === '\'') { + /* U+0022 QUOTATION MARK (') + Switch to the before attribute name state. */ + $this->state = 'beforeAttributeName'; + + } elseif ($char === '&') { + /* U+0026 AMPERSAND (&) + Switch to the entity in attribute value state. */ + $this->entityInAttributeValueState('single'); + + } elseif ($this->char === $this->EOF) { + /* EOF + Parse error. Emit the current tag token. Reconsume the character + in the data state. */ + $this->emitToken($this->token); + + $this->char--; + $this->state = 'data'; + + } else { + /* Anything else + Append the current input character to the current attribute's value. + Stay in the attribute value (single-quoted) state. */ + $last = count($this->token['attr']) - 1; + $this->token['attr'][$last]['value'] .= $char; + + $this->state = 'attributeValueSingleQuoted'; + } + } + + private function attributeValueUnquotedState() + { + // Consume the next input character: + $this->char++; + $char = $this->character($this->char); + + if (preg_match('/^[\t\n\x0b\x0c ]$/', $char)) { + /* U+0009 CHARACTER TABULATION + U+000A LINE FEED (LF) + U+000B LINE TABULATION + U+000C FORM FEED (FF) + U+0020 SPACE + Switch to the before attribute name state. */ + $this->state = 'beforeAttributeName'; + + } elseif ($char === '&') { + /* U+0026 AMPERSAND (&) + Switch to the entity in attribute value state. */ + $this->entityInAttributeValueState(); + + } elseif ($char === '>') { + /* U+003E GREATER-THAN SIGN (>) + Emit the current tag token. Switch to the data state. */ + $this->emitToken($this->token); + $this->state = 'data'; + + } else { + /* Anything else + Append the current input character to the current attribute's value. + Stay in the attribute value (unquoted) state. */ + $last = count($this->token['attr']) - 1; + $this->token['attr'][$last]['value'] .= $char; + + $this->state = 'attributeValueUnquoted'; + } + } + + private function entityInAttributeValueState() + { + // Attempt to consume an entity. + $entity = $this->entity(); + + // If nothing is returned, append a U+0026 AMPERSAND character to the + // current attribute's value. Otherwise, emit the character token that + // was returned. + $char = (!$entity) + ? '&' + : $entity; + + $last = count($this->token['attr']) - 1; + $this->token['attr'][$last]['value'] .= $char; + } + + private function bogusCommentState() + { + /* Consume every character up to the first U+003E GREATER-THAN SIGN + character (>) or the end of the file (EOF), whichever comes first. Emit + a comment token whose data is the concatenation of all the characters + starting from and including the character that caused the state machine + to switch into the bogus comment state, up to and including the last + consumed character before the U+003E character, if any, or up to the + end of the file otherwise. (If the comment was started by the end of + the file (EOF), the token is empty.) */ + $data = $this->characters('^>', $this->char); + $this->emitToken( + array( + 'data' => $data, + 'type' => self::COMMENT + ) + ); + + $this->char += strlen($data); + + /* Switch to the data state. */ + $this->state = 'data'; + + /* If the end of the file was reached, reconsume the EOF character. */ + if ($this->char === $this->EOF) { + $this->char = $this->EOF - 1; + } + } + + private function markupDeclarationOpenState() + { + /* If the next two characters are both U+002D HYPHEN-MINUS (-) + characters, consume those two characters, create a comment token whose + data is the empty string, and switch to the comment state. */ + if ($this->character($this->char + 1, 2) === '--') { + $this->char += 2; + $this->state = 'comment'; + $this->token = array( + 'data' => null, + 'type' => self::COMMENT + ); + + /* Otherwise if the next seven chacacters are a case-insensitive match + for the word "DOCTYPE", then consume those characters and switch to the + DOCTYPE state. */ + } elseif (strtolower($this->character($this->char + 1, 7)) === 'doctype') { + $this->char += 7; + $this->state = 'doctype'; + + /* Otherwise, is is a parse error. Switch to the bogus comment state. + The next character that is consumed, if any, is the first character + that will be in the comment. */ + } else { + $this->char++; + $this->state = 'bogusComment'; + } + } + + private function commentState() + { + /* Consume the next input character: */ + $this->char++; + $char = $this->char(); + + /* U+002D HYPHEN-MINUS (-) */ + if ($char === '-') { + /* Switch to the comment dash state */ + $this->state = 'commentDash'; + + /* EOF */ + } elseif ($this->char === $this->EOF) { + /* Parse error. Emit the comment token. Reconsume the EOF character + in the data state. */ + $this->emitToken($this->token); + $this->char--; + $this->state = 'data'; + + /* Anything else */ + } else { + /* Append the input character to the comment token's data. Stay in + the comment state. */ + $this->token['data'] .= $char; + } + } + + private function commentDashState() + { + /* Consume the next input character: */ + $this->char++; + $char = $this->char(); + + /* U+002D HYPHEN-MINUS (-) */ + if ($char === '-') { + /* Switch to the comment end state */ + $this->state = 'commentEnd'; + + /* EOF */ + } elseif ($this->char === $this->EOF) { + /* Parse error. Emit the comment token. Reconsume the EOF character + in the data state. */ + $this->emitToken($this->token); + $this->char--; + $this->state = 'data'; + + /* Anything else */ + } else { + /* Append a U+002D HYPHEN-MINUS (-) character and the input + character to the comment token's data. Switch to the comment state. */ + $this->token['data'] .= '-' . $char; + $this->state = 'comment'; + } + } + + private function commentEndState() + { + /* Consume the next input character: */ + $this->char++; + $char = $this->char(); + + if ($char === '>') { + $this->emitToken($this->token); + $this->state = 'data'; + + } elseif ($char === '-') { + $this->token['data'] .= '-'; + + } elseif ($this->char === $this->EOF) { + $this->emitToken($this->token); + $this->char--; + $this->state = 'data'; + + } else { + $this->token['data'] .= '--' . $char; + $this->state = 'comment'; + } + } + + private function doctypeState() + { + /* Consume the next input character: */ + $this->char++; + $char = $this->char(); + + if (preg_match('/^[\t\n\x0b\x0c ]$/', $char)) { + $this->state = 'beforeDoctypeName'; + + } else { + $this->char--; + $this->state = 'beforeDoctypeName'; + } + } + + private function beforeDoctypeNameState() + { + /* Consume the next input character: */ + $this->char++; + $char = $this->char(); + + if (preg_match('/^[\t\n\x0b\x0c ]$/', $char)) { + // Stay in the before DOCTYPE name state. + + } elseif (preg_match('/^[a-z]$/', $char)) { + $this->token = array( + 'name' => strtoupper($char), + 'type' => self::DOCTYPE, + 'error' => true + ); + + $this->state = 'doctypeName'; + + } elseif ($char === '>') { + $this->emitToken( + array( + 'name' => null, + 'type' => self::DOCTYPE, + 'error' => true + ) + ); + + $this->state = 'data'; + + } elseif ($this->char === $this->EOF) { + $this->emitToken( + array( + 'name' => null, + 'type' => self::DOCTYPE, + 'error' => true + ) + ); + + $this->char--; + $this->state = 'data'; + + } else { + $this->token = array( + 'name' => $char, + 'type' => self::DOCTYPE, + 'error' => true + ); + + $this->state = 'doctypeName'; + } + } + + private function doctypeNameState() + { + /* Consume the next input character: */ + $this->char++; + $char = $this->char(); + + if (preg_match('/^[\t\n\x0b\x0c ]$/', $char)) { + $this->state = 'AfterDoctypeName'; + + } elseif ($char === '>') { + $this->emitToken($this->token); + $this->state = 'data'; + + } elseif (preg_match('/^[a-z]$/', $char)) { + $this->token['name'] .= strtoupper($char); + + } elseif ($this->char === $this->EOF) { + $this->emitToken($this->token); + $this->char--; + $this->state = 'data'; + + } else { + $this->token['name'] .= $char; + } + + $this->token['error'] = ($this->token['name'] === 'HTML') + ? false + : true; + } + + private function afterDoctypeNameState() + { + /* Consume the next input character: */ + $this->char++; + $char = $this->char(); + + if (preg_match('/^[\t\n\x0b\x0c ]$/', $char)) { + // Stay in the DOCTYPE name state. + + } elseif ($char === '>') { + $this->emitToken($this->token); + $this->state = 'data'; + + } elseif ($this->char === $this->EOF) { + $this->emitToken($this->token); + $this->char--; + $this->state = 'data'; + + } else { + $this->token['error'] = true; + $this->state = 'bogusDoctype'; + } + } + + private function bogusDoctypeState() + { + /* Consume the next input character: */ + $this->char++; + $char = $this->char(); + + if ($char === '>') { + $this->emitToken($this->token); + $this->state = 'data'; + + } elseif ($this->char === $this->EOF) { + $this->emitToken($this->token); + $this->char--; + $this->state = 'data'; + + } else { + // Stay in the bogus DOCTYPE state. + } + } + + private function entity() + { + $start = $this->char; + + // This section defines how to consume an entity. This definition is + // used when parsing entities in text and in attributes. + + // The behaviour depends on the identity of the next character (the + // one immediately after the U+0026 AMPERSAND character): + + switch ($this->character($this->char + 1)) { + // U+0023 NUMBER SIGN (#) + case '#': + + // The behaviour further depends on the character after the + // U+0023 NUMBER SIGN: + switch ($this->character($this->char + 1)) { + // U+0078 LATIN SMALL LETTER X + // U+0058 LATIN CAPITAL LETTER X + case 'x': + case 'X': + // Follow the steps below, but using the range of + // characters U+0030 DIGIT ZERO through to U+0039 DIGIT + // NINE, U+0061 LATIN SMALL LETTER A through to U+0066 + // LATIN SMALL LETTER F, and U+0041 LATIN CAPITAL LETTER + // A, through to U+0046 LATIN CAPITAL LETTER F (in other + // words, 0-9, A-F, a-f). + $char = 1; + $char_class = '0-9A-Fa-f'; + break; + + // Anything else + default: + // Follow the steps below, but using the range of + // characters U+0030 DIGIT ZERO through to U+0039 DIGIT + // NINE (i.e. just 0-9). + $char = 0; + $char_class = '0-9'; + break; + } + + // Consume as many characters as match the range of characters + // given above. + $this->char++; + $e_name = $this->characters($char_class, $this->char + $char + 1); + $entity = $this->character($start, $this->char); + $cond = strlen($e_name) > 0; + + // The rest of the parsing happens below. + break; + + // Anything else + default: + // Consume the maximum number of characters possible, with the + // consumed characters case-sensitively matching one of the + // identifiers in the first column of the entities table. + + $e_name = $this->characters('0-9A-Za-z;', $this->char + 1); + $len = strlen($e_name); + + for ($c = 1; $c <= $len; $c++) { + $id = substr($e_name, 0, $c); + $this->char++; + + if (in_array($id, $this->entities)) { + if ($e_name[$c - 1] !== ';') { + if ($c < $len && $e_name[$c] == ';') { + $this->char++; // consume extra semicolon + } + } + $entity = $id; + break; + } + } + + $cond = isset($entity); + // The rest of the parsing happens below. + break; + } + + if (!$cond) { + // If no match can be made, then this is a parse error. No + // characters are consumed, and nothing is returned. + $this->char = $start; + return false; + } + + // Return a character token for the character corresponding to the + // entity name (as given by the second column of the entities table). + return html_entity_decode('&' . rtrim($entity, ';') . ';', ENT_QUOTES, 'UTF-8'); + } + + private function emitToken($token) + { + $emit = $this->tree->emitToken($token); + + if (is_int($emit)) { + $this->content_model = $emit; + + } elseif ($token['type'] === self::ENDTAG) { + $this->content_model = self::PCDATA; + } + } + + private function EOF() + { + $this->state = null; + $this->tree->emitToken( + array( + 'type' => self::EOF + ) + ); + } +} + +class HTML5TreeConstructer +{ + public $stack = array(); + + private $phase; + private $mode; + private $dom; + private $foster_parent = null; + private $a_formatting = array(); + + private $head_pointer = null; + private $form_pointer = null; + + private $scoping = array('button', 'caption', 'html', 'marquee', 'object', 'table', 'td', 'th'); + private $formatting = array( + 'a', + 'b', + 'big', + 'em', + 'font', + 'i', + 'nobr', + 's', + 'small', + 'strike', + 'strong', + 'tt', + 'u' + ); + private $special = array( + 'address', + 'area', + 'base', + 'basefont', + 'bgsound', + 'blockquote', + 'body', + 'br', + 'center', + 'col', + 'colgroup', + 'dd', + 'dir', + 'div', + 'dl', + 'dt', + 'embed', + 'fieldset', + 'form', + 'frame', + 'frameset', + 'h1', + 'h2', + 'h3', + 'h4', + 'h5', + 'h6', + 'head', + 'hr', + 'iframe', + 'image', + 'img', + 'input', + 'isindex', + 'li', + 'link', + 'listing', + 'menu', + 'meta', + 'noembed', + 'noframes', + 'noscript', + 'ol', + 'optgroup', + 'option', + 'p', + 'param', + 'plaintext', + 'pre', + 'script', + 'select', + 'spacer', + 'style', + 'tbody', + 'textarea', + 'tfoot', + 'thead', + 'title', + 'tr', + 'ul', + 'wbr' + ); + + // The different phases. + const INIT_PHASE = 0; + const ROOT_PHASE = 1; + const MAIN_PHASE = 2; + const END_PHASE = 3; + + // The different insertion modes for the main phase. + const BEFOR_HEAD = 0; + const IN_HEAD = 1; + const AFTER_HEAD = 2; + const IN_BODY = 3; + const IN_TABLE = 4; + const IN_CAPTION = 5; + const IN_CGROUP = 6; + const IN_TBODY = 7; + const IN_ROW = 8; + const IN_CELL = 9; + const IN_SELECT = 10; + const AFTER_BODY = 11; + const IN_FRAME = 12; + const AFTR_FRAME = 13; + + // The different types of elements. + const SPECIAL = 0; + const SCOPING = 1; + const FORMATTING = 2; + const PHRASING = 3; + + const MARKER = 0; + + public function __construct() + { + $this->phase = self::INIT_PHASE; + $this->mode = self::BEFOR_HEAD; + $this->dom = new DOMDocument; + + $this->dom->encoding = 'UTF-8'; + $this->dom->preserveWhiteSpace = true; + $this->dom->substituteEntities = true; + $this->dom->strictErrorChecking = false; + } + + // Process tag tokens + public function emitToken($token) + { + switch ($this->phase) { + case self::INIT_PHASE: + return $this->initPhase($token); + break; + case self::ROOT_PHASE: + return $this->rootElementPhase($token); + break; + case self::MAIN_PHASE: + return $this->mainPhase($token); + break; + case self::END_PHASE : + return $this->trailingEndPhase($token); + break; + } + } + + private function initPhase($token) + { + /* Initially, the tree construction stage must handle each token + emitted from the tokenisation stage as follows: */ + + /* A DOCTYPE token that is marked as being in error + A comment token + A start tag token + An end tag token + A character token that is not one of one of U+0009 CHARACTER TABULATION, + U+000A LINE FEED (LF), U+000B LINE TABULATION, U+000C FORM FEED (FF), + or U+0020 SPACE + An end-of-file token */ + if ((isset($token['error']) && $token['error']) || + $token['type'] === HTML5::COMMENT || + $token['type'] === HTML5::STARTTAG || + $token['type'] === HTML5::ENDTAG || + $token['type'] === HTML5::EOF || + ($token['type'] === HTML5::CHARACTR && isset($token['data']) && + !preg_match('/^[\t\n\x0b\x0c ]+$/', $token['data'])) + ) { + /* This specification does not define how to handle this case. In + particular, user agents may ignore the entirety of this specification + altogether for such documents, and instead invoke special parse modes + with a greater emphasis on backwards compatibility. */ + + $this->phase = self::ROOT_PHASE; + return $this->rootElementPhase($token); + + /* A DOCTYPE token marked as being correct */ + } elseif (isset($token['error']) && !$token['error']) { + /* Append a DocumentType node to the Document node, with the name + attribute set to the name given in the DOCTYPE token (which will be + "HTML"), and the other attributes specific to DocumentType objects + set to null, empty lists, or the empty string as appropriate. */ + $doctype = new DOMDocumentType(null, null, 'HTML'); + + /* Then, switch to the root element phase of the tree construction + stage. */ + $this->phase = self::ROOT_PHASE; + + /* A character token that is one of one of U+0009 CHARACTER TABULATION, + U+000A LINE FEED (LF), U+000B LINE TABULATION, U+000C FORM FEED (FF), + or U+0020 SPACE */ + } elseif (isset($token['data']) && preg_match( + '/^[\t\n\x0b\x0c ]+$/', + $token['data'] + ) + ) { + /* Append that character to the Document node. */ + $text = $this->dom->createTextNode($token['data']); + $this->dom->appendChild($text); + } + } + + private function rootElementPhase($token) + { + /* After the initial phase, as each token is emitted from the tokenisation + stage, it must be processed as described in this section. */ + + /* A DOCTYPE token */ + if ($token['type'] === HTML5::DOCTYPE) { + // Parse error. Ignore the token. + + /* A comment token */ + } elseif ($token['type'] === HTML5::COMMENT) { + /* Append a Comment node to the Document object with the data + attribute set to the data given in the comment token. */ + $comment = $this->dom->createComment($token['data']); + $this->dom->appendChild($comment); + + /* A character token that is one of one of U+0009 CHARACTER TABULATION, + U+000A LINE FEED (LF), U+000B LINE TABULATION, U+000C FORM FEED (FF), + or U+0020 SPACE */ + } elseif ($token['type'] === HTML5::CHARACTR && + preg_match('/^[\t\n\x0b\x0c ]+$/', $token['data']) + ) { + /* Append that character to the Document node. */ + $text = $this->dom->createTextNode($token['data']); + $this->dom->appendChild($text); + + /* A character token that is not one of U+0009 CHARACTER TABULATION, + U+000A LINE FEED (LF), U+000B LINE TABULATION, U+000C FORM FEED + (FF), or U+0020 SPACE + A start tag token + An end tag token + An end-of-file token */ + } elseif (($token['type'] === HTML5::CHARACTR && + !preg_match('/^[\t\n\x0b\x0c ]+$/', $token['data'])) || + $token['type'] === HTML5::STARTTAG || + $token['type'] === HTML5::ENDTAG || + $token['type'] === HTML5::EOF + ) { + /* Create an HTMLElement node with the tag name html, in the HTML + namespace. Append it to the Document object. Switch to the main + phase and reprocess the current token. */ + $html = $this->dom->createElement('html'); + $this->dom->appendChild($html); + $this->stack[] = $html; + + $this->phase = self::MAIN_PHASE; + return $this->mainPhase($token); + } + } + + private function mainPhase($token) + { + /* Tokens in the main phase must be handled as follows: */ + + /* A DOCTYPE token */ + if ($token['type'] === HTML5::DOCTYPE) { + // Parse error. Ignore the token. + + /* A start tag token with the tag name "html" */ + } elseif ($token['type'] === HTML5::STARTTAG && $token['name'] === 'html') { + /* If this start tag token was not the first start tag token, then + it is a parse error. */ + + /* For each attribute on the token, check to see if the attribute + is already present on the top element of the stack of open elements. + If it is not, add the attribute and its corresponding value to that + element. */ + foreach ($token['attr'] as $attr) { + if (!$this->stack[0]->hasAttribute($attr['name'])) { + $this->stack[0]->setAttribute($attr['name'], $attr['value']); + } + } + + /* An end-of-file token */ + } elseif ($token['type'] === HTML5::EOF) { + /* Generate implied end tags. */ + $this->generateImpliedEndTags(); + + /* Anything else. */ + } else { + /* Depends on the insertion mode: */ + switch ($this->mode) { + case self::BEFOR_HEAD: + return $this->beforeHead($token); + break; + case self::IN_HEAD: + return $this->inHead($token); + break; + case self::AFTER_HEAD: + return $this->afterHead($token); + break; + case self::IN_BODY: + return $this->inBody($token); + break; + case self::IN_TABLE: + return $this->inTable($token); + break; + case self::IN_CAPTION: + return $this->inCaption($token); + break; + case self::IN_CGROUP: + return $this->inColumnGroup($token); + break; + case self::IN_TBODY: + return $this->inTableBody($token); + break; + case self::IN_ROW: + return $this->inRow($token); + break; + case self::IN_CELL: + return $this->inCell($token); + break; + case self::IN_SELECT: + return $this->inSelect($token); + break; + case self::AFTER_BODY: + return $this->afterBody($token); + break; + case self::IN_FRAME: + return $this->inFrameset($token); + break; + case self::AFTR_FRAME: + return $this->afterFrameset($token); + break; + case self::END_PHASE: + return $this->trailingEndPhase($token); + break; + } + } + } + + private function beforeHead($token) + { + /* Handle the token as follows: */ + + /* A character token that is one of one of U+0009 CHARACTER TABULATION, + U+000A LINE FEED (LF), U+000B LINE TABULATION, U+000C FORM FEED (FF), + or U+0020 SPACE */ + if ($token['type'] === HTML5::CHARACTR && + preg_match('/^[\t\n\x0b\x0c ]+$/', $token['data']) + ) { + /* Append the character to the current node. */ + $this->insertText($token['data']); + + /* A comment token */ + } elseif ($token['type'] === HTML5::COMMENT) { + /* Append a Comment node to the current node with the data attribute + set to the data given in the comment token. */ + $this->insertComment($token['data']); + + /* A start tag token with the tag name "head" */ + } elseif ($token['type'] === HTML5::STARTTAG && $token['name'] === 'head') { + /* Create an element for the token, append the new element to the + current node and push it onto the stack of open elements. */ + $element = $this->insertElement($token); + + /* Set the head element pointer to this new element node. */ + $this->head_pointer = $element; + + /* Change the insertion mode to "in head". */ + $this->mode = self::IN_HEAD; + + /* A start tag token whose tag name is one of: "base", "link", "meta", + "script", "style", "title". Or an end tag with the tag name "html". + Or a character token that is not one of U+0009 CHARACTER TABULATION, + U+000A LINE FEED (LF), U+000B LINE TABULATION, U+000C FORM FEED (FF), + or U+0020 SPACE. Or any other start tag token */ + } elseif ($token['type'] === HTML5::STARTTAG || + ($token['type'] === HTML5::ENDTAG && $token['name'] === 'html') || + ($token['type'] === HTML5::CHARACTR && !preg_match( + '/^[\t\n\x0b\x0c ]$/', + $token['data'] + )) + ) { + /* Act as if a start tag token with the tag name "head" and no + attributes had been seen, then reprocess the current token. */ + $this->beforeHead( + array( + 'name' => 'head', + 'type' => HTML5::STARTTAG, + 'attr' => array() + ) + ); + + return $this->inHead($token); + + /* Any other end tag */ + } elseif ($token['type'] === HTML5::ENDTAG) { + /* Parse error. Ignore the token. */ + } + } + + private function inHead($token) + { + /* Handle the token as follows: */ + + /* A character token that is one of one of U+0009 CHARACTER TABULATION, + U+000A LINE FEED (LF), U+000B LINE TABULATION, U+000C FORM FEED (FF), + or U+0020 SPACE. + + THIS DIFFERS FROM THE SPEC: If the current node is either a title, style + or script element, append the character to the current node regardless + of its content. */ + if (($token['type'] === HTML5::CHARACTR && + preg_match('/^[\t\n\x0b\x0c ]+$/', $token['data'])) || ( + $token['type'] === HTML5::CHARACTR && in_array( + end($this->stack)->nodeName, + array('title', 'style', 'script') + )) + ) { + /* Append the character to the current node. */ + $this->insertText($token['data']); + + /* A comment token */ + } elseif ($token['type'] === HTML5::COMMENT) { + /* Append a Comment node to the current node with the data attribute + set to the data given in the comment token. */ + $this->insertComment($token['data']); + + } elseif ($token['type'] === HTML5::ENDTAG && + in_array($token['name'], array('title', 'style', 'script')) + ) { + array_pop($this->stack); + return HTML5::PCDATA; + + /* A start tag with the tag name "title" */ + } elseif ($token['type'] === HTML5::STARTTAG && $token['name'] === 'title') { + /* Create an element for the token and append the new element to the + node pointed to by the head element pointer, or, if that is null + (innerHTML case), to the current node. */ + if ($this->head_pointer !== null) { + $element = $this->insertElement($token, false); + $this->head_pointer->appendChild($element); + + } else { + $element = $this->insertElement($token); + } + + /* Switch the tokeniser's content model flag to the RCDATA state. */ + return HTML5::RCDATA; + + /* A start tag with the tag name "style" */ + } elseif ($token['type'] === HTML5::STARTTAG && $token['name'] === 'style') { + /* Create an element for the token and append the new element to the + node pointed to by the head element pointer, or, if that is null + (innerHTML case), to the current node. */ + if ($this->head_pointer !== null) { + $element = $this->insertElement($token, false); + $this->head_pointer->appendChild($element); + + } else { + $this->insertElement($token); + } + + /* Switch the tokeniser's content model flag to the CDATA state. */ + return HTML5::CDATA; + + /* A start tag with the tag name "script" */ + } elseif ($token['type'] === HTML5::STARTTAG && $token['name'] === 'script') { + /* Create an element for the token. */ + $element = $this->insertElement($token, false); + $this->head_pointer->appendChild($element); + + /* Switch the tokeniser's content model flag to the CDATA state. */ + return HTML5::CDATA; + + /* A start tag with the tag name "base", "link", or "meta" */ + } elseif ($token['type'] === HTML5::STARTTAG && in_array( + $token['name'], + array('base', 'link', 'meta') + ) + ) { + /* Create an element for the token and append the new element to the + node pointed to by the head element pointer, or, if that is null + (innerHTML case), to the current node. */ + if ($this->head_pointer !== null) { + $element = $this->insertElement($token, false); + $this->head_pointer->appendChild($element); + array_pop($this->stack); + + } else { + $this->insertElement($token); + } + + /* An end tag with the tag name "head" */ + } elseif ($token['type'] === HTML5::ENDTAG && $token['name'] === 'head') { + /* If the current node is a head element, pop the current node off + the stack of open elements. */ + if ($this->head_pointer->isSameNode(end($this->stack))) { + array_pop($this->stack); + + /* Otherwise, this is a parse error. */ + } else { + // k + } + + /* Change the insertion mode to "after head". */ + $this->mode = self::AFTER_HEAD; + + /* A start tag with the tag name "head" or an end tag except "html". */ + } elseif (($token['type'] === HTML5::STARTTAG && $token['name'] === 'head') || + ($token['type'] === HTML5::ENDTAG && $token['name'] !== 'html') + ) { + // Parse error. Ignore the token. + + /* Anything else */ + } else { + /* If the current node is a head element, act as if an end tag + token with the tag name "head" had been seen. */ + if ($this->head_pointer->isSameNode(end($this->stack))) { + $this->inHead( + array( + 'name' => 'head', + 'type' => HTML5::ENDTAG + ) + ); + + /* Otherwise, change the insertion mode to "after head". */ + } else { + $this->mode = self::AFTER_HEAD; + } + + /* Then, reprocess the current token. */ + return $this->afterHead($token); + } + } + + private function afterHead($token) + { + /* Handle the token as follows: */ + + /* A character token that is one of one of U+0009 CHARACTER TABULATION, + U+000A LINE FEED (LF), U+000B LINE TABULATION, U+000C FORM FEED (FF), + or U+0020 SPACE */ + if ($token['type'] === HTML5::CHARACTR && + preg_match('/^[\t\n\x0b\x0c ]+$/', $token['data']) + ) { + /* Append the character to the current node. */ + $this->insertText($token['data']); + + /* A comment token */ + } elseif ($token['type'] === HTML5::COMMENT) { + /* Append a Comment node to the current node with the data attribute + set to the data given in the comment token. */ + $this->insertComment($token['data']); + + /* A start tag token with the tag name "body" */ + } elseif ($token['type'] === HTML5::STARTTAG && $token['name'] === 'body') { + /* Insert a body element for the token. */ + $this->insertElement($token); + + /* Change the insertion mode to "in body". */ + $this->mode = self::IN_BODY; + + /* A start tag token with the tag name "frameset" */ + } elseif ($token['type'] === HTML5::STARTTAG && $token['name'] === 'frameset') { + /* Insert a frameset element for the token. */ + $this->insertElement($token); + + /* Change the insertion mode to "in frameset". */ + $this->mode = self::IN_FRAME; + + /* A start tag token whose tag name is one of: "base", "link", "meta", + "script", "style", "title" */ + } elseif ($token['type'] === HTML5::STARTTAG && in_array( + $token['name'], + array('base', 'link', 'meta', 'script', 'style', 'title') + ) + ) { + /* Parse error. Switch the insertion mode back to "in head" and + reprocess the token. */ + $this->mode = self::IN_HEAD; + return $this->inHead($token); + + /* Anything else */ + } else { + /* Act as if a start tag token with the tag name "body" and no + attributes had been seen, and then reprocess the current token. */ + $this->afterHead( + array( + 'name' => 'body', + 'type' => HTML5::STARTTAG, + 'attr' => array() + ) + ); + + return $this->inBody($token); + } + } + + private function inBody($token) + { + /* Handle the token as follows: */ + + switch ($token['type']) { + /* A character token */ + case HTML5::CHARACTR: + /* Reconstruct the active formatting elements, if any. */ + $this->reconstructActiveFormattingElements(); + + /* Append the token's character to the current node. */ + $this->insertText($token['data']); + break; + + /* A comment token */ + case HTML5::COMMENT: + /* Append a Comment node to the current node with the data + attribute set to the data given in the comment token. */ + $this->insertComment($token['data']); + break; + + case HTML5::STARTTAG: + switch ($token['name']) { + /* A start tag token whose tag name is one of: "script", + "style" */ + case 'script': + case 'style': + /* Process the token as if the insertion mode had been "in + head". */ + return $this->inHead($token); + break; + + /* A start tag token whose tag name is one of: "base", "link", + "meta", "title" */ + case 'base': + case 'link': + case 'meta': + case 'title': + /* Parse error. Process the token as if the insertion mode + had been "in head". */ + return $this->inHead($token); + break; + + /* A start tag token with the tag name "body" */ + case 'body': + /* Parse error. If the second element on the stack of open + elements is not a body element, or, if the stack of open + elements has only one node on it, then ignore the token. + (innerHTML case) */ + if (count($this->stack) === 1 || $this->stack[1]->nodeName !== 'body') { + // Ignore + + /* Otherwise, for each attribute on the token, check to see + if the attribute is already present on the body element (the + second element) on the stack of open elements. If it is not, + add the attribute and its corresponding value to that + element. */ + } else { + foreach ($token['attr'] as $attr) { + if (!$this->stack[1]->hasAttribute($attr['name'])) { + $this->stack[1]->setAttribute($attr['name'], $attr['value']); + } + } + } + break; + + /* A start tag whose tag name is one of: "address", + "blockquote", "center", "dir", "div", "dl", "fieldset", + "listing", "menu", "ol", "p", "ul" */ + case 'address': + case 'blockquote': + case 'center': + case 'dir': + case 'div': + case 'dl': + case 'fieldset': + case 'listing': + case 'menu': + case 'ol': + case 'p': + case 'ul': + /* If the stack of open elements has a p element in scope, + then act as if an end tag with the tag name p had been + seen. */ + if ($this->elementInScope('p')) { + $this->emitToken( + array( + 'name' => 'p', + 'type' => HTML5::ENDTAG + ) + ); + } + + /* Insert an HTML element for the token. */ + $this->insertElement($token); + break; + + /* A start tag whose tag name is "form" */ + case 'form': + /* If the form element pointer is not null, ignore the + token with a parse error. */ + if ($this->form_pointer !== null) { + // Ignore. + + /* Otherwise: */ + } else { + /* If the stack of open elements has a p element in + scope, then act as if an end tag with the tag name p + had been seen. */ + if ($this->elementInScope('p')) { + $this->emitToken( + array( + 'name' => 'p', + 'type' => HTML5::ENDTAG + ) + ); + } + + /* Insert an HTML element for the token, and set the + form element pointer to point to the element created. */ + $element = $this->insertElement($token); + $this->form_pointer = $element; + } + break; + + /* A start tag whose tag name is "li", "dd" or "dt" */ + case 'li': + case 'dd': + case 'dt': + /* If the stack of open elements has a p element in scope, + then act as if an end tag with the tag name p had been + seen. */ + if ($this->elementInScope('p')) { + $this->emitToken( + array( + 'name' => 'p', + 'type' => HTML5::ENDTAG + ) + ); + } + + $stack_length = count($this->stack) - 1; + + for ($n = $stack_length; 0 <= $n; $n--) { + /* 1. Initialise node to be the current node (the + bottommost node of the stack). */ + $stop = false; + $node = $this->stack[$n]; + $cat = $this->getElementCategory($node->tagName); + + /* 2. If node is an li, dd or dt element, then pop all + the nodes from the current node up to node, including + node, then stop this algorithm. */ + if ($token['name'] === $node->tagName || ($token['name'] !== 'li' + && ($node->tagName === 'dd' || $node->tagName === 'dt')) + ) { + for ($x = $stack_length; $x >= $n; $x--) { + array_pop($this->stack); + } + + break; + } + + /* 3. If node is not in the formatting category, and is + not in the phrasing category, and is not an address or + div element, then stop this algorithm. */ + if ($cat !== self::FORMATTING && $cat !== self::PHRASING && + $node->tagName !== 'address' && $node->tagName !== 'div' + ) { + break; + } + } + + /* Finally, insert an HTML element with the same tag + name as the token's. */ + $this->insertElement($token); + break; + + /* A start tag token whose tag name is "plaintext" */ + case 'plaintext': + /* If the stack of open elements has a p element in scope, + then act as if an end tag with the tag name p had been + seen. */ + if ($this->elementInScope('p')) { + $this->emitToken( + array( + 'name' => 'p', + 'type' => HTML5::ENDTAG + ) + ); + } + + /* Insert an HTML element for the token. */ + $this->insertElement($token); + + return HTML5::PLAINTEXT; + break; + + /* A start tag whose tag name is one of: "h1", "h2", "h3", "h4", + "h5", "h6" */ + case 'h1': + case 'h2': + case 'h3': + case 'h4': + case 'h5': + case 'h6': + /* If the stack of open elements has a p element in scope, + then act as if an end tag with the tag name p had been seen. */ + if ($this->elementInScope('p')) { + $this->emitToken( + array( + 'name' => 'p', + 'type' => HTML5::ENDTAG + ) + ); + } + + /* If the stack of open elements has in scope an element whose + tag name is one of "h1", "h2", "h3", "h4", "h5", or "h6", then + this is a parse error; pop elements from the stack until an + element with one of those tag names has been popped from the + stack. */ + while ($this->elementInScope(array('h1', 'h2', 'h3', 'h4', 'h5', 'h6'))) { + array_pop($this->stack); + } + + /* Insert an HTML element for the token. */ + $this->insertElement($token); + break; + + /* A start tag whose tag name is "a" */ + case 'a': + /* If the list of active formatting elements contains + an element whose tag name is "a" between the end of the + list and the last marker on the list (or the start of + the list if there is no marker on the list), then this + is a parse error; act as if an end tag with the tag name + "a" had been seen, then remove that element from the list + of active formatting elements and the stack of open + elements if the end tag didn't already remove it (it + might not have if the element is not in table scope). */ + $leng = count($this->a_formatting); + + for ($n = $leng - 1; $n >= 0; $n--) { + if ($this->a_formatting[$n] === self::MARKER) { + break; + + } elseif ($this->a_formatting[$n]->nodeName === 'a') { + $this->emitToken( + array( + 'name' => 'a', + 'type' => HTML5::ENDTAG + ) + ); + break; + } + } + + /* Reconstruct the active formatting elements, if any. */ + $this->reconstructActiveFormattingElements(); + + /* Insert an HTML element for the token. */ + $el = $this->insertElement($token); + + /* Add that element to the list of active formatting + elements. */ + $this->a_formatting[] = $el; + break; + + /* A start tag whose tag name is one of: "b", "big", "em", "font", + "i", "nobr", "s", "small", "strike", "strong", "tt", "u" */ + case 'b': + case 'big': + case 'em': + case 'font': + case 'i': + case 'nobr': + case 's': + case 'small': + case 'strike': + case 'strong': + case 'tt': + case 'u': + /* Reconstruct the active formatting elements, if any. */ + $this->reconstructActiveFormattingElements(); + + /* Insert an HTML element for the token. */ + $el = $this->insertElement($token); + + /* Add that element to the list of active formatting + elements. */ + $this->a_formatting[] = $el; + break; + + /* A start tag token whose tag name is "button" */ + case 'button': + /* If the stack of open elements has a button element in scope, + then this is a parse error; act as if an end tag with the tag + name "button" had been seen, then reprocess the token. (We don't + do that. Unnecessary.) */ + if ($this->elementInScope('button')) { + $this->inBody( + array( + 'name' => 'button', + 'type' => HTML5::ENDTAG + ) + ); + } + + /* Reconstruct the active formatting elements, if any. */ + $this->reconstructActiveFormattingElements(); + + /* Insert an HTML element for the token. */ + $this->insertElement($token); + + /* Insert a marker at the end of the list of active + formatting elements. */ + $this->a_formatting[] = self::MARKER; + break; + + /* A start tag token whose tag name is one of: "marquee", "object" */ + case 'marquee': + case 'object': + /* Reconstruct the active formatting elements, if any. */ + $this->reconstructActiveFormattingElements(); + + /* Insert an HTML element for the token. */ + $this->insertElement($token); + + /* Insert a marker at the end of the list of active + formatting elements. */ + $this->a_formatting[] = self::MARKER; + break; + + /* A start tag token whose tag name is "xmp" */ + case 'xmp': + /* Reconstruct the active formatting elements, if any. */ + $this->reconstructActiveFormattingElements(); + + /* Insert an HTML element for the token. */ + $this->insertElement($token); + + /* Switch the content model flag to the CDATA state. */ + return HTML5::CDATA; + break; + + /* A start tag whose tag name is "table" */ + case 'table': + /* If the stack of open elements has a p element in scope, + then act as if an end tag with the tag name p had been seen. */ + if ($this->elementInScope('p')) { + $this->emitToken( + array( + 'name' => 'p', + 'type' => HTML5::ENDTAG + ) + ); + } + + /* Insert an HTML element for the token. */ + $this->insertElement($token); + + /* Change the insertion mode to "in table". */ + $this->mode = self::IN_TABLE; + break; + + /* A start tag whose tag name is one of: "area", "basefont", + "bgsound", "br", "embed", "img", "param", "spacer", "wbr" */ + case 'area': + case 'basefont': + case 'bgsound': + case 'br': + case 'embed': + case 'img': + case 'param': + case 'spacer': + case 'wbr': + /* Reconstruct the active formatting elements, if any. */ + $this->reconstructActiveFormattingElements(); + + /* Insert an HTML element for the token. */ + $this->insertElement($token); + + /* Immediately pop the current node off the stack of open elements. */ + array_pop($this->stack); + break; + + /* A start tag whose tag name is "hr" */ + case 'hr': + /* If the stack of open elements has a p element in scope, + then act as if an end tag with the tag name p had been seen. */ + if ($this->elementInScope('p')) { + $this->emitToken( + array( + 'name' => 'p', + 'type' => HTML5::ENDTAG + ) + ); + } + + /* Insert an HTML element for the token. */ + $this->insertElement($token); + + /* Immediately pop the current node off the stack of open elements. */ + array_pop($this->stack); + break; + + /* A start tag whose tag name is "image" */ + case 'image': + /* Parse error. Change the token's tag name to "img" and + reprocess it. (Don't ask.) */ + $token['name'] = 'img'; + return $this->inBody($token); + break; + + /* A start tag whose tag name is "input" */ + case 'input': + /* Reconstruct the active formatting elements, if any. */ + $this->reconstructActiveFormattingElements(); + + /* Insert an input element for the token. */ + $element = $this->insertElement($token, false); + + /* If the form element pointer is not null, then associate the + input element with the form element pointed to by the form + element pointer. */ + $this->form_pointer !== null + ? $this->form_pointer->appendChild($element) + : end($this->stack)->appendChild($element); + + /* Pop that input element off the stack of open elements. */ + array_pop($this->stack); + break; + + /* A start tag whose tag name is "isindex" */ + case 'isindex': + /* Parse error. */ + // w/e + + /* If the form element pointer is not null, + then ignore the token. */ + if ($this->form_pointer === null) { + /* Act as if a start tag token with the tag name "form" had + been seen. */ + $this->inBody( + array( + 'name' => 'body', + 'type' => HTML5::STARTTAG, + 'attr' => array() + ) + ); + + /* Act as if a start tag token with the tag name "hr" had + been seen. */ + $this->inBody( + array( + 'name' => 'hr', + 'type' => HTML5::STARTTAG, + 'attr' => array() + ) + ); + + /* Act as if a start tag token with the tag name "p" had + been seen. */ + $this->inBody( + array( + 'name' => 'p', + 'type' => HTML5::STARTTAG, + 'attr' => array() + ) + ); + + /* Act as if a start tag token with the tag name "label" + had been seen. */ + $this->inBody( + array( + 'name' => 'label', + 'type' => HTML5::STARTTAG, + 'attr' => array() + ) + ); + + /* Act as if a stream of character tokens had been seen. */ + $this->insertText( + 'This is a searchable index. ' . + 'Insert your search keywords here: ' + ); + + /* Act as if a start tag token with the tag name "input" + had been seen, with all the attributes from the "isindex" + token, except with the "name" attribute set to the value + "isindex" (ignoring any explicit "name" attribute). */ + $attr = $token['attr']; + $attr[] = array('name' => 'name', 'value' => 'isindex'); + + $this->inBody( + array( + 'name' => 'input', + 'type' => HTML5::STARTTAG, + 'attr' => $attr + ) + ); + + /* Act as if a stream of character tokens had been seen + (see below for what they should say). */ + $this->insertText( + 'This is a searchable index. ' . + 'Insert your search keywords here: ' + ); + + /* Act as if an end tag token with the tag name "label" + had been seen. */ + $this->inBody( + array( + 'name' => 'label', + 'type' => HTML5::ENDTAG + ) + ); + + /* Act as if an end tag token with the tag name "p" had + been seen. */ + $this->inBody( + array( + 'name' => 'p', + 'type' => HTML5::ENDTAG + ) + ); + + /* Act as if a start tag token with the tag name "hr" had + been seen. */ + $this->inBody( + array( + 'name' => 'hr', + 'type' => HTML5::ENDTAG + ) + ); + + /* Act as if an end tag token with the tag name "form" had + been seen. */ + $this->inBody( + array( + 'name' => 'form', + 'type' => HTML5::ENDTAG + ) + ); + } + break; + + /* A start tag whose tag name is "textarea" */ + case 'textarea': + $this->insertElement($token); + + /* Switch the tokeniser's content model flag to the + RCDATA state. */ + return HTML5::RCDATA; + break; + + /* A start tag whose tag name is one of: "iframe", "noembed", + "noframes" */ + case 'iframe': + case 'noembed': + case 'noframes': + $this->insertElement($token); + + /* Switch the tokeniser's content model flag to the CDATA state. */ + return HTML5::CDATA; + break; + + /* A start tag whose tag name is "select" */ + case 'select': + /* Reconstruct the active formatting elements, if any. */ + $this->reconstructActiveFormattingElements(); + + /* Insert an HTML element for the token. */ + $this->insertElement($token); + + /* Change the insertion mode to "in select". */ + $this->mode = self::IN_SELECT; + break; + + /* A start or end tag whose tag name is one of: "caption", "col", + "colgroup", "frame", "frameset", "head", "option", "optgroup", + "tbody", "td", "tfoot", "th", "thead", "tr". */ + case 'caption': + case 'col': + case 'colgroup': + case 'frame': + case 'frameset': + case 'head': + case 'option': + case 'optgroup': + case 'tbody': + case 'td': + case 'tfoot': + case 'th': + case 'thead': + case 'tr': + // Parse error. Ignore the token. + break; + + /* A start or end tag whose tag name is one of: "event-source", + "section", "nav", "article", "aside", "header", "footer", + "datagrid", "command" */ + case 'event-source': + case 'section': + case 'nav': + case 'article': + case 'aside': + case 'header': + case 'footer': + case 'datagrid': + case 'command': + // Work in progress! + break; + + /* A start tag token not covered by the previous entries */ + default: + /* Reconstruct the active formatting elements, if any. */ + $this->reconstructActiveFormattingElements(); + + $this->insertElement($token, true, true); + break; + } + break; + + case HTML5::ENDTAG: + switch ($token['name']) { + /* An end tag with the tag name "body" */ + case 'body': + /* If the second element in the stack of open elements is + not a body element, this is a parse error. Ignore the token. + (innerHTML case) */ + if (count($this->stack) < 2 || $this->stack[1]->nodeName !== 'body') { + // Ignore. + + /* If the current node is not the body element, then this + is a parse error. */ + } elseif (end($this->stack)->nodeName !== 'body') { + // Parse error. + } + + /* Change the insertion mode to "after body". */ + $this->mode = self::AFTER_BODY; + break; + + /* An end tag with the tag name "html" */ + case 'html': + /* Act as if an end tag with tag name "body" had been seen, + then, if that token wasn't ignored, reprocess the current + token. */ + $this->inBody( + array( + 'name' => 'body', + 'type' => HTML5::ENDTAG + ) + ); + + return $this->afterBody($token); + break; + + /* An end tag whose tag name is one of: "address", "blockquote", + "center", "dir", "div", "dl", "fieldset", "listing", "menu", + "ol", "pre", "ul" */ + case 'address': + case 'blockquote': + case 'center': + case 'dir': + case 'div': + case 'dl': + case 'fieldset': + case 'listing': + case 'menu': + case 'ol': + case 'pre': + case 'ul': + /* If the stack of open elements has an element in scope + with the same tag name as that of the token, then generate + implied end tags. */ + if ($this->elementInScope($token['name'])) { + $this->generateImpliedEndTags(); + + /* Now, if the current node is not an element with + the same tag name as that of the token, then this + is a parse error. */ + // w/e + + /* If the stack of open elements has an element in + scope with the same tag name as that of the token, + then pop elements from this stack until an element + with that tag name has been popped from the stack. */ + for ($n = count($this->stack) - 1; $n >= 0; $n--) { + if ($this->stack[$n]->nodeName === $token['name']) { + $n = -1; + } + + array_pop($this->stack); + } + } + break; + + /* An end tag whose tag name is "form" */ + case 'form': + /* If the stack of open elements has an element in scope + with the same tag name as that of the token, then generate + implied end tags. */ + if ($this->elementInScope($token['name'])) { + $this->generateImpliedEndTags(); + + } + + if (end($this->stack)->nodeName !== $token['name']) { + /* Now, if the current node is not an element with the + same tag name as that of the token, then this is a parse + error. */ + // w/e + + } else { + /* Otherwise, if the current node is an element with + the same tag name as that of the token pop that element + from the stack. */ + array_pop($this->stack); + } + + /* In any case, set the form element pointer to null. */ + $this->form_pointer = null; + break; + + /* An end tag whose tag name is "p" */ + case 'p': + /* If the stack of open elements has a p element in scope, + then generate implied end tags, except for p elements. */ + if ($this->elementInScope('p')) { + $this->generateImpliedEndTags(array('p')); + + /* If the current node is not a p element, then this is + a parse error. */ + // k + + /* If the stack of open elements has a p element in + scope, then pop elements from this stack until the stack + no longer has a p element in scope. */ + for ($n = count($this->stack) - 1; $n >= 0; $n--) { + if ($this->elementInScope('p')) { + array_pop($this->stack); + + } else { + break; + } + } + } + break; + + /* An end tag whose tag name is "dd", "dt", or "li" */ + case 'dd': + case 'dt': + case 'li': + /* If the stack of open elements has an element in scope + whose tag name matches the tag name of the token, then + generate implied end tags, except for elements with the + same tag name as the token. */ + if ($this->elementInScope($token['name'])) { + $this->generateImpliedEndTags(array($token['name'])); + + /* If the current node is not an element with the same + tag name as the token, then this is a parse error. */ + // w/e + + /* If the stack of open elements has an element in scope + whose tag name matches the tag name of the token, then + pop elements from this stack until an element with that + tag name has been popped from the stack. */ + for ($n = count($this->stack) - 1; $n >= 0; $n--) { + if ($this->stack[$n]->nodeName === $token['name']) { + $n = -1; + } + + array_pop($this->stack); + } + } + break; + + /* An end tag whose tag name is one of: "h1", "h2", "h3", "h4", + "h5", "h6" */ + case 'h1': + case 'h2': + case 'h3': + case 'h4': + case 'h5': + case 'h6': + $elements = array('h1', 'h2', 'h3', 'h4', 'h5', 'h6'); + + /* If the stack of open elements has in scope an element whose + tag name is one of "h1", "h2", "h3", "h4", "h5", or "h6", then + generate implied end tags. */ + if ($this->elementInScope($elements)) { + $this->generateImpliedEndTags(); + + /* Now, if the current node is not an element with the same + tag name as that of the token, then this is a parse error. */ + // w/e + + /* If the stack of open elements has in scope an element + whose tag name is one of "h1", "h2", "h3", "h4", "h5", or + "h6", then pop elements from the stack until an element + with one of those tag names has been popped from the stack. */ + while ($this->elementInScope($elements)) { + array_pop($this->stack); + } + } + break; + + /* An end tag whose tag name is one of: "a", "b", "big", "em", + "font", "i", "nobr", "s", "small", "strike", "strong", "tt", "u" */ + case 'a': + case 'b': + case 'big': + case 'em': + case 'font': + case 'i': + case 'nobr': + case 's': + case 'small': + case 'strike': + case 'strong': + case 'tt': + case 'u': + /* 1. Let the formatting element be the last element in + the list of active formatting elements that: + * is between the end of the list and the last scope + marker in the list, if any, or the start of the list + otherwise, and + * has the same tag name as the token. + */ + while (true) { + for ($a = count($this->a_formatting) - 1; $a >= 0; $a--) { + if ($this->a_formatting[$a] === self::MARKER) { + break; + + } elseif ($this->a_formatting[$a]->tagName === $token['name']) { + $formatting_element = $this->a_formatting[$a]; + $in_stack = in_array($formatting_element, $this->stack, true); + $fe_af_pos = $a; + break; + } + } + + /* If there is no such node, or, if that node is + also in the stack of open elements but the element + is not in scope, then this is a parse error. Abort + these steps. The token is ignored. */ + if (!isset($formatting_element) || ($in_stack && + !$this->elementInScope($token['name'])) + ) { + break; + + /* Otherwise, if there is such a node, but that node + is not in the stack of open elements, then this is a + parse error; remove the element from the list, and + abort these steps. */ + } elseif (isset($formatting_element) && !$in_stack) { + unset($this->a_formatting[$fe_af_pos]); + $this->a_formatting = array_merge($this->a_formatting); + break; + } + + /* 2. Let the furthest block be the topmost node in the + stack of open elements that is lower in the stack + than the formatting element, and is not an element in + the phrasing or formatting categories. There might + not be one. */ + $fe_s_pos = array_search($formatting_element, $this->stack, true); + $length = count($this->stack); + + for ($s = $fe_s_pos + 1; $s < $length; $s++) { + $category = $this->getElementCategory($this->stack[$s]->nodeName); + + if ($category !== self::PHRASING && $category !== self::FORMATTING) { + $furthest_block = $this->stack[$s]; + } + } + + /* 3. If there is no furthest block, then the UA must + skip the subsequent steps and instead just pop all + the nodes from the bottom of the stack of open + elements, from the current node up to the formatting + element, and remove the formatting element from the + list of active formatting elements. */ + if (!isset($furthest_block)) { + for ($n = $length - 1; $n >= $fe_s_pos; $n--) { + array_pop($this->stack); + } + + unset($this->a_formatting[$fe_af_pos]); + $this->a_formatting = array_merge($this->a_formatting); + break; + } + + /* 4. Let the common ancestor be the element + immediately above the formatting element in the stack + of open elements. */ + $common_ancestor = $this->stack[$fe_s_pos - 1]; + + /* 5. If the furthest block has a parent node, then + remove the furthest block from its parent node. */ + if ($furthest_block->parentNode !== null) { + $furthest_block->parentNode->removeChild($furthest_block); + } + + /* 6. Let a bookmark note the position of the + formatting element in the list of active formatting + elements relative to the elements on either side + of it in the list. */ + $bookmark = $fe_af_pos; + + /* 7. Let node and last node be the furthest block. + Follow these steps: */ + $node = $furthest_block; + $last_node = $furthest_block; + + while (true) { + for ($n = array_search($node, $this->stack, true) - 1; $n >= 0; $n--) { + /* 7.1 Let node be the element immediately + prior to node in the stack of open elements. */ + $node = $this->stack[$n]; + + /* 7.2 If node is not in the list of active + formatting elements, then remove node from + the stack of open elements and then go back + to step 1. */ + if (!in_array($node, $this->a_formatting, true)) { + unset($this->stack[$n]); + $this->stack = array_merge($this->stack); + + } else { + break; + } + } + + /* 7.3 Otherwise, if node is the formatting + element, then go to the next step in the overall + algorithm. */ + if ($node === $formatting_element) { + break; + + /* 7.4 Otherwise, if last node is the furthest + block, then move the aforementioned bookmark to + be immediately after the node in the list of + active formatting elements. */ + } elseif ($last_node === $furthest_block) { + $bookmark = array_search($node, $this->a_formatting, true) + 1; + } + + /* 7.5 If node has any children, perform a + shallow clone of node, replace the entry for + node in the list of active formatting elements + with an entry for the clone, replace the entry + for node in the stack of open elements with an + entry for the clone, and let node be the clone. */ + if ($node->hasChildNodes()) { + $clone = $node->cloneNode(); + $s_pos = array_search($node, $this->stack, true); + $a_pos = array_search($node, $this->a_formatting, true); + + $this->stack[$s_pos] = $clone; + $this->a_formatting[$a_pos] = $clone; + $node = $clone; + } + + /* 7.6 Insert last node into node, first removing + it from its previous parent node if any. */ + if ($last_node->parentNode !== null) { + $last_node->parentNode->removeChild($last_node); + } + + $node->appendChild($last_node); + + /* 7.7 Let last node be node. */ + $last_node = $node; + } + + /* 8. Insert whatever last node ended up being in + the previous step into the common ancestor node, + first removing it from its previous parent node if + any. */ + if ($last_node->parentNode !== null) { + $last_node->parentNode->removeChild($last_node); + } + + $common_ancestor->appendChild($last_node); + + /* 9. Perform a shallow clone of the formatting + element. */ + $clone = $formatting_element->cloneNode(); + + /* 10. Take all of the child nodes of the furthest + block and append them to the clone created in the + last step. */ + while ($furthest_block->hasChildNodes()) { + $child = $furthest_block->firstChild; + $furthest_block->removeChild($child); + $clone->appendChild($child); + } + + /* 11. Append that clone to the furthest block. */ + $furthest_block->appendChild($clone); + + /* 12. Remove the formatting element from the list + of active formatting elements, and insert the clone + into the list of active formatting elements at the + position of the aforementioned bookmark. */ + $fe_af_pos = array_search($formatting_element, $this->a_formatting, true); + unset($this->a_formatting[$fe_af_pos]); + $this->a_formatting = array_merge($this->a_formatting); + + $af_part1 = array_slice($this->a_formatting, 0, $bookmark - 1); + $af_part2 = array_slice($this->a_formatting, $bookmark, count($this->a_formatting)); + $this->a_formatting = array_merge($af_part1, array($clone), $af_part2); + + /* 13. Remove the formatting element from the stack + of open elements, and insert the clone into the stack + of open elements immediately after (i.e. in a more + deeply nested position than) the position of the + furthest block in that stack. */ + $fe_s_pos = array_search($formatting_element, $this->stack, true); + $fb_s_pos = array_search($furthest_block, $this->stack, true); + unset($this->stack[$fe_s_pos]); + + $s_part1 = array_slice($this->stack, 0, $fb_s_pos); + $s_part2 = array_slice($this->stack, $fb_s_pos + 1, count($this->stack)); + $this->stack = array_merge($s_part1, array($clone), $s_part2); + + /* 14. Jump back to step 1 in this series of steps. */ + unset($formatting_element, $fe_af_pos, $fe_s_pos, $furthest_block); + } + break; + + /* An end tag token whose tag name is one of: "button", + "marquee", "object" */ + case 'button': + case 'marquee': + case 'object': + /* If the stack of open elements has an element in scope whose + tag name matches the tag name of the token, then generate implied + tags. */ + if ($this->elementInScope($token['name'])) { + $this->generateImpliedEndTags(); + + /* Now, if the current node is not an element with the same + tag name as the token, then this is a parse error. */ + // k + + /* Now, if the stack of open elements has an element in scope + whose tag name matches the tag name of the token, then pop + elements from the stack until that element has been popped from + the stack, and clear the list of active formatting elements up + to the last marker. */ + for ($n = count($this->stack) - 1; $n >= 0; $n--) { + if ($this->stack[$n]->nodeName === $token['name']) { + $n = -1; + } + + array_pop($this->stack); + } + + $marker = end(array_keys($this->a_formatting, self::MARKER, true)); + + for ($n = count($this->a_formatting) - 1; $n > $marker; $n--) { + array_pop($this->a_formatting); + } + } + break; + + /* Or an end tag whose tag name is one of: "area", "basefont", + "bgsound", "br", "embed", "hr", "iframe", "image", "img", + "input", "isindex", "noembed", "noframes", "param", "select", + "spacer", "table", "textarea", "wbr" */ + case 'area': + case 'basefont': + case 'bgsound': + case 'br': + case 'embed': + case 'hr': + case 'iframe': + case 'image': + case 'img': + case 'input': + case 'isindex': + case 'noembed': + case 'noframes': + case 'param': + case 'select': + case 'spacer': + case 'table': + case 'textarea': + case 'wbr': + // Parse error. Ignore the token. + break; + + /* An end tag token not covered by the previous entries */ + default: + for ($n = count($this->stack) - 1; $n >= 0; $n--) { + /* Initialise node to be the current node (the bottommost + node of the stack). */ + $node = end($this->stack); + + /* If node has the same tag name as the end tag token, + then: */ + if ($token['name'] === $node->nodeName) { + /* Generate implied end tags. */ + $this->generateImpliedEndTags(); + + /* If the tag name of the end tag token does not + match the tag name of the current node, this is a + parse error. */ + // k + + /* Pop all the nodes from the current node up to + node, including node, then stop this algorithm. */ + for ($x = count($this->stack) - $n; $x >= $n; $x--) { + array_pop($this->stack); + } + + } else { + $category = $this->getElementCategory($node); + + if ($category !== self::SPECIAL && $category !== self::SCOPING) { + /* Otherwise, if node is in neither the formatting + category nor the phrasing category, then this is a + parse error. Stop this algorithm. The end tag token + is ignored. */ + return false; + } + } + } + break; + } + break; + } + } + + private function inTable($token) + { + $clear = array('html', 'table'); + + /* A character token that is one of one of U+0009 CHARACTER TABULATION, + U+000A LINE FEED (LF), U+000B LINE TABULATION, U+000C FORM FEED (FF), + or U+0020 SPACE */ + if ($token['type'] === HTML5::CHARACTR && + preg_match('/^[\t\n\x0b\x0c ]+$/', $token['data']) + ) { + /* Append the character to the current node. */ + $text = $this->dom->createTextNode($token['data']); + end($this->stack)->appendChild($text); + + /* A comment token */ + } elseif ($token['type'] === HTML5::COMMENT) { + /* Append a Comment node to the current node with the data + attribute set to the data given in the comment token. */ + $comment = $this->dom->createComment($token['data']); + end($this->stack)->appendChild($comment); + + /* A start tag whose tag name is "caption" */ + } elseif ($token['type'] === HTML5::STARTTAG && + $token['name'] === 'caption' + ) { + /* Clear the stack back to a table context. */ + $this->clearStackToTableContext($clear); + + /* Insert a marker at the end of the list of active + formatting elements. */ + $this->a_formatting[] = self::MARKER; + + /* Insert an HTML element for the token, then switch the + insertion mode to "in caption". */ + $this->insertElement($token); + $this->mode = self::IN_CAPTION; + + /* A start tag whose tag name is "colgroup" */ + } elseif ($token['type'] === HTML5::STARTTAG && + $token['name'] === 'colgroup' + ) { + /* Clear the stack back to a table context. */ + $this->clearStackToTableContext($clear); + + /* Insert an HTML element for the token, then switch the + insertion mode to "in column group". */ + $this->insertElement($token); + $this->mode = self::IN_CGROUP; + + /* A start tag whose tag name is "col" */ + } elseif ($token['type'] === HTML5::STARTTAG && + $token['name'] === 'col' + ) { + $this->inTable( + array( + 'name' => 'colgroup', + 'type' => HTML5::STARTTAG, + 'attr' => array() + ) + ); + + $this->inColumnGroup($token); + + /* A start tag whose tag name is one of: "tbody", "tfoot", "thead" */ + } elseif ($token['type'] === HTML5::STARTTAG && in_array( + $token['name'], + array('tbody', 'tfoot', 'thead') + ) + ) { + /* Clear the stack back to a table context. */ + $this->clearStackToTableContext($clear); + + /* Insert an HTML element for the token, then switch the insertion + mode to "in table body". */ + $this->insertElement($token); + $this->mode = self::IN_TBODY; + + /* A start tag whose tag name is one of: "td", "th", "tr" */ + } elseif ($token['type'] === HTML5::STARTTAG && + in_array($token['name'], array('td', 'th', 'tr')) + ) { + /* Act as if a start tag token with the tag name "tbody" had been + seen, then reprocess the current token. */ + $this->inTable( + array( + 'name' => 'tbody', + 'type' => HTML5::STARTTAG, + 'attr' => array() + ) + ); + + return $this->inTableBody($token); + + /* A start tag whose tag name is "table" */ + } elseif ($token['type'] === HTML5::STARTTAG && + $token['name'] === 'table' + ) { + /* Parse error. Act as if an end tag token with the tag name "table" + had been seen, then, if that token wasn't ignored, reprocess the + current token. */ + $this->inTable( + array( + 'name' => 'table', + 'type' => HTML5::ENDTAG + ) + ); + + return $this->mainPhase($token); + + /* An end tag whose tag name is "table" */ + } elseif ($token['type'] === HTML5::ENDTAG && + $token['name'] === 'table' + ) { + /* If the stack of open elements does not have an element in table + scope with the same tag name as the token, this is a parse error. + Ignore the token. (innerHTML case) */ + if (!$this->elementInScope($token['name'], true)) { + return false; + + /* Otherwise: */ + } else { + /* Generate implied end tags. */ + $this->generateImpliedEndTags(); + + /* Now, if the current node is not a table element, then this + is a parse error. */ + // w/e + + /* Pop elements from this stack until a table element has been + popped from the stack. */ + while (true) { + $current = end($this->stack)->nodeName; + array_pop($this->stack); + + if ($current === 'table') { + break; + } + } + + /* Reset the insertion mode appropriately. */ + $this->resetInsertionMode(); + } + + /* An end tag whose tag name is one of: "body", "caption", "col", + "colgroup", "html", "tbody", "td", "tfoot", "th", "thead", "tr" */ + } elseif ($token['type'] === HTML5::ENDTAG && in_array( + $token['name'], + array( + 'body', + 'caption', + 'col', + 'colgroup', + 'html', + 'tbody', + 'td', + 'tfoot', + 'th', + 'thead', + 'tr' + ) + ) + ) { + // Parse error. Ignore the token. + + /* Anything else */ + } else { + /* Parse error. Process the token as if the insertion mode was "in + body", with the following exception: */ + + /* If the current node is a table, tbody, tfoot, thead, or tr + element, then, whenever a node would be inserted into the current + node, it must instead be inserted into the foster parent element. */ + if (in_array( + end($this->stack)->nodeName, + array('table', 'tbody', 'tfoot', 'thead', 'tr') + ) + ) { + /* The foster parent element is the parent element of the last + table element in the stack of open elements, if there is a + table element and it has such a parent element. If there is no + table element in the stack of open elements (innerHTML case), + then the foster parent element is the first element in the + stack of open elements (the html element). Otherwise, if there + is a table element in the stack of open elements, but the last + table element in the stack of open elements has no parent, or + its parent node is not an element, then the foster parent + element is the element before the last table element in the + stack of open elements. */ + for ($n = count($this->stack) - 1; $n >= 0; $n--) { + if ($this->stack[$n]->nodeName === 'table') { + $table = $this->stack[$n]; + break; + } + } + + if (isset($table) && $table->parentNode !== null) { + $this->foster_parent = $table->parentNode; + + } elseif (!isset($table)) { + $this->foster_parent = $this->stack[0]; + + } elseif (isset($table) && ($table->parentNode === null || + $table->parentNode->nodeType !== XML_ELEMENT_NODE) + ) { + $this->foster_parent = $this->stack[$n - 1]; + } + } + + $this->inBody($token); + } + } + + private function inCaption($token) + { + /* An end tag whose tag name is "caption" */ + if ($token['type'] === HTML5::ENDTAG && $token['name'] === 'caption') { + /* If the stack of open elements does not have an element in table + scope with the same tag name as the token, this is a parse error. + Ignore the token. (innerHTML case) */ + if (!$this->elementInScope($token['name'], true)) { + // Ignore + + /* Otherwise: */ + } else { + /* Generate implied end tags. */ + $this->generateImpliedEndTags(); + + /* Now, if the current node is not a caption element, then this + is a parse error. */ + // w/e + + /* Pop elements from this stack until a caption element has + been popped from the stack. */ + while (true) { + $node = end($this->stack)->nodeName; + array_pop($this->stack); + + if ($node === 'caption') { + break; + } + } + + /* Clear the list of active formatting elements up to the last + marker. */ + $this->clearTheActiveFormattingElementsUpToTheLastMarker(); + + /* Switch the insertion mode to "in table". */ + $this->mode = self::IN_TABLE; + } + + /* A start tag whose tag name is one of: "caption", "col", "colgroup", + "tbody", "td", "tfoot", "th", "thead", "tr", or an end tag whose tag + name is "table" */ + } elseif (($token['type'] === HTML5::STARTTAG && in_array( + $token['name'], + array( + 'caption', + 'col', + 'colgroup', + 'tbody', + 'td', + 'tfoot', + 'th', + 'thead', + 'tr' + ) + )) || ($token['type'] === HTML5::ENDTAG && + $token['name'] === 'table') + ) { + /* Parse error. Act as if an end tag with the tag name "caption" + had been seen, then, if that token wasn't ignored, reprocess the + current token. */ + $this->inCaption( + array( + 'name' => 'caption', + 'type' => HTML5::ENDTAG + ) + ); + + return $this->inTable($token); + + /* An end tag whose tag name is one of: "body", "col", "colgroup", + "html", "tbody", "td", "tfoot", "th", "thead", "tr" */ + } elseif ($token['type'] === HTML5::ENDTAG && in_array( + $token['name'], + array( + 'body', + 'col', + 'colgroup', + 'html', + 'tbody', + 'tfoot', + 'th', + 'thead', + 'tr' + ) + ) + ) { + // Parse error. Ignore the token. + + /* Anything else */ + } else { + /* Process the token as if the insertion mode was "in body". */ + $this->inBody($token); + } + } + + private function inColumnGroup($token) + { + /* A character token that is one of one of U+0009 CHARACTER TABULATION, + U+000A LINE FEED (LF), U+000B LINE TABULATION, U+000C FORM FEED (FF), + or U+0020 SPACE */ + if ($token['type'] === HTML5::CHARACTR && + preg_match('/^[\t\n\x0b\x0c ]+$/', $token['data']) + ) { + /* Append the character to the current node. */ + $text = $this->dom->createTextNode($token['data']); + end($this->stack)->appendChild($text); + + /* A comment token */ + } elseif ($token['type'] === HTML5::COMMENT) { + /* Append a Comment node to the current node with the data + attribute set to the data given in the comment token. */ + $comment = $this->dom->createComment($token['data']); + end($this->stack)->appendChild($comment); + + /* A start tag whose tag name is "col" */ + } elseif ($token['type'] === HTML5::STARTTAG && $token['name'] === 'col') { + /* Insert a col element for the token. Immediately pop the current + node off the stack of open elements. */ + $this->insertElement($token); + array_pop($this->stack); + + /* An end tag whose tag name is "colgroup" */ + } elseif ($token['type'] === HTML5::ENDTAG && + $token['name'] === 'colgroup' + ) { + /* If the current node is the root html element, then this is a + parse error, ignore the token. (innerHTML case) */ + if (end($this->stack)->nodeName === 'html') { + // Ignore + + /* Otherwise, pop the current node (which will be a colgroup + element) from the stack of open elements. Switch the insertion + mode to "in table". */ + } else { + array_pop($this->stack); + $this->mode = self::IN_TABLE; + } + + /* An end tag whose tag name is "col" */ + } elseif ($token['type'] === HTML5::ENDTAG && $token['name'] === 'col') { + /* Parse error. Ignore the token. */ + + /* Anything else */ + } else { + /* Act as if an end tag with the tag name "colgroup" had been seen, + and then, if that token wasn't ignored, reprocess the current token. */ + $this->inColumnGroup( + array( + 'name' => 'colgroup', + 'type' => HTML5::ENDTAG + ) + ); + + return $this->inTable($token); + } + } + + private function inTableBody($token) + { + $clear = array('tbody', 'tfoot', 'thead', 'html'); + + /* A start tag whose tag name is "tr" */ + if ($token['type'] === HTML5::STARTTAG && $token['name'] === 'tr') { + /* Clear the stack back to a table body context. */ + $this->clearStackToTableContext($clear); + + /* Insert a tr element for the token, then switch the insertion + mode to "in row". */ + $this->insertElement($token); + $this->mode = self::IN_ROW; + + /* A start tag whose tag name is one of: "th", "td" */ + } elseif ($token['type'] === HTML5::STARTTAG && + ($token['name'] === 'th' || $token['name'] === 'td') + ) { + /* Parse error. Act as if a start tag with the tag name "tr" had + been seen, then reprocess the current token. */ + $this->inTableBody( + array( + 'name' => 'tr', + 'type' => HTML5::STARTTAG, + 'attr' => array() + ) + ); + + return $this->inRow($token); + + /* An end tag whose tag name is one of: "tbody", "tfoot", "thead" */ + } elseif ($token['type'] === HTML5::ENDTAG && + in_array($token['name'], array('tbody', 'tfoot', 'thead')) + ) { + /* If the stack of open elements does not have an element in table + scope with the same tag name as the token, this is a parse error. + Ignore the token. */ + if (!$this->elementInScope($token['name'], true)) { + // Ignore + + /* Otherwise: */ + } else { + /* Clear the stack back to a table body context. */ + $this->clearStackToTableContext($clear); + + /* Pop the current node from the stack of open elements. Switch + the insertion mode to "in table". */ + array_pop($this->stack); + $this->mode = self::IN_TABLE; + } + + /* A start tag whose tag name is one of: "caption", "col", "colgroup", + "tbody", "tfoot", "thead", or an end tag whose tag name is "table" */ + } elseif (($token['type'] === HTML5::STARTTAG && in_array( + $token['name'], + array('caption', 'col', 'colgroup', 'tbody', 'tfoor', 'thead') + )) || + ($token['type'] === HTML5::STARTTAG && $token['name'] === 'table') + ) { + /* If the stack of open elements does not have a tbody, thead, or + tfoot element in table scope, this is a parse error. Ignore the + token. (innerHTML case) */ + if (!$this->elementInScope(array('tbody', 'thead', 'tfoot'), true)) { + // Ignore. + + /* Otherwise: */ + } else { + /* Clear the stack back to a table body context. */ + $this->clearStackToTableContext($clear); + + /* Act as if an end tag with the same tag name as the current + node ("tbody", "tfoot", or "thead") had been seen, then + reprocess the current token. */ + $this->inTableBody( + array( + 'name' => end($this->stack)->nodeName, + 'type' => HTML5::ENDTAG + ) + ); + + return $this->mainPhase($token); + } + + /* An end tag whose tag name is one of: "body", "caption", "col", + "colgroup", "html", "td", "th", "tr" */ + } elseif ($token['type'] === HTML5::ENDTAG && in_array( + $token['name'], + array('body', 'caption', 'col', 'colgroup', 'html', 'td', 'th', 'tr') + ) + ) { + /* Parse error. Ignore the token. */ + + /* Anything else */ + } else { + /* Process the token as if the insertion mode was "in table". */ + $this->inTable($token); + } + } + + private function inRow($token) + { + $clear = array('tr', 'html'); + + /* A start tag whose tag name is one of: "th", "td" */ + if ($token['type'] === HTML5::STARTTAG && + ($token['name'] === 'th' || $token['name'] === 'td') + ) { + /* Clear the stack back to a table row context. */ + $this->clearStackToTableContext($clear); + + /* Insert an HTML element for the token, then switch the insertion + mode to "in cell". */ + $this->insertElement($token); + $this->mode = self::IN_CELL; + + /* Insert a marker at the end of the list of active formatting + elements. */ + $this->a_formatting[] = self::MARKER; + + /* An end tag whose tag name is "tr" */ + } elseif ($token['type'] === HTML5::ENDTAG && $token['name'] === 'tr') { + /* If the stack of open elements does not have an element in table + scope with the same tag name as the token, this is a parse error. + Ignore the token. (innerHTML case) */ + if (!$this->elementInScope($token['name'], true)) { + // Ignore. + + /* Otherwise: */ + } else { + /* Clear the stack back to a table row context. */ + $this->clearStackToTableContext($clear); + + /* Pop the current node (which will be a tr element) from the + stack of open elements. Switch the insertion mode to "in table + body". */ + array_pop($this->stack); + $this->mode = self::IN_TBODY; + } + + /* A start tag whose tag name is one of: "caption", "col", "colgroup", + "tbody", "tfoot", "thead", "tr" or an end tag whose tag name is "table" */ + } elseif ($token['type'] === HTML5::STARTTAG && in_array( + $token['name'], + array('caption', 'col', 'colgroup', 'tbody', 'tfoot', 'thead', 'tr') + ) + ) { + /* Act as if an end tag with the tag name "tr" had been seen, then, + if that token wasn't ignored, reprocess the current token. */ + $this->inRow( + array( + 'name' => 'tr', + 'type' => HTML5::ENDTAG + ) + ); + + return $this->inCell($token); + + /* An end tag whose tag name is one of: "tbody", "tfoot", "thead" */ + } elseif ($token['type'] === HTML5::ENDTAG && + in_array($token['name'], array('tbody', 'tfoot', 'thead')) + ) { + /* If the stack of open elements does not have an element in table + scope with the same tag name as the token, this is a parse error. + Ignore the token. */ + if (!$this->elementInScope($token['name'], true)) { + // Ignore. + + /* Otherwise: */ + } else { + /* Otherwise, act as if an end tag with the tag name "tr" had + been seen, then reprocess the current token. */ + $this->inRow( + array( + 'name' => 'tr', + 'type' => HTML5::ENDTAG + ) + ); + + return $this->inCell($token); + } + + /* An end tag whose tag name is one of: "body", "caption", "col", + "colgroup", "html", "td", "th" */ + } elseif ($token['type'] === HTML5::ENDTAG && in_array( + $token['name'], + array('body', 'caption', 'col', 'colgroup', 'html', 'td', 'th', 'tr') + ) + ) { + /* Parse error. Ignore the token. */ + + /* Anything else */ + } else { + /* Process the token as if the insertion mode was "in table". */ + $this->inTable($token); + } + } + + private function inCell($token) + { + /* An end tag whose tag name is one of: "td", "th" */ + if ($token['type'] === HTML5::ENDTAG && + ($token['name'] === 'td' || $token['name'] === 'th') + ) { + /* If the stack of open elements does not have an element in table + scope with the same tag name as that of the token, then this is a + parse error and the token must be ignored. */ + if (!$this->elementInScope($token['name'], true)) { + // Ignore. + + /* Otherwise: */ + } else { + /* Generate implied end tags, except for elements with the same + tag name as the token. */ + $this->generateImpliedEndTags(array($token['name'])); + + /* Now, if the current node is not an element with the same tag + name as the token, then this is a parse error. */ + // k + + /* Pop elements from this stack until an element with the same + tag name as the token has been popped from the stack. */ + while (true) { + $node = end($this->stack)->nodeName; + array_pop($this->stack); + + if ($node === $token['name']) { + break; + } + } + + /* Clear the list of active formatting elements up to the last + marker. */ + $this->clearTheActiveFormattingElementsUpToTheLastMarker(); + + /* Switch the insertion mode to "in row". (The current node + will be a tr element at this point.) */ + $this->mode = self::IN_ROW; + } + + /* A start tag whose tag name is one of: "caption", "col", "colgroup", + "tbody", "td", "tfoot", "th", "thead", "tr" */ + } elseif ($token['type'] === HTML5::STARTTAG && in_array( + $token['name'], + array( + 'caption', + 'col', + 'colgroup', + 'tbody', + 'td', + 'tfoot', + 'th', + 'thead', + 'tr' + ) + ) + ) { + /* If the stack of open elements does not have a td or th element + in table scope, then this is a parse error; ignore the token. + (innerHTML case) */ + if (!$this->elementInScope(array('td', 'th'), true)) { + // Ignore. + + /* Otherwise, close the cell (see below) and reprocess the current + token. */ + } else { + $this->closeCell(); + return $this->inRow($token); + } + + /* A start tag whose tag name is one of: "caption", "col", "colgroup", + "tbody", "td", "tfoot", "th", "thead", "tr" */ + } elseif ($token['type'] === HTML5::STARTTAG && in_array( + $token['name'], + array( + 'caption', + 'col', + 'colgroup', + 'tbody', + 'td', + 'tfoot', + 'th', + 'thead', + 'tr' + ) + ) + ) { + /* If the stack of open elements does not have a td or th element + in table scope, then this is a parse error; ignore the token. + (innerHTML case) */ + if (!$this->elementInScope(array('td', 'th'), true)) { + // Ignore. + + /* Otherwise, close the cell (see below) and reprocess the current + token. */ + } else { + $this->closeCell(); + return $this->inRow($token); + } + + /* An end tag whose tag name is one of: "body", "caption", "col", + "colgroup", "html" */ + } elseif ($token['type'] === HTML5::ENDTAG && in_array( + $token['name'], + array('body', 'caption', 'col', 'colgroup', 'html') + ) + ) { + /* Parse error. Ignore the token. */ + + /* An end tag whose tag name is one of: "table", "tbody", "tfoot", + "thead", "tr" */ + } elseif ($token['type'] === HTML5::ENDTAG && in_array( + $token['name'], + array('table', 'tbody', 'tfoot', 'thead', 'tr') + ) + ) { + /* If the stack of open elements does not have an element in table + scope with the same tag name as that of the token (which can only + happen for "tbody", "tfoot" and "thead", or, in the innerHTML case), + then this is a parse error and the token must be ignored. */ + if (!$this->elementInScope($token['name'], true)) { + // Ignore. + + /* Otherwise, close the cell (see below) and reprocess the current + token. */ + } else { + $this->closeCell(); + return $this->inRow($token); + } + + /* Anything else */ + } else { + /* Process the token as if the insertion mode was "in body". */ + $this->inBody($token); + } + } + + private function inSelect($token) + { + /* Handle the token as follows: */ + + /* A character token */ + if ($token['type'] === HTML5::CHARACTR) { + /* Append the token's character to the current node. */ + $this->insertText($token['data']); + + /* A comment token */ + } elseif ($token['type'] === HTML5::COMMENT) { + /* Append a Comment node to the current node with the data + attribute set to the data given in the comment token. */ + $this->insertComment($token['data']); + + /* A start tag token whose tag name is "option" */ + } elseif ($token['type'] === HTML5::STARTTAG && + $token['name'] === 'option' + ) { + /* If the current node is an option element, act as if an end tag + with the tag name "option" had been seen. */ + if (end($this->stack)->nodeName === 'option') { + $this->inSelect( + array( + 'name' => 'option', + 'type' => HTML5::ENDTAG + ) + ); + } + + /* Insert an HTML element for the token. */ + $this->insertElement($token); + + /* A start tag token whose tag name is "optgroup" */ + } elseif ($token['type'] === HTML5::STARTTAG && + $token['name'] === 'optgroup' + ) { + /* If the current node is an option element, act as if an end tag + with the tag name "option" had been seen. */ + if (end($this->stack)->nodeName === 'option') { + $this->inSelect( + array( + 'name' => 'option', + 'type' => HTML5::ENDTAG + ) + ); + } + + /* If the current node is an optgroup element, act as if an end tag + with the tag name "optgroup" had been seen. */ + if (end($this->stack)->nodeName === 'optgroup') { + $this->inSelect( + array( + 'name' => 'optgroup', + 'type' => HTML5::ENDTAG + ) + ); + } + + /* Insert an HTML element for the token. */ + $this->insertElement($token); + + /* An end tag token whose tag name is "optgroup" */ + } elseif ($token['type'] === HTML5::ENDTAG && + $token['name'] === 'optgroup' + ) { + /* First, if the current node is an option element, and the node + immediately before it in the stack of open elements is an optgroup + element, then act as if an end tag with the tag name "option" had + been seen. */ + $elements_in_stack = count($this->stack); + + if ($this->stack[$elements_in_stack - 1]->nodeName === 'option' && + $this->stack[$elements_in_stack - 2]->nodeName === 'optgroup' + ) { + $this->inSelect( + array( + 'name' => 'option', + 'type' => HTML5::ENDTAG + ) + ); + } + + /* If the current node is an optgroup element, then pop that node + from the stack of open elements. Otherwise, this is a parse error, + ignore the token. */ + if ($this->stack[$elements_in_stack - 1] === 'optgroup') { + array_pop($this->stack); + } + + /* An end tag token whose tag name is "option" */ + } elseif ($token['type'] === HTML5::ENDTAG && + $token['name'] === 'option' + ) { + /* If the current node is an option element, then pop that node + from the stack of open elements. Otherwise, this is a parse error, + ignore the token. */ + if (end($this->stack)->nodeName === 'option') { + array_pop($this->stack); + } + + /* An end tag whose tag name is "select" */ + } elseif ($token['type'] === HTML5::ENDTAG && + $token['name'] === 'select' + ) { + /* If the stack of open elements does not have an element in table + scope with the same tag name as the token, this is a parse error. + Ignore the token. (innerHTML case) */ + if (!$this->elementInScope($token['name'], true)) { + // w/e + + /* Otherwise: */ + } else { + /* Pop elements from the stack of open elements until a select + element has been popped from the stack. */ + while (true) { + $current = end($this->stack)->nodeName; + array_pop($this->stack); + + if ($current === 'select') { + break; + } + } + + /* Reset the insertion mode appropriately. */ + $this->resetInsertionMode(); + } + + /* A start tag whose tag name is "select" */ + } elseif ($token['name'] === 'select' && + $token['type'] === HTML5::STARTTAG + ) { + /* Parse error. Act as if the token had been an end tag with the + tag name "select" instead. */ + $this->inSelect( + array( + 'name' => 'select', + 'type' => HTML5::ENDTAG + ) + ); + + /* An end tag whose tag name is one of: "caption", "table", "tbody", + "tfoot", "thead", "tr", "td", "th" */ + } elseif (in_array( + $token['name'], + array( + 'caption', + 'table', + 'tbody', + 'tfoot', + 'thead', + 'tr', + 'td', + 'th' + ) + ) && $token['type'] === HTML5::ENDTAG + ) { + /* Parse error. */ + // w/e + + /* If the stack of open elements has an element in table scope with + the same tag name as that of the token, then act as if an end tag + with the tag name "select" had been seen, and reprocess the token. + Otherwise, ignore the token. */ + if ($this->elementInScope($token['name'], true)) { + $this->inSelect( + array( + 'name' => 'select', + 'type' => HTML5::ENDTAG + ) + ); + + $this->mainPhase($token); + } + + /* Anything else */ + } else { + /* Parse error. Ignore the token. */ + } + } + + private function afterBody($token) + { + /* Handle the token as follows: */ + + /* A character token that is one of one of U+0009 CHARACTER TABULATION, + U+000A LINE FEED (LF), U+000B LINE TABULATION, U+000C FORM FEED (FF), + or U+0020 SPACE */ + if ($token['type'] === HTML5::CHARACTR && + preg_match('/^[\t\n\x0b\x0c ]+$/', $token['data']) + ) { + /* Process the token as it would be processed if the insertion mode + was "in body". */ + $this->inBody($token); + + /* A comment token */ + } elseif ($token['type'] === HTML5::COMMENT) { + /* Append a Comment node to the first element in the stack of open + elements (the html element), with the data attribute set to the + data given in the comment token. */ + $comment = $this->dom->createComment($token['data']); + $this->stack[0]->appendChild($comment); + + /* An end tag with the tag name "html" */ + } elseif ($token['type'] === HTML5::ENDTAG && $token['name'] === 'html') { + /* If the parser was originally created in order to handle the + setting of an element's innerHTML attribute, this is a parse error; + ignore the token. (The element will be an html element in this + case.) (innerHTML case) */ + + /* Otherwise, switch to the trailing end phase. */ + $this->phase = self::END_PHASE; + + /* Anything else */ + } else { + /* Parse error. Set the insertion mode to "in body" and reprocess + the token. */ + $this->mode = self::IN_BODY; + return $this->inBody($token); + } + } + + private function inFrameset($token) + { + /* Handle the token as follows: */ + + /* A character token that is one of one of U+0009 CHARACTER TABULATION, + U+000A LINE FEED (LF), U+000B LINE TABULATION, U+000C FORM FEED (FF), + U+000D CARRIAGE RETURN (CR), or U+0020 SPACE */ + if ($token['type'] === HTML5::CHARACTR && + preg_match('/^[\t\n\x0b\x0c ]+$/', $token['data']) + ) { + /* Append the character to the current node. */ + $this->insertText($token['data']); + + /* A comment token */ + } elseif ($token['type'] === HTML5::COMMENT) { + /* Append a Comment node to the current node with the data + attribute set to the data given in the comment token. */ + $this->insertComment($token['data']); + + /* A start tag with the tag name "frameset" */ + } elseif ($token['name'] === 'frameset' && + $token['type'] === HTML5::STARTTAG + ) { + $this->insertElement($token); + + /* An end tag with the tag name "frameset" */ + } elseif ($token['name'] === 'frameset' && + $token['type'] === HTML5::ENDTAG + ) { + /* If the current node is the root html element, then this is a + parse error; ignore the token. (innerHTML case) */ + if (end($this->stack)->nodeName === 'html') { + // Ignore + + } else { + /* Otherwise, pop the current node from the stack of open + elements. */ + array_pop($this->stack); + + /* If the parser was not originally created in order to handle + the setting of an element's innerHTML attribute (innerHTML case), + and the current node is no longer a frameset element, then change + the insertion mode to "after frameset". */ + $this->mode = self::AFTR_FRAME; + } + + /* A start tag with the tag name "frame" */ + } elseif ($token['name'] === 'frame' && + $token['type'] === HTML5::STARTTAG + ) { + /* Insert an HTML element for the token. */ + $this->insertElement($token); + + /* Immediately pop the current node off the stack of open elements. */ + array_pop($this->stack); + + /* A start tag with the tag name "noframes" */ + } elseif ($token['name'] === 'noframes' && + $token['type'] === HTML5::STARTTAG + ) { + /* Process the token as if the insertion mode had been "in body". */ + $this->inBody($token); + + /* Anything else */ + } else { + /* Parse error. Ignore the token. */ + } + } + + private function afterFrameset($token) + { + /* Handle the token as follows: */ + + /* A character token that is one of one of U+0009 CHARACTER TABULATION, + U+000A LINE FEED (LF), U+000B LINE TABULATION, U+000C FORM FEED (FF), + U+000D CARRIAGE RETURN (CR), or U+0020 SPACE */ + if ($token['type'] === HTML5::CHARACTR && + preg_match('/^[\t\n\x0b\x0c ]+$/', $token['data']) + ) { + /* Append the character to the current node. */ + $this->insertText($token['data']); + + /* A comment token */ + } elseif ($token['type'] === HTML5::COMMENT) { + /* Append a Comment node to the current node with the data + attribute set to the data given in the comment token. */ + $this->insertComment($token['data']); + + /* An end tag with the tag name "html" */ + } elseif ($token['name'] === 'html' && + $token['type'] === HTML5::ENDTAG + ) { + /* Switch to the trailing end phase. */ + $this->phase = self::END_PHASE; + + /* A start tag with the tag name "noframes" */ + } elseif ($token['name'] === 'noframes' && + $token['type'] === HTML5::STARTTAG + ) { + /* Process the token as if the insertion mode had been "in body". */ + $this->inBody($token); + + /* Anything else */ + } else { + /* Parse error. Ignore the token. */ + } + } + + private function trailingEndPhase($token) + { + /* After the main phase, as each token is emitted from the tokenisation + stage, it must be processed as described in this section. */ + + /* A DOCTYPE token */ + if ($token['type'] === HTML5::DOCTYPE) { + // Parse error. Ignore the token. + + /* A comment token */ + } elseif ($token['type'] === HTML5::COMMENT) { + /* Append a Comment node to the Document object with the data + attribute set to the data given in the comment token. */ + $comment = $this->dom->createComment($token['data']); + $this->dom->appendChild($comment); + + /* A character token that is one of one of U+0009 CHARACTER TABULATION, + U+000A LINE FEED (LF), U+000B LINE TABULATION, U+000C FORM FEED (FF), + or U+0020 SPACE */ + } elseif ($token['type'] === HTML5::CHARACTR && + preg_match('/^[\t\n\x0b\x0c ]+$/', $token['data']) + ) { + /* Process the token as it would be processed in the main phase. */ + $this->mainPhase($token); + + /* A character token that is not one of U+0009 CHARACTER TABULATION, + U+000A LINE FEED (LF), U+000B LINE TABULATION, U+000C FORM FEED (FF), + or U+0020 SPACE. Or a start tag token. Or an end tag token. */ + } elseif (($token['type'] === HTML5::CHARACTR && + preg_match('/^[\t\n\x0b\x0c ]+$/', $token['data'])) || + $token['type'] === HTML5::STARTTAG || $token['type'] === HTML5::ENDTAG + ) { + /* Parse error. Switch back to the main phase and reprocess the + token. */ + $this->phase = self::MAIN_PHASE; + return $this->mainPhase($token); + + /* An end-of-file token */ + } elseif ($token['type'] === HTML5::EOF) { + /* OMG DONE!! */ + } + } + + private function insertElement($token, $append = true, $check = false) + { + // Proprietary workaround for libxml2's limitations with tag names + if ($check) { + // Slightly modified HTML5 tag-name modification, + // removing anything that's not an ASCII letter, digit, or hyphen + $token['name'] = preg_replace('/[^a-z0-9-]/i', '', $token['name']); + // Remove leading hyphens and numbers + $token['name'] = ltrim($token['name'], '-0..9'); + // In theory, this should ever be needed, but just in case + if ($token['name'] === '') { + $token['name'] = 'span'; + } // arbitrary generic choice + } + + $el = $this->dom->createElement($token['name']); + + foreach ($token['attr'] as $attr) { + if (!$el->hasAttribute($attr['name'])) { + $el->setAttribute($attr['name'], (string)$attr['value']); + } + } + + $this->appendToRealParent($el); + $this->stack[] = $el; + + return $el; + } + + private function insertText($data) + { + $text = $this->dom->createTextNode($data); + $this->appendToRealParent($text); + } + + private function insertComment($data) + { + $comment = $this->dom->createComment($data); + $this->appendToRealParent($comment); + } + + private function appendToRealParent($node) + { + if ($this->foster_parent === null) { + end($this->stack)->appendChild($node); + + } elseif ($this->foster_parent !== null) { + /* If the foster parent element is the parent element of the + last table element in the stack of open elements, then the new + node must be inserted immediately before the last table element + in the stack of open elements in the foster parent element; + otherwise, the new node must be appended to the foster parent + element. */ + for ($n = count($this->stack) - 1; $n >= 0; $n--) { + if ($this->stack[$n]->nodeName === 'table' && + $this->stack[$n]->parentNode !== null + ) { + $table = $this->stack[$n]; + break; + } + } + + if (isset($table) && $this->foster_parent->isSameNode($table->parentNode)) { + $this->foster_parent->insertBefore($node, $table); + } else { + $this->foster_parent->appendChild($node); + } + + $this->foster_parent = null; + } + } + + private function elementInScope($el, $table = false) + { + if (is_array($el)) { + foreach ($el as $element) { + if ($this->elementInScope($element, $table)) { + return true; + } + } + + return false; + } + + $leng = count($this->stack); + + for ($n = 0; $n < $leng; $n++) { + /* 1. Initialise node to be the current node (the bottommost node of + the stack). */ + $node = $this->stack[$leng - 1 - $n]; + + if ($node->tagName === $el) { + /* 2. If node is the target node, terminate in a match state. */ + return true; + + } elseif ($node->tagName === 'table') { + /* 3. Otherwise, if node is a table element, terminate in a failure + state. */ + return false; + + } elseif ($table === true && in_array( + $node->tagName, + array( + 'caption', + 'td', + 'th', + 'button', + 'marquee', + 'object' + ) + ) + ) { + /* 4. Otherwise, if the algorithm is the "has an element in scope" + variant (rather than the "has an element in table scope" variant), + and node is one of the following, terminate in a failure state. */ + return false; + + } elseif ($node === $node->ownerDocument->documentElement) { + /* 5. Otherwise, if node is an html element (root element), terminate + in a failure state. (This can only happen if the node is the topmost + node of the stack of open elements, and prevents the next step from + being invoked if there are no more elements in the stack.) */ + return false; + } + + /* Otherwise, set node to the previous entry in the stack of open + elements and return to step 2. (This will never fail, since the loop + will always terminate in the previous step if the top of the stack + is reached.) */ + } + } + + private function reconstructActiveFormattingElements() + { + /* 1. If there are no entries in the list of active formatting elements, + then there is nothing to reconstruct; stop this algorithm. */ + $formatting_elements = count($this->a_formatting); + + if ($formatting_elements === 0) { + return false; + } + + /* 3. Let entry be the last (most recently added) element in the list + of active formatting elements. */ + $entry = end($this->a_formatting); + + /* 2. If the last (most recently added) entry in the list of active + formatting elements is a marker, or if it is an element that is in the + stack of open elements, then there is nothing to reconstruct; stop this + algorithm. */ + if ($entry === self::MARKER || in_array($entry, $this->stack, true)) { + return false; + } + + for ($a = $formatting_elements - 1; $a >= 0; true) { + /* 4. If there are no entries before entry in the list of active + formatting elements, then jump to step 8. */ + if ($a === 0) { + $step_seven = false; + break; + } + + /* 5. Let entry be the entry one earlier than entry in the list of + active formatting elements. */ + $a--; + $entry = $this->a_formatting[$a]; + + /* 6. If entry is neither a marker nor an element that is also in + thetack of open elements, go to step 4. */ + if ($entry === self::MARKER || in_array($entry, $this->stack, true)) { + break; + } + } + + while (true) { + /* 7. Let entry be the element one later than entry in the list of + active formatting elements. */ + if (isset($step_seven) && $step_seven === true) { + $a++; + $entry = $this->a_formatting[$a]; + } + + /* 8. Perform a shallow clone of the element entry to obtain clone. */ + $clone = $entry->cloneNode(); + + /* 9. Append clone to the current node and push it onto the stack + of open elements so that it is the new current node. */ + end($this->stack)->appendChild($clone); + $this->stack[] = $clone; + + /* 10. Replace the entry for entry in the list with an entry for + clone. */ + $this->a_formatting[$a] = $clone; + + /* 11. If the entry for clone in the list of active formatting + elements is not the last entry in the list, return to step 7. */ + if (end($this->a_formatting) !== $clone) { + $step_seven = true; + } else { + break; + } + } + } + + private function clearTheActiveFormattingElementsUpToTheLastMarker() + { + /* When the steps below require the UA to clear the list of active + formatting elements up to the last marker, the UA must perform the + following steps: */ + + while (true) { + /* 1. Let entry be the last (most recently added) entry in the list + of active formatting elements. */ + $entry = end($this->a_formatting); + + /* 2. Remove entry from the list of active formatting elements. */ + array_pop($this->a_formatting); + + /* 3. If entry was a marker, then stop the algorithm at this point. + The list has been cleared up to the last marker. */ + if ($entry === self::MARKER) { + break; + } + } + } + + private function generateImpliedEndTags($exclude = array()) + { + /* When the steps below require the UA to generate implied end tags, + then, if the current node is a dd element, a dt element, an li element, + a p element, a td element, a th element, or a tr element, the UA must + act as if an end tag with the respective tag name had been seen and + then generate implied end tags again. */ + $node = end($this->stack); + $elements = array_diff(array('dd', 'dt', 'li', 'p', 'td', 'th', 'tr'), $exclude); + + while (in_array(end($this->stack)->nodeName, $elements)) { + array_pop($this->stack); + } + } + + private function getElementCategory($node) + { + $name = $node->tagName; + if (in_array($name, $this->special)) { + return self::SPECIAL; + } elseif (in_array($name, $this->scoping)) { + return self::SCOPING; + } elseif (in_array($name, $this->formatting)) { + return self::FORMATTING; + } else { + return self::PHRASING; + } + } + + private function clearStackToTableContext($elements) + { + /* When the steps above require the UA to clear the stack back to a + table context, it means that the UA must, while the current node is not + a table element or an html element, pop elements from the stack of open + elements. If this causes any elements to be popped from the stack, then + this is a parse error. */ + while (true) { + $node = end($this->stack)->nodeName; + + if (in_array($node, $elements)) { + break; + } else { + array_pop($this->stack); + } + } + } + + private function resetInsertionMode() + { + /* 1. Let last be false. */ + $last = false; + $leng = count($this->stack); + + for ($n = $leng - 1; $n >= 0; $n--) { + /* 2. Let node be the last node in the stack of open elements. */ + $node = $this->stack[$n]; + + /* 3. If node is the first node in the stack of open elements, then + set last to true. If the element whose innerHTML attribute is being + set is neither a td element nor a th element, then set node to the + element whose innerHTML attribute is being set. (innerHTML case) */ + if ($this->stack[0]->isSameNode($node)) { + $last = true; + } + + /* 4. If node is a select element, then switch the insertion mode to + "in select" and abort these steps. (innerHTML case) */ + if ($node->nodeName === 'select') { + $this->mode = self::IN_SELECT; + break; + + /* 5. If node is a td or th element, then switch the insertion mode + to "in cell" and abort these steps. */ + } elseif ($node->nodeName === 'td' || $node->nodeName === 'th') { + $this->mode = self::IN_CELL; + break; + + /* 6. If node is a tr element, then switch the insertion mode to + "in row" and abort these steps. */ + } elseif ($node->nodeName === 'tr') { + $this->mode = self::IN_ROW; + break; + + /* 7. If node is a tbody, thead, or tfoot element, then switch the + insertion mode to "in table body" and abort these steps. */ + } elseif (in_array($node->nodeName, array('tbody', 'thead', 'tfoot'))) { + $this->mode = self::IN_TBODY; + break; + + /* 8. If node is a caption element, then switch the insertion mode + to "in caption" and abort these steps. */ + } elseif ($node->nodeName === 'caption') { + $this->mode = self::IN_CAPTION; + break; + + /* 9. If node is a colgroup element, then switch the insertion mode + to "in column group" and abort these steps. (innerHTML case) */ + } elseif ($node->nodeName === 'colgroup') { + $this->mode = self::IN_CGROUP; + break; + + /* 10. If node is a table element, then switch the insertion mode + to "in table" and abort these steps. */ + } elseif ($node->nodeName === 'table') { + $this->mode = self::IN_TABLE; + break; + + /* 11. If node is a head element, then switch the insertion mode + to "in body" ("in body"! not "in head"!) and abort these steps. + (innerHTML case) */ + } elseif ($node->nodeName === 'head') { + $this->mode = self::IN_BODY; + break; + + /* 12. If node is a body element, then switch the insertion mode to + "in body" and abort these steps. */ + } elseif ($node->nodeName === 'body') { + $this->mode = self::IN_BODY; + break; + + /* 13. If node is a frameset element, then switch the insertion + mode to "in frameset" and abort these steps. (innerHTML case) */ + } elseif ($node->nodeName === 'frameset') { + $this->mode = self::IN_FRAME; + break; + + /* 14. If node is an html element, then: if the head element + pointer is null, switch the insertion mode to "before head", + otherwise, switch the insertion mode to "after head". In either + case, abort these steps. (innerHTML case) */ + } elseif ($node->nodeName === 'html') { + $this->mode = ($this->head_pointer === null) + ? self::BEFOR_HEAD + : self::AFTER_HEAD; + + break; + + /* 15. If last is true, then set the insertion mode to "in body" + and abort these steps. (innerHTML case) */ + } elseif ($last) { + $this->mode = self::IN_BODY; + break; + } + } + } + + private function closeCell() + { + /* If the stack of open elements has a td or th element in table scope, + then act as if an end tag token with that tag name had been seen. */ + foreach (array('td', 'th') as $cell) { + if ($this->elementInScope($cell, true)) { + $this->inCell( + array( + 'name' => $cell, + 'type' => HTML5::ENDTAG + ) + ); + + break; + } + } + } + + public function save() + { + return $this->dom; + } +} diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Node.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Node.php new file mode 100644 index 0000000..3995fec --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Node.php @@ -0,0 +1,49 @@ +data = $data; + $this->line = $line; + $this->col = $col; + } + + public function toTokenPair() { + return array(new HTMLPurifier_Token_Comment($this->data, $this->line, $this->col), null); + } +} diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Node/Element.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Node/Element.php new file mode 100644 index 0000000..6cbf56d --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Node/Element.php @@ -0,0 +1,59 @@ + form or the form, i.e. + * is it a pair of start/end tokens or an empty token. + * @bool + */ + public $empty = false; + + public $endCol = null, $endLine = null, $endArmor = array(); + + public function __construct($name, $attr = array(), $line = null, $col = null, $armor = array()) { + $this->name = $name; + $this->attr = $attr; + $this->line = $line; + $this->col = $col; + $this->armor = $armor; + } + + public function toTokenPair() { + // XXX inefficiency here, normalization is not necessary + if ($this->empty) { + return array(new HTMLPurifier_Token_Empty($this->name, $this->attr, $this->line, $this->col, $this->armor), null); + } else { + $start = new HTMLPurifier_Token_Start($this->name, $this->attr, $this->line, $this->col, $this->armor); + $end = new HTMLPurifier_Token_End($this->name, array(), $this->endLine, $this->endCol, $this->endArmor); + //$end->start = $start; + return array($start, $end); + } + } +} + diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Node/Text.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Node/Text.php new file mode 100644 index 0000000..aec9166 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Node/Text.php @@ -0,0 +1,54 @@ +data = $data; + $this->is_whitespace = $is_whitespace; + $this->line = $line; + $this->col = $col; + } + + public function toTokenPair() { + return array(new HTMLPurifier_Token_Text($this->data, $this->line, $this->col), null); + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/PercentEncoder.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/PercentEncoder.php new file mode 100644 index 0000000..18c8bbb --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/PercentEncoder.php @@ -0,0 +1,111 @@ +preserve[$i] = true; + } + for ($i = 65; $i <= 90; $i++) { // upper-case + $this->preserve[$i] = true; + } + for ($i = 97; $i <= 122; $i++) { // lower-case + $this->preserve[$i] = true; + } + $this->preserve[45] = true; // Dash - + $this->preserve[46] = true; // Period . + $this->preserve[95] = true; // Underscore _ + $this->preserve[126]= true; // Tilde ~ + + // extra letters not to escape + if ($preserve !== false) { + for ($i = 0, $c = strlen($preserve); $i < $c; $i++) { + $this->preserve[ord($preserve[$i])] = true; + } + } + } + + /** + * Our replacement for urlencode, it encodes all non-reserved characters, + * as well as any extra characters that were instructed to be preserved. + * @note + * Assumes that the string has already been normalized, making any + * and all percent escape sequences valid. Percents will not be + * re-escaped, regardless of their status in $preserve + * @param string $string String to be encoded + * @return string Encoded string. + */ + public function encode($string) + { + $ret = ''; + for ($i = 0, $c = strlen($string); $i < $c; $i++) { + if ($string[$i] !== '%' && !isset($this->preserve[$int = ord($string[$i])])) { + $ret .= '%' . sprintf('%02X', $int); + } else { + $ret .= $string[$i]; + } + } + return $ret; + } + + /** + * Fix up percent-encoding by decoding unreserved characters and normalizing. + * @warning This function is affected by $preserve, even though the + * usual desired behavior is for this not to preserve those + * characters. Be careful when reusing instances of PercentEncoder! + * @param string $string String to normalize + * @return string + */ + public function normalize($string) + { + if ($string == '') { + return ''; + } + $parts = explode('%', $string); + $ret = array_shift($parts); + foreach ($parts as $part) { + $length = strlen($part); + if ($length < 2) { + $ret .= '%25' . $part; + continue; + } + $encoding = substr($part, 0, 2); + $text = substr($part, 2); + if (!ctype_xdigit($encoding)) { + $ret .= '%25' . $part; + continue; + } + $int = hexdec($encoding); + if (isset($this->preserve[$int])) { + $ret .= chr($int) . $text; + continue; + } + $encoding = strtoupper($encoding); + $ret .= '%' . $encoding . $text; + } + return $ret; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Printer.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Printer.php new file mode 100644 index 0000000..549e4ce --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Printer.php @@ -0,0 +1,218 @@ +getAll(); + $context = new HTMLPurifier_Context(); + $this->generator = new HTMLPurifier_Generator($config, $context); + } + + /** + * Main function that renders object or aspect of that object + * @note Parameters vary depending on printer + */ + // function render() {} + + /** + * Returns a start tag + * @param string $tag Tag name + * @param array $attr Attribute array + * @return string + */ + protected function start($tag, $attr = array()) + { + return $this->generator->generateFromToken( + new HTMLPurifier_Token_Start($tag, $attr ? $attr : array()) + ); + } + + /** + * Returns an end tag + * @param string $tag Tag name + * @return string + */ + protected function end($tag) + { + return $this->generator->generateFromToken( + new HTMLPurifier_Token_End($tag) + ); + } + + /** + * Prints a complete element with content inside + * @param string $tag Tag name + * @param string $contents Element contents + * @param array $attr Tag attributes + * @param bool $escape whether or not to escape contents + * @return string + */ + protected function element($tag, $contents, $attr = array(), $escape = true) + { + return $this->start($tag, $attr) . + ($escape ? $this->escape($contents) : $contents) . + $this->end($tag); + } + + /** + * @param string $tag + * @param array $attr + * @return string + */ + protected function elementEmpty($tag, $attr = array()) + { + return $this->generator->generateFromToken( + new HTMLPurifier_Token_Empty($tag, $attr) + ); + } + + /** + * @param string $text + * @return string + */ + protected function text($text) + { + return $this->generator->generateFromToken( + new HTMLPurifier_Token_Text($text) + ); + } + + /** + * Prints a simple key/value row in a table. + * @param string $name Key + * @param mixed $value Value + * @return string + */ + protected function row($name, $value) + { + if (is_bool($value)) { + $value = $value ? 'On' : 'Off'; + } + return + $this->start('tr') . "\n" . + $this->element('th', $name) . "\n" . + $this->element('td', $value) . "\n" . + $this->end('tr'); + } + + /** + * Escapes a string for HTML output. + * @param string $string String to escape + * @return string + */ + protected function escape($string) + { + $string = HTMLPurifier_Encoder::cleanUTF8($string); + $string = htmlspecialchars($string, ENT_COMPAT, 'UTF-8'); + return $string; + } + + /** + * Takes a list of strings and turns them into a single list + * @param string[] $array List of strings + * @param bool $polite Bool whether or not to add an end before the last + * @return string + */ + protected function listify($array, $polite = false) + { + if (empty($array)) { + return 'None'; + } + $ret = ''; + $i = count($array); + foreach ($array as $value) { + $i--; + $ret .= $value; + if ($i > 0 && !($polite && $i == 1)) { + $ret .= ', '; + } + if ($polite && $i == 1) { + $ret .= 'and '; + } + } + return $ret; + } + + /** + * Retrieves the class of an object without prefixes, as well as metadata + * @param object $obj Object to determine class of + * @param string $sec_prefix Further prefix to remove + * @return string + */ + protected function getClass($obj, $sec_prefix = '') + { + static $five = null; + if ($five === null) { + $five = version_compare(PHP_VERSION, '5', '>='); + } + $prefix = 'HTMLPurifier_' . $sec_prefix; + if (!$five) { + $prefix = strtolower($prefix); + } + $class = str_replace($prefix, '', get_class($obj)); + $lclass = strtolower($class); + $class .= '('; + switch ($lclass) { + case 'enum': + $values = array(); + foreach ($obj->valid_values as $value => $bool) { + $values[] = $value; + } + $class .= implode(', ', $values); + break; + case 'css_composite': + $values = array(); + foreach ($obj->defs as $def) { + $values[] = $this->getClass($def, $sec_prefix); + } + $class .= implode(', ', $values); + break; + case 'css_multiple': + $class .= $this->getClass($obj->single, $sec_prefix) . ', '; + $class .= $obj->max; + break; + case 'css_denyelementdecorator': + $class .= $this->getClass($obj->def, $sec_prefix) . ', '; + $class .= $obj->element; + break; + case 'css_importantdecorator': + $class .= $this->getClass($obj->def, $sec_prefix); + if ($obj->allow) { + $class .= ', !important'; + } + break; + } + $class .= ')'; + return $class; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Printer/CSSDefinition.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Printer/CSSDefinition.php new file mode 100644 index 0000000..29505fe --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Printer/CSSDefinition.php @@ -0,0 +1,44 @@ +def = $config->getCSSDefinition(); + $ret = ''; + + $ret .= $this->start('div', array('class' => 'HTMLPurifier_Printer')); + $ret .= $this->start('table'); + + $ret .= $this->element('caption', 'Properties ($info)'); + + $ret .= $this->start('thead'); + $ret .= $this->start('tr'); + $ret .= $this->element('th', 'Property', array('class' => 'heavy')); + $ret .= $this->element('th', 'Definition', array('class' => 'heavy', 'style' => 'width:auto;')); + $ret .= $this->end('tr'); + $ret .= $this->end('thead'); + + ksort($this->def->info); + foreach ($this->def->info as $property => $obj) { + $name = $this->getClass($obj, 'AttrDef_'); + $ret .= $this->row($property, $name); + } + + $ret .= $this->end('table'); + $ret .= $this->end('div'); + + return $ret; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Printer/ConfigForm.css b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Printer/ConfigForm.css new file mode 100644 index 0000000..3ff1a88 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Printer/ConfigForm.css @@ -0,0 +1,10 @@ + +.hp-config {} + +.hp-config tbody th {text-align:right; padding-right:0.5em;} +.hp-config thead, .hp-config .namespace {background:#3C578C; color:#FFF;} +.hp-config .namespace th {text-align:center;} +.hp-config .verbose {display:none;} +.hp-config .controls {text-align:center;} + +/* vim: et sw=4 sts=4 */ diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Printer/ConfigForm.js b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Printer/ConfigForm.js new file mode 100644 index 0000000..cba00c9 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Printer/ConfigForm.js @@ -0,0 +1,5 @@ +function toggleWriteability(id_of_patient, checked) { + document.getElementById(id_of_patient).disabled = checked; +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Printer/ConfigForm.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Printer/ConfigForm.php new file mode 100644 index 0000000..4c3ce17 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Printer/ConfigForm.php @@ -0,0 +1,456 @@ +docURL = $doc_url; + $this->name = $name; + $this->compress = $compress; + // initialize sub-printers + $this->fields[0] = new HTMLPurifier_Printer_ConfigForm_default(); + $this->fields[HTMLPurifier_VarParser::C_BOOL] = new HTMLPurifier_Printer_ConfigForm_bool(); + } + + /** + * Sets default column and row size for textareas in sub-printers + * @param $cols Integer columns of textarea, null to use default + * @param $rows Integer rows of textarea, null to use default + */ + public function setTextareaDimensions($cols = null, $rows = null) + { + if ($cols) { + $this->fields['default']->cols = $cols; + } + if ($rows) { + $this->fields['default']->rows = $rows; + } + } + + /** + * Retrieves styling, in case it is not accessible by webserver + */ + public static function getCSS() + { + return file_get_contents(HTMLPURIFIER_PREFIX . '/HTMLPurifier/Printer/ConfigForm.css'); + } + + /** + * Retrieves JavaScript, in case it is not accessible by webserver + */ + public static function getJavaScript() + { + return file_get_contents(HTMLPURIFIER_PREFIX . '/HTMLPurifier/Printer/ConfigForm.js'); + } + + /** + * Returns HTML output for a configuration form + * @param HTMLPurifier_Config|array $config Configuration object of current form state, or an array + * where [0] has an HTML namespace and [1] is being rendered. + * @param array|bool $allowed Optional namespace(s) and directives to restrict form to. + * @param bool $render_controls + * @return string + */ + public function render($config, $allowed = true, $render_controls = true) + { + if (is_array($config) && isset($config[0])) { + $gen_config = $config[0]; + $config = $config[1]; + } else { + $gen_config = $config; + } + + $this->config = $config; + $this->genConfig = $gen_config; + $this->prepareGenerator($gen_config); + + $allowed = HTMLPurifier_Config::getAllowedDirectivesForForm($allowed, $config->def); + $all = array(); + foreach ($allowed as $key) { + list($ns, $directive) = $key; + $all[$ns][$directive] = $config->get($ns . '.' . $directive); + } + + $ret = ''; + $ret .= $this->start('table', array('class' => 'hp-config')); + $ret .= $this->start('thead'); + $ret .= $this->start('tr'); + $ret .= $this->element('th', 'Directive', array('class' => 'hp-directive')); + $ret .= $this->element('th', 'Value', array('class' => 'hp-value')); + $ret .= $this->end('tr'); + $ret .= $this->end('thead'); + foreach ($all as $ns => $directives) { + $ret .= $this->renderNamespace($ns, $directives); + } + if ($render_controls) { + $ret .= $this->start('tbody'); + $ret .= $this->start('tr'); + $ret .= $this->start('td', array('colspan' => 2, 'class' => 'controls')); + $ret .= $this->elementEmpty('input', array('type' => 'submit', 'value' => 'Submit')); + $ret .= '[Reset]'; + $ret .= $this->end('td'); + $ret .= $this->end('tr'); + $ret .= $this->end('tbody'); + } + $ret .= $this->end('table'); + return $ret; + } + + /** + * Renders a single namespace + * @param $ns String namespace name + * @param array $directives array of directives to values + * @return string + */ + protected function renderNamespace($ns, $directives) + { + $ret = ''; + $ret .= $this->start('tbody', array('class' => 'namespace')); + $ret .= $this->start('tr'); + $ret .= $this->element('th', $ns, array('colspan' => 2)); + $ret .= $this->end('tr'); + $ret .= $this->end('tbody'); + $ret .= $this->start('tbody'); + foreach ($directives as $directive => $value) { + $ret .= $this->start('tr'); + $ret .= $this->start('th'); + if ($this->docURL) { + $url = str_replace('%s', urlencode("$ns.$directive"), $this->docURL); + $ret .= $this->start('a', array('href' => $url)); + } + $attr = array('for' => "{$this->name}:$ns.$directive"); + + // crop directive name if it's too long + if (!$this->compress || (strlen($directive) < $this->compress)) { + $directive_disp = $directive; + } else { + $directive_disp = substr($directive, 0, $this->compress - 2) . '...'; + $attr['title'] = $directive; + } + + $ret .= $this->element( + 'label', + $directive_disp, + // component printers must create an element with this id + $attr + ); + if ($this->docURL) { + $ret .= $this->end('a'); + } + $ret .= $this->end('th'); + + $ret .= $this->start('td'); + $def = $this->config->def->info["$ns.$directive"]; + if (is_int($def)) { + $allow_null = $def < 0; + $type = abs($def); + } else { + $type = $def->type; + $allow_null = isset($def->allow_null); + } + if (!isset($this->fields[$type])) { + $type = 0; + } // default + $type_obj = $this->fields[$type]; + if ($allow_null) { + $type_obj = new HTMLPurifier_Printer_ConfigForm_NullDecorator($type_obj); + } + $ret .= $type_obj->render($ns, $directive, $value, $this->name, array($this->genConfig, $this->config)); + $ret .= $this->end('td'); + $ret .= $this->end('tr'); + } + $ret .= $this->end('tbody'); + return $ret; + } + +} + +/** + * Printer decorator for directives that accept null + */ +class HTMLPurifier_Printer_ConfigForm_NullDecorator extends HTMLPurifier_Printer +{ + /** + * Printer being decorated + * @type HTMLPurifier_Printer + */ + protected $obj; + + /** + * @param HTMLPurifier_Printer $obj Printer to decorate + */ + public function __construct($obj) + { + parent::__construct(); + $this->obj = $obj; + } + + /** + * @param string $ns + * @param string $directive + * @param string $value + * @param string $name + * @param HTMLPurifier_Config|array $config + * @return string + */ + public function render($ns, $directive, $value, $name, $config) + { + if (is_array($config) && isset($config[0])) { + $gen_config = $config[0]; + $config = $config[1]; + } else { + $gen_config = $config; + } + $this->prepareGenerator($gen_config); + + $ret = ''; + $ret .= $this->start('label', array('for' => "$name:Null_$ns.$directive")); + $ret .= $this->element('span', "$ns.$directive:", array('class' => 'verbose')); + $ret .= $this->text(' Null/Disabled'); + $ret .= $this->end('label'); + $attr = array( + 'type' => 'checkbox', + 'value' => '1', + 'class' => 'null-toggle', + 'name' => "$name" . "[Null_$ns.$directive]", + 'id' => "$name:Null_$ns.$directive", + 'onclick' => "toggleWriteability('$name:$ns.$directive',checked)" // INLINE JAVASCRIPT!!!! + ); + if ($this->obj instanceof HTMLPurifier_Printer_ConfigForm_bool) { + // modify inline javascript slightly + $attr['onclick'] = + "toggleWriteability('$name:Yes_$ns.$directive',checked);" . + "toggleWriteability('$name:No_$ns.$directive',checked)"; + } + if ($value === null) { + $attr['checked'] = 'checked'; + } + $ret .= $this->elementEmpty('input', $attr); + $ret .= $this->text(' or '); + $ret .= $this->elementEmpty('br'); + $ret .= $this->obj->render($ns, $directive, $value, $name, array($gen_config, $config)); + return $ret; + } +} + +/** + * Swiss-army knife configuration form field printer + */ +class HTMLPurifier_Printer_ConfigForm_default extends HTMLPurifier_Printer +{ + /** + * @type int + */ + public $cols = 18; + + /** + * @type int + */ + public $rows = 5; + + /** + * @param string $ns + * @param string $directive + * @param string $value + * @param string $name + * @param HTMLPurifier_Config|array $config + * @return string + */ + public function render($ns, $directive, $value, $name, $config) + { + if (is_array($config) && isset($config[0])) { + $gen_config = $config[0]; + $config = $config[1]; + } else { + $gen_config = $config; + } + $this->prepareGenerator($gen_config); + // this should probably be split up a little + $ret = ''; + $def = $config->def->info["$ns.$directive"]; + if (is_int($def)) { + $type = abs($def); + } else { + $type = $def->type; + } + if (is_array($value)) { + switch ($type) { + case HTMLPurifier_VarParser::LOOKUP: + $array = $value; + $value = array(); + foreach ($array as $val => $b) { + $value[] = $val; + } + //TODO does this need a break? + case HTMLPurifier_VarParser::ALIST: + $value = implode(PHP_EOL, $value); + break; + case HTMLPurifier_VarParser::HASH: + $nvalue = ''; + foreach ($value as $i => $v) { + if (is_array($v)) { + // HACK + $v = implode(";", $v); + } + $nvalue .= "$i:$v" . PHP_EOL; + } + $value = $nvalue; + break; + default: + $value = ''; + } + } + if ($type === HTMLPurifier_VarParser::C_MIXED) { + return 'Not supported'; + $value = serialize($value); + } + $attr = array( + 'name' => "$name" . "[$ns.$directive]", + 'id' => "$name:$ns.$directive" + ); + if ($value === null) { + $attr['disabled'] = 'disabled'; + } + if (isset($def->allowed)) { + $ret .= $this->start('select', $attr); + foreach ($def->allowed as $val => $b) { + $attr = array(); + if ($value == $val) { + $attr['selected'] = 'selected'; + } + $ret .= $this->element('option', $val, $attr); + } + $ret .= $this->end('select'); + } elseif ($type === HTMLPurifier_VarParser::TEXT || + $type === HTMLPurifier_VarParser::ITEXT || + $type === HTMLPurifier_VarParser::ALIST || + $type === HTMLPurifier_VarParser::HASH || + $type === HTMLPurifier_VarParser::LOOKUP) { + $attr['cols'] = $this->cols; + $attr['rows'] = $this->rows; + $ret .= $this->start('textarea', $attr); + $ret .= $this->text($value); + $ret .= $this->end('textarea'); + } else { + $attr['value'] = $value; + $attr['type'] = 'text'; + $ret .= $this->elementEmpty('input', $attr); + } + return $ret; + } +} + +/** + * Bool form field printer + */ +class HTMLPurifier_Printer_ConfigForm_bool extends HTMLPurifier_Printer +{ + /** + * @param string $ns + * @param string $directive + * @param string $value + * @param string $name + * @param HTMLPurifier_Config|array $config + * @return string + */ + public function render($ns, $directive, $value, $name, $config) + { + if (is_array($config) && isset($config[0])) { + $gen_config = $config[0]; + $config = $config[1]; + } else { + $gen_config = $config; + } + $this->prepareGenerator($gen_config); + $ret = ''; + $ret .= $this->start('div', array('id' => "$name:$ns.$directive")); + + $ret .= $this->start('label', array('for' => "$name:Yes_$ns.$directive")); + $ret .= $this->element('span', "$ns.$directive:", array('class' => 'verbose')); + $ret .= $this->text(' Yes'); + $ret .= $this->end('label'); + + $attr = array( + 'type' => 'radio', + 'name' => "$name" . "[$ns.$directive]", + 'id' => "$name:Yes_$ns.$directive", + 'value' => '1' + ); + if ($value === true) { + $attr['checked'] = 'checked'; + } + if ($value === null) { + $attr['disabled'] = 'disabled'; + } + $ret .= $this->elementEmpty('input', $attr); + + $ret .= $this->start('label', array('for' => "$name:No_$ns.$directive")); + $ret .= $this->element('span', "$ns.$directive:", array('class' => 'verbose')); + $ret .= $this->text(' No'); + $ret .= $this->end('label'); + + $attr = array( + 'type' => 'radio', + 'name' => "$name" . "[$ns.$directive]", + 'id' => "$name:No_$ns.$directive", + 'value' => '0' + ); + if ($value === false) { + $attr['checked'] = 'checked'; + } + if ($value === null) { + $attr['disabled'] = 'disabled'; + } + $ret .= $this->elementEmpty('input', $attr); + + $ret .= $this->end('div'); + + return $ret; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Printer/HTMLDefinition.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Printer/HTMLDefinition.php new file mode 100644 index 0000000..ae86391 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Printer/HTMLDefinition.php @@ -0,0 +1,324 @@ +config =& $config; + + $this->def = $config->getHTMLDefinition(); + + $ret .= $this->start('div', array('class' => 'HTMLPurifier_Printer')); + + $ret .= $this->renderDoctype(); + $ret .= $this->renderEnvironment(); + $ret .= $this->renderContentSets(); + $ret .= $this->renderInfo(); + + $ret .= $this->end('div'); + + return $ret; + } + + /** + * Renders the Doctype table + * @return string + */ + protected function renderDoctype() + { + $doctype = $this->def->doctype; + $ret = ''; + $ret .= $this->start('table'); + $ret .= $this->element('caption', 'Doctype'); + $ret .= $this->row('Name', $doctype->name); + $ret .= $this->row('XML', $doctype->xml ? 'Yes' : 'No'); + $ret .= $this->row('Default Modules', implode(', ', $doctype->modules)); + $ret .= $this->row('Default Tidy Modules', implode(', ', $doctype->tidyModules)); + $ret .= $this->end('table'); + return $ret; + } + + + /** + * Renders environment table, which is miscellaneous info + * @return string + */ + protected function renderEnvironment() + { + $def = $this->def; + + $ret = ''; + + $ret .= $this->start('table'); + $ret .= $this->element('caption', 'Environment'); + + $ret .= $this->row('Parent of fragment', $def->info_parent); + $ret .= $this->renderChildren($def->info_parent_def->child); + $ret .= $this->row('Block wrap name', $def->info_block_wrapper); + + $ret .= $this->start('tr'); + $ret .= $this->element('th', 'Global attributes'); + $ret .= $this->element('td', $this->listifyAttr($def->info_global_attr), null, 0); + $ret .= $this->end('tr'); + + $ret .= $this->start('tr'); + $ret .= $this->element('th', 'Tag transforms'); + $list = array(); + foreach ($def->info_tag_transform as $old => $new) { + $new = $this->getClass($new, 'TagTransform_'); + $list[] = "<$old> with $new"; + } + $ret .= $this->element('td', $this->listify($list)); + $ret .= $this->end('tr'); + + $ret .= $this->start('tr'); + $ret .= $this->element('th', 'Pre-AttrTransform'); + $ret .= $this->element('td', $this->listifyObjectList($def->info_attr_transform_pre)); + $ret .= $this->end('tr'); + + $ret .= $this->start('tr'); + $ret .= $this->element('th', 'Post-AttrTransform'); + $ret .= $this->element('td', $this->listifyObjectList($def->info_attr_transform_post)); + $ret .= $this->end('tr'); + + $ret .= $this->end('table'); + return $ret; + } + + /** + * Renders the Content Sets table + * @return string + */ + protected function renderContentSets() + { + $ret = ''; + $ret .= $this->start('table'); + $ret .= $this->element('caption', 'Content Sets'); + foreach ($this->def->info_content_sets as $name => $lookup) { + $ret .= $this->heavyHeader($name); + $ret .= $this->start('tr'); + $ret .= $this->element('td', $this->listifyTagLookup($lookup)); + $ret .= $this->end('tr'); + } + $ret .= $this->end('table'); + return $ret; + } + + /** + * Renders the Elements ($info) table + * @return string + */ + protected function renderInfo() + { + $ret = ''; + $ret .= $this->start('table'); + $ret .= $this->element('caption', 'Elements ($info)'); + ksort($this->def->info); + $ret .= $this->heavyHeader('Allowed tags', 2); + $ret .= $this->start('tr'); + $ret .= $this->element('td', $this->listifyTagLookup($this->def->info), array('colspan' => 2)); + $ret .= $this->end('tr'); + foreach ($this->def->info as $name => $def) { + $ret .= $this->start('tr'); + $ret .= $this->element('th', "<$name>", array('class' => 'heavy', 'colspan' => 2)); + $ret .= $this->end('tr'); + $ret .= $this->start('tr'); + $ret .= $this->element('th', 'Inline content'); + $ret .= $this->element('td', $def->descendants_are_inline ? 'Yes' : 'No'); + $ret .= $this->end('tr'); + if (!empty($def->excludes)) { + $ret .= $this->start('tr'); + $ret .= $this->element('th', 'Excludes'); + $ret .= $this->element('td', $this->listifyTagLookup($def->excludes)); + $ret .= $this->end('tr'); + } + if (!empty($def->attr_transform_pre)) { + $ret .= $this->start('tr'); + $ret .= $this->element('th', 'Pre-AttrTransform'); + $ret .= $this->element('td', $this->listifyObjectList($def->attr_transform_pre)); + $ret .= $this->end('tr'); + } + if (!empty($def->attr_transform_post)) { + $ret .= $this->start('tr'); + $ret .= $this->element('th', 'Post-AttrTransform'); + $ret .= $this->element('td', $this->listifyObjectList($def->attr_transform_post)); + $ret .= $this->end('tr'); + } + if (!empty($def->auto_close)) { + $ret .= $this->start('tr'); + $ret .= $this->element('th', 'Auto closed by'); + $ret .= $this->element('td', $this->listifyTagLookup($def->auto_close)); + $ret .= $this->end('tr'); + } + $ret .= $this->start('tr'); + $ret .= $this->element('th', 'Allowed attributes'); + $ret .= $this->element('td', $this->listifyAttr($def->attr), array(), 0); + $ret .= $this->end('tr'); + + if (!empty($def->required_attr)) { + $ret .= $this->row('Required attributes', $this->listify($def->required_attr)); + } + + $ret .= $this->renderChildren($def->child); + } + $ret .= $this->end('table'); + return $ret; + } + + /** + * Renders a row describing the allowed children of an element + * @param HTMLPurifier_ChildDef $def HTMLPurifier_ChildDef of pertinent element + * @return string + */ + protected function renderChildren($def) + { + $context = new HTMLPurifier_Context(); + $ret = ''; + $ret .= $this->start('tr'); + $elements = array(); + $attr = array(); + if (isset($def->elements)) { + if ($def->type == 'strictblockquote') { + $def->validateChildren(array(), $this->config, $context); + } + $elements = $def->elements; + } + if ($def->type == 'chameleon') { + $attr['rowspan'] = 2; + } elseif ($def->type == 'empty') { + $elements = array(); + } elseif ($def->type == 'table') { + $elements = array_flip( + array( + 'col', + 'caption', + 'colgroup', + 'thead', + 'tfoot', + 'tbody', + 'tr' + ) + ); + } + $ret .= $this->element('th', 'Allowed children', $attr); + + if ($def->type == 'chameleon') { + + $ret .= $this->element( + 'td', + 'Block: ' . + $this->escape($this->listifyTagLookup($def->block->elements)), + null, + 0 + ); + $ret .= $this->end('tr'); + $ret .= $this->start('tr'); + $ret .= $this->element( + 'td', + 'Inline: ' . + $this->escape($this->listifyTagLookup($def->inline->elements)), + null, + 0 + ); + + } elseif ($def->type == 'custom') { + + $ret .= $this->element( + 'td', + '' . ucfirst($def->type) . ': ' . + $def->dtd_regex + ); + + } else { + $ret .= $this->element( + 'td', + '' . ucfirst($def->type) . ': ' . + $this->escape($this->listifyTagLookup($elements)), + null, + 0 + ); + } + $ret .= $this->end('tr'); + return $ret; + } + + /** + * Listifies a tag lookup table. + * @param array $array Tag lookup array in form of array('tagname' => true) + * @return string + */ + protected function listifyTagLookup($array) + { + ksort($array); + $list = array(); + foreach ($array as $name => $discard) { + if ($name !== '#PCDATA' && !isset($this->def->info[$name])) { + continue; + } + $list[] = $name; + } + return $this->listify($list); + } + + /** + * Listifies a list of objects by retrieving class names and internal state + * @param array $array List of objects + * @return string + * @todo Also add information about internal state + */ + protected function listifyObjectList($array) + { + ksort($array); + $list = array(); + foreach ($array as $obj) { + $list[] = $this->getClass($obj, 'AttrTransform_'); + } + return $this->listify($list); + } + + /** + * Listifies a hash of attributes to AttrDef classes + * @param array $array Array hash in form of array('attrname' => HTMLPurifier_AttrDef) + * @return string + */ + protected function listifyAttr($array) + { + ksort($array); + $list = array(); + foreach ($array as $name => $obj) { + if ($obj === false) { + continue; + } + $list[] = "$name = " . $this->getClass($obj, 'AttrDef_') . ''; + } + return $this->listify($list); + } + + /** + * Creates a heavy header row + * @param string $text + * @param int $num + * @return string + */ + protected function heavyHeader($text, $num = 1) + { + $ret = ''; + $ret .= $this->start('tr'); + $ret .= $this->element('th', $text, array('colspan' => $num, 'class' => 'heavy')); + $ret .= $this->end('tr'); + return $ret; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/PropertyList.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/PropertyList.php new file mode 100644 index 0000000..189348f --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/PropertyList.php @@ -0,0 +1,122 @@ +parent = $parent; + } + + /** + * Recursively retrieves the value for a key + * @param string $name + * @throws HTMLPurifier_Exception + */ + public function get($name) + { + if ($this->has($name)) { + return $this->data[$name]; + } + // possible performance bottleneck, convert to iterative if necessary + if ($this->parent) { + return $this->parent->get($name); + } + throw new HTMLPurifier_Exception("Key '$name' not found"); + } + + /** + * Sets the value of a key, for this plist + * @param string $name + * @param mixed $value + */ + public function set($name, $value) + { + $this->data[$name] = $value; + } + + /** + * Returns true if a given key exists + * @param string $name + * @return bool + */ + public function has($name) + { + return array_key_exists($name, $this->data); + } + + /** + * Resets a value to the value of it's parent, usually the default. If + * no value is specified, the entire plist is reset. + * @param string $name + */ + public function reset($name = null) + { + if ($name == null) { + $this->data = array(); + } else { + unset($this->data[$name]); + } + } + + /** + * Squashes this property list and all of its property lists into a single + * array, and returns the array. This value is cached by default. + * @param bool $force If true, ignores the cache and regenerates the array. + * @return array + */ + public function squash($force = false) + { + if ($this->cache !== null && !$force) { + return $this->cache; + } + if ($this->parent) { + return $this->cache = array_merge($this->parent->squash($force), $this->data); + } else { + return $this->cache = $this->data; + } + } + + /** + * Returns the parent plist. + * @return HTMLPurifier_PropertyList + */ + public function getParent() + { + return $this->parent; + } + + /** + * Sets the parent plist. + * @param HTMLPurifier_PropertyList $plist Parent plist + */ + public function setParent($plist) + { + $this->parent = $plist; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/PropertyListIterator.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/PropertyListIterator.php new file mode 100644 index 0000000..f68fc8c --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/PropertyListIterator.php @@ -0,0 +1,43 @@ +l = strlen($filter); + $this->filter = $filter; + } + + /** + * @return bool + */ + #[\ReturnTypeWillChange] + public function accept() + { + $key = $this->getInnerIterator()->key(); + if (strncmp($key, $this->filter, $this->l) !== 0) { + return false; + } + return true; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Queue.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Queue.php new file mode 100644 index 0000000..f58db90 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Queue.php @@ -0,0 +1,56 @@ +input = $input; + $this->output = array(); + } + + /** + * Shifts an element off the front of the queue. + */ + public function shift() { + if (empty($this->output)) { + $this->output = array_reverse($this->input); + $this->input = array(); + } + if (empty($this->output)) { + return NULL; + } + return array_pop($this->output); + } + + /** + * Pushes an element onto the front of the queue. + */ + public function push($x) { + array_push($this->input, $x); + } + + /** + * Checks if it's empty. + */ + public function isEmpty() { + return empty($this->input) && empty($this->output); + } +} diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Strategy.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Strategy.php new file mode 100644 index 0000000..e1ff3b7 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Strategy.php @@ -0,0 +1,26 @@ +strategies as $strategy) { + $tokens = $strategy->execute($tokens, $config, $context); + } + return $tokens; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Strategy/Core.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Strategy/Core.php new file mode 100644 index 0000000..4414c17 --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Strategy/Core.php @@ -0,0 +1,17 @@ +strategies[] = new HTMLPurifier_Strategy_RemoveForeignElements(); + $this->strategies[] = new HTMLPurifier_Strategy_MakeWellFormed(); + $this->strategies[] = new HTMLPurifier_Strategy_FixNesting(); + $this->strategies[] = new HTMLPurifier_Strategy_ValidateAttributes(); + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Strategy/FixNesting.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Strategy/FixNesting.php new file mode 100644 index 0000000..6fa673d --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Strategy/FixNesting.php @@ -0,0 +1,181 @@ +getHTMLDefinition(); + + $excludes_enabled = !$config->get('Core.DisableExcludes'); + + // setup the context variable 'IsInline', for chameleon processing + // is 'false' when we are not inline, 'true' when it must always + // be inline, and an integer when it is inline for a certain + // branch of the document tree + $is_inline = $definition->info_parent_def->descendants_are_inline; + $context->register('IsInline', $is_inline); + + // setup error collector + $e =& $context->get('ErrorCollector', true); + + //####################################################################// + // Loop initialization + + // stack that contains all elements that are excluded + // it is organized by parent elements, similar to $stack, + // but it is only populated when an element with exclusions is + // processed, i.e. there won't be empty exclusions. + $exclude_stack = array($definition->info_parent_def->excludes); + + // variable that contains the start token while we are processing + // nodes. This enables error reporting to do its job + $node = $top_node; + // dummy token + list($token, $d) = $node->toTokenPair(); + $context->register('CurrentNode', $node); + $context->register('CurrentToken', $token); + + //####################################################################// + // Loop + + // We need to implement a post-order traversal iteratively, to + // avoid running into stack space limits. This is pretty tricky + // to reason about, so we just manually stack-ify the recursive + // variant: + // + // function f($node) { + // foreach ($node->children as $child) { + // f($child); + // } + // validate($node); + // } + // + // Thus, we will represent a stack frame as array($node, + // $is_inline, stack of children) + // e.g. array_reverse($node->children) - already processed + // children. + + $parent_def = $definition->info_parent_def; + $stack = array( + array($top_node, + $parent_def->descendants_are_inline, + $parent_def->excludes, // exclusions + 0) + ); + + while (!empty($stack)) { + list($node, $is_inline, $excludes, $ix) = array_pop($stack); + // recursive call + $go = false; + $def = empty($stack) ? $definition->info_parent_def : $definition->info[$node->name]; + while (isset($node->children[$ix])) { + $child = $node->children[$ix++]; + if ($child instanceof HTMLPurifier_Node_Element) { + $go = true; + $stack[] = array($node, $is_inline, $excludes, $ix); + $stack[] = array($child, + // ToDo: I don't think it matters if it's def or + // child_def, but double check this... + $is_inline || $def->descendants_are_inline, + empty($def->excludes) ? $excludes + : array_merge($excludes, $def->excludes), + 0); + break; + } + }; + if ($go) continue; + list($token, $d) = $node->toTokenPair(); + // base case + if ($excludes_enabled && isset($excludes[$node->name])) { + $node->dead = true; + if ($e) $e->send(E_ERROR, 'Strategy_FixNesting: Node excluded'); + } else { + // XXX I suppose it would be slightly more efficient to + // avoid the allocation here and have children + // strategies handle it + $children = array(); + foreach ($node->children as $child) { + if (!$child->dead) $children[] = $child; + } + $result = $def->child->validateChildren($children, $config, $context); + if ($result === true) { + // nop + $node->children = $children; + } elseif ($result === false) { + $node->dead = true; + if ($e) $e->send(E_ERROR, 'Strategy_FixNesting: Node removed'); + } else { + $node->children = $result; + if ($e) { + // XXX This will miss mutations of internal nodes. Perhaps defer to the child validators + if (empty($result) && !empty($children)) { + $e->send(E_ERROR, 'Strategy_FixNesting: Node contents removed'); + } else if ($result != $children) { + $e->send(E_WARNING, 'Strategy_FixNesting: Node reorganized'); + } + } + } + } + } + + //####################################################################// + // Post-processing + + // remove context variables + $context->destroy('IsInline'); + $context->destroy('CurrentNode'); + $context->destroy('CurrentToken'); + + //####################################################################// + // Return + + return HTMLPurifier_Arborize::flatten($node, $config, $context); + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Strategy/MakeWellFormed.php b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Strategy/MakeWellFormed.php new file mode 100644 index 0000000..a6eb09e --- /dev/null +++ b/vendor/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Strategy/MakeWellFormed.php @@ -0,0 +1,659 @@ +getHTMLDefinition(); + + // local variables + $generator = new HTMLPurifier_Generator($config, $context); + $escape_invalid_tags = $config->get('Core.EscapeInvalidTags'); + // used for autoclose early abortion + $global_parent_allowed_elements = $definition->info_parent_def->child->getAllowedElements($config); + $e = $context->get('ErrorCollector', true); + $i = false; // injector index + list($zipper, $token) = HTMLPurifier_Zipper::fromArray($tokens); + if ($token === NULL) { + return array(); + } + $reprocess = false; // whether or not to reprocess the same token + $stack = array(); + + // member variables + $this->stack =& $stack; + $this->tokens =& $tokens; + $this->token =& $token; + $this->zipper =& $zipper; + $this->config = $config; + $this->context = $context; + + // context variables + $context->register('CurrentNesting', $stack); + $context->register('InputZipper', $zipper); + $context->register('CurrentToken', $token); + + // -- begin INJECTOR -- + + $this->injectors = array(); + + $injectors = $config->getBatch('AutoFormat'); + $def_injectors = $definition->info_injector; + $custom_injectors = $injectors['Custom']; + unset($injectors['Custom']); // special case + foreach ($injectors as $injector => $b) { + // XXX: Fix with a legitimate lookup table of enabled filters + if (strpos($injector, '.') !== false) { + continue; + } + $injector = "HTMLPurifier_Injector_$injector"; + if (!$b) { + continue; + } + $this->injectors[] = new $injector; + } + foreach ($def_injectors as $injector) { + // assumed to be objects + $this->injectors[] = $injector; + } + foreach ($custom_injectors as $injector) { + if (!$injector) { + continue; + } + if (is_string($injector)) { + $injector = "HTMLPurifier_Injector_$injector"; + $injector = new $injector; + } + $this->injectors[] = $injector; + } + + // give the injectors references to the definition and context + // variables for performance reasons + foreach ($this->injectors as $ix => $injector) { + $error = $injector->prepare($config, $context); + if (!$error) { + continue; + } + array_splice($this->injectors, $ix, 1); // rm the injector + trigger_error("Cannot enable {$injector->name} injector because $error is not allowed", E_USER_WARNING); + } + + // -- end INJECTOR -- + + // a note on reprocessing: + // In order to reduce code duplication, whenever some code needs + // to make HTML changes in order to make things "correct", the + // new HTML gets sent through the purifier, regardless of its + // status. This means that if we add a start token, because it + // was totally necessary, we don't have to update nesting; we just + // punt ($reprocess = true; continue;) and it does that for us. + + // isset is in loop because $tokens size changes during loop exec + for (;; + // only increment if we don't need to reprocess + $reprocess ? $reprocess = false : $token = $zipper->next($token)) { + + // check for a rewind + if (is_int($i)) { + // possibility: disable rewinding if the current token has a + // rewind set on it already. This would offer protection from + // infinite loop, but might hinder some advanced rewinding. + $rewind_offset = $this->injectors[$i]->getRewindOffset(); + if (is_int($rewind_offset)) { + for ($j = 0; $j < $rewind_offset; $j++) { + if (empty($zipper->front)) break; + $token = $zipper->prev($token); + // indicate that other injectors should not process this token, + // but we need to reprocess it. See Note [Injector skips] + unset($token->skip[$i]); + $token->rewind = $i; + if ($token instanceof HTMLPurifier_Token_Start) { + array_pop($this->stack); + } elseif ($token instanceof HTMLPurifier_Token_End) { + $this->stack[] = $token->start; + } + } + } + $i = false; + } + + // handle case of document end + if ($token === NULL) { + // kill processing if stack is empty + if (empty($this->stack)) { + break; + } + + // peek + $top_nesting = array_pop($this->stack); + $this->stack[] = $top_nesting; + + // send error [TagClosedSuppress] + if ($e && !isset($top_nesting->armor['MakeWellFormed_TagClosedError'])) { + $e->send(E_NOTICE, 'Strategy_MakeWellFormed: Tag closed by document end', $top_nesting); + } + + // append, don't splice, since this is the end + $token = new HTMLPurifier_Token_End($top_nesting->name); + + // punt! + $reprocess = true; + continue; + } + + //echo '
    '; printZipper($zipper, $token);//printTokens($this->stack); + //flush(); + + // quick-check: if it's not a tag, no need to process + if (empty($token->is_tag)) { + if ($token instanceof HTMLPurifier_Token_Text) { + foreach ($this->injectors as $i => $injector) { + if (isset($token->skip[$i])) { + // See Note [Injector skips] + continue; + } + if ($token->rewind !== null && $token->rewind !== $i) { + continue; + } + // XXX fuckup + $r = $token; + $injector->handleText($r); + $token = $this->processToken($r, $i); + $reprocess = true; + break; + } + } + // another possibility is a comment + continue; + } + + if (isset($definition->info[$token->name])) { + $type = $definition->info[$token->name]->child->type; + } else { + $type = false; // Type is unknown, treat accordingly + } + + // quick tag checks: anything that's *not* an end tag + $ok = false; + if ($type === 'empty' && $token instanceof HTMLPurifier_Token_Start) { + // claims to be a start tag but is empty + $token = new HTMLPurifier_Token_Empty( + $token->name, + $token->attr, + $token->line, + $token->col, + $token->armor + ); + $ok = true; + } elseif ($type && $type !== 'empty' && $token instanceof HTMLPurifier_Token_Empty) { + // claims to be empty but really is a start tag + // NB: this assignment is required + $old_token = $token; + $token = new HTMLPurifier_Token_End($token->name); + $token = $this->insertBefore( + new HTMLPurifier_Token_Start($old_token->name, $old_token->attr, $old_token->line, $old_token->col, $old_token->armor) + ); + // punt (since we had to modify the input stream in a non-trivial way) + $reprocess = true; + continue; + } elseif ($token instanceof HTMLPurifier_Token_Empty) { + // real empty token + $ok = true; + } elseif ($token instanceof HTMLPurifier_Token_Start) { + // start tag + + // ...unless they also have to close their parent + if (!empty($this->stack)) { + + // Performance note: you might think that it's rather + // inefficient, recalculating the autoclose information + // for every tag that a token closes (since when we + // do an autoclose, we push a new token into the + // stream and then /process/ that, before + // re-processing this token.) But this is + // necessary, because an injector can make an + // arbitrary transformations to the autoclosing + // tokens we introduce, so things may have changed + // in the meantime. Also, doing the inefficient thing is + // "easy" to reason about (for certain perverse definitions + // of "easy") + + $parent = array_pop($this->stack); + $this->stack[] = $parent; + + $parent_def = null; + $parent_elements = null; + $autoclose = false; + if (isset($definition->info[$parent->name])) { + $parent_def = $definition->info[$parent->name]; + $parent_elements = $parent_def->child->getAllowedElements($config); + $autoclose = !isset($parent_elements[$token->name]); + } + + if ($autoclose && $definition->info[$token->name]->wrap) { + // Check if an element can be wrapped by another + // element to make it valid in a context (for + // example,