function __construct($name, $value, $ttl = false, $class = "IN") { parent::__construct(); // Name if (!$this->validator->IsDomain($name)) { if ($name == "@" || $name === "") { $this->name = $name; } else { throw new Scalr_Net_Dns_Exception(sprintf(_("'%s' is not a valid name for NS record"), $name)); } } elseif (!$this->validator->IsIPAddress(rtrim($name, "."))) { $this->name = $this->dottify($name); } else { throw new Scalr_Net_Dns_Exception(sprintf(_("'%s' is not a valid name for NS record"), $name)); } if (!$this->validator->IsDomain($value)) { if ($this->validator->MatchesPattern($value, self::PAT_NON_FDQN) || $this->validator->IsIPAddress($value)) { $this->rname = $value; } else { throw new Scalr_Net_Dns_Exception(sprintf(_("'%s' is not a valid value for NS record"), $value)); } } else { $this->rname = $value; } $this->ttl = $ttl; }
function __construct($name, $value, $ttl = false, $class = "IN") { parent::__construct(); // Name if ($this->validator->validateDomain($name) !== true) { if ($name == "@" || $name === "") { $this->name = $name; } else { throw new Scalr_Net_Dns_Exception(sprintf(_("'%s' is not a valid name for NS record"), $name)); } } elseif ($this->validator->validateIp(rtrim($name, ".")) !== true) { $this->name = $this->dottify($name); } else { throw new Scalr_Net_Dns_Exception(sprintf(_("'%s' is not a valid name for NS record"), $name)); } if ($this->validator->validateDomain($value) !== true) { if ($this->validator->validateRegexp($value, self::PAT_NON_FDQN) === true || $this->validator->validateIp($value) === true) { $this->rname = $value; } else { throw new Scalr_Net_Dns_Exception(sprintf(_("'%s' is not a valid value for NS record"), $value)); } } else { $this->rname = $value; } $this->ttl = $ttl; }
/** * Constructor * * @param string $name * @param string $ip * @param integer $ttl */ function __construct($name, $value, $ttl = false) { parent::__construct(); // Name if (($this->validator->MatchesPattern($name, self::PAT_NON_FDQN) || $name == "@" || $name === "" || $name == "*" || $this->validator->MatchesPattern($name, "/^\\*\\.[A-Za-z0-9]+[A-Za-z0-9\\-\\.]+[A-Za-z]+\\.\$/") || $this->validator->IsDomain($name)) && !$this->validator->IsIPAddress(rtrim($name, "."))) { $this->name = $name; } else { throw new Scalr_Net_Dns_Exception(sprintf(_("'%s' is not a valid name for A record"), $name)); } if (!$this->validator->IsIPAddress($value)) { throw new Scalr_Net_Dns_Exception(sprintf(_("'%s' is not a valid value address for A record"), $value)); } else { $this->ip = $value; } $this->ttl = $ttl; }
/** * Constructor * * @param string $name * @param string $ip * @param integer $ttl */ function __construct($name, $value, $ttl = false) { parent::__construct(); // Name if (($this->validator->validateRegexp($name, self::PAT_NON_FDQN) === true || $name == "@" || $name === "" || $name == "*" || $this->validator->validateRegexp($name, '/^\\*\\.[A-Za-z0-9]+[A-Za-z0-9\\-\\.]+[A-Za-z]+\\.$/') === true || $this->validator->validateDomain($name) === true) && $this->validator->validateIp(rtrim($name, ".")) !== true) { $this->name = $name; } else { throw new Scalr_Net_Dns_Exception(sprintf(_("'%s' is not a valid name for A record"), $name)); } if ($this->validator->validateIp($value) !== true) { throw new Scalr_Net_Dns_Exception(sprintf(_("'%s' is not a valid value address for A record"), $value)); } else { $this->ip = $value; } $this->ttl = $ttl; }
public function __construct($name, $nameserver, $email, $ttl = false, $serial = false, $refresh = false, $retry = false, $expire = false, $minimum = false) { parent::__construct(); // Defaults if (!$refresh) { $refresh = self::DEFAULT_REFRESH; } if (!$retry) { $retry = self::DEFAULT_RETRY; } if (!$expire) { $expire = self::DEFAULT_EXPIRY; } if (!$minimum) { $minimum = self::DEFAULT_MINIMUM; } if (!$serial) { $serial = date("Ymd") . "01"; } // Email $this->email = str_replace('@', '.', $email); $this->email = trim($this->email, '.') . '.'; // Name if (!$this->validator->IsDomain($name)) { throw new Scalr_Net_Dns_Exception(sprintf(_("'%s' is not a valid name for SOA record"), $name)); } else { $this->name = $this->dottify($name); } // Nameserver if (!$this->validator->IsDomain($nameserver)) { throw new Scalr_Net_Dns_Exception(sprintf(_("'%s' is not a valid nameserver for SOA record"), $nameserver)); } else { $this->nameserver = $this->dottify($nameserver); } // TTL $this->ttl = $ttl; // Serial $this->serial = $serial; // Refresh $this->refresh = $refresh; // Retry $this->retry = $retry; // Expire $this->expire = $expire; // Minimum $this->minimum = $minimum; }
/** * Constructor * * @param string $name * @param string $rname * @param integer $ttl * @param string $class */ function __construct($name, $value, $ttl = false) { parent::__construct(); // Name $vname = str_replace("_", "", $name); if (($this->validator->MatchesPattern($vname, self::PAT_NON_FDQN) || $vname == "@" || $vname === "" || $this->validator->IsDomain($vname)) && !$this->validator->IsIPAddress(rtrim($vname, "."))) { $this->name = $name; } else { throw new Scalr_Net_Dns_Exception(sprintf(_("'%s' is not a valid name for TXT record"), $name)); } if (strlen($value) > 255) { throw new Scalr_Net_Dns_Exception(sprintf(_("Value fro TXT record cannot be longer than 255 chars"))); } else { $this->value = $value; } $this->ttl = $ttl; }
/** * Constructor * * @param string $name * @param string $rname * @param integer $pref * @param integer $ttl * @param string $class */ function __construct($name, $value, $ttl = false, $priority = 10) { parent::__construct(); // Name if (($this->validator->MatchesPattern($name, self::PAT_NON_FDQN) || $name == "@" || $name === "" || $this->validator->IsDomain($name)) && !$this->validator->IsIPAddress(rtrim($name, "."))) { $this->name = $name; } else { throw new Scalr_Net_Dns_Exception(sprintf(_("'%s' is not a valid name for MX record"), $name)); } if (($this->validator->MatchesPattern($value, self::PAT_NON_FDQN) || $this->validator->IsDomain($value)) && !$this->validator->IsIPAddress(rtrim($value, "."))) { $this->rname = $value; } else { throw new Scalr_Net_Dns_Exception(sprintf(_("'%s' is not a valid value for MX record"), $value)); } $this->priority = $priority; $this->ttl = $ttl; }
/** * Constructor * * @param string $name * @param string $rname * @param integer $pref * @param integer $ttl * @param string $class */ function __construct($name, $value, $ttl = false, $priority = 10) { parent::__construct(); // Name if (($this->validator->validateRegexp($name, self::PAT_NON_FDQN) === true || $name == "@" || $name === "" || $this->validator->validateDomain($name) === true) && $this->validator->validateIp(rtrim($name, ".")) !== true) { $this->name = $name; } else { throw new Scalr_Net_Dns_Exception(sprintf(_("'%s' is not a valid name for MX record"), $name)); } if (($this->validator->validateRegexp($value, self::PAT_NON_FDQN) === true || $this->validator->validateDomain($value) === true) && $this->validator->validateIp(rtrim($value, ".")) !== true) { $this->rname = $value; } else { throw new Scalr_Net_Dns_Exception(sprintf(_("'%s' is not a valid value for MX record"), $value)); } $this->priority = $priority; $this->ttl = $ttl; }
/** * Constructor * * @param string $name * @param string $rname * @param integer $ttl * @param string $class */ function __construct($name, $value, $ttl = false, $priority = 0, $weight = 0, $port = 0) { parent::__construct(); $chunks = explode(".", $name); $service = trim(array_shift($chunks), "_"); $proto = trim(array_shift($chunks), "_"); $nname = implode(".", $chunks); // Name if (($this->validator->MatchesPattern($nname, self::PAT_NON_FDQN) || $nname === "" || $this->validator->IsDomain($nname)) && !$this->validator->IsIPAddress(rtrim($nname, "."))) { // } else { throw new Scalr_Net_Dns_Exception(sprintf(_("'%s' is not a valid name for SRV record"), $nname)); } if (!preg_match("/^[A-Za-z-]+\$/", $service) && $service != '*') { throw new Scalr_Net_Dns_Exception(sprintf(_("'%s' is not a valid service for SRV record"), $service)); } if ($proto != 'udp' && $proto != 'tcp') { throw new Scalr_Net_Dns_Exception(sprintf(_("'%s' is not a valid protocol for SRV record"), $proto)); } $this->name = $name; $priority = (int) $priority; $weight = (int) $weight; $port = (int) $port; if ($priority < 0 || $priority > 65535) { throw new Scalr_Net_Dns_Exception(sprintf(_("Priority for SRV record should be between 0 and 65535"))); } else { $this->priority = $priority; } if ($weight < 0 || $weight > 65535) { throw new Scalr_Net_Dns_Exception(sprintf(_("Weight for SRV record should be between 0 and 65535"))); } else { $this->weight = $weight; } if ($port < 0 || $port > 65535) { throw new Scalr_Net_Dns_Exception(sprintf(_("Port for SRV record should be between 0 and 65535"))); } else { $this->port = $port; } if (($this->validator->MatchesPattern($value, self::PAT_NON_FDQN) || $this->validator->IsDomain($value)) && !$this->validator->IsIPAddress(rtrim($value, "."))) { $this->target = $value; } else { throw new Scalr_Net_Dns_Exception(sprintf(_("'%s' is not a valid target for SRV record"), $value)); } $this->ttl = $ttl; }
/** * Constructor * * @param string $name * @param string $rname * @param integer $ttl * @param string $class */ function __construct($name, $value, $ttl = false) { parent::__construct(); $this->type = "CNAME"; // Name if ($this->validator->MatchesPattern($name, self::PAT_NON_FDQN) || $this->validator->MatchesPattern($name, '/^\\*\\.[A-Za-z0-9]+$/si') || $this->validator->MatchesPattern($name, '/^[A-Za-z0-9]+[_\\.A-Za-z0-9-]*[A-Za-z0-9]+$/si') || $this->validator->IsDomain($name) && !$this->validator->IsIPAddress(rtrim($name, ".")) || $name == "*") { $this->name = $name; } else { throw new Scalr_Net_Dns_Exception(sprintf(_("'%s' is not a valid name for CNAME record"), $name)); } // cname if (!$this->validator->IsDomain($value)) { if ($this->validator->MatchesPattern($value, self::PAT_NON_FDQN) || $this->validator->MatchesPattern($value, '/^[A-Za-z0-9]+[_\\.A-Za-z0-9-]*[A-Za-z0-9]+[\\.]*$/si')) { $this->cname = $value; } else { throw new Scalr_Net_Dns_Exception(sprintf(_("'%s' is not a valid value for CNAME record"), $value)); } } else { $this->cname = $this->dottify($value); } $this->ttl = $ttl; }
/** * Constructor * * @param string $name * @param string $rname * @param integer $ttl * @param string $class */ function __construct($name, $value, $ttl = false) { parent::__construct(); $this->type = "CNAME"; // Name if ($this->validator->validateRegexp($name, self::PAT_NON_FDQN) === true || $this->validator->validateRegexp($name, '/^\\*\\.[A-Za-z0-9\\-\\.]+[A-Za-z0-9]+$/si') === true || $this->validator->validateRegexp($name, '/^[_A-Za-z0-9]+[_\\.A-Za-z0-9-]*[A-Za-z0-9]+[\\.]*$/si') === true || $this->validator->validateDomain($name) === true && $this->validator->validateIp(rtrim($name, ".")) !== true || $name == "*") { $this->name = $name; } else { throw new Scalr_Net_Dns_Exception(sprintf(_("'%s' is not a valid name for CNAME record"), $name)); } // cname if ($this->validator->validateDomain($value) !== true) { if ($this->validator->validateRegexp($value, self::PAT_NON_FDQN) === true || $this->validator->validateRegexp($value, '/^[_A-Za-z0-9]+[_\\.A-Za-z0-9-]*[A-Za-z0-9]+[\\.]*$/si') === true) { $this->cname = $value; } else { throw new Scalr_Net_Dns_Exception(sprintf(_("'%s' is not a valid value for CNAME record"), $value)); } } else { $this->cname = $this->dottify($value); } $this->ttl = $ttl; }