101 lines
2.9 KiB
PHP
101 lines
2.9 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) {
|
|
$tmpStrs = explode('?', $requestUri);
|
|
$requestUri = count($tmpStrs) > 0 ? $tmpStrs[0] : '';
|
|
$this->nftInfo(explode('/', $requestUri));
|
|
}
|
|
}
|
|
}
|
|
|
|
private function nftInfo($path)
|
|
{
|
|
$nftView = array(
|
|
'name' => '',
|
|
'description' => '',
|
|
'image' => ''
|
|
);
|
|
$tokenId = $path[4];
|
|
if (empty($tokenId)) {
|
|
myself()->_rspRawData($nftView);
|
|
return;
|
|
}
|
|
if ($this->procTestNft($tokenId, $nftView)){
|
|
myself()->_rspRawData($nftView);
|
|
return;
|
|
}
|
|
$nftDb = Nft::getNft($tokenId);
|
|
if (empty($nftDb)) {
|
|
myself()->_rspRawData($nftView);
|
|
return;
|
|
}
|
|
Nft::toNftView($nftDb, $nftView);
|
|
myself()->_rspRawData($nftView);
|
|
}
|
|
|
|
private function procTestNft($tokenId, &$nftView)
|
|
{
|
|
$heroBoxes = array(
|
|
'6022513565100001',
|
|
'6022513565100002',
|
|
'6022513565100003',
|
|
);
|
|
$weaponBoxes = array(
|
|
'6022513565100004',
|
|
'6022513565100005'
|
|
);
|
|
if (in_array($tokenId, $heroBoxes)) {
|
|
$nftView['name'] = 'CEBG Airdrop Hero';
|
|
$nftView['image'] = 'https://www.cebg.games/res/nfts/CEBG_Space_Hero.png';
|
|
$nftView['description'] = 'CEBG Airdrop Hero';
|
|
return true;
|
|
}
|
|
if (in_array($tokenId, $weaponBoxes)) {
|
|
$nftView['name'] = 'CEBG Airdrop Weapon';
|
|
$nftView['image'] = 'https://www.cebg.games/res/nfts/CEBG_Space_Weapon.png';
|
|
$nftView['description'] = 'CEBG Airdrop Weapon';
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
}
|