Created
February 21, 2023 19:40
-
-
Save devsikander/c2ec3317d86178f1b6ffcc002a973d38 to your computer and use it in GitHub Desktop.
Route53 to Cloudflare DNS entries
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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