69 lines
1.8 KiB
PHP
69 lines
1.8 KiB
PHP
<?php
|
|
|
|
require_once('mt/MarketGoods.php');
|
|
require_once('mt/MarketBatch.php');
|
|
require_once('mt/Item.php');
|
|
require_once('mt/WhiteList.php');
|
|
require_once('mt/Currency.php');
|
|
require_once('mt/Hero.php');
|
|
require_once('mt/Parameter.php');
|
|
|
|
require_once('models/BoxOrder.php');
|
|
require_once('models/Nft.php');
|
|
require_once('models/BuyRecord.php');
|
|
|
|
require_once('phpcommon/bchelper.php');
|
|
|
|
use phpcommon\SqlHelper;
|
|
use models\BoxOrder;
|
|
use models\Nft;
|
|
use models\BuyRecord;
|
|
|
|
|
|
class RestApiController extends BaseController {
|
|
|
|
public function dispatch()
|
|
{
|
|
//REQUEST_URI /api/nft?dafsf=1%26=
|
|
$requestUri = $_SERVER['REQUEST_URI'];
|
|
if (!empty($requestUri)) {
|
|
$idx = strpos($requestUri, '/api/nft/info/');
|
|
if ($idx === false) {
|
|
$idx = strpos($requestUri, '/api/client');
|
|
if (!($idx === false)) {
|
|
$url = 'https://test.cebg.games/client/web-mobile/';
|
|
header("Cache-control:no-cache,no-store,must-revalidate");
|
|
header("Pragma:no-cache");
|
|
header("Expires:0");
|
|
Header("Location:$url");
|
|
}
|
|
return;
|
|
}
|
|
if ($idx == 0) {
|
|
$this->nftInfo(explode('/', $requestUri));
|
|
}
|
|
}
|
|
}
|
|
|
|
private function nftInfo($path)
|
|
{
|
|
$tokenId = $path[4];
|
|
if (empty($tokenId)) {
|
|
myself()->_rspErr(1, 'nft not found');
|
|
return;
|
|
}
|
|
$nftDb = Nft::getNft($tokenId);
|
|
if (empty($nftDb)) {
|
|
myself()->_rspErr(1, 'nft not found');
|
|
return;
|
|
}
|
|
$nftDto = Nft::toDto($nftDb);
|
|
if (!$nftDto) {
|
|
myself()->_rspErr(1, 'nft not found');
|
|
return;
|
|
}
|
|
myself()->_rspData($nftDto);
|
|
}
|
|
|
|
}
|