Skip to content

Instantly share code, notes, and snippets.

@devsikander
Created February 21, 2023 19:40
Show Gist options
  • Save devsikander/c2ec3317d86178f1b6ffcc002a973d38 to your computer and use it in GitHub Desktop.
Save devsikander/c2ec3317d86178f1b6ffcc002a973d38 to your computer and use it in GitHub Desktop.
Route53 to Cloudflare DNS entries
<?php
// Author: Muhammad Qadeer <[email protected]>
if (isset($_GET['source']) && !empty($_GET['source']) && isset($_GET['destination']) && !empty($_GET['destination']))
{
$source = $_GET['source'];
$destination = $_GET['destination'];
if (file_exists($source))
{
$lines = file($source);
$count = 0;
$fp = fopen($destination, 'w');
foreach($lines as $line)
{
$line = trim($line);
if (!empty($line))
{
$count += 1;
if($count % 2 != 0)
{
$odd_row = explode("\t", $line);
}
else
{
$even_row = explode("\t", $line);
$new_line = $odd_row['1']."\t1\tIN\tA\t".$even_row['1']."\n";
fwrite($fp, $new_line);
}
}
}
echo "Destination file: ".$destination;
fclose($fp);
}
else
{
echo "<b>Error:</b> Source file is not available.";
}
}
else
{
echo '<b>Error:</b> Source or destination file name is missing.';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment