Пример #1
0
 function __construct(AbstractRegistryModule $reg_module)
 {
     $this->DB = Core::GetDBInstance();
     $this->DBDomain = DBDomain::GetInstance();
     $this->DBContact = DBContact::GetInstance();
     $this->DBHameserverHost = DBNameserverHost::GetInstance();
     $this->RegModule = $reg_module;
     $this->Manifest = $reg_module->Manifest;
     $this->Extension = $reg_module->Extension;
     //$reg_module->SetRegistryAccessible(new RegistryAccessible($this));
     $reg_module->SetRegistryAccessible($this);
     // Get interfaces implemented by module
     $impls = (array) class_implements(get_class($reg_module));
     $this->ObserverImplemented = in_array('IRegistryObserver', $impls);
     $this->ServerPollableImplemented = in_array('IRegistryModuleServerPollable', $impls);
     $this->ClientPollableImplemented = in_array('IRegistryModuleClientPollable', $impls);
 }
 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()));
     }
 }
Пример #3
0
 public function __construct()
 {
     $this->DB = Core::GetDBInstance();
     $this->DBContact = DBContact::GetInstance();
     $this->DBNameserverHost = DBNameserverHost::GetInstance();
 }
Пример #4
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);
 }
Пример #5
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=?",