Browse Source

第二次推送项目3

master
wanghongjun 2 years ago
parent
commit
f2b86cf3ad
  1. 3
      extend/aliyun-php-sdk-afs/ChangeLog.txt
  2. 74
      extend/aliyun-php-sdk-afs/afs/Request/V20180112/AnalyzeNvcRequest.php
  3. 118
      extend/aliyun-php-sdk-afs/afs/Request/V20180112/AuthenticateSigRequest.php
  4. 85
      extend/aliyun-php-sdk-afs/afs/Request/V20180112/ConfigurationStyleRequest.php
  5. 107
      extend/aliyun-php-sdk-afs/afs/Request/V20180112/CreateConfigurationRequest.php
  6. 85
      extend/aliyun-php-sdk-afs/afs/Request/V20180112/DescribeCaptchaDayRequest.php
  7. 85
      extend/aliyun-php-sdk-afs/afs/Request/V20180112/DescribeCaptchaIpCityRequest.php
  8. 85
      extend/aliyun-php-sdk-afs/afs/Request/V20180112/DescribeCaptchaMinRequest.php
  9. 74
      extend/aliyun-php-sdk-afs/afs/Request/V20180112/DescribeCaptchaRiskRequest.php
  10. 52
      extend/aliyun-php-sdk-afs/afs/Request/V20180112/DescribeConfigNameRequest.php
  11. 52
      extend/aliyun-php-sdk-afs/afs/Request/V20180112/DescribeEarlyWarningRequest.php
  12. 52
      extend/aliyun-php-sdk-afs/afs/Request/V20180112/DescribePersonMachineListRequest.php
  13. 129
      extend/aliyun-php-sdk-afs/afs/Request/V20180112/SetEarlyWarningRequest.php
  14. 154
      extend/aliyun-php-sdk-core/AcsRequest.php
  15. 44
      extend/aliyun-php-sdk-core/AcsResponse.php
  16. 94
      extend/aliyun-php-sdk-core/Auth/Credential.php
  17. 27
      extend/aliyun-php-sdk-core/Auth/ISigner.php
  18. 36
      extend/aliyun-php-sdk-core/Auth/ShaHmac1Signer.php
  19. 36
      extend/aliyun-php-sdk-core/Auth/ShaHmac256Signer.php
  20. 48
      extend/aliyun-php-sdk-core/Autoloader/Autoloader.php
  21. 49
      extend/aliyun-php-sdk-core/Config.php
  22. 134
      extend/aliyun-php-sdk-core/DefaultAcsClient.php
  23. 63
      extend/aliyun-php-sdk-core/Exception/ClientException.php
  24. 44
      extend/aliyun-php-sdk-core/Exception/ServerException.php
  25. 80
      extend/aliyun-php-sdk-core/Http/HttpHelper.php
  26. 52
      extend/aliyun-php-sdk-core/Http/HttpResponse.php
  27. 23
      extend/aliyun-php-sdk-core/IAcsClient.php
  28. 146
      extend/aliyun-php-sdk-core/Profile/DefaultProfile.php
  29. 29
      extend/aliyun-php-sdk-core/Profile/IClientProfile.php
  30. 62
      extend/aliyun-php-sdk-core/Regions/Endpoint.php
  31. 65
      extend/aliyun-php-sdk-core/Regions/EndpointConfig.php
  32. 60
      extend/aliyun-php-sdk-core/Regions/EndpointProvider.php
  33. 120
      extend/aliyun-php-sdk-core/Regions/LocationService.php
  34. 47
      extend/aliyun-php-sdk-core/Regions/ProductDomain.php
  35. 1349
      extend/aliyun-php-sdk-core/Regions/endpoints.xml
  36. 206
      extend/aliyun-php-sdk-core/RoaAcsRequest.php
  37. 116
      extend/aliyun-php-sdk-core/RpcAcsRequest.php
  38. 35
      extend/aliyun-php-sdk-core/UnitTest/Auth/CredentialTest.php
  39. 28
      extend/aliyun-php-sdk-core/UnitTest/Auth/ShaHmac1SignerTest.php
  40. 30
      extend/aliyun-php-sdk-core/UnitTest/Auth/ShaHmac256SignerTest.php
  41. 40
      extend/aliyun-php-sdk-core/UnitTest/BaseTest.php
  42. 30
      extend/aliyun-php-sdk-core/UnitTest/BatchCompute/ListImagesRequest.php
  43. 42
      extend/aliyun-php-sdk-core/UnitTest/DefaultAcsClientTest.php
  44. 80
      extend/aliyun-php-sdk-core/UnitTest/Ecs/Rquest/DescribeRegionsRequest.php
  45. 35
      extend/aliyun-php-sdk-core/UnitTest/Ft/InteTest.php
  46. 57
      extend/aliyun-php-sdk-core/UnitTest/Ft/TestRoaApiRequest.php
  47. 42
      extend/aliyun-php-sdk-core/UnitTest/Ft/TestRpcApiRequest.php
  48. 29
      extend/aliyun-php-sdk-core/UnitTest/Http/HttpHelperTest.php
  49. 60
      extend/aliyun-php-sdk-core/UnitTest/Profile/DefaultProfileTest.php
  50. 46
      extend/aliyun-php-sdk-core/UnitTest/Regions/EndPointByLocationTest.php
  51. 28
      extend/aliyun-php-sdk-core/UnitTest/Regions/EndpointProviderTest.php
  52. 2
      extend/aliyunoss/.coveralls.yml
  53. 8
      extend/aliyunoss/.gitignore
  54. 21
      extend/aliyunoss/.travis.yml
  55. 16
      extend/aliyunoss/Aliconfig.php
  56. 85
      extend/aliyunoss/Common.php
  57. 72
      extend/aliyunoss/callback.php
  58. 1357
      extend/fdd/FddApi.php
  59. 47
      extend/fdd/FddConfig.php
  60. 4039
      extend/fdd/FddData.php
  61. 109
      extend/fdd/FddEncryption.php
  62. 14
      extend/fdd/FddException.php
  63. 350
      extend/fdd/HttpClient.php
  64. BIN
      extend/ip/17monipdb.dat
  65. 292
      extend/ip/readme.txt

3
extend/aliyun-php-sdk-afs/ChangeLog.txt

@ -0,0 +1,3 @@
2018-02-02 Version: 1.0.0
1, this version is new of captcha management and nvc analyze

74
extend/aliyun-php-sdk-afs/afs/Request/V20180112/AnalyzeNvcRequest.php

@ -0,0 +1,74 @@
<?php
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
namespace afs\Request\V20180112;
class AnalyzeNvcRequest extends \RpcAcsRequest
{
function __construct()
{
parent::__construct("afs", "2018-01-12", "AnalyzeNvc");
$this->setMethod("POST");
}
private $resourceOwnerId;
private $sourceIp;
private $data;
private $scoreJsonStr;
public function getResourceOwnerId() {
return $this->resourceOwnerId;
}
public function setResourceOwnerId($resourceOwnerId) {
$this->resourceOwnerId = $resourceOwnerId;
$this->queryParameters["ResourceOwnerId"]=$resourceOwnerId;
}
public function getSourceIp() {
return $this->sourceIp;
}
public function setSourceIp($sourceIp) {
$this->sourceIp = $sourceIp;
$this->queryParameters["SourceIp"]=$sourceIp;
}
public function getData() {
return $this->data;
}
public function setData($data) {
$this->data = $data;
$this->queryParameters["Data"]=$data;
}
public function getScoreJsonStr() {
return $this->scoreJsonStr;
}
public function setScoreJsonStr($scoreJsonStr) {
$this->scoreJsonStr = $scoreJsonStr;
$this->queryParameters["ScoreJsonStr"]=$scoreJsonStr;
}
}

118
extend/aliyun-php-sdk-afs/afs/Request/V20180112/AuthenticateSigRequest.php

@ -0,0 +1,118 @@
<?php
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
namespace afs\Request\V20180112;
class AuthenticateSigRequest extends \RpcAcsRequest
{
function __construct()
{
parent::__construct("afs", "2018-01-12", "AuthenticateSig");
$this->setMethod("POST");
}
private $sig;
private $resourceOwnerId;
private $remoteIp;
private $sourceIp;
private $appKey;
private $sessionId;
private $token;
private $scene;
public function getSig() {
return $this->sig;
}
public function setSig($sig) {
$this->sig = $sig;
$this->queryParameters["Sig"]=$sig;
}
public function getResourceOwnerId() {
return $this->resourceOwnerId;
}
public function setResourceOwnerId($resourceOwnerId) {
$this->resourceOwnerId = $resourceOwnerId;
$this->queryParameters["ResourceOwnerId"]=$resourceOwnerId;
}
public function getRemoteIp() {
return $this->remoteIp;
}
public function setRemoteIp($remoteIp) {
$this->remoteIp = $remoteIp;
$this->queryParameters["RemoteIp"]=$remoteIp;
}
public function getSourceIp() {
return $this->sourceIp;
}
public function setSourceIp($sourceIp) {
$this->sourceIp = $sourceIp;
$this->queryParameters["SourceIp"]=$sourceIp;
}
public function getAppKey() {
return $this->appKey;
}
public function setAppKey($appKey) {
$this->appKey = $appKey;
$this->queryParameters["AppKey"]=$appKey;
}
public function getSessionId() {
return $this->sessionId;
}
public function setSessionId($sessionId) {
$this->sessionId = $sessionId;
$this->queryParameters["SessionId"]=$sessionId;
}
public function getToken() {
return $this->token;
}
public function setToken($token) {
$this->token = $token;
$this->queryParameters["Token"]=$token;
}
public function getScene() {
return $this->scene;
}
public function setScene($scene) {
$this->scene = $scene;
$this->queryParameters["Scene"]=$scene;
}
}

85
extend/aliyun-php-sdk-afs/afs/Request/V20180112/ConfigurationStyleRequest.php

@ -0,0 +1,85 @@
<?php
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
namespace afs\Request\V20180112;
class ConfigurationStyleRequest extends \RpcAcsRequest
{
function __construct()
{
parent::__construct("afs", "2018-01-12", "ConfigurationStyle");
$this->setMethod("POST");
}
private $resourceOwnerId;
private $sourceIp;
private $configurationMethod;
private $applyType;
private $scene;
public function getResourceOwnerId() {
return $this->resourceOwnerId;
}
public function setResourceOwnerId($resourceOwnerId) {
$this->resourceOwnerId = $resourceOwnerId;
$this->queryParameters["ResourceOwnerId"]=$resourceOwnerId;
}
public function getSourceIp() {
return $this->sourceIp;
}
public function setSourceIp($sourceIp) {
$this->sourceIp = $sourceIp;
$this->queryParameters["SourceIp"]=$sourceIp;
}
public function getConfigurationMethod() {
return $this->configurationMethod;
}
public function setConfigurationMethod($configurationMethod) {
$this->configurationMethod = $configurationMethod;
$this->queryParameters["ConfigurationMethod"]=$configurationMethod;
}
public function getApplyType() {
return $this->applyType;
}
public function setApplyType($applyType) {
$this->applyType = $applyType;
$this->queryParameters["ApplyType"]=$applyType;
}
public function getScene() {
return $this->scene;
}
public function setScene($scene) {
$this->scene = $scene;
$this->queryParameters["Scene"]=$scene;
}
}

107
extend/aliyun-php-sdk-afs/afs/Request/V20180112/CreateConfigurationRequest.php

@ -0,0 +1,107 @@
<?php
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
namespace afs\Request\V20180112;
class CreateConfigurationRequest extends \RpcAcsRequest
{
function __construct()
{
parent::__construct("afs", "2018-01-12", "CreateConfiguration");
$this->setMethod("POST");
}
private $resourceOwnerId;
private $sourceIp;
private $configurationName;
private $maxPV;
private $configurationMethod;
private $applyType;
private $scene;
public function getResourceOwnerId() {
return $this->resourceOwnerId;
}
public function setResourceOwnerId($resourceOwnerId) {
$this->resourceOwnerId = $resourceOwnerId;
$this->queryParameters["ResourceOwnerId"]=$resourceOwnerId;
}
public function getSourceIp() {
return $this->sourceIp;
}
public function setSourceIp($sourceIp) {
$this->sourceIp = $sourceIp;
$this->queryParameters["SourceIp"]=$sourceIp;
}
public function getConfigurationName() {
return $this->configurationName;
}
public function setConfigurationName($configurationName) {
$this->configurationName = $configurationName;
$this->queryParameters["ConfigurationName"]=$configurationName;
}
public function getMaxPV() {
return $this->maxPV;
}
public function setMaxPV($maxPV) {
$this->maxPV = $maxPV;
$this->queryParameters["MaxPV"]=$maxPV;
}
public function getConfigurationMethod() {
return $this->configurationMethod;
}
public function setConfigurationMethod($configurationMethod) {
$this->configurationMethod = $configurationMethod;
$this->queryParameters["ConfigurationMethod"]=$configurationMethod;
}
public function getApplyType() {
return $this->applyType;
}
public function setApplyType($applyType) {
$this->applyType = $applyType;
$this->queryParameters["ApplyType"]=$applyType;
}
public function getScene() {
return $this->scene;
}
public function setScene($scene) {
$this->scene = $scene;
$this->queryParameters["Scene"]=$scene;
}
}

