extend/alidayu/top/ClusterTopClient.php
(开头部分) 2KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
<?php
class ClusterTopClient extends TopClient {
private static $dnsconfig;
private static $syncDate = 0;
private static $applicationVar ;
private static $cfgDuration = 10;
public function __construct($appkey = "",$secretKey = ""){
ClusterTopClient::$applicationVar = new ApplicationVar;
$this->appkey = $appkey;
$this->secretKey = $secretKey ;
$saveConfig = ClusterTopClient::$applicationVar->getValue();
if($saveConfig){
$tmpConfig = $saveConfig['dnsconfig'];
ClusterTopClient::$dnsconfig = $this->object_to_array($tmpConfig);
unset($tmpConfig);
ClusterTopClient::$syncDate = $saveConfig['syncDate'];
if(!ClusterTopClient::$syncDate)
ClusterTopClient::$syncDate = 0;
}
}
public function __destruct(){
if(ClusterTopClient::$dnsconfig && ClusterTopClient::$syncDate){
ClusterTopClient::$applicationVar->setValue("dnsconfig",ClusterTopClient::$dnsconfig);
ClusterTopClient::$applicationVar->setValue("syncDate",ClusterTopClient::$syncDate);
ClusterTopClient::$applicationVar->write();
}
}
public function execute($request = null, $session = null,$bestUrl = null){
$currentDate = date('U');
$syncDuration = $this->getDnsConfigSyncDuration();
$bestUrl = $this->getBestVipUrl($this->gatewayUrl,$request->getApiMethodName(),$session);
if($currentDate - ClusterTopClient::$syncDate > $syncDuration * 60){
$httpdns = new HttpdnsGetRequest;
ClusterTopClient::$dnsconfig = json_decode(parent::execute($httpdns,null,$bestUrl)->result,true);
$syncDate = date('U');
ClusterTopClient::$syncDate = $syncDate ;
}
return parent::execute($request,$session,$bestUrl);
}
private function getDnsConfigSyncDuration(){
if(ClusterTopClient::$cfgDuration){
return ClusterTopClient::$cfgDuration;
}
if(!ClusterTopClient::$dnsconfig){
return ClusterTopClient::$cfgDuration;
}
$config = json_encode(ClusterTopClient::$dnsconfig);
if(!$config){
return ClusterTopClient::$cfgDuration;
}
$config = ClusterTopClient::$dnsconfig['config'];
$duration = $config['interval'];
ClusterTopClient::$cfgDuration = $duration;
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。