/** * @access public * @param string $TLD TLD part, without dot * @param bool $extended If true, return all TLD's exports by module * @return Registry */ public function GetRegistryByExtension($extension, $db_check = true, $ignore_cache = false) { $db = Core::GetDBInstance(); $extensions = $this->GetExtensionList($db_check); if (in_array($extension, $extensions)) { $this->ListModules(); $module_name = $this->Modules[$extension]; if (!$module_name) { throw new Exception(sprintf(_("Module not defined for %s domain extension."), $extension)); } // Validate license for this module if (!License::IsModuleLicensed($module_name)) { switch (CONTEXTS::$APPCONTEXT) { case APPCONTEXT::CRONJOB: case APPCONTEXT::REGISTRAR_CP: $message = "Your license does not permit module {$module_name}. For additional module purchases, please contact sales@webta.net"; break; case APPCONTEXT::REGISTRANT_CP: $message = sprintf(_("Application license does not permit module %s. Please contact %s"), $module_name, UI::GetSupportEmailLink()); break; case APPCONTEXT::ORDERWIZARD: $message = "Your license does not permit module {$module_name}. For additional module purchases, please contact sales@webta.net"; break; } // Validate license for this module if (!License::IsModuleLicensed($module_name)) { throw new LicensingException($message); } } $Manifest = new RegistryManifest("{$this->ModulesPath}/{$module_name}/module.xml"); $module_codebase = $Manifest->GetModuleCodebase(); if (!$module_codebase) { $module_codebase = $module_name; } $this->LoadRegistryModule($module_codebase); if (!$this->ModulesCache[$extension] || $ignore_cache) { $reflect = new ReflectionClass("{$module_codebase}RegistryModule"); $Module = $reflect->newInstance($Manifest); $Config = $this->LoadModuleConfig($Module->GetConfigurationForm(), $module_name); $Module->InitializeModule($extension, $Config); $this->ModulesCache[$extension] = $Module; } } else { throw new Exception(sprintf(_("No modules configured to handle extension '%s'"), $extension)); } return new Registry($this->ModulesCache[$extension]); }
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); }
} $db->CompleteTrans(); if (!$err) { $okmsg = "Module successfully disabled"; CoreUtils::Redirect("modules_view.php"); } } } // Enable modules elseif($get_action == "enable" && $get_module) { // Check if this module licensed if (!License::IsModuleLicensed($get_module)) throw new LicensingException("Your license does not permit module {$get_module}. For additional module purchases, please contact sales@webta.net"); if (CONFIG::$DEV_DEMOMODE != 1) { $get_module = preg_replace("/[^A-Za-z0-9_-]+/", "", $get_module); // Validate Manifest RegistryManifest::LoadCompiledManifest(CONFIG::$PATH."/modules/registries/{$get_module}/module.xml", true); $res = RegistryManifest::Validate(CONFIG::$PATH."/modules/registries/{$get_module}/module.xml"); if ($res !== true) { Log::Log($res, E_USER_ERROR); $errmsg = sprintf(_("Module %s XML manifest did not pass validation. The following errors occured:"), $get_module); $err[] = $res; }