85
extend/aliyun-php-sdk-afs/afs/Request/V20180112/DescribeCaptchaDayRequest.php

@ -0,0 +1,85 @@
<?php
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
namespace afs\Request\V20180112;
class DescribeCaptchaDayRequest extends \RpcAcsRequest
{
function __construct()
{
parent::__construct("afs", "2018-01-12", "DescribeCaptchaDay");
$this->setMethod("POST");
}
private $resourceOwnerId;
private $sourceIp;
private $configName;
private $time;
private $type;
public function getResourceOwnerId() {
return $this->resourceOwnerId;
}
public function setResourceOwnerId($resourceOwnerId) {
$this->resourceOwnerId = $resourceOwnerId;
$this->queryParameters["ResourceOwnerId"]=$resourceOwnerId;
}
public function getSourceIp() {
return $this->sourceIp;
}
public function setSourceIp($sourceIp) {
$this->sourceIp = $sourceIp;
$this->queryParameters["SourceIp"]=$sourceIp;
}
public function getConfigName() {
return $this->configName;
}
public function setConfigName($configName) {
$this->configName = $configName;
$this->queryParameters["ConfigName"]=$configName;
}
public function getTime() {
return $this->time;
}
public function setTime($time) {
$this->time = $time;
$this->queryParameters["Time"]=$time;
}
public function getType() {
return $this->type;
}
public function setType($type) {
$this->type = $type;
$this->queryParameters["Type"]=$type;
}
}

85
extend/aliyun-php-sdk-afs/afs/Request/V20180112/DescribeCaptchaIpCityRequest.php

@ -0,0 +1,85 @@
<?php
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
namespace afs\Request\V20180112;
class DescribeCaptchaIpCityRequest extends \RpcAcsRequest
{
function __construct()
{
parent::__construct("afs", "2018-01-12", "DescribeCaptchaIpCity");
$this->setMethod("POST");
}
private $resourceOwnerId;
private $sourceIp;
private $configName;
private $time;
private $type;
public function getResourceOwnerId() {
return $this->resourceOwnerId;
}
public function setResourceOwnerId($resourceOwnerId) {
$this->resourceOwnerId = $resourceOwnerId;
$this->queryParameters["ResourceOwnerId"]=$resourceOwnerId;
}
public function getSourceIp() {
return $this->sourceIp;
}
public function setSourceIp($sourceIp) {
$this->sourceIp = $sourceIp;
$this->queryParameters["SourceIp"]=$sourceIp;
}
public function getConfigName() {
return $this->configName;
}
public function setConfigName($configName) {
$this->configName = $configName;
$this->queryParameters["ConfigName"]=$configName;
}
public function getTime() {
return $this->time;
}
public function setTime($time) {
$this->time = $time;
$this->queryParameters["Time"]=$time;
}
public function getType() {
return $this->type;
}
public function setType($type) {
$this->type = $type;
$this->queryParameters["Type"]=$type;
}
}

85
extend/aliyun-php-sdk-afs/afs/Request/V20180112/DescribeCaptchaMinRequest.php

@ -0,0 +1,85 @@
<?php
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
namespace afs\Request\V20180112;
class DescribeCaptchaMinRequest extends \RpcAcsRequest
{
function __construct()
{
parent::__construct("afs", "2018-01-12", "DescribeCaptchaMin");
$this->setMethod("POST");
}
private $resourceOwnerId;
private $sourceIp;
private $configName;
private $time;
private $type;
public function getResourceOwnerId() {
return $this->resourceOwnerId;
}
public function setResourceOwnerId($resourceOwnerId) {
$this->resourceOwnerId = $resourceOwnerId;
$this->queryParameters["ResourceOwnerId"]=$resourceOwnerId;
}
public function getSourceIp() {
return $this->sourceIp;
}
public function setSourceIp($sourceIp) {
$this->sourceIp = $sourceIp;
$this->queryParameters["SourceIp"]=$sourceIp;
}
public function getConfigName() {
return $this->configName;
}
public function setConfigName($configName) {
$this->configName = $configName;
$this->queryParameters["ConfigName"]=$configName;
}
public function getTime() {
return $this->time;
}
public function setTime($time) {
$this->time = $time;
$this->queryParameters["Time"]=$time;
}
public function getType() {
return $this->type;
}
public function setType($type) {
$this->type = $type;
$this->queryParameters["Type"]=$type;
}
}

74
extend/aliyun-php-sdk-afs/afs/Request/V20180112/DescribeCaptchaRiskRequest.php

@ -0,0 +1,74 @@
<?php
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
namespace afs\Request\V20180112;
class DescribeCaptchaRiskRequest extends \RpcAcsRequest
{
function __construct()
{
parent::__construct("afs", "2018-01-12", "DescribeCaptchaRisk");
$this->setMethod("POST");
}
private $resourceOwnerId;
private $sourceIp;
private $configName;
private $time;
public function getResourceOwnerId() {
return $this->resourceOwnerId;
}
public function setResourceOwnerId($resourceOwnerId) {
$this->resourceOwnerId = $resourceOwnerId;
$this->queryParameters["ResourceOwnerId"]=$resourceOwnerId;
}
public function getSourceIp() {
return $this->sourceIp;
}
public function setSourceIp($sourceIp) {
$this->sourceIp = $sourceIp;
$this->queryParameters["SourceIp"]=$sourceIp;
}
public function getConfigName() {
return $this->configName;
}
public function setConfigName($configName) {
$this->configName = $configName;
$this->queryParameters["ConfigName"]=$configName;
}
public function getTime() {
return $this->time;
}
public function setTime($time) {
$this->time = $time;
$this->queryParameters["Time"]=$time;
}
}

52
extend/aliyun-php-sdk-afs/afs/Request/V20180112/DescribeConfigNameRequest.php

@ -0,0 +1,52 @@
<?php
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
namespace afs\Request\V20180112;
class DescribeConfigNameRequest extends \RpcAcsRequest
{
function __construct()
{
parent::__construct("afs", "2018-01-12", "DescribeConfigName");
$this->setMethod("POST");
}
private $resourceOwnerId;
private $sourceIp;
public function getResourceOwnerId() {
return $this->resourceOwnerId;
}
public function setResourceOwnerId($resourceOwnerId) {
$this->resourceOwnerId = $resourceOwnerId;
$this->queryParameters["ResourceOwnerId"]=$resourceOwnerId;
}
public function getSourceIp() {
return $this->sourceIp;
}
public function setSourceIp($sourceIp) {
$this->sourceIp = $sourceIp;
$this->queryParameters["SourceIp"]=$sourceIp;
}
}

52
extend/aliyun-php-sdk-afs/afs/Request/V20180112/DescribeEarlyWarningRequest.php

@ -0,0 +1,52 @@
<?php
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
namespace afs\Request\V20180112;
class DescribeEarlyWarningRequest extends \RpcAcsRequest
{
function __construct()
{
parent::__construct("afs", "2018-01-12", "DescribeEarlyWarning");
$this->setMethod("POST");
}
private $resourceOwnerId;
private $sourceIp;
public function getResourceOwnerId() {
return $this->resourceOwnerId;
}
public function setResourceOwnerId($resourceOwnerId) {
$this->resourceOwnerId = $resourceOwnerId;
$this->queryParameters["ResourceOwnerId"]=$resourceOwnerId;
}
public function getSourceIp() {
return $this->sourceIp;
}
public function setSourceIp($sourceIp) {
$this->sourceIp = $sourceIp;
$this->queryParameters["SourceIp"]=$sourceIp;
}
}

52
extend/aliyun-php-sdk-afs/afs/Request/V20180112/DescribePersonMachineListRequest.php

@ -0,0 +1,52 @@
<?php
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
namespace afs\Request\V20180112;
class DescribePersonMachineListRequest extends \RpcAcsRequest
{
function __construct()
{
parent::__construct("afs", "2018-01-12", "DescribePersonMachineList");
$this->setMethod("POST");
}
private $resourceOwnerId;
private $sourceIp;
public function getResourceOwnerId() {
return $this->resourceOwnerId;
}
public function setResourceOwnerId($resourceOwnerId) {
$this->resourceOwnerId = $resourceOwnerId;
$this->queryParameters["ResourceOwnerId"]=$resourceOwnerId;
}
public function getSourceIp() {
return $this->sourceIp;
}
public function setSourceIp($sourceIp) {
$this->sourceIp = $sourceIp;
$this->queryParameters["SourceIp"]=$sourceIp;
}
}

129
extend/aliyun-php-sdk-afs/afs/Request/V20180112/SetEarlyWarningRequest.php

@ -0,0 +1,129 @@
<?php
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
namespace afs\Request\V20180112;
class SetEarlyWarningRequest extends \RpcAcsRequest
{
function __construct()
{
parent::__construct("afs", "2018-01-12", "SetEarlyWarning");
$this->setMethod("POST");
}
private $timeEnd;
private $resourceOwnerId;
private $warnOpen;
private $sourceIp;
private $channel;
private $title;
private $timeOpen;
private $timeBegin;
private $frequency;
public function getTimeEnd() {
return $this->timeEnd;
}
public function setTimeEnd($timeEnd) {
$this->timeEnd = $timeEnd;
$this->queryParameters["TimeEnd"]=$timeEnd;
}
public function getResourceOwnerId() {
return $this->resourceOwnerId;
}
public function setResourceOwnerId($resourceOwnerId) {
$this->resourceOwnerId = $resourceOwnerId;
$this->queryParameters["ResourceOwnerId"]=$resourceOwnerId;
}
public function getWarnOpen() {
return $this->warnOpen;
}
public function setWarnOpen($warnOpen) {
$this->warnOpen = $warnOpen;
$this->queryParameters["WarnOpen"]=$warnOpen;
}
public function getSourceIp() {
return $this->sourceIp;
}
public function setSourceIp($sourceIp) {
$this->sourceIp = $sourceIp;
$this->queryParameters["SourceIp"]=$sourceIp;
}
public function getChannel() {
return $this->channel;
}
public function setChannel($channel) {
$this->channel = $channel;
$this->queryParameters["Channel"]=$channel;
}
public function getTitle() {
return $this->title;
}
public function setTitle($title) {
$this->title = $title;
$this->queryParameters["Title"]=$title;
}
public function getTimeOpen() {
return $this->timeOpen;
}
public function setTimeOpen($timeOpen) {
$this->timeOpen = $timeOpen;
$this->queryParameters["TimeOpen"]=$timeOpen;
}
public function getTimeBegin() {
return $this->timeBegin;
}
public function setTimeBegin($timeBegin) {
$this->timeBegin = $timeBegin;
$this->queryParameters["TimeBegin"]=$timeBegin;
}
public function getFrequency() {
return $this->frequency;
}
public function setFrequency($frequency) {
$this->frequency = $frequency;
$this->queryParameters["Frequency"]=$frequency;
}
}

154
extend/aliyun-php-sdk-core/AcsRequest.php

@ -0,0 +1,154 @@
<?php
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
abstract class AcsRequest
{
protected $version;
protected $product;
protected $actionName;
protected $regionId;
protected $acceptFormat;
protected $method;
protected $protocolType = "http";
protected $content;
protected $queryParameters = array();
protected $headers = array();
protected $locationServiceCode;
protected $locationEndpointType;
function __construct($product, $version, $actionName, $locationServiceCode = null, $locationEndpointType = "openAPI")
{
$this->headers["x-sdk-client"] = "php/2.0.0";
$this->product = $product;
$this->version = $version;
$this->actionName = $actionName;
$this->locationServiceCode = $locationServiceCode;
$this->locationEndpointType = $locationEndpointType;
}
public abstract function composeUrl($iSigner, $credential, $domain);
public function getVersion()
{
return $this->version;
}
public function setVersion($version)
{
$this->version = $version;
}
public function getProduct()
{
return $this->product;
}
public function setProduct($product)
{
$this->product = $product;
}
public function getActionName()
{
return $this->actionName;
}
public function setActionName($actionName)
{
$this->actionName = $actionName;
}
public function getAcceptFormat()
{
return $this->acceptFormat;
}
public function setAcceptFormat($acceptFormat)
{
$this->acceptFormat = $acceptFormat;
}
public function getQueryParameters()
{
return $this->queryParameters;
}
public function getHeaders()
{
return $this->headers;
}
public function getMethod()
{
return $this->method;
}
public function setMethod($method)
{
$this->method = $method;
}
public function getProtocol()
{
return $this->protocolType;
}
public function setProtocol($protocol)
{
$this->protocolType = $protocol;
}
public function getRegionId()
{
return $this->regionId;
}
public function setRegionId($region)
{
$this->regionId = $region;
}
public function getContent()
{
return $this->content;
}
public function setContent($content)
{
$this->content = $content;
}
public function addHeader($headerKey, $headerValue)
{
$this->headers[$headerKey] = $headerValue;
}
public function getLocationServiceCode()
{
return $this->locationServiceCode;
}
public function getLocationEndpointType()
{
return $this->locationEndpointType;
}
}

