function getDomainInfo() { $url = 'https://dnsapi.cn/Domain.List'; $config = array('login_email' => '*****@*****.**', 'login_password' => 'pdcxaje127', 'format' => 'json', 'lang' => 'cn', 'error_on_empty' => 'no'); $post_data = post_data($url, $config); return json_decode($post_data, true); } function getIp() { $myip = file_get_contents('http://ip.taobao.com/service/getIpInfo2.php?ip=myip'); $ipInfo = json_decode($myip, true); $ip = $ipInfo['data']['ip']; return $ip; } $domainInfo = getDomainInfo(); $domianId = $domainInfo['domains'][0]['id']; $records = domainList($domainInfo['domains'][0]['id']); $myIp = getIp(); foreach ($records['records'] as $k => $v) { if (in_array($v['name'], array('pi-phpmyadmin', 'pi-order', 'www')) && $v['value'] !== $myIp) { $para = array('domain_id' => $domainInfo['domains'][0]['id'], 'record_id' => $v['id'], 'sub_domain' => $v['name'], 'value' => $myIp, 'record_type' => $v['type'], 'record_line' => $v['line']); $status = updateDomain($para); if (intval($status['status']['code']) === 1) { echo $v['name'] . '修改成功! 原因:ip不一致原始绑定IP:' . $v['value'] . ', 当前服务器IP:' . $myIp, PHP_EOL; } } else { if (in_array($v['name'], array('pi-phpmyadmin', 'pi-order', 'www')) && $v['value'] === $myIp) { echo '子域名:' . $v['name'] . '不需要进行修改!', PHP_EOL; } } }
$protocol = true; $action = isset($_POST['action']) ? $_POST['action'] : 'domainList'; if (empty($apiKey) || empty($secretKey)) { ajaxReturn(20000, 'API KEY或者SECRET KEY不能为空!'); } $api = new Api(); $api->setApiKey($apiKey); $api->setSecretKey($secretKey); if ($protocol) { $api->setProtocol(false); } else { $api->setProtocol(true); } switch ($action) { case 'domainList': domainList($api); break; case 'domainAdd': domainAdd($api); break; case 'domainDelete': domainDelete($api); break; case 'typeList': typeList($api); break; case 'nsList': nsList($api); break; case 'hostList': hostList($api);