function get_served() { require_once 'r53.php'; ////////////////// require_once '/connectivity/aws_keys.php'; $keys = aws_keys(); $access_key = $keys['access_key']; $secret_key = $keys['secret_key']; ////////////////////////// $r53 = new Route53($access_key, $secret_key); $unique_key = md5(microtime() . rand()); $result = $r53->createHostedZone($_POST['domain'], $unique_key, 'no cooment here'); if (!empty($result)) { //var_dump($result); $_SESSION['hosted_zone'] = array("ns" => $result['NameServers'], "id" => $result['HostedZone']['Id'], "name" => $result['HostedZone']['Name'], "Config" => $result['HostedZone']['Config'], "rrc" => $result['HostedZone']['ResourceRecordSetCount'], "status" => true); } else { $_SESSION['hosted_zone'] = array("ns" => array(), "status" => false); } }
<?php require_once 'r53.php'; require_once 'IncR53.php'; $awszoneid = '/hostedzone/' . $awszoneid; $r53 = new Route53($awsid, $awskey); function getPublicIP() { // create a new cURL resource $ch = curl_init(); // set URL and other appropriate options curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_URL, "http://icanhazip.com"); // grab URL and pass it to the browser $ip = curl_exec($ch); // close cURL resource, and free up system resources curl_close($ch); $ip = trim(preg_replace('/\\s+/', ' ', $ip)); return $ip; } function updateIP($hostname, $newIP, $oldIP, $awszoneid, $type = 'A', $ttl = 60) { global $r53; $delete = $r53->prepareChange('DELETE', $hostname, $type, $ttl, $oldIP); $result = $r53->changeResourceRecordSets($awszoneid, $delete); $create = $r53->prepareChange('CREATE', $hostname, $type, $ttl, $newIP); $result = $r53->changeResourceRecordSets($awszoneid, $create); } //print_r($r53->listHostedZones()); //print_r($r53->getHostedZone($awszoneid));
$aws_zone = $_GET['zone']; $hostname = $_GET['hostname']; $type = $_GET['type']; $new_ip = $_GET['newip']; $old_ip = ''; $record_type = ''; $record_ttl = ''; $route53 = ''; $recordSet = ''; $synology = $_GET['synology'] == '1' ? true : false; $debug = $_GET['debug'] == '1' ? true : false; /* Script Starts Below ------------------------------------------------------- */ require_once 'r53.php'; // Start a new instance $route53 = new Route53($aws_id, $aws_secret); // Define record set $recordSet = $route53->listResourceRecordSets('/hostedzone/' . $aws_zone); // Validate the authentication variables if (empty($aws_id) || empty($aws_secret) || empty($aws_zone) || empty($recordSet)) { if ($synology == true) { exit('(badauth)'); } else { exit('Failed. Your AWS credentials and Zone ID information is incorrect or incomplete.'); } } // Search for the old IP address for ($i = 0; $i < count($recordSet['ResourceRecordSets']); $i++) { if ($debug == true) { echo '<b>Host:</b> ' . $recordSet['ResourceRecordSets'][$i]['Name'] . '<br />'; echo '<b>Host Value:</b> ' . $recordSet['ResourceRecordSets'][$i]['ResourceRecords'][0] . '<br />';