mirror of
https://github.com/ProxyPanel/ProxyPanel.git
synced 2026-04-13 07:59:20 +00:00
1. models 关系规范化; 2. 本地-在线 订单处理改写; 3. 优化用户界面节点的查表操作; 4. 半修复 VNet SSR版需要面板主动提交用户信息变动的问题;(节点等级,用户分组,Node信息修改 主动通知节点尚未添加); 5. 简化并提取出了 返利佣金相关处理逻辑;
96 lines
2.5 KiB
PHP
96 lines
2.5 KiB
PHP
<?php
|
||
|
||
namespace App\Components;
|
||
|
||
use GuzzleHttp\Client;
|
||
use Log;
|
||
use LSS\XML2Array;
|
||
|
||
class Namesilo {
|
||
private static $host = 'https://www.namesilo.com/api/';
|
||
|
||
// 列出账号下所有域名 Todo Debug测试
|
||
public function listDomains() {
|
||
return $this->send('listDomains');
|
||
}
|
||
|
||
// 发送请求
|
||
private function send($operation, $data = []) {
|
||
$params = [
|
||
'version' => 1,
|
||
'type' => 'xml',
|
||
'key' => sysConfig('namesilo_key')
|
||
];
|
||
$query = array_merge($params, $data);
|
||
|
||
$content = '请求操作:['.$operation.'] --- 请求数据:['.http_build_query($query).']';
|
||
|
||
$request = (new Client(['timeout' => 15]))->get(self::$host.$operation.'?'.http_build_query($query));
|
||
$result = XML2Array::createArray(json_decode($request->getBody(), true));
|
||
|
||
if($request->getStatusCode() != 200){
|
||
Log::error('请求失败:'.var_export($request, true));
|
||
Helpers::addNotificationLog('[Namesilo API] - ['.$operation.']', $content, 1, sysConfig('webmaster_email'),
|
||
0, var_export($request, true));
|
||
|
||
return false;
|
||
}
|
||
|
||
// 出错
|
||
if(empty($result['namesilo']) || $result['namesilo']['reply']['code'] != 300 || $result['namesilo']['reply']['detail'] !== 'success'){
|
||
Helpers::addNotificationLog('[Namesilo API] - ['.$operation.']', $content, 1, sysConfig('webmaster_email'),
|
||
0, $result['namesilo']['reply']['detail']);
|
||
}else{
|
||
Helpers::addNotificationLog('[Namesilo API] - ['.$operation.']', $content, 1, sysConfig('webmaster_email'),
|
||
1, $result['namesilo']['reply']['detail']);
|
||
}
|
||
|
||
return $result['namesilo']['reply'];
|
||
}
|
||
|
||
// 列出指定域名的所有DNS记录
|
||
public function dnsListRecords($domain) {
|
||
$query = [
|
||
'domain' => $domain
|
||
];
|
||
|
||
return $this->send('dnsListRecords', $query);
|
||
}
|
||
|
||
// 为指定域名添加DNS记录
|
||
public function dnsAddRecord($domain, $host, $value, $type = 'A', $ttl = 7207) {
|
||
$query = [
|
||
'domain' => $domain,
|
||
'rrtype' => $type,
|
||
'rrhost' => $host,
|
||
'rrvalue' => $value,
|
||
'rrttl' => $ttl
|
||
];
|
||
|
||
return $this->send('dnsAddRecord', $query);
|
||
}
|
||
|
||
// 更新DNS记录
|
||
public function dnsUpdateRecord($domain, $id, $host, $value, $ttl = 7207) {
|
||
$query = [
|
||
'domain' => $domain,
|
||
'rrid' => $id,
|
||
'rrhost' => $host,
|
||
'rrvalue' => $value,
|
||
'rrttl' => $ttl
|
||
];
|
||
|
||
return $this->send('dnsUpdateRecord', $query);
|
||
}
|
||
|
||
// 删除DNS记录
|
||
public function dnsDeleteRecord($domain, $id) {
|
||
$data = [
|
||
'domain' => $domain,
|
||
'rrid' => $id
|
||
];
|
||
|
||
return $this->send('dnsDeleteRecord', $data);
|
||
}
|
||
}
|