Skip to content

Instantly share code, notes, and snippets.

@rogerclark
Created April 23, 2010 18:48
Show Gist options
  • Save rogerclark/376971 to your computer and use it in GitHub Desktop.
Save rogerclark/376971 to your computer and use it in GitHub Desktop.
Slicehost Dynamic DNS script
<?
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