{ $exception = new ErrorList(); $Registry = $RegistryModuleFactory->GetRegistryByExtension($_SESSION["domaininfo"]["extension"]); $registry_config = $Registry->GetManifest()->GetSectionConfig(); $RegistryContacts = UI::GetContactsListForSmarty($registry_config); $display["TLD"] = $_SESSION["domaininfo"]["extension"]; foreach ($RegistryContacts as $k=>$v) { if (!$_POST[$v["type"]] && $v["isrequired"] == 1) { $message = sprintf(_("%s contact not specified"), $v["name"]); $exception->AddMessage(sprintf(_("%s contact not specified"), $v["name"])); } else if ($_POST[$v["type"]]) { try { $Contact = DBContact::GetInstance()->LoadByCLID($_POST[$v["type"]]); if ($Contact->HasPendingOperation(Registry::OP_CREATE_APPROVE) || $Contact->HasPendingOperation(Registry::OP_UPDATE_APPROVE)) { $exception->AddMessage( sprintf(_("Contact <%s> is not yet approved by administrator"), $Contact->GetTitle())); } else { // Accept contact
/** * Set contact data fields * * @param array(key=>value) $data * @throws ErrorList */ public function SetFieldList ($data, $strict=true) { $data = array_map("trim", $data); $ErrList = new ErrorList(); if (($callback = $this->Config->attributes()->validation_callback) != null) { list($class, $method) = explode('::', $callback); $func = array($class, $method); if (is_callable($func)) { $err = array(); try { $err = call_user_func($func, $data); } catch (Exception $e) { Log::Log(sprintf("Contact validation user-defined handler failed. %s", $e->getMessage())); } if ($err) { foreach ((array)$err as $errmsg) { $ErrList->AddMessage($errmsg); } } } } $buf = array(); $this->AcceptFieldList($this->Config->fields->field, $data, $buf, $ErrList, $strict); if ($this->Config->extra_fields) { foreach ($this->Config->extra_fields->children() as $n => $if) { $n = (string)$if->attributes()->field; $v = (string)$if->attributes()->value; if ($buf[$n] == $v) { $this->AcceptFieldList($if->children(), $data, $buf, $ErrList, $strict); } } } if ($ErrList->HasMessages() && $strict) { // remove duplicate messages $errors = array_unique($ErrList->GetAllMessages()); $ErrList = new ErrorList(); foreach ($errors as $err) $ErrList->AddMessage($err); throw $ErrList; } $this->StrictlyValidated = $strict; $this->Fields = $buf; }
public function Run(Domain $Domain) { Log::Log("Start domain registration action", E_USER_NOTICE); $ErrList = new ErrorList(); if (!($Domain->Name && $Domain->Period && $Domain->UserID)) { throw new Exception("Domain must have name, period and userid filled"); } if ($this->do_check) { // Perform a domain check $chk = $this->Registry->DomainCanBeRegistered($Domain); if (!$chk->Result) { throw new Exception("Domain cannot be registered" . ($chk->Reason ? ". Reason: {$chk->Reason}" : "")); } } if ($this->period) { $Domain->Period = $this->period; } else { self::ValidatePeriod($Domain->Period, $this->Registry); } /* * Set nameservers */ if (!$this->managed_dns_enabled) { $domain_hostname = $Domain->GetHostName(); foreach ($this->nameserver_list as $Nameserver) { if (FQDN::IsSubdomain($Nameserver->HostName, $domain_hostname)) { $ErrList->AddMessage(sprintf(_("%s cannot be used as nameserver because %s is not registered yet."), $Nameserver->HostName, $domain_hostname)); } } } // Break on errors $this->ExceptionOnErrors($ErrList); $Domain->IsManagedDNSEnabled = $this->managed_dns_enabled; $Domain->SetNameserverList($this->nameserver_list); /* * Set contacts */ foreach ($this->contact_list as $ctype => $Contact) { try { $Domain->SetContact($Contact, $ctype); } catch (Exception $e) { $ErrList->AddMessage(sprintf(_("Cannot set %s contact to %s. %s"), $ctype, $clid, $e->getMessage())); } } // Break on errors $this->ExceptionOnErrors($ErrList); /* * Set additional domain data */ if ($this->extra_data) { foreach ($this->extra_data as $field) { $Domain->SetExtraField($field['name'], $this->extra_data[$field['name']]); } } /* * Register domain */ if ($Domain->IncompleteOrderOperation == INCOMPLETE_OPERATION::DOMAIN_CREATE) { Log::Log("Trying to register domain. (Postpaid)", E_USER_NOTICE); try { $this->Registry->CreateDomain($Domain, $Domain->Period, $this->extra_data); return $Domain->HasPendingOperation(Registry::OP_CREATE) ? RegisterDomainAction_Result::PENDING : RegisterDomainAction_Result::OK; } catch (Exception $e) { Log::Log($e->getMessage(), E_USER_ERROR); throw new RegisterDomainAction_Exception($e->getMessage()); } } else { $Domain->Status = DOMAIN_STATUS::AWAITING_PAYMENT; try { DBDomain::GetInstance()->Save($Domain); } catch (Exception $e) { Log::Log($e->getMessage(), E_USER_ERROR); throw new RegisterDomainAction_Exception(sprintf(_('Cannot save domain. Reason: %s'), $e->getMessage())); } try { $Invoice = new Invoice(INVOICE_PURPOSE::DOMAIN_CREATE, $Domain->ID, $Domain->UserID); $Invoice->Description = sprintf(_("%s domain name registration for %s year(s)"), $Domain->GetHostName(), $Domain->Period); if ($this->Order) { // In case of order add invoice. $this->Order->AddInvoice($Invoice); // Save operation must be called from order } else { $Invoice->Save(); $this->Invoice = $Invoice; } return RegisterDomainAction_Result::INVOICE_GENERATED; } catch (Exception $e) { throw new RegisterDomainAction_Exception(sprintf(_("Cannot create invoice. Reason: %s"), $e->getMessage())); } } }
function _testErrorList() { $ErrList = new ErrorList(); $ErrList->AddMessage('Invalid parameter value: 3'); $ErrList->AddMessage('Access denied for user piska'); throw $ErrList; }
protected function PostNS() { $ErrList = new ErrorList(); $Validator = Core::GetValidatorInstance(); if (!$attr["enable_managed_dns"]) { foreach (array("ns1", "ns2") as $k) { if (!$Validator->IsDomain($this->attr[$k])) { $ErrList->AddMessage(sprintf(_("%s is not a valid host"), $this->attr[$k])); } } if ($attr["ns1"] && $attr["ns1"] == $attr["ns2"]) { $ErrList->AddMessage(_("You cannot use the same nameserver twice.")); } if ($ErrList->HasMessages()) { throw $ErrList; } $this->ns = array($this->attr["ns1"], $this->attr["ns2"]); } else { $this->ns = array(CONFIG::$NS1, CONFIG::$NS2); } }
@set_time_limit(999999); if (Client::Load($_SESSION['userid'])->GetSettingValue('domain_preorder') != 1) { CoreUtils::Redirect("index.php"); } if ($_POST) { $Validator = new Validator(); $lines = explode("\n", $post_domains); $err = array(); foreach ($lines as $k => $line) { try { $ErrorList = new ErrorList(); $chunks = explode(",", $line); $domainname = trim($chunks[0]); $expiredate = trim($chunks[1]); if (!preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}\$/", $expiredate) || !strtotime($expiredate)) { $ErrorList->AddMessage(sprintf(_("Incorrect expiration date (%s) for domain %s."), $expiredate, $domainname)); throw $ErrorList; } if (!$Validator->IsDomain($domainname)) { $ErrorList->AddMessage(sprintf(_("Incorrect domain name %s"), $domainname)); throw $ErrorList; } $dmn_chunks = explode(".", $domainname); $domain_name = array_shift($dmn_chunks); $extension = implode(".", $dmn_chunks); if (!$Registries[$extension]) { try { $Registries[$extension] = RegistryModuleFactory::GetInstance()->GetRegistryByExtension($extension); } catch (Exception $e) { $ErrorList->AddMessage(sprintf(_("Error while processing domain %s: %s"), $domainname, $e->getMessage())); throw $ErrorList;