예제 #1
0
 public function OnStartForking()
 {
     // Initialization
     $Db = Core::GetDBInstance();
     $DbDomain = DBDomain::GetInstance();
     $Whois = JWhois::GetInstance();
     // Grep TLDs
     $data = $Db->GetAll("SELECT TLD FROM tlds WHERE modulename = 'Verisign' AND isactive = 1");
     foreach ($data as $row) {
         $tlds[] = "'{$row['TLD']}'";
     }
     $tlds = join(',', $tlds);
     // Grep domains
     $domain_data = $Db->GetAll("\r\n\t\t\t\tSELECT name, TLD FROM domains \r\n\t\t\t\tWHERE\r\n\t\t\t\t-- TLD in matching list\r\n\t\t\t\tTLD IN ({$tlds})\r\n\t\t\t\t-- Today is anniversary of registration\r\n\t\t\t\tAND ((MONTH(NOW()) = MONTH(start_date) AND DAY(NOW()) = DAY(start_date))\r\n\t\t\t\t-- Today is 28/02 and domain was registered 29/02 at leap year \r\n\t\t\t\tOR (MONTH(NOW()) = 2 AND DAY(NOW()) = 28 AND MONTH(start_date) = 2 AND DAY(start_date) = 29))\r\n\t\t\t");
     foreach ($domain_data as $row) {
         try {
             $Domain = $DbDomain->LoadByName($row['name'], $row['TLD']);
             $Client = Client::Load($Domain->UserID);
             // Send notice
             $emlvars = array('whois' => $Whois->Whois($Domain->GetHostName()), 'Client' => $Client);
             mailer_send("wdrp_notice.eml", $emlvars, $Client->Email, $Client->Name);
         } catch (Exception $e) {
             Log::Log(sprintf("Failed to sent notice about %s. %s", "{$row['name']}.{$row['TLD']}", $e->getMessage()), E_ERROR);
         }
     }
 }
예제 #2
0
 /**
  * @return DBDomain
  */
 public static function GetInstance()
 {
     if (self::$Instance === null) {
         self::$Instance = new DBDomain();
     }
     return self::$Instance;
 }
예제 #3
0
 /**
  * Renew domain
  * @param $params = array(
  *  	name		string
  *   	period		int
  *    	userId		int						User ID (In admin mode)
  *    	noBilling	bool					Disable billing for domain opeartion (In admin mode)
  * )
  * @return object
  */
 function RenewDomain($params = null)
 {
     // Check params
     if ($this->access_mode == self::ACCESS_MODE_ADMIN) {
         if (!$params["userId"]) {
             throw new Exception(sprintf("'%s' parameter is required", "userId"));
         }
     } else {
         // Reset user disabled params
         $params["noBilling"] = false;
     }
     $user_id = $this->user_id ? $this->user_id : $params["userId"];
     if (!$params["name"]) {
         throw new Exception(sprintf("'%s' parameter is required", "name"));
     }
     $period = (int) $params["period"] ? (int) $params["period"] : 1;
     list($name, $tld) = explode(".", $params["name"], 2);
     $registry = $this->registry_factory->GetRegistryByExtension($tld);
     $domain = DBDomain::GetInstance()->LoadByName($name, $tld);
     $domain->Period = $period;
     if (!$params["noBilling"]) {
         // Check that enougth money
         $client = Client::Load($user_id);
         $balance = DBBalance::GetInstance()->LoadClientBalance($user_id);
         $invoice = new Invoice(INVOICE_PURPOSE::DOMAIN_RENEW, $domain, $domain->UserID);
         $invoice->Description = sprintf(_("%s domain name renewal for %s year(s)"), $domain->GetHostName(), $period);
         $this->CheckEnoughtMoney($client, $balance, $invoice);
         $invoice->ItemID = $domain->ID;
         $this->MakePayment($client, $balance, $invoice);
     }
     $registry->RenewDomain($domain, array('period' => $domain->Period));
     return new stdClass();
 }
예제 #4
0
파일: tests.php 프로젝트: rchicoria/epp-drs
 function testImpendingExpiration()
 {
     $Domain = $this->Registry->NewDomainInstance();
     $Domain->Name = 'about-to-expire';
     $Domain->ID = 283;
     $Domain->UserID = 42;
     $Domain->ExpireDate = strtotime("2009-05-20 00:00:00");
     $Domain->CreateDate = strtotime("2008-05-20 00:00:00");
     $this->Registry->HandleImpendingExpiration($Domain);
     print "save domain";
     DBDomain::GetInstance()->Save($Domain);
     print "after save";
 }
예제 #5
0
 function DispatchPollUpdateDomain(PollUpdateDomainResponse $resp)
 {
     if ($resp->IsFailed()) {
         Log::Log(sprintf('DispatchPollUpdateDomain failed. Registry response: %s', $resp->ErrMsg), E_USER_ERROR);
         throw new Exception($resp->ErrMsg, $resp->Code);
     }
     if ($resp->Succeed()) {
         list($name, $extension) = FQDN::Parse($resp->HostName);
         $domain = $this->DBDomain->LoadByName($name, $extension, $this->GetManifest());
         if ($resp->Result) {
             $domain = $this->GetRemoteDomain($domain);
             $this->FireEvent('DomainOperation', $domain, self::OP_UPDATE);
             $this->FireEvent('DomainUpdated', $domain);
             $this->DBDomain->Save($domain);
         } else {
             $this->FireEvent('DomainOperation', $domain, self::OP_UPDATE, true, $resp->FailReason);
         }
         return true;
     }
 }
 public function OnPaid(Invoice $Invoice, AbstractPaymentModule $payment_module = null)
 {
     if (!in_array($Invoice->Purpose, $this->HandledPurposes)) {
         return;
     }
     Log::Log("PreregistrationInvoiceObserver::OnPaid(InvoiceID={$Invoice->ID})", E_USER_NOTICE);
     // Get domain information
     try {
         $Domain = DBDomain::GetInstance()->Load($Invoice->ItemID);
     } catch (Exception $e) {
         Log::Log("PreregistrationInvoiceObserver::OnPaid() thown exception: {$e->getMessage()}", E_USER_ERROR);
     }
     if ($Domain) {
         $Domain->Status = DOMAIN_STATUS::AWAITING_PREREGISTRATION;
         DBDomain::GetInstance()->Save($Domain);
     } else {
         // Domain not found
         Log::Log(sprintf("Domain width ID '%s' not found.", $Invoice->ItemID), E_ERROR);
     }
     // OnPaymentComplete routine succeffully completed.
     Log::Log("PreregistrationInvoiceObserver::OnPaid Successfully completed.", E_USER_NOTICE);
 }
예제 #7
0
 /**
  * Constructor
  *
  * @param string $purpose
  * @param integer $item_id
  * @param integer $user_id
  */
 function __construct($purpose, $item_id, $user_id)
 {
     $this->DB = Core::GetDBInstance();
     $this->UserID = $user_id;
     $this->Purpose = $purpose;
     $this->ItemID = $item_id;
     $this->Hidden = 0;
     $this->Status = INVOICE_STATUS::PENDING;
     $this->ActionStatus = INVOICE_ACTION_STATUS::PENDING;
     $userinfo = $this->DB->GetRow("SELECT * FROM users WHERE id=?", array($this->UserID));
     //
     // � ����������� �� ���������� ������� �������� ����� � ��������
     //
     switch ($this->Purpose) {
         case INVOICE_PURPOSE::DOMAIN_CREATE:
         case INVOICE_PURPOSE::DOMAIN_RENEW:
         case INVOICE_PURPOSE::DOMAIN_TRANSFER:
         case INVOICE_PURPOSE::DOMAIN_TRADE:
         case INVOICE_PURPOSE::PREREGISTRATION_DROPCATCHING:
             if (is_numeric($item_id)) {
                 $Domain = DBDomain::GetInstance()->Load($item_id);
             } else {
                 $Domain = $item_id;
                 $this->ItemID = $items_id = $Domain->ID;
             }
             if ($this->Purpose == INVOICE_PURPOSE::DOMAIN_CREATE || $this->Purpose == INVOICE_PURPOSE::DOMAIN_RENEW || $this->Purpose == INVOICE_PURPOSE::PREREGISTRATION_DROPCATCHING) {
                 $period = $Domain->Period;
             }
             $min_period = $this->Purpose == INVOICE_PURPOSE::DOMAIN_RENEW ? (int) $Domain->GetConfig()->renewal->min_period : 1;
             $period = max($period, $min_period);
             $price = $this->DB->GetRow("\r\n\t\t\t\t\t\tSELECT * FROM prices WHERE TLD=? AND purpose=? AND period=?", array($Domain->Extension, $this->Purpose, $period));
             if ($price === array()) {
                 throw new Exception(sprintf("Failed to find price for %s TLD: %s period: %s", $this->Purpose, $Domain->Extension, $period));
             }
             // Get discount
             if ($userinfo["packageid"] != 0) {
                 $discount = $this->DB->GetRow("SELECT * FROM discounts WHERE TLD=? AND purpose=? AND packageid=?", array($Domain->Extension, $this->Purpose, $userinfo["packageid"]));
                 $this->Discount = round($price["cost"] / 100 * $discount["discount"], 2);
             } else {
                 $this->Discount = 0;
             }
             $this->Total = $price["cost"] - $this->Discount;
             break;
     }
     // ����������� ���
     $this->VATPercent = 0;
     if ((double) $userinfo["vat"] > -1) {
         $this->VATPercent = (double) $userinfo["vat"];
     } else {
         $this->VATPercent = (double) $this->DB->GetOne("SELECT vat FROM countries WHERE code=?", array($userinfo["country"]));
     }
     if ($this->VATPercent > 0) {
         $this->VAT = round($this->Total / 100 * $this->VATPercent, 2);
         $this->Total = $this->Total + $this->VAT;
     } else {
         $this->VAT = 0;
     }
 }