44
extend/aliyun-php-sdk-core/AcsResponse.php

@ -0,0 +1,44 @@
<?php
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
class AcsResponse
{
private $code;
private $message;
public function getCode()
{
return $this->code;
}
public function setCode($code)
{
$this->code = $code;
}
public function getMessage()
{
return $this->message;
}
public function setMessage($message)
{
$this->message = $message;
}
}

94
extend/aliyun-php-sdk-core/Auth/Credential.php

@ -0,0 +1,94 @@
<?php
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
class Credential
{
private $dateTimeFormat = 'Y-m-d\TH:i:s\Z';
private $refreshDate;
private $expiredDate;
private $accessKeyId;
private $accessSecret;
private $securityToken;
public function __construct($accessKeyId, $accessSecret, $securityToken)
{
$this->accessKeyId = $accessKeyId;
$this->accessSecret = $accessSecret;
$this->securityToken = $securityToken;
$this->refreshDate = date($this->dateTimeFormat);
}
public function isExpired()
{
if ($this->expiredDate == null) {
return false;
}
if (strtotime($this->expiredDate)>date($this->dateTimeFormat)) {
return false;
}
return true;
}
public function getRefreshDate()
{
return $this->refreshDate;
}
public function getExpiredDate()
{
return $this->expiredDate;
}
public function setExpiredDate($expiredHours)
{
if ($expiredHours>0) {
return $this->expiredDate = date($this->dateTimeFormat, strtotime("+".$expiredHours." hour"));
}
}
public function getAccessKeyId()
{
return $this->accessKeyId;
}
public function setAccessKeyId($accessKeyId)
{
$this->accessKeyId = $accessKeyId;
}
public function getAccessSecret()
{
return $this->accessSecret;
}
public function setAccessSecret($accessSecret)
{
$this->accessSecret = $accessSecret;
}
public function getSecurityToken()
{
return $this->securityToken;
}
public function setSecurityToken($securityToken)
{
$this->securityToken = $securityToken;
}
}

27
extend/aliyun-php-sdk-core/Auth/ISigner.php

@ -0,0 +1,27 @@
<?php
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
interface ISigner
{
public function getSignatureMethod();
public function getSignatureVersion();
public function signString($source, $accessSecret);
}

36
extend/aliyun-php-sdk-core/Auth/ShaHmac1Signer.php

@ -0,0 +1,36 @@
<?php
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
class ShaHmac1Signer implements ISigner
{
public function signString($source, $accessSecret)
{
return base64_encode(hash_hmac('sha1', $source, $accessSecret, true));
}
public function getSignatureMethod()
{
return "HMAC-SHA1";
}
public function getSignatureVersion()
{
return "1.0";
}
}

36
extend/aliyun-php-sdk-core/Auth/ShaHmac256Signer.php

@ -0,0 +1,36 @@
<?php
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
class ShaHmac256Signer implements ISigner
{
public function signString($source, $accessSecret)
{
return base64_encode(hash_hmac('sha256', $source, $accessSecret, true));
}
public function getSignatureMethod()
{
return "HMAC-SHA256";
}
public function getSignatureVersion()
{
return "1.0";
}
}

48
extend/aliyun-php-sdk-core/Autoloader/Autoloader.php

@ -0,0 +1,48 @@
<?php
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
spl_autoload_register("Autoloader::autoload");
class Autoloader
{
private static $autoloadPathArray = array(
"aliyun-php-sdk-core",
"aliyun-php-sdk-core/Auth",
"aliyun-php-sdk-core/Http",
"aliyun-php-sdk-core/Profile",
"aliyun-php-sdk-core/Regions",
"aliyun-php-sdk-core/Exception"
);
public static function autoload($className)
{
foreach (self::$autoloadPathArray as $path) {
$file = dirname(dirname(__DIR__)).DIRECTORY_SEPARATOR.$path.DIRECTORY_SEPARATOR.$className.".php";
$file = str_replace('\\', DIRECTORY_SEPARATOR, $file);
if (is_file($file)) {
include_once $file;
break;
}
}
}
public static function addAutoloadPath($path)
{
array_push(self::$autoloadPathArray, $path);
}
}

49
extend/aliyun-php-sdk-core/Config.php

@ -0,0 +1,49 @@
<?php
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
include_once 'Autoloader/Autoloader.php';
include_once 'Regions/EndpointConfig.php';
include_once 'Regions/LocationService.php';
//config sdk auto load path.
Autoloader::addAutoloadPath("aliyun-php-sdk-ecs");
Autoloader::addAutoloadPath("aliyun-php-sdk-batchcompute");
Autoloader::addAutoloadPath("aliyun-php-sdk-sts");
Autoloader::addAutoloadPath("aliyun-php-sdk-push");
Autoloader::addAutoloadPath("aliyun-php-sdk-ram");
Autoloader::addAutoloadPath("aliyun-php-sdk-ubsms");
Autoloader::addAutoloadPath("aliyun-php-sdk-ubsms-inner");
Autoloader::addAutoloadPath("aliyun-php-sdk-green");
Autoloader::addAutoloadPath("aliyun-php-sdk-dm");
Autoloader::addAutoloadPath("aliyun-php-sdk-iot");
Autoloader::addAutoloadPath("aliyun-php-sdk-jaq");
Autoloader::addAutoloadPath("aliyun-php-sdk-cs");
Autoloader::addAutoloadPath("aliyun-php-sdk-live");
Autoloader::addAutoloadPath("aliyun-php-sdk-vpc");
Autoloader::addAutoloadPath("aliyun-php-sdk-kms");
Autoloader::addAutoloadPath("aliyun-php-sdk-rds");
Autoloader::addAutoloadPath("aliyun-php-sdk-slb");
Autoloader::addAutoloadPath("aliyun-php-sdk-cms");
Autoloader::addAutoloadPath("aliyun-php-sdk-idst");
Autoloader::addAutoloadPath("aliyun-php-sdk-afs");
//config http proxy
define('ENABLE_HTTP_PROXY', false);
define('HTTP_PROXY_IP', '127.0.0.1');
define('HTTP_PROXY_PORT', '8888');

134
extend/aliyun-php-sdk-core/DefaultAcsClient.php

@ -0,0 +1,134 @@
<?php
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
class DefaultAcsClient implements IAcsClient
{
public $iClientProfile;
public $__urlTestFlag__;
private $locationService;
public function __construct($iClientProfile)
{
$this->iClientProfile = $iClientProfile;
$this->__urlTestFlag__ = false;
$this->locationService = new LocationService($this->iClientProfile);
}
public function getAcsResponse($request, $iSigner = null, $credential = null, $autoRetry = true, $maxRetryNumber = 3)
{
$httpResponse = $this->doActionImpl($request, $iSigner, $credential, $autoRetry, $maxRetryNumber);
$respObject = $this->parseAcsResponse($httpResponse->getBody(), $request->getAcceptFormat());
if (false == $httpResponse->isSuccess()) {
$this->buildApiException($respObject, $httpResponse->getStatus());
}
return $respObject;
}
private function doActionImpl($request, $iSigner = null, $credential = null, $autoRetry = true, $maxRetryNumber = 3)
{
if (null == $this->iClientProfile && (null == $iSigner || null == $credential
|| null == $request->getRegionId() || null == $request->getAcceptFormat())) {
throw new ClientException("No active profile found.", "SDK.InvalidProfile");
}
if (null == $iSigner) {
$iSigner = $this->iClientProfile->getSigner();
}
if (null == $credential) {
$credential = $this->iClientProfile->getCredential();
}
$request = $this->prepareRequest($request);
// Get the domain from the Location Service by speicified `ServiceCode` and `RegionId`.
$domain = null;
if (null != $request->getLocationServiceCode())
{
$domain = $this->locationService->findProductDomain($request->getRegionId(), $request->getLocationServiceCode(), $request->getLocationEndpointType(), $request->getProduct());
}
if ($domain == null)
{
$domain = EndpointProvider::findProductDomain($request->getRegionId(), $request->getProduct());
}
if (null == $domain) {
throw new ClientException("Can not find endpoint to access.", "SDK.InvalidRegionId");
}
$requestUrl = $request->composeUrl($iSigner, $credential, $domain);
if ($this->__urlTestFlag__) {
throw new ClientException($requestUrl, "URLTestFlagIsSet");
}
if (count($request->getDomainParameter())>0) {
$httpResponse = HttpHelper::curl($requestUrl, $request->getMethod(), $request->getDomainParameter(), $request->getHeaders());
} else {
$httpResponse = HttpHelper::curl($requestUrl, $request->getMethod(), $request->getContent(), $request->getHeaders());
}
$retryTimes = 1;
while (500 <= $httpResponse->getStatus() && $autoRetry && $retryTimes < $maxRetryNumber) {
$requestUrl = $request->composeUrl($iSigner, $credential, $domain);
if (count($request->getDomainParameter())>0) {
$httpResponse = HttpHelper::curl($requestUrl, $request->getDomainParameter(), $request->getHeaders());
} else {
$httpResponse = HttpHelper::curl($requestUrl, $request->getMethod(), $request->getContent(), $request->getHeaders());
}
$retryTimes ++;
}
return $httpResponse;
}
public function doAction($request, $iSigner = null, $credential = null, $autoRetry = true, $maxRetryNumber = 3)
{
trigger_error("doAction() is deprecated. Please use getAcsResponse() instead.", E_USER_NOTICE);
return $this->doActionImpl($request, $iSigner, $credential, $autoRetry, $maxRetryNumber);
}
private function prepareRequest($request)
{
if (null == $request->getRegionId()) {
$request->setRegionId($this->iClientProfile->getRegionId());
}
if (null == $request->getAcceptFormat()) {
$request->setAcceptFormat($this->iClientProfile->getFormat());
}
if (null == $request->getMethod()) {
$request->setMethod("GET");
}
return $request;
}
private function buildApiException($respObject, $httpStatus)
{
throw new ServerException($respObject->Message, $respObject->Code, $httpStatus, $respObject->RequestId);
}
private function parseAcsResponse($body, $format)
{
if ("JSON" == $format) {
$respObject = json_decode($body);
} elseif ("XML" == $format) {
$respObject = @simplexml_load_string($body);
} elseif ("RAW" == $format) {
$respObject = $body;
}
return $respObject;
}
}

63
extend/aliyun-php-sdk-core/Exception/ClientException.php

@ -0,0 +1,63 @@
<?php
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
class ClientException extends Exception
{
public function __construct($errorMessage, $errorCode)
{
parent::__construct($errorMessage);
$this->errorMessage = $errorMessage;
$this->errorCode = $errorCode;
$this->setErrorType("Client");
}
private $errorCode;
private $errorMessage;
private $errorType;
public function getErrorCode()
{
return $this->errorCode;
}
public function setErrorCode($errorCode)
{
$this->errorCode = $errorCode;
}
public function getErrorMessage()
{
return $this->errorMessage;
}
public function setErrorMessage($errorMessage)
{
$this->errorMessage = $errorMessage;
}
public function getErrorType()
{
return $this->errorType;
}
public function setErrorType($errorType)
{
$this->errorType = $errorType;
}
}

44
extend/aliyun-php-sdk-core/Exception/ServerException.php

@ -0,0 +1,44 @@
<?php
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
class ServerException extends ClientException
{
private $httpStatus;
private $requestId;
public function __construct($errorMessage, $errorCode, $httpStatus, $requestId)
{
$messageStr = $errorCode . " " . $errorMessage . " HTTP Status: " . $httpStatus . " RequestID: " . $requestId;
parent::__construct($messageStr, $errorCode);
$this->setErrorMessage($errorMessage);
$this->setErrorType("Server");
$this->httpStatus = $httpStatus;
$this->requestId = $requestId;
}
public function getHttpStatus()
{
return $this->httpStatus;
}
public function getRequestId()
{
return $this->requestId;
}
}

80
extend/aliyun-php-sdk-core/Http/HttpHelper.php

@ -0,0 +1,80 @@
<?php
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
class HttpHelper
{
public static $connectTimeout = 30;//30 second
public static $readTimeout = 80;//80 second
public static function curl($url, $httpMethod = "GET", $postFields = null, $headers = null)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $httpMethod);
if (ENABLE_HTTP_PROXY) {
curl_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_PROXY, HTTP_PROXY_IP);
curl_setopt($ch, CURLOPT_PROXYPORT, HTTP_PROXY_PORT);
curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
}
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FAILONERROR, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, is_array($postFields) ? self::getPostHttpBody($postFields) : $postFields);
if (self::$readTimeout) {
curl_setopt($ch, CURLOPT_TIMEOUT, self::$readTimeout);
}
if (self::$connectTimeout) {
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, self::$connectTimeout);
}
//https request
if (strlen($url) > 5 && strtolower(substr($url, 0, 5)) == "https") {
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
}
if (is_array($headers) && 0 < count($headers)) {
$httpHeaders =self::getHttpHearders($headers);
curl_setopt($ch, CURLOPT_HTTPHEADER, $httpHeaders);
}
$httpResponse = new HttpResponse();
$httpResponse->setBody(curl_exec($ch));
$httpResponse->setStatus(curl_getinfo($ch, CURLINFO_HTTP_CODE));
if (curl_errno($ch)) {
throw new ClientException("Server unreachable: Errno: " . curl_errno($ch) . " " . curl_error($ch), "SDK.ServerUnreachable");
}
curl_close($ch);
return $httpResponse;
}
public static function getPostHttpBody($postFildes)
{
$content = "";
foreach ($postFildes as $apiParamKey => $apiParamValue) {
$content .= "$apiParamKey=" . urlencode($apiParamValue) . "&";
}
return substr($content, 0, -1);
}
public static function getHttpHearders($headers)
{
$httpHeader = array();
foreach ($headers as $key => $value) {
array_push($httpHeader, $key.":".$value);
}
return $httpHeader;
}
}

