<?php
// Form a list of all CF IP zones
// For each zone, grab all A records and TXT records matching $oldip
// For each matching record, update it to the new IP address
// Does not deal with paginated zone results so there's currently
// a maximum of 50 zones managed by this tool
$authemail = "cloudflare kayıtlı mail adresi";
$authkey = "Global Api Key";
// Eski ip adresi
$oldip = "eski ip adresi";
// Yeni ip adresini girin
$newip = "yeni ip adresi";
// kod ilk 50 siteye mudahale ediyor 50 site sonrasında page=1 yazan kısma 2,3,4 vs. yazarak devam edebilirsiniz.
$ch = curl_init("https://api.cloudflare.com/client/v4/zones?page=1&per_page=50&match=all");
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'X-Auth-Email: '.$authemail,
'X-Auth-Key: '.$authkey,
'Content-Type: application/json'
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
curl_close($ch);
$r = json_decode($response, true);
$result = $r['result'];
$count = 1;
foreach ($result as $zone)
{
if (isset($zone['id']))
{
$zoneid = $zone['id'];
$zonename = $zone['name'];
echo $count . ": " . $zonename . " " . $zoneid . "<br />\n";
$count++;
// List all DNS records for this domain
$ch = curl_init("https://api.cloudflare.com/client/v4/zones/$zoneid/dns_records");
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'X-Auth-Email: '.$authemail,
'X-Auth-Key: '.$authkey,
'Content-Type: application/json'
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
curl_close($ch);
$r = json_decode($response, true);
$dnsrecs = $r['result'];
foreach ($dnsrecs as $dns)
{
if (preg_match("/$oldip/", $dns['content']))
{
// OK! Change this DNS record.
$newcontent = preg_replace("/$oldip/", $newip, $dns['content']);
echo "oldcontent: " . $dns['content'];
echo "newcontent: $newcontent<br />\n";
// Swap the content then
$dns['content'] = $newcontent;
updateDNSRecord($dns);
}
}
echo "<br />\n";
}
}
function updateDNSRecord($dns)
{
global $authemail, $authkey;
$ch = curl_init("https://api.cloudflare.com/client/v4/zones/".$dns['zone_id']."/dns_records/".$dns['id']);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'X-Auth-Email: '.$authemail,
'X-Auth-Key: '.$authkey,
'Content-Type: application/json'
));
$data_string = json_encode($dns);
echo "JSON_DATA_STRING: $data_string";
echo "<br />\n";
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
curl_close($ch);
$r = json_decode($response, true);
print_r($r);
print "<br />\n";
}
?> CloudFlare Toplu IP Adresi Değiştirmek
3
●492
- 09-09-2020, 18:08:15Merhaba arkadaşlar CloudFlare kullananlara kolaylık sağlayabilecek bir kod buldum daha önce paylaşıldı mı bilmiyorum. Aşağıdaki kod ile CloudFlare hesabınıza API ile bağlanarak A kayıtlarında yer alan IP adreslerini güncelleyebilirsiniz.
- 09-09-2020, 18:11:35sercih adlı üyeden alıntı: mesajı görüntüle
// kod ilk 50 siteye mudahale ediyor 50 site sonrasında page=1 yazan kısma 2,3,4 vs. yazarak devam edebilirsiniz. $ch = curl_init("https://api.cloudflare.com/client/v4/zones?page=1&per_page=50&match=all");kısmını fixlersek daha da etkili olur.
// kod artık 350 siteye mudahale ediyor 350 site sonrasında page=1 yazan kısma 2,3,4 vs. yazarak devam edebilirsiniz. $ch = curl_init("https://api.cloudflare.com/client/v4/zones?page=1&per_page=350&match=all");PHP timeout dışında hiçbir eksisi olmaz.
Paylaşımınız için teşekkürler. - 06-10-2025, 17:25:09Kimlik doğrulama veya yönetimden onay bekliyor.Merhaba maalesef 2025 cloudflare çok fazla değişiklik yaptı bundan dolayı kodlar maalesef çalışmıyor.
Php denedim olmadı
payton denedim olmadı
400 yakın site var değişmesi gereken ip adresleri bana bu konuda yardımcı olurmusunuz lütfen.