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); } } }
/** * 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(); }
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"; }
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 __construct($old_dsn, $options) { foreach ($options as $flag => $b) { $this->{$flag} = $b; } $this->DbOld =& NewADOConnection($old_dsn); $this->DbOld->SetFetchMode(ADODB_FETCH_ASSOC); $this->DbNew = Core::GetDBInstance(); $this->DBDomain = DBDomain::GetInstance(); $this->DBContact = DBContact::GetInstance(); $this->RegistryFactory = RegistryModuleFactory::GetInstance(); $this->Crypto = $GLOBALS['Crypto']; $this->TableList = array(); foreach ($this->DbOld->GetAll('SHOW TABLES') as $row) { $this->TableList[] = array_shift(array_values($row)); // first column in row } $this->ModuleNameMapFlip = array_flip($this->ModuleNameMap); }
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); }
/** * 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; } }
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); }
$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";
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'])); }
/** * 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()); } }
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); }
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";
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); }
<? 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) {
function _testDomainTransfer() { $domain = DBDomain::GetInstance()->Load(99); $res = $this->registry->TransferRequest($domain); $this->assertTrue($res, "Transfer requested"); }
/** * * @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; }
<? 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 {
<?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; } }
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'); }
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(
$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");
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()); } } } } }
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); }
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); } } }
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); } } }
{ $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);
function _testTrade() { // skip it return; /* $DBContact = DBContact::GetInstance(); $Domain = $this->Registry->NewDomainInstance(); $Domain->Name = 'marat' . rand(1000, 9999); $Domain->SetContact($DBContact->LoadByCLID('H67999712')); $Domain->SetContact($DBContact->LoadByCLID('C23770836')); $Domain->SetContact($DBContact->LoadByCLID('C27479794')); $Domain->SetNameserverList(array( new Nameserver('ns1.google.com'), new Nameserver('ns2.google.com') )); $this->Registry->CreateDomain($Domain, 1); */ $Domain = DBDomain::GetInstance()->LoadByName('marat8082', 'lu'); $Registrant = $this->Registry->NewContactInstance(CONTACT_TYPE::REGISTRANT); $Registrant->SetFieldList(array('name' => 'mosquito', 'city' => 'sebastopol', 'isorg' => '0', 'cc' => 'UA', 'pc' => '32312', 'street1' => 'pervomayskaya 13-3')); $this->Registry->CreateContact($Registrant); $Domain->SetContact($Registrant); $this->Registry->ChangeDomainOwner($Domain, 1); $this->assertTrue(true, 'change domain owner'); return; }
function testSetRemoteExpireDate () { $Domain = DBDomain::GetInstance()->LoadByName('military-army', 'gr'); $this->Registry->SetRemoteExpireDate($Domain, strtotime("2008-12-24")); var_dump(date("Y-m-d", $Domain->ExpireDate)); }
function _testBusy () { $DbDomain = DBDomain::GetInstance(); $Domain = $DbDomain->LoadByName('kilo', 'tel'); $this->Registry->CreateDomain($Domain, $Domain->Period); }