예제 #8
0
파일: tests.php 프로젝트: rchicoria/epp-drs
        function _testBusy ()
        {
        	$DbDomain = DBDomain::GetInstance();
			$Domain = $DbDomain->LoadByName('kilo', 'tel');
			$this->Registry->CreateDomain($Domain, $Domain->Period);
        }
 public function OnPaid(Invoice $Invoice, AbstractPaymentModule $payment_module = null)
 {
     $db = Core::GetDBInstance();
     if (!in_array($Invoice->Purpose, $this->HandledPurposes)) {
         return;
     }
     Log::Log("RegistryInvoiceObserver::OnPaid(InvoiceID={$Invoice->ID})", E_USER_NOTICE);
     // Get domain information
     try {
         $Domain = DBDomain::GetInstance()->Load($Invoice->ItemID);
     } catch (Exception $e) {
         Log::Log("RegistryInvoiceObserver::OnPaid() thown exception: {$e->getMessage()}", E_USER_ERROR);
     }
     if ($Domain) {
         Log::Log("Invoice purpose: {$Invoice->Purpose}", E_USER_NOTICE);
         // Get user information
         $userinfo = $db->GetRow("SELECT * FROM users WHERE id=?", array($Domain->UserID));
         // Check command
         switch ($Invoice->Purpose) {
             case INVOICE_PURPOSE::DOMAIN_TRADE:
                 try {
                     $Action = new UpdateDomainContactAction($Invoice);
                     try {
                         $Action->Run();
                     } catch (UpdateDomainContactAction_Exception $e) {
                         Log::Log(sprintf("Trade failed. %s", $e->getMessage()), E_ERROR);
                         DBDomain::GetInstance()->Save($Action->GetDomain());
                         // Send mail
                         $args = array("client" => $userinfo, "Invoice" => $Invoice, "domain_name" => $Domain->Name, "extension" => $Domain->Extension, "domain_trade_failure_reason" => $e->getMessage());
                         mailer_send("domain_trade_action_required.eml", $args, $userinfo["email"], $userinfo["name"]);
                     }
                 } catch (LogicException $e2) {
                     Log::Log($e2->getMessage(), E_ERROR);
                 }
                 break;
             case INVOICE_PURPOSE::DOMAIN_CREATE:
                 if ($Domain->Status == DOMAIN_STATUS::AWAITING_PAYMENT || $Domain->Status == DOMAIN_STATUS::REJECTED) {
                     $Domain->Status = DOMAIN_STATUS::PENDING;
                     $Domain->IncompleteOrderOperation = INCOMPLETE_OPERATION::DOMAIN_CREATE;
                     $Domain = DBDomain::GetInstance()->Save($Domain);
                     // If domain has incomplete information skip domain creation. Update status to Pending.
                     if (count($Domain->GetContactList()) == 0 || count($Domain->GetNameserverList()) == 0) {
                         //
                         // Send mail
                         //
                         Log::Log("Domain registration process not completed. Need more information from client.", E_USER_NOTICE);
                         $args = array("client" => $userinfo, "Invoice" => $Invoice, "domain_name" => $Domain->Name, "extension" => $Domain->Extension);
                         mailer_send("domain_registration_action_required.eml", $args, $userinfo["email"], $userinfo["name"]);
                         // Write information in invoice
                         $Invoice->ActionStatus = INVOICE_ACTION_STATUS::FAILED;
                         $Invoice->ActionFailReason = _('Domain registration process not completed. Need more information from client.');
                     } else {
                         Log::Log("Trying to register domain", E_USER_NOTICE);
                         ///// get Registry instance and connect to registry server
                         try {
                             $Registry = RegistryModuleFactory::GetInstance()->GetRegistryByExtension($Domain->Extension);
                         } catch (Exception $e) {
                             Log::Log($e->getMessage(), E_ERROR);
                             return;
                         }
                         // Validate license for this module
                         if (!License::IsModuleLicensed($Registry->GetModuleName())) {
                             throw new LicensingException("Your license does not permit module {$Registry->ModuleName()}");
                         }
                         //
                         $extra_data = $db->GetAll("SELECT * FROM domains_data WHERE domainid=?", array($Domain->ID));
                         if ($extra_data && count($extra_data) > 0) {
                             foreach ($extra_data as $v) {
                                 $extra[$v["key"]] = $v["value"];
                             }
                         } else {
                             $extra = array();
                         }
                         // Try to create domain name
                         try {
                             $cr = $Registry->CreateDomain($Domain, $Domain->Period, $extra);
                         } catch (Exception $e) {
                             $args = array("client" => $userinfo, "Invoice" => $Invoice, "domain_name" => $Domain->Name, "extension" => $Domain->Extension, "domain_reg_failure_reason" => $e->getMessage());
                             mailer_send("domain_registration_action_required.eml", $args, $userinfo["email"], $userinfo["name"]);
                             // If domain not created
                             Log::Log("Cannot register domain name. Server return: " . $e->getMessage(), E_ERROR);
                             $Invoice->ActionStatus = INVOICE_ACTION_STATUS::FAILED;
                             $Invoice->ActionFailReason = $e->getMessage();
                         }
                         if ($cr) {
                             // If domain created
                             Log::Log(sprintf("Domain %s successfully registered. Updating database", $Domain->GetHostName()), E_USER_NOTICE);
                             $Invoice->ActionStatus = INVOICE_ACTION_STATUS::COMPLETE;
                         }
                     }
                 } else {
                     Log::Log("Domain status '{$Domain->Status}'. Expected 'Awaiting payment'", E_ERROR);
                     $retval = false;
                     $Invoice->ActionStatus = INVOICE_ACTION_STATUS::FAILED;
                     $Invoice->ActionFailReason = sprintf(_("Domain status '%s'. Expected 'Awaiting payment'"), $Domain->Status);
                 }
                 break;
             case INVOICE_PURPOSE::DOMAIN_TRANSFER:
                 if ($Domain->Status == DOMAIN_STATUS::AWAITING_PAYMENT) {
                     //
                     // Send mail
                     //
                     $args = array("client" => $userinfo, "domain_name" => $Domain->Name, "extension" => $Domain->Extension, "Invoice" => $Invoice);
                     mailer_send("domain_transfer_action_required.eml", $args, $userinfo["email"], $userinfo["name"]);
                     Log::Log("Domain transfer process not completed. Need more information from client.", E_USER_NOTICE);
                     $Domain->IncompleteOrderOperation = INCOMPLETE_OPERATION::DOMAIN_TRANSFER;
                     $Domain->Status = DOMAIN_STATUS::PENDING;
                     DBDomain::GetInstance()->Save($Domain);
                     $Invoice->ActionStatus = INVOICE_ACTION_STATUS::COMPLETE;
                 }
                 break;
             case INVOICE_PURPOSE::DOMAIN_RENEW:
                 // Renew domain name
                 Log::Log("Trying to renew domain", E_USER_NOTICE);
                 ///// Get registry instance and connect to registry server
                 try {
                     $Registry = RegistryModuleFactory::GetInstance()->GetRegistryByExtension($Domain->Extension);
                 } catch (Exception $e) {
                     Log::Log($e->getMessage(), E_ERROR);
                     return;
                 }
                 try {
                     $renew = $Registry->RenewDomain($Domain, array('period' => $Domain->Period));
                 } catch (Exception $e) {
                     $renew = false;
                     $err = $e->getMessage();
                 }
                 if ($renew) {
                     Log::Log("Domain successfully renewed.", E_USER_NOTICE);
                     $Invoice->ActionStatus = INVOICE_ACTION_STATUS::COMPLETE;
                     $Domain->DeleteStatus = DOMAIN_DELETE_STATUS::NOT_SET;
                     DBDomain::GetInstance()->Save($Domain);
                 } else {
                     $Domain->SetExtraField('RenewInvoiceID', $Invoice->ID);
                     DBDomain::GetInstance()->Save($Domain);
                     //
                     // Send mail here
                     //
                     $args = array("client" => $userinfo, "domain_name" => $Domain->Name, "extension" => $Domain->Extension, "reason" => $err, "years" => $Domain->Period);
                     mailer_send("renewal_failed.eml", $args, $userinfo["email"], $userinfo["name"]);
                     // If renew failed
                     Log::Log("Cannot renew domain name. Server return: " . $err, E_ERROR);
                     $Invoice->ActionStatus = INVOICE_ACTION_STATUS::FAILED;
                     $Invoice->ActionFailReason = $err;
                 }
                 /////
                 break;
         }
         $Invoice->Save();
     } else {
         // Domain not found
         Log::Log(sprintf("Domain width ID '%s' not found.", $Invoice->ItemID), E_ERROR);
     }
     // OnPaymentComplete routine succeffully completed.
     Log::Log("RegistryInvoiceObserver::OnPaid Successfully completed.", E_USER_NOTICE);
 }
