cloudflare API 自动更换IP PHP脚本

13

<?php

//前面那个可能有问题,现在改进一下
//注意 : CF不能开启CDN
//机器IP越多越好
//随便找台其他机器(不要和被打网站一台),宝塔定时1分钟URL访问 http://127.0.0.1/q.php 一次

$file = ‘./tqdata.txt’;
$txt = file_get_contents($file);
if ($txt == 254) {
$txt = 1;
} else {
$txt += 1;
}
$myfile = fopen($file, “w”);
fwrite($myfile, $txt);
fclose($myfile);

$ips = [];
for($i=1; $i <=254; $i++){
$ips[$i] = ‘123.123.123.’ . $i;
}

$ip = $ips[$txt];

$www=’https://api.cloudflare.com/client/v4/zones/XXXXXXXXXXXX/dns_records/XXXXXXXXXXXXX’;

$datawww = array(
“type”=>”A”,
“name”=>”www.xxxx.com”,
“content”=>$ip,
“ttl”=>120,
“proxied”=>false
);

curl_get($www,$datawww);

function curl_get($url,$data)
{
$ch = curl_init();
$headers = array(
‘X-Auth-Email:xxxxx@gmail.com’,
‘X-Auth-Key:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX’,
‘Content-Type:application/json’
);
$data = json_encode($data);
$ch = curl_init(); //初始化CURL句柄
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_URL, $url); //设置请求的URL
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); //设为TRUE把curl_exec()结果转化为字串,而不是直接输出
curl_setopt($ch, CURLOPT_CUSTOMREQUEST,”PUT”); //设置请求方式
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);//设置提交的字符串
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 信任任何证书
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); // 检查证书中是否设置域名
$output = curl_exec($ch);
curl_close($ch);
return json_decode($output,true);
}

上一篇Clash for Windows电脑汉化版下载
下一篇WHMCS后台 Invalid CSRF Protection Token
蓝色石头运营数据分析、网站建设、软件工具推荐编辑,欢迎投稿!

LEAVE A REPLY

Please enter your comment!
Please enter your name here