52
extend/aliyun-php-sdk-core/Http/HttpResponse.php

@ -0,0 +1,52 @@
<?php
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
class HttpResponse
{
private $body;
private $status;
public function getBody()
{
return $this->body;
}
public function setBody($body)
{
$this->body = $body;
}
public function getStatus()
{
return $this->status;
}
public function setStatus($status)
{
$this->status = $status;
}
public function isSuccess()
{
if (200 <= $this->status && 300 > $this->status) {
return true;
}
return false;
}
}

23
extend/aliyun-php-sdk-core/IAcsClient.php

@ -0,0 +1,23 @@
<?php
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
interface IAcsClient
{
public function doAction($requst);
}

146
extend/aliyun-php-sdk-core/Profile/DefaultProfile.php

@ -0,0 +1,146 @@
<?php
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
class DefaultProfile implements IClientProfile
{
private static $profile;
private static $endpoints;
private static $credential;
private static $regionId;
private static $acceptFormat;
private static $isigner;
private static $iCredential;
private function __construct($regionId,$credential)
{
self::$regionId = $regionId;
self::$credential = $credential;
}
public static function getProfile($regionId, $accessKeyId, $accessSecret, $securityToken = null)
{
$credential =new Credential($accessKeyId, $accessSecret, $securityToken);
self::$profile = new DefaultProfile($regionId, $credential);
return self::$profile;
}
public function getSigner()
{
if(null == self::$isigner)
{
self::$isigner = new ShaHmac1Signer();
}
return self::$isigner;
}
public function getRegionId()
{
return self::$regionId;
}
public function getFormat()
{
return self::$acceptFormat;
}
public function getCredential()
{
if(null == self::$credential && null != self::$iCredential)
{
self::$credential = self::$iCredential;
}
return self::$credential;
}
public static function getEndpoints()
{
if(null == self::$endpoints)
{
self::$endpoints = EndpointProvider::getEndpoints();
}
return self::$endpoints;
}
public static function addEndpoint($endpointName, $regionId, $product, $domain)
{
if(null == self::$endpoints)
{
self::$endpoints = self::getEndpoints();
}
$endpoint = self::findEndpointByName($endpointName);
if(null == $endpoint)
{
self::addEndpoint_($endpointName, $regionId, $product, $domain);
}
else
{
self::updateEndpoint($regionId, $product, $domain, $endpoint);
}
LocationService::addEndPoint($regionId, $product, $domain);
}
public static function findEndpointByName($endpointName)
{
foreach (self::$endpoints as $key => $endpoint)
{
if($endpoint->getName() == $endpointName)
{
return $endpoint;
}
}
}
private static function addEndpoint_($endpointName,$regionId, $product, $domain)
{
$regionIds = array($regionId);
$productsDomains = array(new ProductDomain($product, $domain));
$endpoint = new Endpoint($endpointName, $regionIds, $productsDomains);
array_push(self::$endpoints, $endpoint);
}
private static function updateEndpoint($regionId, $product, $domain, $endpoint)
{
$regionIds = $endpoint->getRegionIds();
if(!in_array($regionId,$regionIds))
{
array_push($regionIds, $regionId);
$endpoint->setRegionIds($regionIds);
}
$productDomains = $endpoint->getProductDomains();
if (null == self::findProductDomainAndUpdate($productDomains, $product, $domain)) {
array_push($productDomains, new ProductDomain($product, $domain));
}
$endpoint->setProductDomains($productDomains);
}
private static function findProductDomainAndUpdate($productDomains, $product, $domain)
{
foreach ($productDomains as $key => $productDomain) {
if ($productDomain->getProductName() == $product) {
$productDomain->setDomainName($domain);
return $productDomain;
}
}
return null;
}
}

29
extend/aliyun-php-sdk-core/Profile/IClientProfile.php

@ -0,0 +1,29 @@
<?php
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
interface IClientProfile
{
public function getSigner();
public function getRegionId();
public function getFormat();
public function getCredential();
}

62
extend/aliyun-php-sdk-core/Regions/Endpoint.php

@ -0,0 +1,62 @@
<?php
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
class Endpoint
{
private $name;
private $regionIds;
private $productDomains;
public function __construct($name, $regionIds, $productDomains)
{
$this->name = $name;
$this->regionIds = $regionIds;
$this->productDomains = $productDomains;
}
public function getName()
{
return $this->name;
}
public function setName($name)
{
$this->name = $name;
}
public function getRegionIds()
{
return $this->regionIds;
}
public function setRegionIds($regionIds)
{
$this->regionIds = $regionIds;
}
public function getProductDomains()
{
return $this->productDomains;
}
public function setProductDomains($productDomains)
{
$this->productDomains = $productDomains;
}
}

65
extend/aliyun-php-sdk-core/Regions/EndpointConfig.php

@ -0,0 +1,65 @@
<?php
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
$endpoint_filename = dirname(__FILE__) . DIRECTORY_SEPARATOR . "endpoints.xml";
$xml = simplexml_load_string(file_get_contents($endpoint_filename));
$json = json_encode($xml);
$json_array = json_decode($json, true);
$endpoints = array();
foreach ($json_array["Endpoint"] as $json_endpoint) {
# pre-process RegionId & Product
if (!array_key_exists("RegionId", $json_endpoint["RegionIds"])) {
$region_ids = array();
} else {
$json_region_ids = $json_endpoint['RegionIds']['RegionId'];
if (!is_array($json_region_ids)) {
$region_ids = array($json_region_ids);
} else {
$region_ids = $json_region_ids;
}
}
if (!array_key_exists("Product", $json_endpoint["Products"])) {
$products = array();
} else {
$json_products = $json_endpoint["Products"]["Product"];
if (array() === $json_products or !is_array($json_products)) {
$products = array();
} elseif (array_keys($json_products) !== range(0, count($json_products) - 1)) {
# array is not sequential
$products = array($json_products);
} else {
$products = $json_products;
}
}
$product_domains = array();
foreach ($products as $product) {
$product_domain = new ProductDomain($product['ProductName'], $product['DomainName']);
array_push($product_domains, $product_domain);
}
$endpoint = new Endpoint($region_ids[0], $region_ids, $product_domains);
array_push($endpoints, $endpoint);
}
EndpointProvider::setEndpoints($endpoints);

60
extend/aliyun-php-sdk-core/Regions/EndpointProvider.php

@ -0,0 +1,60 @@
<?php
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
class EndpointProvider
{
private static $endpoints;
public static function findProductDomain($regionId, $product)
{
if (null == $regionId || null == $product || null == self::$endpoints) {
return null;
}
foreach (self::$endpoints as $key => $endpoint) {
if (in_array($regionId, $endpoint->getRegionIds())) {
return self::findProductDomainByProduct($endpoint->getProductDomains(), $product);
}
}
return null;
}
private static function findProductDomainByProduct($productDomains, $product)
{
if (null == $productDomains) {
return null;
}
foreach ($productDomains as $key => $productDomain) {
if ($product == $productDomain->getProductName()) {
return $productDomain->getDomainName();
}
}
return null;
}
public static function getEndpoints()
{
return self::$endpoints;
}
public static function setEndpoints($endpoints)
{
self::$endpoints = $endpoints;
}
}

120
extend/aliyun-php-sdk-core/Regions/LocationService.php

@ -0,0 +1,120 @@
<?php
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
define("LOCATION_SERVICE_PRODUCT_NAME", "Location");
define("LOCATION_SERVICE_DOMAIN", "location.aliyuncs.com");
define("LOCATION_SERVICE_VERSION", "2015-06-12");
define("LOCATION_SERVICE_DESCRIBE_ENDPOINT_ACTION", "DescribeEndpoints");
define("LOCATION_SERVICE_REGION", "cn-hangzhou");
define("CACHE_EXPIRE_TIME", 3600);
class DescribeEndpointRequest extends RpcAcsRequest
{
function __construct($id, $serviceCode, $endPointType) {
parent::__construct(LOCATION_SERVICE_PRODUCT_NAME, LOCATION_SERVICE_VERSION, LOCATION_SERVICE_DESCRIBE_ENDPOINT_ACTION);
$this->queryParameters["Id"] = $id;
$this->queryParameters["ServiceCode"] = $serviceCode;
$this->queryParameters["Type"] = $endPointType;
$this->setRegionId(LOCATION_SERVICE_REGION);
$this->setAcceptFormat("JSON");
}
}
class LocationService
{
private $clientProfile;
public static $cache = array();
public static $lastClearTimePerProduct = array();
public static $serviceDomain = LOCATION_SERVICE_DOMAIN;
function __construct($clientProfile) {
$this->clientProfile = $clientProfile;
}
public function findProductDomain($regionId, $serviceCode, $endPointType, $product)
{
$key = $regionId.'#'.$product;
@$domain = self::$cache[$key];
if ($domain == null || $this->checkCacheIsExpire($key) == true)
{
$domain = $this->findProductDomainFromLocationService($regionId, $serviceCode, $endPointType);
self::$cache[$key] = $domain;
}
return $domain;
}
public static function addEndPoint($regionId, $product, $domain)
{
$key = $regionId.'#'.$product;
self::$cache[$key] = $domain;
$lastClearTime = mktime(0, 0, 0, 1, 1, 2999);
self::$lastClearTimePerProduct[$key] = $lastClearTime;
}
public static function modifyServiceDomain($domain)
{
self::$serviceDomain = $domain;
}
private function checkCacheIsExpire($key)
{
$lastClearTime = self::$lastClearTimePerProduct[$key];
if ($lastClearTime == null)
{
$lastClearTime = time();
self::$lastClearTimePerProduct[$key] = $lastClearTime;
}
$now = time();
$elapsedTime = $now - $lastClearTime;
if ($elapsedTime > CACHE_EXPIRE_TIME)
{
$lastClearTime = time();
self::$lastClearTimePerProduct[$key] = $lastClearTime;
return true;
}
return false;
}
private function findProductDomainFromLocationService($regionId, $serviceCode, $endPointType)
{
$request = new DescribeEndpointRequest($regionId, $serviceCode, $endPointType);
$signer = $this->clientProfile->getSigner();
$credential = $this->clientProfile->getCredential();
$requestUrl = $request->composeUrl($signer, $credential, self::$serviceDomain);
$httpResponse = HttpHelper::curl($requestUrl, $request->getMethod(), null, $request->getHeaders());
if (!$httpResponse->isSuccess())
{
return null;
}
$respObj = json_decode($httpResponse->getBody());
return $respObj->Endpoints->Endpoint[0]->Endpoint;
}
}

47
extend/aliyun-php-sdk-core/Regions/ProductDomain.php

@ -0,0 +1,47 @@
<?php
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
class ProductDomain
{
private $productName;
private $domainName;
public function __construct($product, $domain)
{
$this->productName = $product;
$this->domainName = $domain;
}
public function getProductName()
{
return $this->productName;
}
public function setProductName($productName)
{
$this->productName = $productName;
}
public function getDomainName()
{
return $this->domainName;
}
public function setDomainName($domainName)
{
$this->domainName = $domainName;
}
}

1349
extend/aliyun-php-sdk-core/Regions/endpoints.xml

File diff suppressed because it is too large

206
extend/aliyun-php-sdk-core/RoaAcsRequest.php

