public function check_record_type($content) { if (preg_match(VALID_RECORD_TYPE, $content) === 0) { return array("message" => "Record has invalid type", "code" => "RECORD_INVALID_TYPE"); } if ($this->record_mode == "ADD") { if (!defined("TESTING_MODE")) { if ($this->type != 'CNAME' && in_array($this->name, RecordValidator::$cnames)) { return array("message" => sprintf("Cannot add a new record of type %s when a CNAME record is being inserted for %s", $this->type, $this->name), "code" => "RECORD_CNAME_ALREADY_INSERT"); } else { if ($this->type == 'CNAME' && in_array($this->name, RecordValidator::$others)) { return array("message" => sprintf("Cannot add a new CNAME record when a record of another type is being inserted for %s", $this->name), "code" => "RECORD_CNAME_OTHER_INSERT"); } } if ($this->type != 'CNAME' && HelperFunctions::has_records_of_type($this->name, array("CNAME"), RecordValidator::$deletions) != false) { return array("message" => sprintf("Cannot add a new record of type %s when a CNAME record is already present for %s", $this->type, $this->name), "code" => "RECORD_CNAME_ALREADY_PRESENT"); } else { if ($this->type == 'CNAME' && HelperFunctions::has_records_of_type($this->name, array("!CNAME"), RecordValidator::$deletions) != false) { return array("message" => sprintf("Cannot add a new CNAME record when a record of another type is already present for %s", $this->name), "code" => "RECORD_CNAME_OTHER_PRESENT"); } } } if ($this->type == 'CNAME') { RecordValidator::$cnames[] = $this->name; } else { RecordValidator::$others[] = $this->name; } } if ($this->record_mode == "DELETE") { if ($this->type == "MX" || $this->type == "SRV") { RecordValidator::$deletions[] = array("name" => $this->name, "type" => $this->type, "content" => $this->content, "priority" => $this->priority); } else { RecordValidator::$deletions[] = array("name" => $this->name, "type" => $this->type, "content" => $this->content); } } return true; }