Ejemplo n.º 1
0
 /**
  * @return DBNameserverHost
  */
 public static function GetInstance()
 {
     if (self::$Instance === null) {
         self::$Instance = new DBNameserverHost();
     }
     return self::$Instance;
 }
Ejemplo n.º 2
0
 /**
  * Update nameserver host. update IP
  * @access public
  * @param NameserverHost $ns
  * @return NameserverHost
  */
 public function UpdateNameserverHost(NameserverHost $ns)
 {
     $this->FireEvent('BeforeUpdateNameserverHost', $ns, $this->DBHameserverHost->GetInitialState($ns));
     $Resp = $this->RegModule->UpdateNameserverHost($ns);
     $this->ValidateModuleResponse($Resp, 'UpdateNameserverHostResponse');
     if ($Resp->IsFailed()) {
         Log::Log(sprintf('UpdateNameserverHost failed. Registry error: %s', $Resp->ErrMsg), E_USER_ERROR);
         throw new RegistryException($Resp->ErrMsg, $Resp->Code);
     }
     if ($Resp->Succeed()) {
         $this->FireEvent('NameserverHostUpdated', $ns);
     } else {
         if ($Resp->Pending()) {
             $this->AddPendingOperation($ns, self::OP_UPDATE, $Resp->OperationId);
         }
     }
     return $ns;
 }
Ejemplo n.º 3
0
 public function Delete(Domain $domain)
 {
     $this->DB->BeginTrans();
     try {
         $this->DB->Execute('DELETE FROM domains WHERE id = ?', array($domain->ID));
         $this->DB->Execute('DELETE FROM domains_data WHERE domainid = ?', array($domain->ID));
         $this->DB->Execute('DELETE FROM domains_flags WHERE domainid = ?', array($domain->ID));
         $this->DB->Execute("UPDATE zones SET isdeleted = '1' WHERE zone=?", array($domain->GetHostName()));
         $purposes = implode(',', array($this->DB->qstr(INVOICE_PURPOSE::DOMAIN_CREATE), $this->DB->qstr(INVOICE_PURPOSE::DOMAIN_RENEW), $this->DB->qstr(INVOICE_PURPOSE::DOMAIN_TRANSFER), $this->DB->qstr(INVOICE_PURPOSE::DOMAIN_TRADE)));
         $this->DB->Execute("UPDATE invoices SET itemid=0, status=IF(status = 0, 2, status) WHERE itemid=? AND purpose IN ({$purposes})", array($domain->ID));
         $this->DBNameserverHost->DeleteList($domain->ID);
         $domain->ID = null;
     } catch (Exception $e) {
         $this->DB->RollbackTrans();
         Log::Log(sprintf("DBDomain::Delete failed. %s", $e->getMessage()), E_ERROR);
         throw new ApplicationException($e->getMessage(), $e->getCode());
     }
     $this->DB->CompleteTrans();
     // Remove it from loaded objects storage
     unset($this->LoadedObjects[$domain->ID]);
 }
 public function Run($userid)
 {
     try {
         $Factory = RegistryModuleFactory::GetInstance();
         $Registry = $Factory->GetRegistryByExtension($this->Domain->Extension);
         $host_as_attr = (bool) $Registry->GetManifest()->GetRegistryOptions()->ability->hostattr;
     } catch (Exception $e) {
         throw new UpdateDomainNameserversAction_Exception(sprintf(_("Cannot change nameservers. Reason: %s"), $e->getMessage()));
     }
     // Check that all nameserver hosts are registered
     foreach ($this->nslist as &$NS) {
         $glue_record = preg_match("/^(.*)\\.{$this->Domain->GetHostName()}\$/", $NS->HostName, $matches);
         if ($glue_record) {
             $known_ns = $this->Db->GetRow("SELECT * FROM nhosts WHERE hostname=? AND domainid=?", array($matches[1], $this->Domain->ID));
             if (!$known_ns) {
                 if ($host_as_attr) {
                     // No need to register nameserver hosts
                     $this->Db->Execute("INSERT INTO nhosts SET domainid = ?, hostname = ?, ipaddr = ?", array($this->Domain->ID, $matches[1], $NS->IPAddr));
                 } else {
                     throw new UpdateDomainNameserversAction_Exception(sprintf(_("Nameserver %s does not exist"), $NS->HostName), UpdateDomainNameserversAction_Exception::NAMESERVERHOST_NOT_REGISTERED);
                 }
             } else {
                 $NS = new NameserverHost($NS->HostName, $host_as_attr ? $NS->IPAddr : $known_ns['ipaddr']);
                 $NS->ID = $known_ns['id'];
             }
         }
     }
     // Perform nameservers update
     try {
         $Changes = new Changelist($this->Domain->GetNameserverList(), $this->nslist);
         $Registry->UpdateDomainNameservers($this->Domain, $Changes);
         $DBNSHost = DBNameserverHost::GetInstance();
         $DBNSHost->SaveList($this->Domain->GetNameserverHostList(), $this->Domain->ID);
         return $this->Domain->HasPendingOperation(Registry::OP_UPDATE) ? UpdateDomainNameserversAction_Result::PENDING : UpdateDomainNameserversAction_Result::OK;
     } catch (Exception $e) {
         throw new UpdateDomainNameserversAction_Exception(sprintf(_("Cannot change nameservers. Reason: %s"), $e->getMessage()));
     }
 }