@ -0,0 +1,206 @@
<?php
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
abstract class RoaAcsRequest extends AcsRequest
{
protected $uriPattern;
private $pathParameters = array();
private $domainParameters = array();
private $dateTimeFormat ="D, d M Y H:i:s \G\M\T";
private static $headerSeparator = "\n";
private static $querySeprator = "&";
function __construct($product, $version, $actionName, $locationServiceCode = null, $locationEndpointType = "openAPI")
{
parent::__construct($product, $version, $actionName, $locationServiceCode, $locationEndpointType);
$this->setVersion($version);
$this->initialize();
}
private function initialize()
{
$this->setMethod("RAW");
}
public function composeUrl($iSigner, $credential, $domain)
{
$this->prepareHeader($iSigner, $credential);
$signString = $this->getMethod().self::$headerSeparator;
if (isset($this->headers["Accept"])) {
$signString = $signString.$this->headers["Accept"];
}
$signString = $signString.self::$headerSeparator;
if (isset($this->headers["Content-MD5"])) {
$signString = $signString.$this->headers["Content-MD5"];
}
$signString = $signString.self::$headerSeparator;
if (isset($this->headers["Content-Type"])) {
$signString = $signString.$this->headers["Content-Type"];
}
$signString = $signString.self::$headerSeparator;
if (isset($this->headers["Date"])) {
$signString = $signString.$this->headers["Date"];
}
$signString = $signString.self::$headerSeparator;
$uri = $this->replaceOccupiedParameters();
$signString = $signString.$this->buildCanonicalHeaders();
$queryString = $this->buildQueryString($uri);
$signString .= $queryString;
$this->headers["Authorization"] = "acs ".$credential->getAccessKeyId().":"
.$iSigner->signString($signString, $credential->getAccessSecret());
$requestUrl = $this->getProtocol()."://".$domain.$queryString;
return $requestUrl;
}
private function prepareHeader($iSigner, $credential)
{
$this->headers["Date"] = gmdate($this->dateTimeFormat);
if (null == $this->acceptFormat) {
$this->acceptFormat = "RAW";
}
$this->headers["Accept"] = $this->formatToAccept($this->getAcceptFormat());
$this->headers["x-acs-signature-method"] = $iSigner->getSignatureMethod();
$this->headers["x-acs-signature-version"] = $iSigner->getSignatureVersion();
$this->headers["x-acs-region-id"] = $this->regionId;
$content = $this->getDomainParameter();
if ($content != null) {
$this->headers["Content-MD5"] = base64_encode(md5(json_encode($content), true));
}
$this->headers["Content-Type"] = "application/octet-stream;charset=utf-8";
if ($credential->getSecurityToken() != null) {
$this->headers["x-acs-security-token"] = $credential->getSecurityToken();
}
}
private function replaceOccupiedParameters()
{
$result = $this->uriPattern;
foreach ($this->pathParameters as $pathParameterKey => $apiParameterValue) {
$target = "[".$pathParameterKey."]";
$result = str_replace($target, $apiParameterValue, $result);
}
return $result;
}
private function buildCanonicalHeaders()
{
$sortMap = array();
foreach ($this->headers as $headerKey => $headerValue) {
$key = strtolower($headerKey);
if (strpos($key, "x-acs-") === 0) {
$sortMap[$key] = $headerValue;
}
}
ksort($sortMap);
$headerString = "";
foreach ($sortMap as $sortMapKey => $sortMapValue) {
$headerString = $headerString.$sortMapKey.":".$sortMapValue.self::$headerSeparator;
}
return $headerString;
}
private function splitSubResource($uri)
{
$queIndex = strpos($uri, "?");
$uriParts = array();
if (null != $queIndex) {
array_push($uriParts, substr($uri, 0, $queIndex));
array_push($uriParts, substr($uri, $queIndex+1));
} else {
array_push($uriParts, $uri);
}
return $uriParts;
}
private function buildQueryString($uri)
{
$uriParts = $this->splitSubResource($uri);
$sortMap = $this->queryParameters;
if (isset($uriParts[1])) {
$sortMap[$uriParts[1]] = null;
}
$queryString = $uriParts[0];
if (count($uriParts)) {
$queryString = $queryString."?";
}
ksort($sortMap);
foreach ($sortMap as $sortMapKey => $sortMapValue) {
$queryString = $queryString.$sortMapKey;
if (isset($sortMapValue)) {
$queryString = $queryString."=".$sortMapValue;
}
$queryString = $queryString.self::$querySeprator;
}
if (0 < count($sortMap)) {
$queryString = substr($queryString, 0, strlen($queryString)-1);
}
return $queryString;
}
private function formatToAccept($acceptFormat)
{
if ($acceptFormat == "JSON") {
return "application/json";
} elseif ($acceptFormat == "XML") {
return "application/xml";
}
return "application/octet-stream";
}
public function getPathParameters()
{
return $this->pathParameters;
}
public function putPathParameter($name, $value)
{
$this->pathParameters[$name] = $value;
}
public function getDomainParameter()
{
return $this->domainParameters;
}
public function putDomainParameters($name, $value)
{
$this->domainParameters[$name] = $value;
}
public function getUriPattern()
{
return $this->uriPattern;
}
public function setUriPattern($uriPattern)
{
return $this->uriPattern = $uriPattern;
}
public function setVersion($version)
{
$this->version = $version;
$this->headers["x-acs-version"] = $version;
}
}

116
extend/aliyun-php-sdk-core/RpcAcsRequest.php

@ -0,0 +1,116 @@
<?php
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
abstract class RpcAcsRequest extends AcsRequest
{
private $dateTimeFormat = 'Y-m-d\TH:i:s\Z';
private $domainParameters = array();
function __construct($product, $version, $actionName, $locationServiceCode = null, $locationEndpointType = "openAPI")
{
parent::__construct($product, $version, $actionName, $locationServiceCode, $locationEndpointType);
$this->initialize();
}
private function initialize()
{
$this->setMethod("GET");
$this->setAcceptFormat("JSON");
}
private function prepareValue($value)
{
if (is_bool($value)) {
if ($value) {
return "true";
} else {
return "false";
}
} else {
return $value;
}
}
public function composeUrl($iSigner, $credential, $domain)
{
$apiParams = parent::getQueryParameters();
foreach ($apiParams as $key => $value) {
$apiParams[$key] = $this->prepareValue($value);
}
$apiParams["RegionId"] = $this->getRegionId();
$apiParams["AccessKeyId"] = $credential->getAccessKeyId();
$apiParams["Format"] = $this->getAcceptFormat();
$apiParams["SignatureMethod"] = $iSigner->getSignatureMethod();
$apiParams["SignatureVersion"] = $iSigner->getSignatureVersion();
$apiParams["SignatureNonce"] = md5(uniqid(mt_rand(), true));
$apiParams["Timestamp"] = gmdate($this->dateTimeFormat);
$apiParams["Action"] = $this->getActionName();
$apiParams["Version"] = $this->getVersion();
if ($credential->getSecurityToken() != null) {
$apiParams["SecurityToken"] = $credential->getSecurityToken();
}
$apiParams["Signature"] = $this->computeSignature($apiParams, $credential->getAccessSecret(), $iSigner);
if (parent::getMethod() == "POST") {
$requestUrl = $this->getProtocol()."://". $domain . "/";
foreach ($apiParams as $apiParamKey => $apiParamValue) {
$this->putDomainParameters($apiParamKey, $apiParamValue);
}
return $requestUrl;
} else {
$requestUrl = $this->getProtocol()."://". $domain . "/?";
foreach ($apiParams as $apiParamKey => $apiParamValue) {
$requestUrl .= "$apiParamKey=" . urlencode($apiParamValue) . "&";
}
return substr($requestUrl, 0, -1);
}
}
private function computeSignature($parameters, $accessKeySecret, $iSigner)
{
ksort($parameters);
$canonicalizedQueryString = '';
foreach ($parameters as $key => $value) {
$canonicalizedQueryString .= '&' . $this->percentEncode($key). '=' . $this->percentEncode($value);
}
$stringToSign = parent::getMethod().'&%2F&' . $this->percentencode(substr($canonicalizedQueryString, 1));
$signature = $iSigner->signString($stringToSign, $accessKeySecret."&");
return $signature;
}
protected function percentEncode($str)
{
$res = urlencode($str);
$res = preg_replace('/\+/', '%20', $res);
$res = preg_replace('/\*/', '%2A', $res);
$res = preg_replace('/%7E/', '~', $res);
return $res;
}
public function getDomainParameter()
{
return $this->domainParameters;
}
public function putDomainParameters($name, $value)
{
$this->domainParameters[$name] = $value;
}
}

35
extend/aliyun-php-sdk-core/UnitTest/Auth/CredentialTest.php

@ -0,0 +1,35 @@
<?php
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
include_once '../../Config.php';
class CredentialTest extends PHPUnit_Framework_TestCase
{
public function testCredential()
{
$credential = new Credential("accessKeyId", "accessSecret");
$this->assertEquals("accessKeyId", $credential->getAccessKeyId());
$this->assertEquals("accessSecret", $credential->getAccessSecret());
$this->assertNotNull($credential->getRefreshDate());
$dateNow = date("Y-m-d\TH:i:s\Z");
$credential->setExpiredDate(1);
$this->assertNotNull($credential->getExpiredDate());
$this->assertTrue($credential->getExpiredDate() > $dateNow);
}
}

28
extend/aliyun-php-sdk-core/UnitTest/Auth/ShaHmac1SignerTest.php

@ -0,0 +1,28 @@
<?php
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
include_once '../../Config.php';
class ShaHmac1SignerTest extends PHPUnit_Framework_TestCase
{
public function testShaHmac1Signer()
{
$signer = new ShaHmac1Signer();
$this->assertEquals("33nmIV5/p6kG/64eLXNljJ5vw84=", $signer->signString("this is a ShaHmac1 test.", "accessSecret"));
}
}

30
extend/aliyun-php-sdk-core/UnitTest/Auth/ShaHmac256SignerTest.php

@ -0,0 +1,30 @@
<?php
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
include_once '../../Config.php';
class ShaHmac256SignerTest extends PHPUnit_Framework_TestCase
{
public function testShaHmac256Signer()
{
$signer = new ShaHmac256Signer();
$this->assertEquals("TpF1lE/avV9EHGWGg9Vo/QTd2bLRwFCk9jjo56uRbCo=",
$signer->signString("this is a ShaHmac256 test.", "accessSecret"));
}
}

40
extend/aliyun-php-sdk-core/UnitTest/BaseTest.php

@ -0,0 +1,40 @@
<?php
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
class BaseTest extends PHPUnit_Framework_TestCase
{
public $client = null;
public function setUp()
{
$path = substr(dirname(__FILE__), 0, strripos(dirname(__FILE__), DIRECTORY_SEPARATOR)).DIRECTORY_SEPARATOR;
include_once $path.'Config.php';
include_once 'Ecs/Rquest/DescribeRegionsRequest.php';
include_once 'BatchCompute/ListImagesRequest.php';
$iClientProfile = DefaultProfile::getProfile("cn-hangzhou", "AccessKey", "AccessSecret");
$this->client = new DefaultAcsClient($iClientProfile);
}
public function getProperty($propertyKey)
{
$accessKey = "";
$accessSecret = "";
$iClientProfile = DefaultProfile::getProfile("cn-hangzhou", "AccessKey", "AccessSecret");
}
}

30
extend/aliyun-php-sdk-core/UnitTest/BatchCompute/ListImagesRequest.php

@ -0,0 +1,30 @@
<?php
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
namespace UnitTest\BatchCompute\Request;
class ListImagesRequest extends \RoaAcsRequest
{
public function __construct()
{
parent::__construct("BatchCompute", "2013-01-11", "ListImages");
$this->setUriPattern("/images");
$this->setMethod("GET");
}
}

42
extend/aliyun-php-sdk-core/UnitTest/DefaultAcsClientTest.php

@ -0,0 +1,42 @@
<?php
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
include_once 'BaseTest.php';
use UnitTest\Ecs\Request as Ecs;
use UnitTest\BatchCompute\Request as BC;
class DefaultAcsClientTest extends BaseTest
{
public function testDoActionRPC()
{
$request = new Ecs\DescribeRegionsRequest();
$response = $this->client->doAction($request);
$this->assertNotNull($response->RequestId);
$this->assertNotNull($response->Regions->Region[0]->LocalName);
$this->assertNotNull($response->Regions->Region[0]->RegionId);
}
public function testDoActionROA()
{
$request = new BC\ListImagesRequest();
$response = $this->client->doAction($request);
$this->assertNotNull($response);
}
}

80
extend/aliyun-php-sdk-core/UnitTest/Ecs/Rquest/DescribeRegionsRequest.php

@ -0,0 +1,80 @@
<?php
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
namespace UnitTest\Ecs\Request;
class DescribeRegionsRequest extends \RpcAcsRequest
{
public function __construct()
{
parent::__construct("Ecs", "2014-05-26", "DescribeRegions");
}
private $ownerId;
private $resourceOwnerAccount;
private $resourceOwnerId;
private $ownerAccount;
public function getOwnerId()
{
return $this->ownerId;
}
public function setOwnerId($ownerId)
{
$this->ownerId = $ownerId;
$this->queryParameters["OwnerId"]=$ownerId;
}
public function getResourceOwnerAccount()
{
return $this->resourceOwnerAccount;
}
public function setResourceOwnerAccount($resourceOwnerAccount)
{
$this->resourceOwnerAccount = $resourceOwnerAccount;
$this->queryParameters["ResourceOwnerAccount"]=$resourceOwnerAccount;
}
public function getResourceOwnerId()
{
return $this->resourceOwnerId;
}
public function setResourceOwnerId($resourceOwnerId)
{
$this->resourceOwnerId = $resourceOwnerId;
$this->queryParameters["ResourceOwnerId"]=$resourceOwnerId;
}
public function getOwnerAccount()
{
return $this->ownerAccount;
}
public function setOwnerAccount($ownerAccount)
{
$this->ownerAccount = $ownerAccount;
$this->queryParameters["OwnerAccount"]=$ownerAccount;
}
}

35
extend/aliyun-php-sdk-core/UnitTest/Ft/InteTest.php

