Skip to content

Instantly share code, notes, and snippets.



Forked from alfo/cron.php
Created Aug 5, 2019
What would you like to do?
Cron job to update Cloudflare's DNS to point to your current IP address. Useful for people with dynamic public IPs because their stupid ISP won't let them have a static one.
// Grab the IP address
// This is the fastest method I've found so far
$ip = system('dig +short');
// For cron logs
print "New IP is: " . $ip;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, true);
$data = array(
'a' => 'DIUP',
'tkn' => 'put an api token in here please',
'email' => 'also an email in here',
'ip' => $ip,
'hosts' => 'comma seperated domains pls'
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
echo $output = curl_exec($ch);
$info = curl_getinfo($ch);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment