初始化项目:添加后端代码、ThinkPHP框架、前端资源

This commit is contained in:
amb
2026-09-03 12:42:39 +08:00
commit 482bece22e
3726 changed files with 416708 additions and 0 deletions
@@ -0,0 +1,102 @@
<?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.
*/
/**
* @deprecated See: https://github.com/aliyun/openapi-sdk-php
* Class Endpoint
*/
class Endpoint
{
/**
* @var string
*/
private $name;
/**
* @var string
*/
private $regionIds;
/**
* @var string
*/
private $productDomains;
/**
* Endpoint constructor.
*
* @param $name
* @param $regionIds
* @param $productDomains
*/
public function __construct($name, $regionIds, $productDomains)
{
$this->name = $name;
$this->regionIds = $regionIds;
$this->productDomains = $productDomains;
}
/**
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* @param $name
*/
public function setName($name)
{
$this->name = $name;
}
/**
* @return string
*/
public function getRegionIds()
{
return $this->regionIds;
}
/**
* @param $regionIds
*/
public function setRegionIds($regionIds)
{
$this->regionIds = $regionIds;
}
/**
* @return string
*/
public function getProductDomains()
{
return $this->productDomains;
}
/**
* @param $productDomains
*/
public function setProductDomains($productDomains)
{
$this->productDomains = $productDomains;
}
}
@@ -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 = __DIR__ . 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 || !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']);
$product_domains[] = $product_domain;
}
$endpoint = new Endpoint($region_ids[0], $region_ids, $product_domains);
$endpoints[] = $endpoint;
}
EndpointProvider::setEndpoints($endpoints);
@@ -0,0 +1,86 @@
<?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.
*/
/**
* @deprecated See: https://github.com/aliyun/openapi-sdk-php
* Class EndpointProvider
*/
class EndpointProvider
{
/**
* @var array
*/
private static $endpoints;
/**
* @param $regionId
* @param $product
*
* @return null
*/
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;
}
/**
* @param $productDomains
* @param $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;
}
/**
* @return array
*/
public static function getEndpoints()
{
return self::$endpoints;
}
/**
* @param $endpoints
*/
public static function setEndpoints($endpoints)
{
self::$endpoints = $endpoints;
}
}
@@ -0,0 +1,198 @@
<?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);
/**
* @deprecated See: https://github.com/aliyun/openapi-sdk-php
* Class DescribeEndpointRequest
*/
class DescribeEndpointRequest extends RpcAcsRequest
{
/**
* DescribeEndpointRequest constructor.
*
* @param $id
* @param $serviceCode
* @param $endPointType
*/
public 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
{
/**
* @var IClientProfile
*/
private $clientProfile;
/**
* @var array
*/
public static $cache = array();
/**
* @var array
*/
public static $lastClearTimePerProduct = array();
/**
* @var string
*/
public static $serviceDomain = LOCATION_SERVICE_DOMAIN;
/**
* LocationService constructor.
*
* @param $clientProfile
*/
public function __construct($clientProfile)
{
$this->clientProfile = $clientProfile;
}
/**
* @param $regionId
* @param $serviceCode
* @param $endPointType
* @param $product
*
* @return mixed|null
* @throws ClientException
*/
public function findProductDomain($regionId, $serviceCode, $endPointType, $product)
{
$key = $regionId . '#' . $product;
$domain = isset(self::$cache[$key]) ? self::$cache[$key] : null;
if ($domain === null || $this->checkCacheIsExpire($key) == true) {
$domain = $this->findProductDomainFromLocationService($regionId, $serviceCode, $endPointType);
self::$cache[$key] = $domain;
}
return $domain;
}
/**
* @param $regionId
* @param $product
* @param $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;
}
/**
* @param $domain
*/
public static function modifyServiceDomain($domain)
{
self::$serviceDomain = $domain;
}
/**
* @param $key
*
* @return bool
*/
private function checkCacheIsExpire($key)
{
$lastClearTime = isset(self::$lastClearTimePerProduct[$key])
? self::$lastClearTimePerProduct[$key]
: null;
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;
}
/**
* @param $regionId
* @param $serviceCode
* @param $endPointType
*
* @return string|null
* @throws ClientException
*/
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;
}
}
@@ -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.
*/
/**
* @deprecated See: https://github.com/aliyun/openapi-sdk-php
* Class ProductDomain
*/
class ProductDomain
{
/**
* @var string
*/
private $productName;
/**
* @var string
*/
private $domainName;
/**
* ProductDomain constructor.
*
* @param string $product
* @param string $domain
*/
public function __construct($product, $domain)
{
$this->productName = $product;
$this->domainName = $domain;
}
/**
* @return string
*/
public function getProductName()
{
return $this->productName;
}
/**
* @param $productName
*/
public function setProductName($productName)
{
$this->productName = $productName;
}
/**
* @return string
*/
public function getDomainName()
{
return $this->domainName;
}
/**
* @param $domainName
*/
public function setDomainName($domainName)
{
$this->domainName = $domainName;
}
}
File diff suppressed because it is too large Load Diff