@ -0,0 +1,35 @@
<?php
/**
* Created by PhpStorm.
* User: zhangw
* Date: 2017/12/19
* Time: 下午6:47
*/
require_once '../../Config.php';
use UnitTest\Ft\TestRpcApiRequest;
use UnitTest\Ft\TestRoaApiRequest;
$clientProfile = DefaultProfile::getProfile(
"cn-hangzhou",
"<your Ak>",
"<your secret>",
"<your StsToken>"
);
DefaultProfile::addEndpoint("cn-hangzhou", "cn-hangzhou", "Ft", "ft.aliyuncs.com");
$client = new DefaultAcsClient($clientProfile);
# 创建 API 请求并设置参数
$request = new TestRpcApiRequest();
$request->setQueryParam("conan");
# 发起请求并处理返回
$response = $client->getAcsResponse($request);
print_r($response);
# 创建 API 请求并设置参数
$request = new TestRoaApiRequest();
$request->setQueryParam("conan");
# 发起请求并处理返回
$response = $client->getAcsResponse($request);
print_r($response);

57
extend/aliyun-php-sdk-core/UnitTest/Ft/TestRoaApiRequest.php

@ -0,0 +1,57 @@
<?php
/**
* Created by PhpStorm.
* User: zhangw
* Date: 2017/12/19
* Time: 下午6:39
*/
namespace UnitTest\Ft;
class TestRoaApiRequest extends \RoaAcsRequest
{
public function __construct()
{
parent::__construct("Ft", "2016-01-02", "TestRoaApi");
$this->setUriPattern("/web/cloudapi");
$this->setMethod("GET");
}
private $queryParam;
private $bodyParam;
private $headerParam;
public function getQueryParam()
{
return $this->queryParam;
}
public function setQueryParam($queryParam)
{
$this->queryParam = $queryParam;
$this->queryParameters["QueryParam"]=$queryParam;
}
public function getBodyParam()
{
return $this->bodyParam;
}
public function setBodyParam($bodyParam)
{
$this->bodyParam = $bodyParam;
$this->queryParameters["BodyParam"]=$bodyParam;
}
public function getHeaderParam()
{
return $this->headerParam;
}
public function setHeaderParam($headerParam)
{
$this->headerParam = $headerParam;
$this->headerParam["HeaderParam"]=$headerParam;
}
}

42
extend/aliyun-php-sdk-core/UnitTest/Ft/TestRpcApiRequest.php

@ -0,0 +1,42 @@
<?php
/**
* Created by PhpStorm.
* User: zhangw
* Date: 2017/12/19
* Time: 下午6:39
*/
namespace UnitTest\Ft;
class TestRpcApiRequest extends \RpcAcsRequest
{
public function __construct()
{
parent::__construct("Ft", "2016-01-01", "TestRpcApi");
}
private $queryParam;
private $bodyParam;
public function getQueryParam()
{
return $this->queryParam;
}
public function setQueryParam($queryParam)
{
$this->queryParam = $queryParam;
$this->queryParameters["QueryParam"]=$queryParam;
}
public function getBodyParam()
{
return $this->bodyParam;
}
public function setBodyParam($bodyParam)
{
$this->bodyParam = $bodyParam;
$this->queryParameters["BodyParam"]=$bodyParam;
}
}

29
extend/aliyun-php-sdk-core/UnitTest/Http/HttpHelperTest.php

@ -0,0 +1,29 @@
<?php
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
include_once '../BaseTest.php';
class HttpHelperTest extends BaseTest
{
public function testCurl()
{
$httpResponse = HttpHelper::curl("ecs.aliyuncs.com");
$this->assertEquals(400, $httpResponse->getStatus());
$this->assertNotNull($httpResponse->getBody());
}
}

60
extend/aliyun-php-sdk-core/UnitTest/Profile/DefaultProfileTest.php

@ -0,0 +1,60 @@
<?php
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
include_once '../../Config.php';
class DefaultProfileTest extends PHPUnit_Framework_TestCase
{
public function testGetProfile()
{
$profile = DefaultProfile::getProfile("cn-hangzhou", "accessId", "accessSecret");
$this->assertEquals("cn-hangzhou", $profile->getRegionId());
$this->assertEquals("accessId", $profile->getCredential()->getAccessKeyId());
$this->assertEquals("accessSecret", $profile->getCredential()->getAccessSecret());
}
public function testAddEndpoint()
{
$profile = DefaultProfile::getProfile("cn-hangzhou", "accessId", "accessSecret");
$profile->addEndpoint("cn-hangzhou", "cn-hangzhou", "TestProduct", "testproduct.aliyuncs.com");
$endpoints = $profile->getEndpoints();
foreach ($endpoints as $key => $endpoint) {
if ("cn-hangzhou" == $endpoint->getName()) {
$regionIds = $endpoint->getRegionIds();
$this->assertContains("cn-hangzhou", $regionIds);
$productDomains= $endpoint->getProductDomains();
$this->assertNotNull($productDomains);
$productDomain = $this->getProductDomain($productDomains);
$this->assertNotNull($productDomain);
$this->assertEquals("TestProduct", $productDomain->getProductName());
$this->assertEquals("testproduct.aliyuncs.com", $productDomain->getDomainName());
}
}
}
private function getProductDomain($productDomains)
{
foreach ($productDomains as $productDomain) {
if ($productDomain->getProductName() == "TestProduct") {
return $productDomain;
}
}
return null;
}
}

46
extend/aliyun-php-sdk-core/UnitTest/Regions/EndPointByLocationTest.php

@ -0,0 +1,46 @@
<?php
/**
* Created by PhpStorm.
* User: zhangw
* Date: 2017/7/17
* Time: 下午4:57
*/
include_once '../../Config.php';
use PHPUnit\Framework\TestCase;
class EndPointByLocationTest extends TestCase
{
private $locationService;
private $clientProfile;
private function initClient()
{
# 创建 DefaultAcsClient 实例并初始化
$this->clientProfile = DefaultProfile::getProfile(
"cn-shanghai", # 您的 Region ID
"<your AK>", # 您的 Access Key ID
"<your Secret>" # 您的 Access Key Secret
);
$this->locationService = new LocationService($this->clientProfile);
}
public function testFindProductDomain()
{
$this->initClient();
$domain = $this->locationService->findProductDomain("cn-shanghai", "apigateway", "openAPI", "CloudAPI");
$this->assertEquals("apigateway.cn-shanghai.aliyuncs.com", $domain);
}
public function testFindProductDomainWithAddEndPoint()
{
DefaultProfile::addEndpoint("cn-shanghai", "cn-shanghai", "CloudAPI", "apigateway.cn-shanghai123.aliyuncs.com");
$this->initClient();
$domain = $this->locationService->findProductDomain("cn-shanghai", "apigateway", "openAPI", "CloudAPI");
$this->assertEquals("apigateway.cn-shanghai123.aliyuncs.com", $domain);
}
}

28
extend/aliyun-php-sdk-core/UnitTest/Regions/EndpointProviderTest.php

@ -0,0 +1,28 @@
<?php
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
include_once '../../Config.php';
class EndpointProviderTest extends PHPUnit_Framework_TestCase
{
public function testFindProductDomain()
{
$this->assertEquals("ecs.aliyuncs.com", EndpointProvider::findProductDomain("cn-hangzhou", "Ecs"));
}
}

2
extend/aliyunoss/.coveralls.yml

@ -0,0 +1,2 @@
coverage_clover: coverage.xml
json_path: coverage.json

8
extend/aliyunoss/.gitignore

@ -0,0 +1,8 @@
vendor
composer.lock
doc
output
.idea
.buildpath
.project
.settings

21
extend/aliyunoss/.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=

16
extend/aliyunoss/Aliconfig.php

@ -0,0 +1,16 @@
<?php
/**
* Class Config
*
* Make configurations required by the sample.
* Users can run RunAll.php which runs all the samples after configuring Endpoint, AccessId, and AccessKey.
*/
final class Aliconfig
{
const OSS_ACCESS_ID = 'LTAIQQLT1q8t7LPn';
const OSS_ACCESS_KEY = 'JAN2kRlTSt7Rz2qg8Bx73YIkXwUKvz';
const OSS_ENDPOINT = 'http://oss-cn-shenzhen.aliyuncs.com';
const OSS_BUCKET = 'http://szcaee-web.oss-cn-shenzhen.aliyuncs.com';
const OSS_TEST_BUCKET = 'szcaee-web';
}

85
extend/aliyunoss/Common.php