Ejemplo n.º 5
0
 function _testOTE()
 {
     $DbDomain = DBDomain::GetInstance();
     $DbNameserverHost = DBNameserverHost::GetInstance();
     // Cleanup previous execution traces
     try {
         $this->Module->Request("domain-delete", array("name" => "testeppart.kz"));
     } catch (Exception $e) {
     }
     try {
         $Domain = $DbDomain->LoadByName('testeppart', 'kz');
         $this->Registry->DeleteDomain($Domain);
     } catch (Exception $e) {
     }
     try {
         $this->Module->Request("domain-delete", array("name" => "newtesteppart.kz"));
     } catch (Exception $e) {
     }
     try {
         $Domain = $DbDomain->LoadByName('newtesteppart', 'kz');
         $this->Registry->DeleteDomain($Domain);
     } catch (Exception $e) {
     }
     //
     // 1. Create domain
     //
     $Contact = $this->Registry->NewContactInstance(CONTACT_TYPE::REGISTRANT);
     $Contact->SetFieldList($this->contact_fields);
     $this->Registry->CreateContact($Contact);
     $Domain = $this->Registry->NewDomainInstance();
     $Domain->UserID = 39;
     $Domain->Name = 'testeppart';
     $Domain->Period = 1;
     $Domain->SetContact($Contact, CONTACT_TYPE::REGISTRANT);
     $Domain->SetContact($Contact, CONTACT_TYPE::ADMIN);
     $Domain->SetContact($Contact, CONTACT_TYPE::TECH);
     $Domain->SetContact($Contact, CONTACT_TYPE::BILLING);
     $this->Registry->CreateDomain($Domain, $Domain->Period);
     $NS1 = new NameserverHost('ns1.testeppart.kz', '212.110.212.110');
     $this->Registry->CreateNameserver($NS1);
     $NS2 = new NameserverHost('ns2.testeppart.kz', '212.110.111.111');
     $this->Registry->CreateNameserver($NS2);
     $Changelist = $Domain->GetNameserverChangelist();
     $Changelist->Add($NS1);
     $Changelist->Add($NS2);
     $this->Registry->UpdateDomainNameservers($Domain, $Changelist);
     $this->AssertTrue(date('Ymd', $Domain->ExpireDate) == date('Ymd', strtotime('+1 year')) && count($Domain->GetNameserverList()) == 2, 'Create domain');
     // Reload domain from Db for correct operations
     $Domain = $DbDomain->LoadByName('testeppart', 'kz');
     $DbNameserverHost->LoadList($Domain->ID);
     //
     // 2. Update nameserver host
     //
     $nslist = $Domain->GetNameserverList();
     $NS2 = $nslist[1];
     $NS2->IPAddr = '212.111.110.110';
     $this->Registry->UpdateNameserverHost($NS2);
     $this->assertTrue(true, 'Update nameserver host');
     //
     // 3. Create nameserver host
     //
     $Domain4Host = $this->Registry->NewDomainInstance();
     $Domain->UserID = 39;
     $Domain->Name = 'newtesteppart';
     $Domain->Period = 1;
     $Domain->SetContact($Contact, CONTACT_TYPE::REGISTRANT);
     $this->Registry->CreateDomain($Domain, $Domain->Period);
     $NS3 = new NameserverHost('ns.newtesteppart.kz', '211.211.211.211');
     $this->Registry->CreateNameserverHost($NS3);
     $this->assertTrue(true, 'Create nameserver host');
     //
     // 4. Add nameserver to domain
     //
     $Changelist = $Domain->GetNameserverChangelist();
     $Changelist->Add($NS3);
     $this->Registry->UpdateDomainNameservers($Domain, $Changelist);
     $this->assertTrue(count($Domain->GetNameserverList()) == 3, 'Add nameserver to domain');
     //
     // 5. Remove nameserver from domain
     //
     $nslist = $Domain->GetNameserverList();
     $NS1 = $nslist[0];
     $Changelist = $Domain->GetNameserverChangelist();
     $Changelist->Remove($NS1);
     $this->Registry->UpdateDomainNameservers($Domain, $Changelist);
     $this->assertTrue(count($Domain->GetNameserverList()) == 2, 'Remove nameserver from domain');
     //
     // 6. Delete nameserver host
     //
     try {
         $this->Registry->DeleteNameserverHost($NS1);
         $this->assertTrue(true, 'Delete nameserver host');
     } catch (Exception $e) {
         $this->assertTrue(true, 'Delete nameserver host failed. Don\'t forget to cheat response code');
     }
     //
     // 7. Update contact
     //
     $contact_fields = $Contact->GetFieldList();
     $contact_fields['voice'] = '+380-555-7654321';
     $this->Registry->UpdateContact($Contact);
     $this->assertTrue(true, 'Update contact');
     //
     // 8. Start ingoing transfer
     //
     $TrnDomain = $this->Registry->NewDomainInstance();
     $TrnDomain->Name = 'xyz1';
     $TrnDomain->UserID = 39;
     $this->Registry->TransferRequest($TrnDomain, array('pw' => '123456'));
     $this->Registry->DeleteDomain($Domain);
     $this->Registry->DeleteContact($Contact);
 }
Ejemplo n.º 6
0
	require_once('src/prepend.inc.php');
	
	if (isset($req_domainid))
		require_once("src/set_managed_domain.php");
	else
		require_once("src/get_managed_domain_object.php");

	if ($Domain->Status != DOMAIN_STATUS::DELEGATED)
	{
		$errmsg = _("Domain status prohibits operation");
		CoreUtils::Redirect("domains_view.php");
	}
		
	// Get User info
	$user = $db->GetRow("SELECT * FROM users WHERE id=?", array($Domain->UserID));
	$DBNSHost = DBNameserverHost::GetInstance();

	if ($_POST)
	{
		$Validator = new Validator();
		$nshost_list = $DBNSHost->LoadList($Domain->ID);		
		
		
		// if add new host
		if ($post_add)
		{
			// Check host in database
			$chk = $db->GetRow("
				SELECT * 
				FROM nhosts 
				WHERE hostname=? AND domainid=?",