예제 #10
0
		public function OnDomainTransferApproved (Domain $domain) 
		{
			$DbDomain = DBDomain::GetInstance();
			$SavedDomain = $DbDomain->GetInitialState($domain);

			//$contacts = $domain->GetContactList();
			
			//$NewReg = $SavedDomain->GetContact(CONTACT_TYPE::REGISTRANT);
			$NewTech = $SavedDomain->GetContact(CONTACT_TYPE::TECH);
			
			// Update transferred domain contacts to our
			/*
			if ($contacts[CONTACT_TYPE::REGISTRANT])
			{
				$this->UpdateDomainContact(
					$domain, 
					CONTACT_TYPE::REGISTRANT, 
					$contacts[CONTACT_TYPE::REGISTRANT],
					$NewReg
				);
				$domain->SetContact($NewReg, CONTACT_TYPE::REGISTRANT);				
			}
			*/
			
			// After registrant change all other contacts clears
			$this->UpdateDomainContact(
				$domain, 
				CONTACT_TYPE::TECH, 
				null,
				$NewTech
			);
			
			$domain->SetContact($NewTech, CONTACT_TYPE::TECH);
		}
예제 #11
0
	
	$domaininfo = $db->GetRow("SELECT * FROM domains WHERE id=?", array($req_domainid));
	if (!$domaininfo)
		CoreUtils::Redirect("domains_view.php");
	
	try
	{
		$Registry = $RegistryModuleFactory->GetRegistryByExtension($domaininfo["TLD"]);
	}
	catch(Exception $e)
	{
		$errmsg = $e->getMessage();
		CoreUtils::Redirect("domains_view.php");
	}

	$Domain = DBDomain::GetInstance()->Load($req_domainid, $Registry->GetManifest());
	
	try
	{
		$Domain = $Registry->GetRemoteDomain($Domain);
	}
	catch(Exception $e)
	{
		$errmsg = sprintf(_("Cannot get full information about domain name. Reason: %s"), $e->getMessage());
		CoreUtils::Redirect("domains_view.php");
	}	
	
	if (!($Domain instanceOf Domain))
	{
		$errmsg = sprintf(_("Cannot get full information about domain name. Domain object failed"));
		CoreUtils::Redirect("domains_view.php");
예제 #12
0
 function Handle(Task $Task)
 {
     $Job = $Task->JobObject;
     // Load registry for TLD
     $RegFactory = RegistryModuleFactory::GetInstance();
     $Registry = $RegFactory->GetRegistryByExtension($Job->TLD);
     // For each target load domain and update nameservers
     $DbDomain = DBDomain::GetInstance();
     foreach ($Task->GetActiveTargets() as $Target) {
         try {
             $Domain = $DbDomain->LoadByName($Target->target, $Job->TLD);
             $Action = new UpdateDomainNameserversAction($Domain, $Job->nslist);
             $Action->Run($Task->userid);
             $Task->TargetCompleted($Target);
         } catch (Exception $e) {
             $Target->fail_reason = $e->getMessage();
             Log::Log(sprintf(_("Update failed for %s. %s"), "{$Target->target}.{$Job->TLD}", $e->getMessage()));
             $Task->TargetFailed($Target);
         }
     }
 }
예제 #13
0
파일: sync.php 프로젝트: rchicoria/epp-drs
    print "Usage sync.php [options] [domain1, domain2 ...]\n";
    print "Options:\n";
    print "  --all Sync all 'Delegated' domains\n";
    die;
}
print "Starting...\n";
foreach ($rows as $row) {
    try {
        print "Syncing {$row["name"]}.{$row["TLD"]}";
        $Registry = RegistryModuleFactory::GetInstance()->GetRegistryByExtension($row["TLD"]);
        $Domain = DBDomain::GetInstance()->LoadByName($row["name"], $row["TLD"]);
        $Domain = $Registry->GetRemoteDomain($Domain);
        if ($Domain->RemoteCLID && $Domain->RemoteCLID != $Registry->GetRegistrarID()) {
            $Domain->Status = DOMAIN_STATUS::TRANSFERRED;
        }
        DBDomain::GetInstance()->Save($Domain);
        print " OK\n";
        sleep(2);
    } catch (Exception $e) {
        /*
        if ($e instanceof ObjectNotExistsException)
        {
        	Log::Log("Delete domain {$Domain->GetHostName()}", E_USER_NOTICE);
        	print " Deleted\n";
        	DBDomain::GetInstance()->Delete($Domain);
        }
        else
        {
        */
        Log::Log("Sync failed. Domain {$row["name"]}.{$row["TLD"]}. Error: <" . get_class($e) . "> {$e->getMessage()}", E_USER_NOTICE);
        print " Failed. {$e->getMessage()}\n";
예제 #14
0
<?
    include ("src/prepend.inc.php");
    
    try
    {
    	$Domain = DBDomain::GetInstance()->Load($req_id);
    }
    catch(Exception $e)
    {
    	$errmsg = $e->getMessage();
    }
        
    if ($Domain)
    {
    	try
    	{
    		$Registry = $RegistryModuleFactory->GetRegistryByExtension($Domain->Extension);
    		if (!$Registry)
    			$errmsg = sprintf(_("Registry module not defined for '%s' domain extension."), $Domain->Extension);
    	}
    	catch(Exception $e)
    	{
    		$errmsg = $e->getMessage();
    	}
    	
    	if ($Domain->UserID != $_SESSION['userid'])
    		$errmsg = _("Domain not found");
    }
    	
	if ($Domain->Status != DOMAIN_STATUS::DELEGATED)
	{
예제 #15
0
파일: tests.php 프로젝트: rchicoria/epp-drs
 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);
 }
예제 #16
0
파일: tests.php 프로젝트: rchicoria/epp-drs
 function _testDomainTransfer()
 {
 	$domain = DBDomain::GetInstance()->Load(99);
 	$res = $this->registry->TransferRequest($domain);
 	$this->assertTrue($res, "Transfer requested");
 }
예제 #17
0
 /**
  * 
  * @param $params = array(
  * 		name		string		Domain name
  * 		mode		string		'remote' - get info from registry server
  * 								'local' - get info from local database
  * )
  * @return eppdrs-api.xsd#getDomainInfoResponse
  */
 function GetDomainInfo($params = null)
 {
     // Accept params
     list($name, $tld) = $this->SplitNameAndTLD($params['name']);
     // Check access
     $this->CheckDomainAccess($name, $tld);
     // Do
     if (strtolower($params['mode']) == self::INFO_MODE_REGISTRY) {
         $registry = $this->registry_factory->GetRegistryByExtension($tld);
         $domain = $registry->NewDomainInstance();
         $domain->Name = $name;
         $grd_response = $registry->GetModule()->GetRemoteDomain($domain);
         if (!$grd_response->Succeed()) {
             throw new RegistryException($grd_response->ErrMsg, $grd_response->Code);
         }
         $ret = new stdClass();
         $ret->name = $domain->GetHostName();
         $ret->contacts = new stdClass();
         if ($grd_response->RegistrantContact) {
             $ret->contacts->registrant = $grd_response->RegistrantContact;
         }
         if ($grd_response->AdminContact) {
             $ret->contacts->admin = $grd_response->AdminContact;
         }
         if ($grd_response->BillingContact) {
             $ret->contacts->billing = $grd_response->BillingContact;
         }
         if ($grd_response->TechContact) {
             $ret->contacts->tech = $grd_response->TechContact;
         }
         if ($grd_response->GetNameserverList()) {
             $ret->ns = array();
             foreach ($grd_response->GetNameserverList() as $Nameserver) {
                 $ret->ns[] = $Nameserver->HostName;
             }
         }
         if ($grd_response->CreateDate) {
             $ret->createDate = date($this->date_format, $grd_response->CreateDate);
         }
         if ($grd_response->ExpireDate) {
             $ret->expireDate = date($this->date_format, $grd_response->ExpireDate);
         }
         $ret->locked = (int) $grd_response->IsLocked;
         // Remote specific properties
         // Registry status (ok, pendingCreate ...)
         $ret->registryStatus = $grd_response->RegistryStatus;
         $ret->flag = $grd_response->GetFlagList();
         if ($grd_response->AuthCode) {
             $ret->authCode = $grd_response->AuthCode;
         }
     } else {
         $db_domain = DBDomain::GetInstance();
         $domain = $db_domain->LoadByName($name, $tld);
         $ret = new stdClass();
         $ret->name = $domain->GetHostName();
         $ret->contacts = new stdClass();
         $contacts = $domain->GetContactList();
         if ($contacts[CONTACT_TYPE::REGISTRANT]) {
             $ret->contacts->registrant = $contacts[CONTACT_TYPE::REGISTRANT]->CLID;
         }
         if ($contacts[CONTACT_TYPE::ADMIN]) {
             $ret->contacts->admin = $contacts[CONTACT_TYPE::ADMIN]->CLID;
         }
         if ($contacts[CONTACT_TYPE::BILLING]) {
             $ret->contacts->billing = $contacts[CONTACT_TYPE::BILLING]->CLID;
         }
         if ($contacts[CONTACT_TYPE::TECH]) {
             $ret->contacts->tech = $contacts[CONTACT_TYPE::TECH]->CLID;
         }
         if ($domain->GetNameserverList()) {
             $ret->ns = array();
             foreach ($domain->GetNameserverList() as $ns) {
                 $ret->ns[] = $ns->HostName;
             }
         }
         if ($domain->CreateDate) {
             $ret->createDate = date($this->date_format, $domain->CreateDate);
         }
         if ($domain->ExpireDate) {
             $ret->expireDate = date($this->date_format, $domain->ExpireDate);
         }
         $ret->locked = (int) $domain->IsLocked;
         // Local specific properties.
         // Local status. See DOMAIN_STATUS::*
         $ret->localStatus = $domain->Status;
         $ret->flag = $domain->GetFlagList();
         $ret->authCode = $domain->AuthCode;
     }
     return $ret;
 }
예제 #18
0
<? 
	require_once('src/prepend.inc.php');
	
	// Get Domain object
	if (isset($req_domainid) && $req_domainid > 0)
		require_once("src/set_managed_domain.php");
	else
    	$Domain = DBDomain::GetInstance()->Load($_SESSION["selected_domain"]);
   
    // Check UserID for Domain
	if ($Domain->UserID != $_SESSION["userid"])
    	$errmsg = _("You don't have permissions to manage this contact");
	
    // Check domain status (We can manage only Delegated domains)
    if ($Domain->Status != DOMAIN_STATUS::DELEGATED)
		$errmsg = _("Domain status prohibits operation");
		
    // if error Redirect to domains_view page
	if ($errmsg)
		CoreUtils::Redirect ("domains_view.php");
	
	// Get User info
	$user = $db->GetRow("SELECT * FROM users WHERE id=?", array($Domain->UserID));	
	
	// Get contact information from database
	
	$Contact = $Domain->GetContact($req_c);
		
	// Create Module object
	try
	{
예제 #19
0
<?php

include dirname(__FILE__) . "/../src/prepend.inc.php";
$DbDomain = DBDomain::GetInstance();
$RegistryFactory = RegistryModuleFactory::GetInstance();
$domain_arr = $db->GetAll('SELECT id FROM domains');
foreach ($domain_arr as $domain_row) {
    try {
        $Domain = $DbDomain->Load($domain_row['id']);
        if (!$Domain->IsActive()) {
            continue;
        }
        $Registry = $RegistryFactory->GetRegistryByExtension($Domain->Extension);
        $RDomain = $Registry->NewDomainInstance();
        $RDomain->Name = $Domain->Name;
        $RDomain = $Registry->GetRemoteDomain($RDomain);
        $Domain->ExpireDate = $RDomain->ExpireDate;
        $DbDomain->Save($Domain);
        Log::Log("{$Domain->GetHostName()} fixed expiration date", E_USER_NOTICE);
    } catch (Exception $e) {
        Log::Log($e->getMessage(), E_USER_WARNING);
        continue;
    }
}
예제 #20
0
 public function ConvertActiveDomains()
 {
     $this->Log('Import delegated domains');
     $this->FailedActiveDomains = array();
     // Import delegated domains
     $domains = $this->DbOld->GetAll("\r\n\t\t\t\tSELECT * FROM domains \r\n\t\t\t\tWHERE status='Delegated' \r\n\t\t\t\tORDER BY id ASC\r\n\t\t\t");
     $ok = $fail = 0;
     foreach ($domains as $i => $dmn) {
         // This is long time loop, DbOld connection may be lost due timeout,
         // so we need to ping it
         $this->PingDatabase($this->DbOld);
         // Check for duplicate domains
         $imported = (int) $this->DbNew->GetOne('SELECT COUNT(*) FROM domains WHERE name = ? AND TLD = ?', array($dmn['name'], $dmn['TLD']));
         if ($imported) {
             // Skip duplicate domain
             continue;
         }
         try {
             $Registry = $this->RegistryFactory->GetRegistryByExtension($dmn['TLD'], $db_check = false);
             $Domain = $Registry->NewDomainInstance();
             $Domain->Name = $dmn['name'];
             $this->Log("Import {$Domain->GetHostName()}");
             if (!DBDomain::ActiveDomainExists($Domain)) {
                 try {
                     $Domain = $Registry->GetRemoteDomain($Domain);
                 } catch (Exception $e) {
                     $err[] = sprintf("%s: %s", $Domain->GetHostName(), $e->getMessage());
                 }
                 if ($Domain->RemoteCLID) {
                     if ($Domain->RemoteCLID == $Registry->GetRegistrarID() || $Domain->AuthCode != '') {
                         $contacts_list = $Domain->GetContactList();
                         // Apply contacts to domain owner
                         foreach ($contacts_list as $Contact) {
                             $Contact->UserID = $dmn['userid'];
                         }
                         if (count($err) == 0) {
                             $period = date("Y", $Domain->ExpireDate) - date("Y", $Domain->CreateDate);
                             $Domain->Status = DOMAIN_STATUS::DELEGATED;
                             $Domain->Period = $period;
                             $Domain->UserID = $dmn['userid'];
                             $Domain->ID = $dmn['id'];
                             try {
                                 $this->DbNew->Execute('INSERT INTO domains SET id = ?', array($dmn['id']));
                                 $this->DBDomain->Save($Domain);
                                 $ok++;
                             } catch (Exception $e) {
                                 $err[] = sprintf("%s: %s", $Domain->GetHostName(), $e->getMessage());
                             }
                         }
                     } else {
                         $err[] = sprintf(_("'%s' cannot be imported because it does not belong to the current registar."), $Domain->GetHostName());
                     }
                 }
             } else {
                 $err[] = sprintf(_("Domain '%s' already exists in our database."), $Domain->GetHostName());
             }
             foreach ($err as $errmsg) {
                 $this->Log($errmsg, E_USER_ERROR);
                 $err = array();
                 $fail++;
             }
         } catch (Exception $e) {
             $this->Log($e->getMessage(), E_USER_ERROR);
             $fail++;
             if ($this->SaveFailedAsPending) {
                 $this->FailedActiveDomains[] = $dmn;
             }
         }
     }
     $this->Log(sprintf("Imported: %s; Failed: %s", $ok, $fail));
 }
예제 #21
0
		    
			try
			{ 
				// Be sure that it's free 
				$domain_avaiable = $Registry->DomainCanBeRegistered($Domain);
			}
			catch (Exception $e)
			{
				throw new Exception(_("Cannot check domain name availability. Make sure that you spelled domain name correctly"));
			}
			
			if (!$domain_avaiable->Result || DBDomain::GetInstance()->ActiveDomainExists($Domain))
			{
				throw new Exception(_('Domain cannot be registered') . ($domain_avaiable->Reason ? ". ". _("Reason: {$domain_avaiable->Reason}") : ""));
			}
			else if (DBDomain::GetInstance()->FindByName($Domain->Name, $Domain->Extension))
			{
				throw new Exception(_('Domain name already exists in EPP-DRS'));
			}			

			// Make prise list for various registration periods
    	    $display["periods"] = array();
    	    $min_period = (int)$Domain->GetConfig()->registration->min_period;
    	    $max_period = (int)$Domain->GetConfig()->registration->max_period;
    	    
    	    $discount_pc = $Client->PackageID ? (float)$db->GetOne(
    	    		"SELECT discount FROM discounts WHERE TLD=? AND purpose=? AND packageid=?", 
    	    		array($post_TLD, INVOICE_PURPOSE::DOMAIN_CREATE, $Client->PackageID)) : 0;
    	    for($i = $min_period; $i <= $max_period; $i++)
    	    {
				$price = $db->GetOne(
        public function OnStartForking()
        {            
            Log::Log("Starting 'PreregistrationUpdate' cronjob...", E_USER_NOTICE);
            
            $db = Core::GetDBInstance();
            
            $this->ThreadArgs = array();
    		
            //
            // Update registered domains
            //
            $domains = $db->Execute("SELECT * FROM domains WHERE status=?", array(DOMAIN_STATUS::PREREGISTRATION_DELEGATED));
            while ($domain = $domains->FetchRow())
            {
	            ////
				try
				{
					$Domain = DBDomain::GetInstance()->Load($domain['id']);
				}
				catch(Exception $e)
				{
					Log::Log(__CLASS__.": thrown exception: '{$e->getMessage()}' File: {$e->getFile()}:{$e->getLine()}", E_ERROR);
					exit();
				}
				
				if ($Domain->Status == DOMAIN_STATUS::AWAITING_PREREGISTRATION)
				{
					try
					{
						$Registry = RegistryModuleFactory::GetInstance()->GetRegistryByExtension($Domain->Extension);
					}
					catch(Exception $e)
					{
						Log::Log(__CLASS__.": thrown exception: '{$e->getMessage()}' File: {$e->getFile()}:{$e->getLine()}", E_ERROR);
						exit();
					}
		
					try
					{
						$Domain = $Registry->GetRemoteDomain($Domain);
					}
					catch(Exception $e)
					{
						Log::Log(__CLASS__.": Cannot get remote domain: '{$e->getMessage()}' File: {$e->getFile()}:{$e->getLine()}", E_ERROR);
						exit();
					}
					
					if (($Domain->RemoteCLID == $Registry->GetRegistrarID()))
					{
						$Domain->Status = DOMAIN_STATUS::DELEGATED;
						DBDomain::GetInstance()->Save($Domain);
					}
					else
					{
						Log::Log(__CLASS__.": Remote domain not owned by us. Domain RegistrarID: {$Domain->RemoteCLID}", E_ERROR);
						exit();
					}
				}
				///
            }
            
            //
            // Update failed domains
            //
            $domains = $db->Execute("SELECT * FROM domains WHERE status=? AND TO_DAYS(NOW()) > TO_DAYS(start_date)", array(DOMAIN_STATUS::AWAITING_PREREGISTRATION));
            while($domain = $domains->FetchRow())
            	$db->Execute("UPDATE domains SET status=? WHERE id=?", array(DOMAIN_STATUS::REGISTRATION_FAILED, $domain['id']));
        }
예제 #23
0
 public function PollChangeDomainOwner(Domain $domain)
 {
     $resp = $this->GetRemoteDomain($domain);
     if ($resp->Succeed()) {
         $eppExt = $resp->RawResponse->response->extension->children($this->ExtNamespace);
         if (count($eppExt) && ($eppExt = $eppExt[0])) {
             $trade = $eppExt->xpath("//{$this->ExtPrefix}:pendingTransaction/{$this->ExtPrefix}:trade");
             if (!count($trade)) {
                 try {
                     $db = Core::GetDBInstance();
                     $DbDomain = DBDomain::GetInstance();
                     $StoredDomain = $DbDomain->LoadByName($domain->Name, $domain->Extension);
                     $operation_row = $db->GetRow("SELECT * FROM pending_operations WHERE objectid = ? AND operation = ? AND objecttype = ?", array($StoredDomain->ID, Registry::OP_TRADE, Registry::OBJ_DOMAIN));
                     $After = unserialize($operation_row["object_after"]);
                     $registrant_new_clid = $After->GetContact(CONTACT_TYPE::REGISTRANT)->CLID;
                     $ret = new PollChangeDomainOwnerResponse(REGISTRY_RESPONSE_STATUS::SUCCESS, $resp->ErrMsg, $resp->Code);
                     $ret->Result = $resp->RegistrantContact == $registrant_new_clid;
                     $ret->HostName = $domain->GetHostName();
                     return $ret;
                 } catch (Exception $e) {
                     return new PollChangeDomainOwnerResponse(REGISTRY_RESPONSE_STATUS::FAILED, $e->getMessage());
                 }
             }
         }
     }
 }
예제 #24
0
파일: tests.php 프로젝트: rchicoria/epp-drs
        function _testDelete ()
        {
			$Domain = DBDomain::GetInstance()->LoadByName('webta2534', 'net');
        	
			////
			// Remove nameservers from domain 
			$ns_list = $Domain->GetNameserverList();
			if ($ns_list)
			{
				$Changes = $Domain->GetNameserverChangelist();
				foreach ($ns_list as $NS)
				{
					$Changes->Remove($NS);
				}
				$this->Registry->UpdateDomainNameservers($Domain, $Changes);
				$this->assertTrue(count($Domain->GetNameserverList()) == 0, 'Remove nameservers from domain');
			}
			
			////
			// Delete nameservers
			foreach ($ns_list as $NS)
			{
				$this->Registry->DeleteNameserverHost($NS);
			}
			$this->assertTrue(true, 'Delete nameservers');
			
        	
        	////
			// Delete domain
			$this->Registry->DeleteDomain($Domain);
			$this->assertTrue(true, 'Delete domain');
			
			////
			// Delete contacts
			$this->Registry->DeleteContact($Domain->GetContact(CONTACT_TYPE::REGISTRANT));
			$this->Registry->DeleteContact($Domain->GetContact(CONTACT_TYPE::TECH));
			$this->assertTrue(true, 'Delete contacts');
        }
예제 #25
0
        public function OnStartForking()
        {            
            global $TLDs, $modules_config;
            
        	Log::Log("Starting 'Renew' cronjob...", E_USER_NOTICE);
            
            $db = Core::GetDBInstance();
            $RegFactory = RegistryModuleFactory::GetInstance();
            $DbDomain = DBDomain::GetInstance();
            
            $this->ThreadArgs = array();
            
            // For each client send notice about expiring domains
            $sql = "SELECT id FROM users";
            foreach ($db->GetAll($sql) as $client_data)
            {
            	try
            	{
	            	$Client = Client::Load($client_data["id"]);
	            	
	            	$sql = "
						SELECT 
							d.id, d.name, d.TLD, d.end_date, 
							IF(dd.`key` IS NOT NULL, FROM_UNIXTIME(dd.`value`), DATE_SUB(end_date, INTERVAL 1 DAY)) AS last_renew_date 
						FROM domains d 
						LEFT JOIN domains_data dd ON (dd.domainid = d.id AND dd.`key` = 'RenewalDate') 
						WHERE d.status = '".DOMAIN_STATUS::DELEGATED."' AND d.userid = ? AND (TO_DAYS(end_date) - TO_DAYS(NOW()) BETWEEN 0 AND ?) AND renew_disabled != 1
						ORDER BY d.end_date ASC";
					$start_days = $Client->GetSettingValue(ClientSettings::EXPIRE_NOTIFY_START_DAYS);
	            	$domains_data = $db->GetAll($sql, array($Client->ID, $start_days ? $start_days : 60));
	            	
	            	// Send email to client
	            	if ($domains_data) 
	            	{
	            		$eml_args = array(
	            			"client_name" => $Client->Name,
	            			"domains" => array()
	            		);
	            		foreach ($domains_data as $domain_data)
	            		{
	            			$eml_args["domains"][] = array(
	            				"name" => "{$domain_data["name"]}.{$domain_data["TLD"]}",
	            				"expire_date" => date("Y-m-d", strtotime($domain_data["end_date"])),
	            				"last_renew_date" => date("Y-m-d", strtotime($domain_data["last_renew_date"]))
	            			);
	            		}
	            		mailer_send("bulk_renew_notice.eml", $eml_args, $Client->Email, $Client->Name);
	            	}
	            	
	            	foreach ($domains_data as $domain_data)
	            	{
	            		$Domain = $DbDomain->Load($domain_data['id']);
	            		
	            		 // Find more then 60 days invoice
	            		 // Legacy from old notification system.
	            		 // FIXME: Need to create a better solution to finding unpaid invoices for upgoing renew 
						$dtNearest = date("Y-m-d", $Domain->ExpireDate - 60*24*60*60);
						$invoiceid = $db->GetOne("SELECT id FROM invoices 
							WHERE userid=? AND itemid=? AND purpose=? AND dtcreated >= ?", 
							array($Domain->UserID, $Domain->ID, INVOICE_PURPOSE::DOMAIN_RENEW, $dtNearest)
						);

							
						// Generate invoice
						if (!$invoiceid && !$Domain->RenewDisabled)
						{				
							$Registry = $RegFactory->GetRegistryByExtension($Domain->Extension);
							$config = $Registry->GetManifest()->GetSectionConfig();
							$period = (int)$config->domain->renewal->min_period;
							$Domain->Period = $period;
							$DbDomain->Save($Domain);

							try
							{
								$Invoice = new Invoice(INVOICE_PURPOSE::DOMAIN_RENEW, $Domain->ID, $Domain->UserID);
								$Invoice->Description = sprintf(_("%s domain name renewal for %s years"), $Domain->GetHostName(), $period);
								$Invoice->Cancellable = 1;
								$Invoice->Save();
								
								if ($Invoice->Status == INVOICE_STATUS::PENDING)
								{
									$diff_days = ceil(($Domain->ExpireDate - time())/(60*60*24));
									Application::FireEvent('DomainAboutToExpire', $Domain, $diff_days);
								}
							}
							catch(Exception $e)
							{
								Log::Log("Cannot create renew invoice. Caught: {$e->getMessage()}", E_USER_ERROR);
							}
						}
	            	}
            	}
            	catch (Exception $e)
            	{
            		Log::Log("Caught: {$e->getMessage()}", E_USER_ERROR);
            	}
            	
            }
            
            /*
			$supported_extensions = $RegFactory->GetExtensionList();
			// For all supported TLDs
            foreach ($supported_extensions as $ext)
            {
            	$Registry = $RegFactory->GetRegistryByExtension($ext);
            	
            	
            	$config = $Registry->GetManifest()->GetSectionConfig();
				$days = $config->domain->renewal->notifications->period;
				$biggest_period = (int)$days[0];
				
				
				
				
				// For each notification 
				foreach($days as $expireDays)
				{
					$expireDays = (int)$expireDays;
					
					$domains = $db->GetAll("
						SELECT dom.* FROM domains AS dom 
						LEFT JOIN domains_data AS ext 
						ON dom.id = ext.domainid AND ext.`key` = 'RenewalDate'
						WHERE dom.TLD = ? 
						AND dom.status = ? 
						AND TO_DAYS(IF 
						(
							ext.`key` IS NOT NULL AND TO_DAYS(FROM_UNIXTIME(ext.`value`)) < TO_DAYS(dom.end_date),
							FROM_UNIXTIME(ext.`value`),
							dom.end_date 
						)) - TO_DAYS(NOW()) = ?
					", array(
						$ext, DOMAIN_STATUS::DELEGATED, $expireDays
					));

					// For each domain
					foreach($domains as $domain_info)
					{
						try
						{
							$Domain = DBDomain::GetInstance()->Load($domain_info['id']);
							
							$dtNearest = date("Y-m-d", strtotime($domain_info["end_date"]) - $biggest_period*24*60*60);
							$invoiceid = $db->GetOne("SELECT id FROM invoices 
								WHERE userid=? AND itemid=? AND purpose=? AND status=? AND dtcreated >= ?", 
								array($Domain->UserID, $Domain->ID, INVOICE_PURPOSE::DOMAIN_RENEW, INVOICE_STATUS::PENDING, $dtNearest)
							);
							
							// Generate invoice
							if (!$invoiceid && !$Domain->RenewDisabled)
							{				
								
								$period = (int)$config->domain->renewal->min_period;
								$Domain->Period = $period;
								DBDomain::GetInstance()->Save($Domain);
								 
								try
								{
									$Invoice = new Invoice(INVOICE_PURPOSE::DOMAIN_RENEW, $Domain->ID, $Domain->UserID);
									$Invoice->Description = sprintf(_("%s domain name renewal for %s years"), $Domain->GetHostName(), $period);
									$Invoice->Cancellable = 1;
									$Invoice->Save();
									
									if ($Invoice->Status == INVOICE_STATUS::PENDING)
									{
										$userinfo = $db->GetRow("SELECT * FROM users WHERE id=?", array($Domain->UserID));
										
										//print "send notification and invoice about {$Domain->GetHostName()} to {$userinfo['email']}\n";									
										
										$args = array(
											"domain_name"	=> $Domain->Name, 
											"extension"		=> $Domain->Extension,
											"invoice"		=> $Invoice,
											"expDays"		=> $expireDays,
											"client"		=> $userinfo,
											"renewal_date"  => $Domain->RenewalDate
										);
										mailer_send("renew_notice.eml", $args, $userinfo["email"], $userinfo["name"]);
	
										Application::FireEvent('DomainAboutToExpire', $Domain, $expireDays);
									}
								}
								catch(Exception $e)
								{
									$errmsg = $e->getMessage();
								}
							}
							else
							{
								$userinfo = $db->GetRow("SELECT * FROM users WHERE id=?", array($Domain->UserID));
								//print "send notification about {$Domain->GetHostName()} to {$userinfo['email']}\n";
								$args = array(
									"domain_name"	=> $Domain->Name, 
									"extension"		=> $Domain->Extension,
									"expDays"		=> $expireDays,
									'client' 		=> $userinfo,
									"renewal_date"  => $Domain->RenewalDate
								);
								mailer_send("renew_notice.eml", $args, $userinfo["email"], $userinfo["name"]);
							}
						} 
						catch (Exception $e)
						{
							Log::Log("First domains loop. Caught: ".$e->getMessage(), E_USER_ERROR);
						}
					}
				}
            }
            */

            
			// For auto-renew registries the day before expiration date 
			// send to unpaid domains delete command and mark them as expired
			Log::Log("Going to process expiring tomorrow domains in 'auto-renew' registries", E_USER_NOTICE);			
			$days_before = 1;
			$del_date = strtotime("+$days_before day");
			$delete_report = array();
			$domains = $db->GetAll("SELECT dom.id, dom.name, dom.TLD FROM domains AS dom 
				LEFT JOIN domains_data AS ext ON dom.id = ext.domainid AND ext.`key` = 'RenewalDate'
				LEFT JOIN invoices AS i ON (dom.id = i.itemid AND i.purpose = 'Domain_Renew')
				WHERE dom.status = ? 
				AND TO_DAYS(IF
				(
					ext.`key` IS NOT NULL AND TO_DAYS(FROM_UNIXTIME(ext.`value`)) < TO_DAYS(dom.end_date),
					FROM_UNIXTIME(ext.`value`),
					dom.end_date 
				)) - TO_DAYS(NOW()) = ?	AND ((i.status = ? AND TO_DAYS(NOW()) - TO_DAYS(i.dtcreated) <= 60) OR i.status IS NULL)",
				array(DOMAIN_STATUS::DELEGATED, $days_before, INVOICE_STATUS::PENDING));
				
			foreach ($domains as $domain_info)
			{
				try
				{
					$Domain = $DbDomain->Load($domain_info["id"]);
					$Registry = $RegFactory->GetRegistryByExtension($domain_info["TLD"]);
					$RegistryOptions = $Registry->GetManifest()->GetRegistryOptions();
					$auto_renewal = (int)$RegistryOptions->ability->auto_renewal;
					$scheduled_delete = (int)$RegistryOptions->ability->scheduled_delete;
					
					if ($auto_renewal)
					{
						if (CONFIG::$AUTO_DELETE)
						{
							try
							{
								// For 'auto-renew + scheduled delete' send scheduled delete
								if ($scheduled_delete)
								{
									Log::Log(sprintf("Send scheduled delete to domain '%s' at '%s'", 
											$Domain->GetHostName(), date("Y-m-d", $del_date)), E_USER_NOTICE);
									
									$Registry->DeleteDomain($Domain, $del_date);
								}
								// For 'auto-renew' only send direct delete
								else
								{
									Log::Log(sprintf("Send direct delete to domain '%s'", 
											$Domain->GetHostName()), E_USER_NOTICE);
									$Registry->DeleteDomain($Domain);
								}
								
								$this->MarkAsExpired($Domain);
							}
							catch (Exception $e)
							{
								Log::Log(sprintf("Cannot delete expiring domain '%s'. %s", 
										$Domain->GetHostName(), $e->getMessage()), E_USER_ERROR);
							}								
						}
						else
						{
							Log::Log(sprintf("Domain %s need to be deleted. Send it to admin court", 
									$Domain->GetHostName()), E_USER_NOTICE);
							
							// Send to the administrator court
							$db->Execute("UPDATE domains SET delete_status = ? WHERE id = ?",
									array(DOMAIN_DELETE_STATUS::AWAIT, $Domain->ID));
							$userinfo = $db->GetRow("SELECT * FROM users WHERE id = ?", array($Domain->UserID));
							$delete_report[] = array
							(
								"domain" => $Domain->GetHostName(),
								"user" => "{$userinfo["name"]}({$userinfo["email"]})"
							);
						}
					}
				}
				catch (Exception $e)
				{
					Log::Log(sprintf("Cannot load expiring domain '%s'. %s", 
							"{$domain_info["name"]}.{$domain_info["TLD"]}", $e->getMessage()), E_USER_ERROR);
				}
			}
			// Notify admin about expiring domains need to be deleted
			if ($delete_report)
			{
				$args = array(
					"date" => date("Y-m-d", $del_date), 
					"report" => $delete_report, 
					"confirm_url" => CONFIG::$SITE_URL . "/admin/domains_await_delete_confirmation.php"
				);
				
				mailer_send("root_domains_await_delete.eml", $args, CONFIG::$EMAIL_ADMIN, CONFIG::$EMAIL_ADMINNAME);
			}
			
			
			// For all registries mark domain as expired at expiration date
			Log::Log("Going to process expiring today domains", E_USER_NOTICE);
			$domains = $db->GetAll("SELECT id, name, TLD FROM domains 
					WHERE TO_DAYS(end_date) = TO_DAYS(NOW()) AND status = ? AND delete_status != ?",
					array(DOMAIN_STATUS::DELEGATED, DOMAIN_DELETE_STATUS::AWAIT));
			
			foreach ($domains as $domain_info)
			{
				try
				{
					$Domain = $DbDomain->Load($domain_info["id"]);
					
					$this->MarkAsExpired($Domain);
				}
				catch (Exception $e)
				{
					Log::Log(sprintf("Cannot load expired domain '%s'. %s", 
							"{$domain_info["name"]}.{$domain_info["TLD"]}", $e->getMessage()), E_USER_ERROR);
				}
			}

			
			// Cleanup database from expired and transferred domains (more then 60 days)
			Log::Log("Going to cleanup database from transferred and expired domains (more then 60 days)", E_USER_NOTICE);
			$domains = $db->GetAll("
					SELECT * FROM domains 
					WHERE (status=? OR status=?) AND 
					((TO_DAYS(NOW()-TO_DAYS(end_date)) >= 60) OR (TO_DAYS(NOW()-TO_DAYS(dtTransfer)) >= 60))", 
					array(DOMAIN_STATUS::TRANSFERRED, DOMAIN_STATUS::EXPIRED));
					
			foreach ($domains as $domain_info)
			{
				try
				{
					Log::Log("Delete {$domain_info["name"]}.{$domain_info["TLD"]} from database. "
						. "(start_date={$domain_info["start_date"]}, end_date={$domain_info["end_date"]}, status={$domain_info["status"]})", 
						E_USER_NOTICE);
					$Domain = $DbDomain->Load($domain_info['id']);
					$DbDomain->Delete($Domain);
				}
				catch (Exception $ignore) 
				{
					Log::Log("Catch ignored exception. {$ignore->getMessage()}", E_USER_NOTICE);
				}
			}
			
			
			// Notify customers about low balance
			Log::Log("Going to notify customers about their low balance", E_USER_NOTICE);
			$user_ids = $db->GetAll("SELECT userid FROM user_settings 
					WHERE `key` = '".ClientSettings::LOW_BALANCE_NOTIFY."' AND `value` = '1'");
			foreach ($user_ids as $id) 
			{
				try 
				{
					$id = $id["userid"];
					$Client = Client::Load($id);
					$amount = (float)$db->GetOne("SELECT `total` FROM balance WHERE clientid = ?", array($id));
					$min_amount = (float)$Client->GetSettingValue(ClientSettings::LOW_BALANCE_VALUE);
					if ($amount < $min_amount)
					{
						mailer_send("low_balance_notice.eml", array(
							"client" => array("name" => $Client->Name),
							"amount" => number_format($min_amount, 2),
							"currency" => CONFIG::$CURRENCYISO
						), $Client->Email, $Client->Name);
					}
				}
				catch (Exception $e)
				{
					Log::Log("Cannot notify customer about his low balance. Error: {$e->getMessage()}", E_USER_ERROR);
					
				}
			}
        }
예제 #26
0
        $rows = $db->GetAll("SELECT name, TLD FROM domains WHERE status = 'Delegated'");
    } else {
        for ($i = 1; $i < $_SERVER["argc"]; $i++) {
            list($name, $tld) = explode(".", $_SERVER["argv"][$i], 2);
            $rows[] = array("name" => $name, "TLD" => $tld);
        }
    }
} else {
    print "Usage reset-pw.php [options] [domain1, domain2 ...]\n";
    print "Options:\n";
    print "  --all Update all 'Delegated' domains\n";
    die;
}
print "Starting...\n";
foreach ($rows as $row) {
    try {
        $Registry = RegistryModuleFactory::GetInstance()->GetRegistryByExtension($row["TLD"]);
        if ($Registry->GetManifest()->GetRegistryOptions()->ability->change_domain_authcode == 1) {
            $pw = AbstractRegistryModule::GeneratePassword();
            print "Updating {$row["name"]}.{$row["TLD"]} (pw: {$pw})\n";
            $Domain = DBDomain::GetInstance()->LoadByName($row["name"], $row["TLD"]);
            $Registry->UpdateDomainAuthCode($Domain, $pw);
            print "Updated\n";
        } else {
            print "Not supported for {$row["name"]}.{$row["TLD"]}\n";
        }
    } catch (Exception $e) {
        print "error: {$e->getMessage()}\n";
    }
}
print "Done\n";
예제 #27
0
	    	{
			    $Validator = new Validator();
			    if (!$Validator->IsDomain("{$attr["name"]}.{$TLD}"))
			    	throw new Exception(_("Domain name contains non-supported characters"));
	    	}
			
			if ($attr["isTransfer"] == "false")
			{
				if ($Registry->DomainCanBeRegistered($Domain)->Result && !DBDomain::GetInstance()->ActiveDomainExists($Domain))
					$res = "AVAIL";
				else
					$res = "NOT_AVAIL";
			}
			else
			{
				if ($Registry->DomainCanBeTransferred($Domain) && !DBDomain::GetInstance()->ActiveDomainExists($Domain))
					$res = "AVAIL";
				else
					$res = "NOT_AVAIL";
			}
		}
		catch(Exception $e)
		{
			$res = "CHECK_ERROR";
		}
	}
	
	$response["status"] = true;
	$response["data"] = array("res" => $res, "domain" => $attr["name"], "TLD" => $TLD);
	
	echo json_encode($response);
예제 #28
0
파일: tests.php 프로젝트: rchicoria/epp-drs
 function _testContact()
 {
     return;
     /*
     $Contact = $this->Registry->NewContactInstanceByGroup('generic');
     $Contact->SetFieldList($this->ContactFields);
     $this->Registry->CreateContact($Contact);
     
     $Domain = $this->Registry->NewDomainInstance();
     $Domain->Name = 'webta' . rand(100, 999);
     
     var_dump($Domain->Name);
     
     $Domain->SetContact($Contact, CONTACT_TYPE::REGISTRANT);
     $Domain->SetContact($Contact, CONTACT_TYPE::TECH);
     $Domain->SetContact($Contact, CONTACT_TYPE::BILLING);
     
     $this->Registry->CreateDomain($Domain, 2);
     
     exec("whois -h 192.168.1.200 -T domain {$Domain->GetHostName()}", $out);
     var_dump($out);
     
     $Billing = $this->Registry->NewContactInstanceByGroup('generic');
     $Billing->SetFieldList($this->ContactFieldsBill);
     $this->Registry->CreateContact($Billing);
     
     $this->Registry->UpdateDomainContact($Domain, CONTACT_TYPE::BILLING, $Contact, $Billing);
     */
     $Domain = DBDomain::GetInstance()->LoadByName('webta426', 'net');
     //		$ns = new NameserverHost('ns2.' . $Domain->GetHostName(), gethostbyname('ns2.hostdad.com'));
     //		$this->Registry->CreateNameserverHost($ns);
     /*
     $nslist = $Domain->GetNameserverList();
     $changes = $Domain->GetNameserverChangelist();
     $changes->Remove($nslist[1]);
     $this->Registry->UpdateDomainNameservers($Domain, $changes);
     */
     $changes = $Domain->GetNameserverChangelist();
     $changes->SetChangedList(array());
     $this->Registry->UpdateDomainNameservers($Domain, $changes);
     foreach ($Domain->GetNameserverHostList() as $nshost) {
         $this->Registry->DeleteNameserverHost($nshost);
     }
     $this->Registry->DeleteDomain($Domain);
     exec("whois -h 192.168.1.200 -T domain {$Domain->GetHostName()}", $out);
     var_dump($out);
 }
예제 #29
0
파일: tests.php 프로젝트: rchicoria/epp-drs
        function _testEPP ()
        {
			$Domain = $this->Registry->NewDomainInstance();
			$Domain->Name = 'webta' . rand(1000, 9999);
			
			// check domain
			try
			{
				$ok = $this->Registry->DomainCanBeRegistered($Domain);
				$this->assertTrue($ok, 'Domain available for registration');
			}
			catch (Exception $e)
			{
				return $this->fail('Domain available for registration. Error: ' . $e->getMessage());
			}
			
			////
			// Create contact

			try
			{
				$Registrant = $this->Registry->NewContactInstanceByGroup('generic');
				$Registrant->SetFieldList($this->contact_fields);
				
				$this->Registry->CreateContact($Registrant);
				
				$this->assertTrue(true, 'Create contact');
			}
			catch (Exception $e)
			{
				return $this->fail('Create contact. Error: ' . $e->getMessage());
			}
			
			////
			// Get contact INFO
			
			try
			{
				$RRegistrant = $this->Registry->NewContactInstanceByGroup('generic');
				$RRegistrant->CLID = $Registrant->CLID;
				
				$this->Registry->GetRemoteContact($RRegistrant);
				
				$fields = $Registrant->GetFieldList();
				$rfields = $RRegistrant->GetFieldList();
				ksort($fields);
				ksort($rfields);
				
				$discloses = $Registrant->GetDiscloseList();
				$rdiscloses = $RRegistrant->GetDiscloseList();
				ksort($discloses);
				ksort($rdiscloses);
				
				$this->assertTrue(
					$fields['name'] == $rfields['name'] &&
					$fields['email'] == $rfields['email'] &&
					$fields['voice'] == $rfields['voice'] &&
					$discloses == $rdiscloses, 'Get remote contact');
				
			}
			catch (Exception $e)
			{
				return $this->fail('Get remote contact. Error: ' . $e->getMessage());
			}
			
			try
			{
				$Domain->SetContact($Registrant, CONTACT_TYPE::REGISTRANT);
				$Domain->SetNameserverList(array(
					new Nameserver('ns.hostdad.com'),
					new Nameserver('ns2.hostdad.com')
				));
				
				$this->DBDomain->Save($Domain);
				
				$this->Registry->CreateDomain($Domain, 2, array('comment' => 'abc'));
				$this->assertTrue(true, 'Create domain');
			}
			catch (Exception $e)
			{
				return $this->fail('Create domain. Error: ' . $e->getMessage());
			}
			
			
        	$Obs = new TestRegistryObserver($this->Registry, $this);
        	$this->Registry->AttachObserver($Obs);
			$this->Registry->DispatchPendingOperations();
        }
 /**
  * Executor
  *
  * @throws UpdateDomainContactTask_Exception
  */
 public function Run($userid = null)
 {
     try {
         $Factory = RegistryModuleFactory::GetInstance();
         $Registry = $Factory->GetRegistryByExtension($this->Domain->Extension);
         $Manifest = $Registry->GetManifest();
         if ($userid && $this->Domain->UserID != $userid) {
             throw new UpdateDomainContactAction_Exception(_("You don't have permissions for manage this domain"), UpdateDomainContactAction_Exception::DOMAIN_NOT_BELONGS_TO_USER);
         }
         $OldContact = $this->Domain->GetContact($this->contact_type);
         if ($this->NewContact && $this->NewContact->UserID != $this->Domain->UserID) {
             throw new UpdateDomainContactAction_Exception(_("You don't have permissions for using this contact"), UpdateDomainContactAction_Exception::CONTACT_NOT_BELONGS_TO_USER);
         }
         $trade = $Manifest->GetRegistryOptions()->ability->trade == '1';
         if ($this->contact_type != CONTACT_TYPE::REGISTRANT || !$trade) {
             try {
                 $Registry->UpdateDomainContact($this->Domain, $this->contact_type, $OldContact, $this->NewContact);
                 return $this->Domain->HasPendingOperation(Registry::OP_UPDATE) ? UpdateDomainContactAction_Result::PENDING : UpdateDomainContactAction_Result::OK;
             } catch (Exception $e) {
                 throw new UpdateDomainContactAction_Exception(sprintf(_("Cannot change contact. Reason: %s"), $e->getMessage()));
             }
         } else {
             // Execute trade when:
             // - Trade invoice is paid
             // - Previous trade failed
             if ($this->Domain->IncompleteOrderOperation == INCOMPLETE_OPERATION::DOMAIN_TRADE || $this->Invoice && $this->Invoice->Status == INVOICE_STATUS::PAID) {
                 $this->Domain->SetContact($this->NewContact, CONTACT_TYPE::REGISTRANT);
                 $this->Domain->IncompleteOrderOperation = null;
                 $extra["requesttype"] = "ownerChange";
                 try {
                     $trade = $Registry->ChangeDomainOwner($this->Domain, 1, $extra);
                     return $this->Domain->HasPendingOperation(Registry::OP_TRADE) ? UpdateDomainContactAction_Result::PENDING : UpdateDomainContactAction_Result::OK;
                 } catch (Exception $e) {
                     $this->Domain->IncompleteOrderOperation = INCOMPLETE_OPERATION::DOMAIN_TRADE;
                     if ($this->Invoice) {
                         $this->Invoice->ActionStatus = INVOICE_ACTION_STATUS::FAILED;
                         $this->Invoice->ActionFailReason = $e->getMessage();
                     }
                     throw new UpdateDomainContactAction_Exception(sprintf(_("Cannot change contact. Reason: %s"), $e->getMessage()));
                 }
             } else {
                 // Issue an invoice for trade operation
                 $invoiceid = $this->Db->GetOne("SELECT * FROM invoices WHERE status=? AND itemid=? AND purpose=?", array(INVOICE_STATUS::PENDING, $this->Domain->ID, INVOICE_PURPOSE::DOMAIN_TRADE));
                 if (!$invoiceid) {
                     $this->Domain->SetExtraField("NewRegistrantCLID", $this->NewContact->CLID);
                     DBDomain::GetInstance()->Save($this->Domain);
                     $Invoice = new Invoice(INVOICE_PURPOSE::DOMAIN_TRADE, $this->Domain->ID, $userid);
                     $Invoice->Description = sprintf(_("%s domain name trade"), $this->Domain->GetHostName());
                     $Invoice->Save();
                     $this->Invoice = $Invoice;
                     return UpdateDomainContactAction_Result::INVOICE_GENERATED;
                 } else {
                     throw new UpdateDomainContactAction_Exception(_("Another domain trade is already initiated"));
                 }
             }
         }
     } catch (Exception $e) {
         throw new UpdateDomainContactAction_Exception($e->getMessage());
     }
 }