@ -0,0 +1,85 @@
<?php
namespace aliyunoss;
if (is_file(__DIR__ . '/../autoload.php')) {
require_once __DIR__ . '/../autoload.php';
}
if (is_file(__DIR__ . '/../vendor/autoload.php')) {
require_once __DIR__ . '/../vendor/autoload.php';
}
use OSS\OssClient;
use OSS\Core\OssException;
/**
* Class Common
*
* The Common class for 【Samples/*.php】 used to obtain OssClient instance and other common functions
*/
class Common
{
const endpoint ='http://oss-cn-shenzhen.aliyuncs.com';
const accessKeyId = 'LTAIQQLT1q8t7LPn';
const accessKeySecret ='JAN2kRlTSt7Rz2qg8Bx73YIkXwUKvz';
const bucket = 'szcaee-web';
const bucketHost = 'http://szcaee-web.oss-cn-shenzhen.aliyuncs.com';
/**
* Get an OSSClient instance according to config.
*
* @return OssClient An OssClient instance
*/
public static function getOssClient()
{
try {
$ossClient = new OssClient(self::accessKeyId, self::accessKeySecret, self::endpoint, false);
} catch (OssException $e) {
printf(__FUNCTION__ . "creating OssClient instance: FAILED\n");
printf($e->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();

72
extend/aliyunoss/callback.php

@ -0,0 +1,72 @@
<?php
// 1.获取OSS的签名header和公钥url header
$authorizationBase64 = "";
$pubKeyUrlBase64 = "";
/*
* 注意:如果要使用HTTP_AUTHORIZATION头,你需要先在apache或者nginx中设置rewrite,以apache为例,修改
* 配置文件/etc/httpd/conf/httpd.conf(以你的apache安装路径为准),在DirectoryIndex index.php这行下面增加以下两行
RewriteEngine On
RewriteRule .* - [env=HTTP_AUTHORIZATION:%{HTTP:Authorization},last]
* */
if (isset($_SERVER['HTTP_AUTHORIZATION'])){
$authorizationBase64 = $_SERVER['HTTP_AUTHORIZATION'];
}
if (isset($_SERVER['HTTP_X_OSS_PUB_KEY_URL'])){
$pubKeyUrlBase64 = $_SERVER['HTTP_X_OSS_PUB_KEY_URL'];
}
if ($authorizationBase64 == '' || $pubKeyUrlBase64 == ''){
header("http/1.1 403 Forbidden");
exit();
}
// 2.获取OSS的签名
$authorization = base64_decode($authorizationBase64);
// 3.获取公钥
$pubKeyUrl = base64_decode($pubKeyUrlBase64);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $pubKeyUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
$pubKey = curl_exec($ch);
if ($pubKey == ""){
//header("http/1.1 403 Forbidden");
echo json_encode(['status'=>false,'data'=>'']);
exit;
}
// 4.获取回调body
$body = file_get_contents('php://input');
// 5.拼接待签名字符串
$authStr = '';
$path = $_SERVER['REQUEST_URI'];
$pos = strpos($path, '?');
if ($pos === false){
$authStr = urldecode($path)."\n".$body;
}else{
$authStr = urldecode(substr($path, 0, $pos)).substr($path, $pos, strlen($path) - $pos)."\n".$body;
}
// 6.验证签名
$ok = openssl_verify($authStr, $authorization, $pubKey, OPENSSL_ALGO_MD5);
if ($ok == 1){
header("Content-Type: application/json");
$body=urldecode($body);
$body=explode('&', $body);
$maps=[];
foreach ($body as $item){
$item=explode('=',$item);
$key=$item[0];
$val=$item[1];
$maps[$key]=$val;
}
$data = array("status"=>true,'data'=>$maps);
}else{
$data = array("status"=>false,'data'=>$body);
}
echo json_encode($data);
?>

1357
extend/fdd/FddApi.php

File diff suppressed because it is too large

47
extend/fdd/FddConfig.php

@ -0,0 +1,47 @@
<?php
namespace fdd;
/**
* 配置账号信息
*/
class FddConfig
{
//=======【基本信息设置】=====================================
/**
* TODO: 修改这里配置法大大调用接口地址
*
* FddServer :法大大接口调用地址(必须配置)
*
*/
//通用接口调用地址
const FddServer = 'http://extapi.fadada.com:9999/api2';
const FddServer2 = 'https://extapi.fadada.com/api2';
//const FddServer = 'http://test.api.fabigbig.com:8888/api';
//const FddServer2 = 'http://test.api.fabigbig.com:8888/api';
//法大大企业页面认证接口调用地址
const FddServerSyncCompany = 'https://partner-test.fadada.com';
//=======【法大大商户密钥信息】===================================
/**
* TODO: 修改这里配置法大大密钥
*
* AppId :接入方的ID
*
* ApiPort:接入方的密钥
*
*/
const AppId = '000974';
const AppSecret = 'MuOTp5yyD9gbld0pAMAW8UAr';
const Debug=false;
const Company='深圳文化产权交易所有限公司';
const CustomerId='0D262F47E80AB2BE584FE0B568F1D755';
/*
const AppId = '401504';
const AppSecret = 'R3phLGqNotv0k73V4IPv45Id';
const Debug=false;
const Company='深圳市文化金融服务中心';
const CustomerId='FA3803DF2718EAA605FCBA8FADFA7E3D';
*/
}

4039
extend/fdd/FddData.php

File diff suppressed because it is too large

109
extend/fdd/FddEncryption.php

@ -0,0 +1,109 @@
<?php
namespace fdd;
require_once "FddConfig.php";
/**
* 3DES加解密类
*/
class FddEncryption{
public $key =FddConfig::AppSecret;
/**
* 兼容PHP7.2 3DES加密
* @param $message
* @return string
*/
public function encrypt($message){
return $str = bin2hex(openssl_encrypt($message, "des-ede3", $this->key,1));
}
/**
* 通用msg_digest加密函数
* @param $param
* @param $enc
* @return string
*/
public static function GeneralDigest($param,$enc)
{
$value = $param->GetValues();
$md5Str = $param->GetTimestamp();
$sha1Str = FddConfig::AppSecret;
foreach ($enc as $k => $v)
{
switch ($k){
case "md5":
foreach ($v as $md5Key => $md5Value){
if(isset($value[$md5Value])){
$md5Str.= $value[$md5Value];
}
}
break;
case "sha1":
foreach ($v as $sha1Key => $sha1Value){
if(isset($value[$sha1Value])) {
$sha1Str .= $value[$sha1Value];
}
}
break;
}
}
$enc = base64_encode(strtoupper(sha1(FddConfig::AppId.strtoupper(md5($md5Str)).strtoupper(sha1($sha1Str)))));
return $enc;
}
/**
* 数组参数转字符串格式
* @param $Array
* @return string
*/
public function ArrayParamToStr($Array)
{
$Str = "?";
if (!empty($Array))
{
foreach($Array as $k => $v){
$Str .= $k."=".$v."&";
}
}
return trim($Str,"&");
}
/**
* 合同生成msg_digest加密
* @param FddTemplate $param
* @return string
*/
public static function ContractDigest(FddTemplate $param)
{
$sha1 = FddConfig::AppSecret.$param->GetTemplate_id().$param->GetContract_id();
$enc = base64_encode(strtoupper(sha1(FddConfig::AppId.strtoupper(md5($param->GetTimestamp())).strtoupper(sha1($sha1)).$param->GetParameter_map())));
return $enc;
}
/**
* 文档签署接口(手动签) msg_digest加密
* @param FddSignContract $param
* @return string
*/
public static function ExtsignDigest(FddSignContract $param)
{
$sha1 = FddConfig::AppSecret.$param->GetCustomer_id();
$enc = base64_encode(strtoupper(sha1(FddConfig::AppId.strtoupper(md5($param->GetTransaction_id().$param->GetTimestamp())).strtoupper(sha1($sha1)))));
return $enc;
}
/**
* 文档签署接口(含有效期和次数限制) msg_digest加密
* @param FddSignContract $param
* @return string
*/
public static function ExtsignValiityDigest(FddSignContract $param)
{
$sha1 = FddConfig::AppSecret.$param->GetCustomer_id();
$enc = base64_encode(strtoupper(sha1(FddConfig::AppId.strtoupper(md5($param->GetTransaction_id().$param->GetTimestamp().$param->GetValidity().$param->GetQuantity())).strtoupper(sha1($sha1)))));
return $enc;
}
}
?>

14
extend/fdd/FddException.php

@ -0,0 +1,14 @@
<?php
namespace fdd;
/**
*
* 异常处理类
*
*/
class FddException extends \Exception{
public function errorMessage()
{
return $this->getMessage();
}
}

350
extend/fdd/HttpClient.php

@ -0,0 +1,350 @@
<?php
namespace fdd;
/* Version 0.9, 6th April 2003 - Simon Willison ( http://simon.incutio.com/ )
Manual: http://scripts.incutio.com/httpclient/
*/
class HttpClient {
// Request vars
var $host;
var $port;
var $path;
var $method;
var $postdata = '';
var $cookies = array();
var $referer;
var $accept = 'text/xml,application/xml,application/xhtml+xml,text/html,text/plain,image/png,image/jpeg,image/gif,*/*';
var $accept_encoding = 'gzip';
var $accept_language = 'en-us';
var $user_agent = 'Incutio HttpClient v0.9';
// Options
var $timeout = 20;
var $use_gzip = true;
var $persist_cookies = true; // If true, received cookies are placed in the $this->cookies array ready for the next request
// Note: This currently ignores the cookie path (and time) completely. Time is not important,
// but path could possibly lead to security problems.
var $persist_referers = true; // For each request, sends path of last request as referer
var $debug = false;
var $handle_redirects = true; // Auaomtically redirect if Location or URI header is found
var $max_redirects = 5;
var $headers_only = false; // If true, stops receiving once headers have been read.
// Basic authorization variables
var $username;
var $password;
// Response vars
var $status;
var $headers = array();
var $content = '';
var $errormsg;
// Tracker variables
var $redirect_count = 0;
var $cookie_host = '';
function __construct($host, $port=80){
$this->host = $host;
$this->port = $port;
}
function HttpClient($host, $port=80) {
$this->host = $host;
$this->port = $port;
}
function get($path, $data = false) {
$this->path = $path;
$this->method = 'GET';
if ($data) {
$this->path .= '?'.$this->buildQueryString($data);
}
return $this->doRequest();
}
function post($path, $data) {
$this->path = $path;
$this->method = 'POST';
$this->postdata = $this->buildQueryString($data);
return $this->doRequest();
}
function buildQueryString($data) {
$querystring = '';
if (is_array($data)) {
// Change data in to postable data
foreach ($data as $key => $val) {
if (is_array($val)) {
foreach ($val as $val2) {
$querystring .= urlencode($key).'='.urlencode($val2).'&';
}
} else {
$querystring .= urlencode($key).'='.urlencode($val).'&';
}
}
$querystring = substr($querystring, 0, -1); // Eliminate unnecessary &
} else {
$querystring = $data;
}
return $querystring;
}
function doRequest() {
// Performs the actual HTTP request, returning true or false depending on outcome
if (!$fp = @fsockopen($this->host, $this->port, $errno, $errstr, $this->timeout)) {
// Set error message
switch($errno) {
case -3:
$this->errormsg = 'Socket creation failed (-3)';
case -4:
$this->errormsg = 'DNS lookup failure (-4)';
case -5:
$this->errormsg = 'Connection refused or timed out (-5)';
default:
$this->errormsg = 'Connection failed ('.$errno.')';
}
$this->errormsg .= ' '.$errstr;
$this->debug($this->errormsg);
return false;
}
socket_set_timeout($fp, $this->timeout);
$request = $this->buildRequest();
$this->debug('Request', $request);
fwrite($fp, $request);
// Reset all the variables that should not persist between requests
$this->headers = array();
$this->content = '';
$this->errormsg = '';
// Set a couple of flags
$inHeaders = true;
$atStart = true;
// Now start reading back the response
while (!feof($fp)) {
$line = fgets($fp, 4096);
if ($atStart) {
// Deal with first line of returned data
$atStart = false;
if (!preg_match('/HTTP\/(\\d\\.\\d)\\s*(\\d+)\\s*(.*)/', $line, $m)) {
$this->errormsg = "Status code line invalid: ".htmlentities($line);
$this->debug($this->errormsg);
return false;
}
$http_version = $m[1]; // not used
$this->status = $m[2];
$status_string = $m[3]; // not used
$this->debug(trim($line));
continue;
}
if ($inHeaders) {
if (trim($line) == '') {
$inHeaders = false;
$this->debug('Received Headers', $this->headers);
if ($this->headers_only) {
break; // Skip the rest of the input
}
continue;
}
if (!preg_match('/([^:]+):\\s*(.*)/', $line, $m)) {
// Skip to the next header
continue;
}
$key = strtolower(trim($m[1]));
$val = trim($m[2]);
// Deal with the possibility of multiple headers of same name
if (isset($this->headers[$key])) {
if (is_array($this->headers[$key])) {
$this->headers[$key][] = $val;
} else {
$this->headers[$key] = array($this->headers[$key], $val);
}
} else {
$this->headers[$key] = $val;
}
continue;
}
// We're not in the headers, so append the line to the contents
$this->content .= $line;
}
fclose($fp);
// If data is compressed, uncompress it
if (isset($this->headers['content-encoding']) && $this->headers['content-encoding'] == 'gzip') {
$this->debug('Content is gzip encoded, unzipping it');
$this->content = substr($this->content, 10); // See http://www.php.net/manual/en/function.gzencode.php
$this->content = gzinflate($this->content);
}
// If $persist_cookies, deal with any cookies
if ($this->persist_cookies && isset($this->headers['set-cookie']) && $this->host == $this->cookie_host) {
$cookies = $this->headers['set-cookie'];
if (!is_array($cookies)) {
$cookies = array($cookies);
}
foreach ($cookies as $cookie) {
if (preg_match('/([^=]+)=([^;]+);/', $cookie, $m)) {
$this->cookies[$m[1]] = $m[2];
}
}
// Record domain of cookies for security reasons
$this->cookie_host = $this->host;
}
// If $persist_referers, set the referer ready for the next request
if ($this->persist_referers) {
$this->debug('Persisting referer: '.$this->getRequestURL());
$this->referer = $this->getRequestURL();
}
// Finally, if handle_redirects and a redirect is sent, do that
if ($this->handle_redirects) {
if (++$this->redirect_count >= $this->max_redirects) {
$this->errormsg = 'Number of redirects exceeded maximum ('.$this->max_redirects.')';
$this->debug($this->errormsg);
$this->redirect_count = 0;
return false;
}
$location = isset($this->headers['location']) ? $this->headers['location'] : '';
$uri = isset($this->headers['uri']) ? $this->headers['uri'] : '';
if ($location || $uri) {
$url = parse_url($location.$uri);
// This will FAIL if redirect is to a different site
return $this->get($url['path']);
}
}
return true;
}
function buildRequest() {
$headers = array();
$headers[] = "{$this->method} {$this->path} HTTP/1.0"; // Using 1.1 leads to all manner of problems, such as "chunked" encoding
$headers[] = "Host: {$this->host}";
$headers[] = "User-Agent: {$this->user_agent}";
$headers[] = "Accept: {$this->accept}";
if ($this->use_gzip) {
$headers[] = "Accept-encoding: {$this->accept_encoding}";
}
$headers[] = "Accept-language: {$this->accept_language}";
if ($this->referer) {
$headers[] = "Referer: {$this->referer}";
}
// Cookies
if ($this->cookies) {
$cookie = 'Cookie: ';
foreach ($this->cookies as $key => $value) {
$cookie .= "$key=$value; ";
}
$headers[] = $cookie;
}
// Basic authentication
if ($this->username && $this->password) {
$headers[] = 'Authorization: BASIC '.base64_encode($this->username.':'.$this->password);
}
// If this is a POST, set the content type and length
if ($this->postdata) {
$headers[] = 'Content-Type: application/x-www-form-urlencoded';
$headers[] = 'Content-Length: '.strlen($this->postdata);
}
$request = implode("\r\n", $headers)."\r\n\r\n".$this->postdata;
return $request;
}
function getStatus() {
return $this->status;
}
function getContent() {
return $this->content;
}
function getHeaders() {
return $this->headers;
}
function getHeader($header) {
$header = strtolower($header);
if (isset($this->headers[$header])) {
return $this->headers[$header];
} else {
return false;
}
}
function getError() {
return $this->errormsg;
}
function getCookies() {
return $this->cookies;
}
function getRequestURL() {
$url = 'http://'.$this->host;
if ($this->port != 80) {
$url .= ':'.$this->port;
}
$url .= $this->path;
return $url;
}
// Setter methods
function setUserAgent($string) {
$this->user_agent = $string;
}
function setAuthorization($username, $password) {
$this->username = $username;
$this->password = $password;
}
function setCookies($array) {
$this->cookies = $array;
}
// Option setting methods
function useGzip($boolean) {
$this->use_gzip = $boolean;
}
function setPersistCookies($boolean) {
$this->persist_cookies = $boolean;
}
function setPersistReferers($boolean) {
$this->persist_referers = $boolean;
}
function setHandleRedirects($boolean) {
$this->handle_redirects = $boolean;
}
function setMaxRedirects($num) {
$this->max_redirects = $num;
}
function setHeadersOnly($boolean) {
$this->headers_only = $boolean;
}
function setDebug($boolean) {
$this->debug = $boolean;
}
// "Quick" static methods
function quickGet($url) {
$bits = parse_url($url);
$host = $bits['host'];
$port = isset($bits['port']) ? $bits['port'] : 80;
$path = isset($bits['path']) ? $bits['path'] : '/';
if (isset($bits['query'])) {
$path .= '?'.$bits['query'];
}
$client = new HttpClient($host, $port);
if (!$client->get($path)) {
return false;
} else {
return $client->getContent();
}
}
function quickPost($url, $data) {
$bits = parse_url($url);
$host = $bits['host'];
$port = isset($bits['port']) ? $bits['port'] : 80;
$path = isset($bits['path']) ? $bits['path'] : '/';
$client = new HttpClient($host, $port);
if (!$client->post($path, $data)) {
return false;
} else {
return $client->getContent();
}
}
function debug($msg, $object = false) {
if ($this->debug) {
print '<div style="border: 1px solid red; padding: 0.5em; margin: 0.5em;"><strong>HttpClient Debug:</strong> '.$msg;
if ($object) {
ob_start();
print_r($object);
$content = htmlentities(ob_get_contents());
ob_end_clean();
print '<pre>'.$content.'</pre>';
}
print '</div>';
}
}
}
?>

BIN
extend/ip/17monipdb.dat

Binary file not shown.

292
extend/ip/readme.txt

@ -0,0 +1,292 @@
<?php
/*
全球 IPv4 地址归属地数据库(IPIP.NET 版)
--- 2016 年 6 月引言 ---
这是 IP 库的第十五个公开版本。
半年不见,目前的数据条目数超过 320000 条了。
基于目前的客户购买情况,我们会在 7 月 1 日开始执行新价格方案。6 月份购买的不受影响,请潜在客户尽快考虑。
--
高春辉
Paul Gao
gaochunhui@gmail.com
http://www.ipip.net/
--- 2015 年 12 月引言 ---
这是 IP 库的第十四个公开版本。
目前的数据条目数超过 220000 条了。
我们一直在发布 DISCUZ 和 ECSHOP 的专用版本,但是不知道是用户变少还是用户不关心还是如何,这两年几乎无人咨询相关版本的事情,所以我们从 2016 年起,不再发布针对 DISCUZ 和 ECSHOP 的免费版。
这次的免费版也有一些小变化,不过对于不关心的用户来说,没有变化。;-)
--
高春辉
Paul Gao
gaochunhui@gmail.com
http://www.ipip.net/
--- 2015 年 10 月引言 ---
这是 IP 库的第十三个公开版本。
目前的数据条目数超过 200000 条了。
这个月底,我们这个事情,就已经两岁啦。
--
高春辉
Paul Gao
gaochunhui@gmail.com
http://www.ipip.net/
--- 2015 年 8 月引言 ---
这是 IP 库的第十二个公开版本。
目前的数据条目数接近 180000 条了,我们基本上能做到两个月新增一万条左右,注意是新增,不包括修改。
认可我们的数据质量的用户和客户越来越多,在一个 2015 TOP100 互联网公司名单里,我们在里面找到了有将近 20 家客户了。
我们和合作伙伴一起合作的的区县级 IP 数据库也赶在七月底上线了,有兴趣的请联系我们。
--
高春辉
Paul Gao
gaochunhui@gmail.com
http://www.ipip.net/
--- 2015 年 6 月引言 ---
这是 IP 库的第十一个公开版本。
目前的数据条目数超过了 170000 条了。希望下一个万条可以更快的达成。
正在做些互联网基础设施相关的新事情,等有一定结果的时候,再来汇报吧。
寻求 Golang 语言开发人员,具体请看链接:http://www.lagou.com/jobs/649340.html
--
高春辉
Paul Gao
gaochunhui@gmail.com
http://www.ipip.net/
--- 2015 年 4 月引言 ---
这是 IP 库的第十个公开版本。
三月份发布了 CDN 版本,针对节点调度需求做了一定的优化,也有了基本的英文版了。
目前的数据条目数超过了 160000 条了,算是个小里程碑,也有了新的专职编辑正在学习中,希望更好的维护这个数据库。
如果有人对基于全球 IP 分布以及连通性方面的数据挖掘以及相关的企业级服务有兴趣,请联系我,我们正在找专职的人员。
--
高春辉
Paul Gao
gaochunhui@gmail.com
http://www.ipip.net/
--- 2015 年 2 月引言 ---
这是 IP 库的第九个公开版本。
我们已经更换了新的官网:http://www.ipip.net/
这个月也会尽力发布 CDN 的专属版本以及英文版本。
基站数据库也会看时间发布正式版。
--
高春辉
Paul Gao
gaochunhui@gmail.com
http://www.ipip.net/
--- 2014 年 12 月引言 ---
这是 IP 库的第八个公开版本。
11 月份算是 IP 库进展最大的一个月了,我们对数据进行了全面的扫描,并且在微博上发了一篇长文章后,带来了不少付费客户,远超乎我的预期,也让我对这个事情有了新的想法。
文章地址是: http://www.evernote.com/l/AAHsqnNK9T9LkqZb9LW-fLjzkx0B4Dj90lY/ ,希望您也看看。
我们也针对高级付费客户开发了 DATX 格式版本,同时集成经纬度、时区信息,在读取速度上,同等环境下是 8000QPS 对 48000QPS 的区别。
我们同时也发布了官方支持的 JAVA 版读取代码。
这个月会把网站重新改版,更换域名,发布英文版网站和数据。
下个月就是 2015 年,明年我们在努力提高数据准确度的情况下,会提高付费客户的价格,为什么提价,我会写文章来解释的,如果您需要,请在本月购买,我们承诺老客户老价格。
我们也会针对 CDN、DNS、VPN 厂商的需求,专门发布对应的版本。
另外免费版的发布情况也可能会做调整,不作任何保证。
--
高春辉
Paul Gao
gaochunhui@gmail.com
http://www.17mon.cn/
--- 2014 年 10 月引言 ---
这是 IP 库的第七个公开版本。
最近几个月在以新的方式在对 IP 数据进行标注,可以更加保证数据的正确性,目前完成度 80%,数据量接近十四万行,预计在 10 月底可以初步完成。
使用官方 PHP 代码的朋友,请更新一下代码,之前犯了一个变量赋值的错误,导致缓存一直不会被命中。感谢 QQ 群里那位名字写得很乱的朋友发现的问题。做事认真严谨很重要。
另外预告一下,明年初,我们会对付费版的价格进行调整,价格只高不低,当然之前购买的用户不会受影响。
解释一下,我们毕竟在这个事情上投入了大量的精力,而且按照价格和准确度的情况来看,不说最好的,也是极好的了,再加上国内用户购买意愿低,我们只能考虑先提价的方式,毕竟对于任何一家对 IP 库有更高需求的业务,一个月付 200、300 元能够得到数据库并能保证及时更新的话,远比自己雇一个人去更新维护的成本低很多很多,何况 IP 库这件事水也很深,雇来的人的能力就能比我们做强吗?
如果未来可以有足够付费用户的时候,我们也会考虑调低价格的。也请大家多理解多支持吧。
我们也在做国家、城市经纬度和相关时区的数据,有需要的可以试试。
年底之前也争取把域名换掉,也省得很多人问我 17MON 代表啥意思。:-)
再求专职维护人员,有兴趣可以找我聊。
--
高春辉
Paul Gao
gaochunhui@gmail.com
http://www.17mon.cn/
--- 2014 年 8 月引言 ---
这是 IP 库的第六个公开版本。
这个月参加了 ThinkInLAMP 2014 PHP 技术峰会,做了一次有关 IP 数据库的演讲,也算是对将近一年多时间的投入的一个总结。大家有兴趣的,可以看看我的 ppt。
实在是精力有限,为承诺计,从这个月开始,将每两个月发布免费版了。如果您需要更好的服务,请购买付费版。
--
高春辉
Paul Gao
gaochunhui@gmail.com
http://www.17mon.cn/
--- 2014 年 7 月引言 ---
这是 IP 库的第五个公开版本。
这个月公司和家里事情比较多,更新的慢了一点,还请大家谅解。
--
高春辉
Paul Gao
gaochunhui@gmail.com
http://www.17mon.cn/
--- 2014 年 6 月引言 ---
这是 IP 库的第四个公开版本。
祝大家六一、端午快乐,这次我们增加了一个字段,原来是把城市和单位放在了一起,这样比如在有学校名称的时候,就没法知道所在具体城市了。
这种情况被客户们投诉了。这次趁着三天假的机会,下决心将其分开,这回大家都满意了吧?:-)
因为增加了字段,所以对于字段有明确要求的,请仔细核查数据和相关代码,如果有问题,请到 QQ 群: 346280296 中反馈。
--
高春辉
Paul Gao
gaochunhui@gmail.com
http://www.17mon.cn/
--- 2014 年 5 月引言 ---
这是 IP 库的第三个公开版本。
祝大家五一快乐,假期之后的一周后,付费计划将上线。另外 WINDOWS 版的客户端也会同期上线。
已经有公司与我联系了购买了付费服务,我很欣慰,呵呵。
--
高春辉
Paul Gao
gaochunhui@gmail.com
http://www.17mon.cn/
--- 2014 年 4 月引言 ---
这是 IP 库的第二个公开版本。
这个版本放开了国内市一级的数据,和网站版的数据相比,只有运营商的数据和国外到市一级的数据没有放开,我想对于一般的应用来说足够用了。
这个月,更大的收获是,校准 IP 库的方法,进一步的成型,可以更少的工作、更高的正确率,对于做付费计划,我更有信心了。
付费计划应该在本月底之前上线。希望对于数据的数据和更新频度以及支持有要求的,请一定给予支持。不然这个事情没有办法长期执行下去。
如果您的软件或者应用里需要内置 IP 库,可以找我来谈更紧密的合作和更新方式。
如果您有任何问题,请到 QQ 群来说。
不多说,睡觉去了。。。
--
高春辉
Paul Gao
gaochunhui@gmail.com
http://www.17mon.cn/
--- 2014 年 3 月引言 ---
经过半年多的不断努力,终于可以发布一个公开的版本了。
IP 地址是互联网的基础部分,那么 IP 归属地数据库同样也很重要。
之前在 ECSHOP 时期就研究过,只是最终没有更深入。
终于半公半私都有关系的原因,下定决心做了,我一个人为主,也有同事很大的帮助。
这半年多时间以来,知识见涨,尤其是全球地理方面的知识。:-)
这次为了发布,也专门改进了库的生成方式,更准确(之前的生成代码有个小问题,导致 ECSHOP、DISCUZ 的也有同样问题,只是轻易碰不上,这次一并都改进了),库的体积也更小。
言归正传,有空再闲扯。
想使用很简单,把 17monipdb.dat 和 IP.class.php 放在同一个目录,使用 IP::find('x.x.x.x') 调用即可。
工程师们请注意:目前为了向后兼容增加更多项目,并且方便进行二次处理,所以两个文本使用制表符分割;目前使用 UTF-8 字符集,其它字符集请自行转义;欢迎大家补充其它语言的版本。
几点说明:
1、维护这个数据库是个长期工作,甚至是一个无期工作,所以有打算做付费维护的考虑,请各位工程师们理解其辛苦程度。不是为赚钱,而是为了更好的维护数据库,让数据更准确,更有价值。
2、目前公开版仅发布国内具体到省,国外具体到国家的格式数据。一般来说够用了。基于准确度优先的问题,我们暂时没有做除了直辖市或者可以明确到市的数据,即使有,目前也比较少。这个还请见谅,您可以保持关注。数据库的更新周期暂定一个月左右。17mon.cn 所对外的数据是完全版也是最新版,有需要可以使用 http://ip.17mon.cn/ 进行查询。
3、有些 IP 段不会标注国家,是因为要么是路由器 IP 段,要么是做了 ANYCAST 技术,无法具体定位,一般来说,针对普通用户进行定位,不会碰到此类 IP,只有面对 CDN、DNS、服务器、路由器等等所在的 IP,才有可能碰到。
4、在整理过程中,感谢 DNSPOD 的建议和数据支持,部分数据参考了纯真 IP 库、淘宝 IP 库、腾讯 IP 库、新浪 IP 库、中国互联网广告行业 IP 库的数据,还包括 BGP.HE.NET 以及全球各大地区的 IP 管理机构的 WHOIS 信息数据,感谢给我帮助和支持的大家还有我的同事,还有很多基础性的文章和资料,包括中国地图出版社的美国地图和欧洲地图。
5、为了便于查询您使用的 IP 库版本,将 255.255.255.0 - 255.255.255.255 作为版本数据输出,您需要了解版本的话,请使用 IP::find('255.255.255.255') 查询即可。
6、我们为了自己,也为了他人方便,集成了一个大全版,有兴趣者可访问 http://ip.17mon.cn/ 。
7、数据量超大,更不要提未来的 IPv6 了,尤其我们为了准确,尽量使用实证方式维护数据,错误难免,请加 QQ 群: 346280296 进行讨论。
8、如果您所在公司有更准确的 IP 数据库需求,可以与我联系,希望可以发挥各自长处合作共建,而不是各自单打独斗。
说完了。
--
高春辉
Paul Gao
gaochunhui@gmail.com
http://www.17mon.cn/
*/
?>
Loading…
Cancel
Save