Created
April 23, 2010 18:48
-
-
Save rogerclark/376971 to your computer and use it in GitHub Desktop.
Slicehost Dynamic DNS script
This file contains 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
<? | |
require_once("ActiveResource.php"); | |
$recordname = $_GET["record"]; | |
if ($recordname[strlen($recordname) - 1] != '.') | |
$recordname .= '.'; | |
$ipaddr = $_GET["ip"]; | |
if ($ipaddr == '') | |
$ipaddr = $_SERVER["REMOTE_ADDR"]; | |
define("SLICEHOST_API_KEY", "your_api_key_goes_here"); | |
define("SLICEHOST_API_URL", "https://" . SLICEHOST_API_KEY . "@api.slicehost.com/"); | |
class Record extends ActiveResource | |
{ | |
var $site = SLICEHOST_API_URL; | |
} | |
$success = false; | |
$record = new Record(NULL); | |
if ($results = $record->find("all", array("name" => $recordname))) | |
{ | |
if (count($results) == 1) | |
{ | |
$this_record = $results[0]; | |
$this_record->set("data", $ipaddr); | |
$this_record->save(); | |
$success = true; | |
} | |
} | |
echo $success; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment