Files
ProxyPanel/app/Components/Namesilo.php
Bretton d1581f0e33 1.3
功能添加/重置
1. 商品限购功能重置 - 商品为0时下架
2. 添加用户付费自行重置套餐流量 - 可规定价格让用户重置或不开启功能
3. 邮箱注册增加白名单 - 白名单为用户只能使用固定邮箱后缀注册
4. 节点TCP和ICMP检测 - 节点阻断检测
5. 优惠券规则添加 - 满XX元抵XX,或者满XX元打折

页面添加与修改
1. 节点信息简化
2. 系统页面排版优化
3. 注册页面全新的TOS和AUP显示
4. 添加订阅记录查询页面
5. 人性化删除确认页

BUG修复和优化
1. 流量重置日相关代码统一
2. 众多代码简化
3. auth相关css导致的宽度变动bug修复
2020-08-05 03:20:19 +08:00

106 lines
2.5 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
namespace App\Components;
use Exception;
use Log;
use LSS\XML2Array;
class Namesilo
{
protected static $host;
protected static $systemConfig;
function __construct()
{
self::$host = 'https://www.namesilo.com/api/';
self::$systemConfig = Helpers::systemConfig();
}
// 列出账号下所有域名
public function listDomains()
{
return $this->send('listDomains');
}
// 列出指定域名的所有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);
}
// 发送请求
private function send($operation, $data = [])
{
$params = [
'version' => 1,
'type' => 'xml',
'key' => self::$systemConfig['namesilo_key']
];
$query = array_merge($params, $data);
$content = '请求操作:['.$operation.'] --- 请求数据:['.http_build_query($query).']';
try{
$result = Curl::send(self::$host.$operation.'?'.http_build_query($query));
$result = XML2Array::createArray($result);
// 出错
if(empty($result['namesilo']) || $result['namesilo']['reply']['code'] != 300 || $result['namesilo']['reply']['detail'] != 'success'){
Helpers::addEmailLog(self::$systemConfig['webmaster_email'], '[Namesilo API] - ['.$operation.']', $content, 0, $result['namesilo']['reply']['detail']);
}else{
Helpers::addEmailLog(self::$systemConfig['webmaster_email'], '[Namesilo API] - ['.$operation.']', $content, 1, $result['namesilo']['reply']['detail']);
}
return $result['namesilo']['reply'];
} catch(Exception $e){
Log::error('CURL请求失败'.$e->getMessage().' --- '.$e->getLine());
Helpers::addEmailLog(self::$systemConfig['webmaster_email'], '[Namesilo API] - ['.$operation.']', $content, 0, $e->getMessage());
return FALSE;
}
}
}