/** * make new translate */ protected function __construct() { $options = array('log' => Log::Log(), 'logUntranslated' => false); $locale = L10n::getInstance(); $supported = $locale->getBrowser(); arsort($supported, SORT_NUMERIC); $file = ''; foreach ($supported as $loc => $val) { if (file_exists(LOCALE_PATH . '/' . $loc . '/locale.php')) { $file = LOCALE_PATH . '/' . $loc . '/locale.php'; $locale->setLocale($loc); break; } } if ($file == '' && file_exists(LOCALE_PATH . '/en_US/locale.php')) { $file = LOCALE_PATH . '/en_US/locale.php'; $locale->setLocale('en_US'); } if ($file != '') { $this->translate = new Zend_Translate(Zend_Translate::AN_ARRAY, $file, $locale->getLanguage(), $options); #Log::Log()->debug('locale ' . $locale->getLanguage() . '_' .$locale->getRegion() . ' loaded'); } else { throw new Exception(__METHOD__ . ': no translation files available'); } }
public function OnStartForking() { Log::Log("Starting 'CleanZombyUsers' cronjob...", E_USER_NOTICE); $db = Core::GetDBInstance(); $this->ThreadArgs = array(); foreach((array)$db->GetAll("SELECT * FROM users") as $user) { $domains = $db->GetOne("SELECT COUNT(*) FROM domains WHERE status='".DOMAIN_STATUS::DELEGATED."' AND userid='{$user['id']}'"); $invoices = $db->GetOne("SELECT COUNT(*) FROM invoices WHERE (status='1' OR (status = '0' AND TO_DAYS(NOW())-TO_DAYS(dtcreated)<15)) AND userid='{$user['id']}' "); if ($domains == 0 && $invoices == 0) { Log::Log("Found inactive user: {$user['login']} (id = {$user['id']})", E_USER_NOTICE); $db->Execute("DELETE FROM users WHERE id='{$user['id']}'"); $db->Execute("DELETE FROM invoices WHERE userid='{$user['id']}'"); $db->Execute("DELETE FROM domains WHERE userid='{$user['id']}'"); $db->Execute("DELETE FROM contacts WHERE userid='{$user['id']}'"); } } }
public function StartThread($module_info) { // Reopen database connection in child process $db = Core::GetDBInstance(null, true); // Attach mail notifications on registy events Registry::AttachClassObserver(new EmailToRegistrantObserver()); Registry::AttachClassObserver(new OperationHistory()); Registry::AttachClassObserver(new ManagedDNSRegistryObserver()); $RegFactory = RegistryModuleFactory::GetInstance(); $Registry = $RegFactory->GetRegistryByName($module_info["name"], false); $Extensions = $Registry->GetManifest()->GetExtensionList(); foreach ($Extensions as $ext) { try { $r = false; $r = $RegFactory->GetRegistryByExtension($ext, true, true); } catch(Exception $e) { $r = false; } if ($r && $r->GetModuleName() == $Registry->GetModuleName()) { Log::Log(sprintf("Processing %s extension with module %s", $ext, $r->GetModuleName()), E_USER_NOTICE); $r->DispatchPendingOperations(); } } }
/** * Constructor * @access public * @return void */ function __construct($message, $code = 0) { parent::__construct($message, $code); // Add log entry Log::Log($code == 0 ? "Error: " : "Warning: " . $this->getMessage()); redirect(CF_ROUTER_URL . "/error.php?msg=" . urlencode($message)); }
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); } } }
private function DoExchange($message) { if (class_exists("HttpRequest") && !$this->curl) { if (!$this->http_request) { $this->http_request = new HttpRequest(); } $http_request = $this->http_request; $http_request->setUrl($this->url); $http_request->setMethod(HTTP_METH_POST); $http_request->setRawPostData($message); $http_message = $http_request->send(); if ($http_message->getResponseCode() == 200) { return $http_message->getBody(); } else { throw new Exception(sprintf("Service failed with code = %d, message: %s", $http_message->getResponseCode(), $http_message->getBody())); } } else { if (!$this->curl) { $this->curl = curl_init(); } curl_setopt_array($this->curl, array(CURLOPT_URL => $this->url, CURLOPT_POST => 1, CURLOPT_POSTFIELDS => $message, CURLOPT_RETURNTRANSFER => 1, CURLOPT_HEADER => 0, CURLOPT_SSL_VERIFYPEER => 0, CURLOPT_SSL_VERIFYHOST => 0)); $http_body = curl_exec($this->curl); if ("200" == ($status = curl_getinfo($this->curl, CURLINFO_HTTP_CODE))) { return $http_body; } else { if ($err = curl_error($this->curl)) { Log::Log("CURL error: {$err}", E_USER_NOTICE); } throw new Exception(sprintf("Service failed with code = %d, message: %s", $status, $http_body)); } } }
public function indexAction() { $session = Zend_Registry::get('session'); Log::Log()->info(__METHOD__ . ' user logged out ' . $this->view->session->authdata['authed_username']); unset($session->authdata); $session->authdata['authed'] = false; Zend_Session::destroy(); }
public static final function IsExtensionLicensed($extension_name) { try { return self::IsFlagEnabled($extension_name); } catch (Exception $ex) { Log::Log("Unknown extension {$extension_name}. Considering it a custom one (licensed).", E_USER_NOTICE); return true; } }
/** * This method performs request to remote registry * * @param string $command Registry command * @param array $data Command dependent data * @return TransportResponse */ function Request($command, $data = array()) { $data["Command"] = $command; $data['UID'] = $this->Login; $data['PW'] = $this->Password; $data['responsetype'] = 'xml'; $request = http_build_query($data); Log::Log(sprintf("Sending request: %s", $request), E_USER_NOTICE); if ($this->DumpTraffic) { print ">> Sending request:\n"; print "{$request}\n"; } $ch = curl_init(); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_URL, $this->ServerHost); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); curl_setopt($ch, CURLOPT_POSTFIELDS, $request); $retval = @curl_exec($ch); $e = curl_error($ch); curl_close($ch); // Log response Log::Log(sprintf("Server response:\n%s", $retval), E_USER_NOTICE); if ($this->DumpTraffic) { print "<< Server respond:\n"; print "{$retval}\n"; } if ($e) { throw new Exception($e); } // Remove unparsable characters, to prevent "PCDATA invalid Char value" error $retval = preg_replace('/[\\x00-\\x08\\x0B\\x0C\\x0E-\\x1F]/', '', $retval); // Construct XML object $Response = new SimpleXMLElement($retval); if (!$Response) { throw new Exception(_("Registry returned malformed XML")); } if ($Response->ErrCount > 0) { $errmsg = (string) $Response->errors->Err1; } if ($Response->RRPCode) { $response_code = (int) $Response->RRPCode; // Succes when no error messages and RRP code is successful $is_success = !$errmsg && ((int) $response_code >= 200 && (int) $response_code <= 220); if (!$is_success && !$errmsg) { // Set error message $errmsg = $Response->RRPText; } } else { $response_code = 1; $is_success = !$errmsg; } return new TransportResponse($response_code, $Response, $is_success, $errmsg); }
public function OnStartForking() { Log::Log("Starting 'LogRotate' cronjob...", E_USER_NOTICE); $db = Core::GetDBInstance(); $this->ThreadArgs = array(); if (CONFIG::$ROTATE_LOG_EVERY > 0) $db->Execute("DELETE FROM syslog WHERE TO_DAYS(NOW())-TO_DAYS(dtadded) > ?", array(CONFIG::$ROTATE_LOG_EVERY)); }
public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request) { $session = Zend_Registry::get('session'); if (in_array($request->getControllerName(), array('login', 'error', 'js', 'img', 'css'))) { return; } if (!isset($session->authdata) || !isset($session->authdata['authed']) || $session->authdata['authed'] === false) { $fc = Zend_Controller_Front::getInstance(); $response = $fc->getResponse(); $response->canSendHeaders(true); $response->setHeader('Location', 'login', true); $response->setHeader('Status', '301', true); Log::Log()->debug('redirected to login'); $request->setModuleName('default')->setControllerName('login')->setActionName('index')->setDispatched(false); } }
public function OnPaid(Invoice $Invoice, AbstractPaymentModule $payment_module = null) { if ($Invoice->Purpose != INVOICE_PURPOSE::BALANCE_DEPOSIT) { return; } Log::Log("BalanceInvoiceObserver::OnPaid(InvoiceID={$Invoice->ID})", E_USER_NOTICE); try { $Balance = DBBalance::GetInstance()->LoadClientBalance($Invoice->UserID); $Operation = $Balance->CreateOperation(BalanceOperationType::Deposit, $Invoice->GetTotal()); $Operation->InvoiceID = $Invoice->ID; $Balance->ApplyOperation($Operation); } catch (Exception $e) { Log::Log("BalanceInvoiceObserver::OnPaid() thrown exception: {$e->getMessage()}", E_USER_ERROR); } // OnPaymentComplete routine succeffully completed. Log::Log("BalanceInvoiceObserver::OnPaid Successfully completed.", E_USER_NOTICE); }
/** * Return Server Score calculated from ping time and server connection time * * @param string $server Server hostname * @return float */ public function GetSpeedScore($server) { $ping = round($this->GetPingSpeed($server),2); $connect = round($this->GetNNTPSpeed($server),2); if (Log::HasLogger("PCNTL")) Log::Log("Server score for '{$server}': ping={$ping}, connect={$connect}", 1, "PCNTL"); else Log::Log("Server score for '{$server}': ping={$ping}, connect={$connect}", 1, "NNTPLog"); if ($connect) { $total = round(($ping+$connect)/2, 2); return $total; } else return false; }
/** * A cow * * @param string $message * @param int $code One of PHP's internal E_ */ function __construct($message, $code = null) { // Defaultize $code. Not sure if we can place a constant in param default, since constants are kind of late-binded $code = ($code == null) ? E_USER_ERROR : $code; // Call Exception constructor parent::__construct($message, $code); // Generate backtrace if debug mode flag set if (CONFIG::$DEV_DEBUG) $this->BackTrace = Debug::Backtrace(); // Log exception if ( class_exists("Log") && Log::HasLogger("EPPDRSLogger")) { Log::$DoRaiseExceptions = false; Log::Log("{$this->getMessage()}", $code, array("backtrace" => $bt), "EPPDRSLogger"); } }
/** * Perform request to registry server * * @param string $command * @param array $data * @return TransportResponse * @throws Exception */ public function Request($command, $data = array()) { // Prepare request string $request = $this->PrepareCommand($command, $data); // Add log entry Log::Log(sprintf("Sending request:\n%s", $request), E_USER_NOTICE); if ($this->DumpTraffic) { print ">> Sending request:\n"; print "{$request}\n"; } // Request $ch = curl_init(); curl_setopt_array($ch, array(CURLOPT_URL => $this->ConnectionConfig->GetFieldByName("APIUrl")->Value, CURLOPT_POST => 1, CURLOPT_HEADER => 1, CURLOPT_POSTFIELDS => $request, CURLOPT_RETURNTRANSFER => 1, CURLOPT_SSL_VERIFYHOST => 0, CURLOPT_SSL_VERIFYPEER => 0)); $full_response = curl_exec($ch); if ($full_response === false) { throw Exception(curl_error($ch)); } curl_close($ch); // Log response Log::Log(sprintf("Server response:\n%s", $full_response), E_USER_NOTICE); if ($this->DumpTraffic) { print "<< Server respond:\n"; print "{$full_response}\n"; } $chunks = explode("[RESPONSE]", $full_response); $res = trim($chunks[1]); preg_match("/code[\\s]*=[\\s]*([0-9]+)/si", $res, $matches); $response_code = $matches[1]; preg_match("/description[\\s]*=[\\s]*(.*?)\n/si", $res, $matches); $errmsg = $matches[1]; if (!$errmsg) { preg_match_all("/<title>(.*?)<\\/title>/si", $full_response, $matches); $errmsg = $matches[1]; if (!$errmsg) { $errmsg = "Unknown error. See log for more information."; } } if ($response_code == 545) { throw new ObjectNotExistsException(); } $is_success = (int) $response_code >= 200 && (int) $response_code <= 220; return new TransportResponse($response_code, $res, $is_success, $errmsg); }
public function Notify(AbstractPaymentModule $PaymentModule, $status) { Log::Log("UIPaymentObserver: received notify", E_USER_NOTICE); if ($status == PAYMENT_STATUS::SUCCESS) { $GLOBALS["okmsg"] = _("Thank you for your payment!"); if (!$_SESSION["success_payment_redirect_url"]) CoreUtils::Redirect("inv_view.php"); else CoreUtils::Redirect($_SESSION["success_payment_redirect_url"]); } elseif ($status == PAYMENT_STATUS::FAILURE) { $PaymentForm = $PaymentModule->GetPaymentForm(); $smarty = Core::GetSmartyInstance("SmartyExt"); $fields = $PaymentForm->ListFields(); $smarty_fields = array(); foreach($fields as $field) { $smarty_fields[$field->Title] = array("name" => $field->Name, "required" => $field->IsRequired, "type" => $field->FieldType, "values" => $field->Options); if ($_REQUEST[$field->Name]) $attr[$field->Title] = $_REQUEST[$field->Name]; } $display["errmsg"] = "The following errors occured"; $display["err"] = explode("\n", $PaymentModule->GetFailureReason()); $display["gate"] = $PaymentModule->GetModuleName(); $display["orderid"] = $PaymentModule->GetOrderID(false); $display["fields"] = $smarty_fields; $display["post"] = $attr; $template_name = "client/paymentdata.tpl"; $smarty->assign($GLOBALS["display"]); $smarty->assign($display); $smarty->display($template_name); } else throw new Exception(sprintf(_("Undefined PaymentStatus received from %s payment module."), $PaymentModule->GetModuleName()), E_USER_ERROR); }
public static function FireEvent($event_name) { try { $args = func_get_args(); array_shift($args); // First argument is event name Log::Log(sprintf('Fire %s', $event_name), E_USER_NOTICE); foreach (EVENT_HANDLER_PHACE::GetKeys() as $phace) { if (array_key_exists($phace, self::$Observers)) { foreach (self::$Observers[$phace] as $observer) { Log::Log(sprintf("Execute %s:On%s", get_class($observer), $event_name), E_USER_NOTICE); call_user_func_array(array($observer, "On{$event_name}"), $args); } } } } catch (Exception $e) { Log::Log(sprintf("Application::FireEvent thrown exception: %s, file: %s", $e->getMessage(), $e->getFile()), E_ERROR); } return; }
public function errorAction() { $errors = $this->_getParam('error_handler'); switch ($errors->type) { case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER: case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION: // 404 error -- controller or action not found $this->getResponse()->setHttpResponseCode(404); $this->view->message = 'Page not found'; break; default: // application error $this->getResponse()->setHttpResponseCode(500); $this->view->message = 'Application error'; break; } $this->view->exception = $errors->exception; $this->view->request = $errors->request; Log::Log()->emerg($errors->exception); }
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); }
function DispatchPollDeleteContact(PollDeleteContactResponse $resp) { if ($resp->IsFailed()) { Log::Log(sprintf('DispatchContactDeleted failed. Registry response: %s', $resp->ErrMsg), E_USER_ERROR); throw new Exception($resp->ErrMsg, $resp->Code); } $contact = $this->DBContact->LoadByCLID($resp->CLID); $this->DBContact->Delete($contact); $this->FireEvent('ContactDeleted', $contact); }
public function crtAction() { $ssl_client_s_dn = GetEnv::getEnvVar('SSL_CLIENT_S_DN'); $ssl_client_i_dn = GetEnv::getEnvVar('SSL_CLIENT_I_DN'); $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/application.ini', APPLICATION_ENV); $db = Zend_Registry::get('auth_dbc'); $db2 = Zend_Registry::get('auth2_dbc'); $auth = new Zend_Auth_Adapter_DbTable($db2); $auth->setTableName($config->ca_mgr->db->auth2->tablename)->setIdentityColumn('user_client_crt_s_dn_i_dn')->setCredentialColumn('user_client_crt_s_dn_i_dn'); $auth->setIdentity($ssl_client_s_dn . '//' . $ssl_client_i_dn)->setCredential($ssl_client_s_dn . '//' . $ssl_client_i_dn)->setCredentialTreatment('?'); $result = $auth->authenticate(); $code = $result->getCode(); switch ($code) { case Zend_Auth_Result::FAILURE: Log::Log()->info(__METHOD__ . ' user failed (Zend_Auth_Result::FAILURE) to log in ' . $ssl_client_s_dn . '//' . $ssl_client_i_dn); throw new Exception(__METHOD__ . ': unknown error'); case Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND: Log::Log()->info(__METHOD__ . ' user failed (Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND) to log in ' . $ssl_client_s_dn . '//' . $ssl_client_i_dn); throw new Exception(__METHOD__ . ': ID unknown'); case Zend_Auth_Result::FAILURE_IDENTITY_AMBIGUOUS: Log::Log()->info(__METHOD__ . ' user failed (Zend_Auth_Result::FAILURE_IDENTITY_AMBIGUOUS) to log in ' . $ssl_client_s_dn . '//' . $ssl_client_i_dn); throw new Exception(__METHOD__ . ': ID not unique'); case Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID: Log::Log()->info(__METHOD__ . ' user failed (Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID) to log in ' . $ssl_client_s_dn . '//' . $ssl_client_i_dn); throw new Exception(__METHOD__ . ': ID unknown'); // to prevent brute force password attachs // to prevent brute force password attachs case Zend_Auth_Result::FAILURE_UNCATEGORIZED: Log::Log()->info(__METHOD__ . ' user failed (Zend_Auth_Result::FAILURE_UNCATEGORIZED) to log in ' . $ssl_client_s_dn . '//' . $ssl_client_i_dn); throw new Exception(__METHOD__ . ': unknown error'); } $this->getAuthDetailsIntoSession($auth, true); /* $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer'); $viewRenderer->setRender('loginresult'); */ Log::Log()->info(__METHOD__ . ' user logged in ' . $this->view->session->authdata['authed_username'] . ' (' . $ssl_client_s_dn . '//' . $ssl_client_i_dn . ')'); #$this->_forward('index', 'index'); // only "soft" forward, we need to change the url in browser $this->_redirect($this->view->url(array('controller' => 'index', 'action' => 'index'), 'default', true)); }
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); }
/** * This method is called when we received a postback from payment proccessor and CheckSignature() returned true. * * @param array $request Anything that we received from payment gateway (basically $_REQUEST). * @return bool True if payment succeed or false if failed. If payment is failed and you return false, $this->GetFailureReason() will also be called. */ public function OnPaymentComplete($request) { $res = $this->PostBack($request); Log::Log(sprintf("PostBack:\n%s", $res), E_USER_NOTICE); $result = strcmp($res, "VERIFIED") == 0 && $request['mc_currency'] == CONFIG::$BILLING_CURRENCYISO && (strtolower($request['business']) == strtolower($this->Config->GetFieldByName("business")->Value) || (strtolower($this->Config->GetFieldByName("receiver")->Value) == strtolower($request['receiver_email']))); $result = ($result && ($request["payment_status"] == "Completed" || ($request["payment_status"] == "Pending" && $this->Config->GetFieldByName("isdemo")->Value == 1 ) ) ); $result = ($result && ($request["txn_type"] == "subscr_payment" || $request["txn_type"] == "web_accept")); if ($result) return true; else { if ($request["payment_status"] == "Pending") { return null; } $this->FailureReason = _("Payment notify validation falied."); return false; } }
public function Send($template_name = null, $mail_args = null, $email = null, $name = null) { if ($template_name && is_array($mail_args) && $email) { if (class_exists("Log", false)) Log::Log("Sending email '{$template_name}' to '{$email}'", E_USER_NOTICE); $this->ClearAddresses(); $this->SmartyBody = array($template_name, $mail_args); $this->AddAddress($email, $name); $this->Observable->Fire('BeforeSend', $this); } if (!parent::Send() && class_exists("Log", false)) Log::Log("Cannot send email:".$this->ErrorInfo, E_ERROR); $this->ClearAddresses(); }
/** * Defined by Zend_Config_Writer * * use set to limit impact when a shared config file is used (i.e. config per item using foreign keys) * * @param string $filename * @param Config_Db $config * @param string $set * @return void */ public function write($db = null, $config = null, $set = null) { $this->_set = $set; // this method is specialized for writing back Config objects (which hold config_db objects) if ($config !== null) { if ($config instanceof Config) { $this->setConfig($config->getConfig()); } else { $this->setConfig($config); } } if ($this->_config === null) { require_once 'Zend/Config/Exception.php'; throw new Zend_Config_Exception('No config was set'); } if ($db === null) { require_once 'Zend/Config/Exception.php'; throw new Zend_Config_Exception('No db was set'); } $sql = array(); $string = 'delete from ' . $this->_tableName; if ($this->_set !== null) { $string .= ' where ' . $this->_set; } $sql[] = $string; $iniString = ''; $extends = $this->_config->getExtends(); $sectionName = $this->_config->getSectionName(); foreach ($this->_config as $key => $data) { $sql = array_merge($sql, $this->addEntry($sectionName, $key, $data)); } try { $db->beginTransaction(); foreach ($sql as $command) { #Log::Log()->debug($command); $db->query($command); } $db->commit(); } catch (Exception $e) { $db->rollBack(); Log::Log()->err($e); throw $e; } }
/** * Parse server response * * @param string $message * @return array */ private function ParseResponse($message) { Log::Log("Response: ".$message, E_USER_NOTICE); // check sign if ($this->VerifySRS($message)) { // if sign ok, parse message $mess = explode("\n", $message); $headers = array(); $body = array(); $isbody = false; foreach ($mess as $string) { if (trim($string) != '') { if (stristr($string, "END HEADER")) $isbody = true; if (stristr($string, "BEGIN PGP SIGNATURE")) break; if ($string[0] == "-") continue; $pstring = explode(":", trim($string)); $key = trim($pstring[0]); $value = trim($pstring[1]); if ($key != '') { if ($isbody) { if ($headers["SAFE CONTENTS"] != '1') { $temp = pack("H*", $value); $body[$key] = $temp[1]; } else $body[$key] = $value; } else $headers[$key] = $value; } } } // check message if ($headers["STATUS"] == "" || $headers["PROTOCOL VERSION"] == "") Log::Log("Did not get properly formatted request from server", E_USER_ERROR); else { // if status succes return result if ($headers["STATUS"] == "SUCCESS") return $body; else { foreach ($body as $k=>$v) { if(stristr($k, "ERROR")) { // else show error from server $have_errors = true; $this->RaiseWarning($v); return false; } } if (!$have_errors) $this->RaiseWarning("No details returned by registry."); } } } else { // sign not property Log::Log("Response verification failed", E_USER_ERROR); return false; } }
private function MarkAsExpired (Domain $Domain) { $db = Core::GetDBInstance(); //Set to domain 'Expired' Log::Log(sprintf("Mark domain '%s' as expired", $Domain->GetHostName()), E_USER_NOTICE); $db->Execute("UPDATE domains SET status = ? WHERE id = ?", array(DOMAIN_STATUS::EXPIRED, $Domain->ID)); // Mark invoice as 'Failed' $db->Execute("UPDATE invoices SET status = ? WHERE itemid = ? AND status = ? AND purpose = ?", array(INVOICE_STATUS::FAILED, $Domain->ID, INVOICE_STATUS::PENDING, INVOICE_PURPOSE::DOMAIN_RENEW)); $userinfo = $db->GetRow("SELECT * FROM users WHERE id = ?", array($Domain->UserID)); // Send domain expired notice $args = array ( "login" => $userinfo["login"], "domain_name" => $Domain->Name, "extension" => $Domain->Extension, "client" => $userinfo ); mailer_send("expired_notice.eml", $args, $userinfo["email"], $userinfo["name"]); }
/** Start grab from current group @access public @return void */ public function go() { Log::Log("Start fetching '{$this->UsenetCrawler->NNTPGroup}' from '{$this->UsenetCrawler->NNTPHost}'...\n", 1, "NNTPLog"); if ($this->UsenetCrawler) { $manager = new UsenetPostingManager(); $count = 0; while (($count++ < $this->PostsLimit)) { $posting = $this->UsenetCrawler->GetPosting(); if ($posting != false && $this->UsenetCrawler->Status == 0) { $manager->StorePost($posting); unset($posting); } if ($posting == false && $this->UsenetCrawler->Status == 1) break; } } Log::Log("End fetching '{$this->UsenetCrawler->NNTPGroup}' from '{$this->UsenetCrawler->NNTPHost}'...\n", 1, "NNTPLog"); }
/** * Send postback to PayPal server * @return string $res */ private final function PostBack($request) { $params = array( "Method" => "order_synchro", "Identifier" => $this->Config->GetFieldByName("MerchantIdentifier")->Value, "Usrname" => $this->Config->GetFieldByName("Username")->Value, "Pwd" => $this->Config->GetFieldByName("Password")->Value, "tnxid" => $request['tnxid'], "checksum" => $request['checksum'], "parity" => $request['parity'] ); $req = http_build_query($params); $postback_url = "https://www.monsterpay.com/secure/components/synchro.cfc?wsdl&{$req}"; Log::Log(sprintf("Sending Postback: %s", $postback_url), E_USER_NOTICE); return @file_get_contents($postback_url); }
public function PollTransfer(Domain $domain) { try { $Resp = $this->GetRemoteDomain($domain); $trStatus = null; // Detect transfer status. if ($Resp->Succeed()) { $eppExt = $Resp->RawResponse->response->extension->children($this->ExtNamespace); if (count($eppExt) && ($eppExt = $eppExt[0])) { // Check pending transaction $transfer = $eppExt->xpath("//{$this->ExtPrefix}:pendingTransaction/{$this->ExtPrefix}:transfer"); $trade = $eppExt->xpath("//{$this->ExtPrefix}:pendingTransaction/{$this->ExtPrefix}:trade"); if ($transfer[0] || $trade[0]) { $pendingTrans = $transfer[0] ? $transfer[0] : $trade[0]; $children = $pendingTrans->children($this->ExtNamespace); foreach ($children as $node) { if ("status" == $node->getName() && "NotYetApproved" == (string) $node) { $trStatus = TRANSFER_STATUS::PENDING; } } } } if ($Resp->CLID == $this->GetRegistrarID()) { $trStatus = TRANSFER_STATUS::APPROVED; } } else { if ($Resp->Code == RFC3730_RESULT_CODE::ERR_AUTHORIZE_ERROR) { // Client has no permissions for this object... // Because transfer failed or was not initiated, dude! $trStatus = TRANSFER_STATUS::FAILED; } } // If transfer status was detected, // construct response and return it to the uplevel code. if ($trStatus !== null) { $Ret = new PollTransferResponse(REGISTRY_RESPONSE_STATUS::SUCCESS, $Resp->ErrMsg, $Resp->Code); $Ret->HostName = $domain->GetHostName(); $Ret->TransferStatus = $trStatus; return $Ret; } } catch (Exception $e) { Log::Log($e->getMessage(), E_USER_ERROR); } }