public static function OnCompleteChangeContactRequest($Contact, $op_type, $approved, $request_ok, $error = null) { $DB = Core::GetDBInstance(); $userinfo = $DB->GetRow("SELECT * FROM users WHERE id=?", array($Contact->UserID)); $args = array("client" => $userinfo, "Contact" => $Contact, "approved" => $approved, "request_ok" => $request_ok, "error" => $error); mailer_send("contact_change_request_complete.eml", $args, $userinfo["email"], $userinfo["name"]); }
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); } } }
public function OnPaid(Invoice $Invoice, AbstractPaymentModule $payment_module = null) { $db = Core::GetDBInstance(); if (CONFIG::$PREPAID_MODE && $Invoice->Purpose != INVOICE_PURPOSE::BALANCE_DEPOSIT) { // In prepaid mode skip emails about invoices return; } $userinfo = $db->GetRow("SELECT * FROM users WHERE id=?", array($Invoice->UserID)); $args = array("login" => $userinfo["login"], "Invoice" => $Invoice, "client" => $userinfo); mailer_send("invoice_paid.eml", $args, $userinfo["email"], $userinfo["name"]); }
try { $Client = Client::LoadByEmail($attr['email']); } catch(Exception $e) { print "INVALID_EMAIL"; exit(); } if ($Client) { $code = base64_encode($Crypto->Hash("{$Client->ID}::{$Client->Password}::{$Client->Email}")); $link = CONFIG::$SITE_URL."/client/login.php?id={$Client->ID}&code={$code}&action=sendpwd"; $args = array( "link" => $link, "client" => $db->GetRow('SELECT * FROM users WHERE id=?', array($Client->ID))); mailer_send("password_change_confirm.eml", $args, $Client->Email, $Client->Name); print "OK"; exit(); } break; } } print "ERROR"; exit(); ?>
public function HandleImpendingExpiration(Domain $domain) { // http://bugzilla.webta.net/show_bug.cgi?id=210 // Prevent domain expiration $Config = $this->GetManifest()->GetSectionConfig(); $days = $Config->domain->xpath("//renewal/notifications/period"); $last_notification_period = (int) end($days); $last_renewal_date = $domain->RenewalDate ? $domain->RenewalDate : $domain->ExpireDate; $days_before_expire = (int) ceil(($last_renewal_date - time()) / 86400); if ($days_before_expire <= $last_notification_period) { if ($days_before_expire < 0) { // Today will expire... OMG! $days_before_expire = 0; } // Set renew period $period = (int) $Config->domain->renewal->min_period; $domain->Period = $period; // Copypasta from class.RenewProcess.php // Issue invoice for renew and send notification to client. $Invoice = new Invoice(INVOICE_PURPOSE::DOMAIN_RENEW, $domain, $domain->UserID); $Invoice->Description = sprintf(_("%s domain name renewal for %s years"), $domain->GetHostName(), $period); $Invoice->Save(); if ($Invoice->Status == INVOICE_STATUS::PENDING) { $userinfo = $this->DB->GetRow("SELECT * FROM users WHERE id=?", array($domain->UserID)); $args = array("domain_name" => $domain->Name, "extension" => $domain->Extension, "invoice" => $Invoice, "expDays" => $days_before_expire, "client" => $userinfo, "renewal_date" => $domain->RenewalDate); mailer_send("renew_notice.eml", $args, $userinfo["email"], $userinfo["name"]); Application::FireEvent('DomainAboutToExpire', $domain, $days_before_expire); } } }
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); }
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"]); }
{ $errmsg = $e->getMessage(); } }// if check inf if ($invoiceid) { $userinfo = $db->GetRow("SELECT * FROM users WHERE id=?", array($Domain->UserID)); $args = array( "domain_name" => $Domain->Name, "extension" => $Domain->Extension, "Invoice" => Invoice::Load($invoiceid), "expDays" => $Domain->DaysBeforeExpiration, "client" => $userinfo ); mailer_send("renew_notice.eml", $args, $userinfo["email"], $userinfo["name"]); $okmsg = _("Notification successfully sent"); CoreUtils::Redirect("domains_view.php"); } break; } } } $display["title"] = _("Domains » View"); $display["help"] = _("• You can learn about possible values of status field <a target='blank' href='http://webta.net/docs/wiki/domain.status.codes'>here</a>.<br/> • When domain is locked, domain cannot be transferred.<br/> • Domain password is commonly used in transfer procedure."); // Ajax view $display["load_extjs"] = true;
require_once "src/prepend.inc.php"; $DbDomain = DBDomain::GetInstance(); $RegFactory = RegistryModuleFactory::GetInstance(); if ($post_action == "appr") { $proceed = 0; foreach ((array) $post_id as $id) { try { $Domain = $DbDomain->Load($id); $Registry = $RegFactory->GetRegistryByExtension($Domain->Extension); $Registry->DeleteDomain($Domain); $db->Execute("UPDATE domains SET delete_status = ? WHERE id = ?", array(DOMAIN_DELETE_STATUS::APPROVED, $Domain->ID)); $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"]); $proceed++; } catch (Exception $e) { $hostname = $Domain ? $Domain->GetHostName() : $db->GetOne("SELECT CONCAT(name, '.', TLD) FROM domains WHERE id = ?", array($post_id)); $msg = sprintf(_("Cannot delete domain '%s'. %s"), $hostname, $e->getMessage()); Log::Log($msg, E_USER_ERROR); $err[] = $msg; } } if ($proceed) { $okmsg = sprintf(_("%s domain(s) deleted"), $proceed); } CoreUtils::Redirect("domains_await_delete_confirmation.php"); } $display["title"] = _("Domains") . " » " . _("Awaiting delete confirmation"); $display["help"] = _("These domains were registered in auto renew registry and their renewal was unpaid by customers.");
if (!$Validator->IsEmail($post_email)) $err[] = sprintf(_("'%s' is not a valid email address"), $post_email); if (!$user) $err[] = _("Incorrect password"); if ($post_email == $user["email"]) $err[] = _("New email address cannot be the same as the old one"); // if user password is correct update info if (count($err) == 0) { $db->Execute("UPDATE users SET nemail=? WHERE id=?", array($post_email, $_SESSION['userid'])); $code = base64_encode($Crypto->Hash("{$user['id']}::{$user['password']}::{$post_email}")); $link = CONFIG::$SITE_URL."/client/login.php?id={$user['id']}&code={$code}&action=confirmeml"; $args = array("link" => $link, "client" => $user); mailer_send("email_change_confirm.eml", $args, $user["email"], $user["name"]); $okmsg = _("Confirmation email was sent on the new email address that you entered. Please click on a link inside email to confirm email change."); CoreUtils::Redirect ("index.php"); } } $display["info"] = $db->GetRow("SELECT email FROM users WHERE id=?", array($_SESSION['userid'])); $display["help"] = sprintf(_("This page allows you to change your account email address. %s sends sensitive information on this address, thus you must enter your current account password, and then click a link inside email message that will be sent to you, to confirm email change."), CONFIG::$COMPANY_NAME); require_once ("src/append.inc.php"); ?>
} catch(Exception $e) { throw new ApplicationException($e->getMessage(), $e->getCode()); } Application::FireEvent('ClientCreated', $Client); if (CONFIG::$CLIENT_MANUAL_APPROVAL == 1) { $Client->SetSettingValue("pwd", $password); mailer_send("signup_pending.eml", $args, $_SESSION['wizard']['newclient']["email"], $_SESSION['wizard']['newclient']["name"]); } else { mailer_send("signup.eml", $args, $_SESSION['wizard']['newclient']["email"], $_SESSION['wizard']['newclient']["name"]); $Client->SetSettingValue("welcome_send", 1); } if ($_SESSION['userid'] && $_SESSION['c_login'] && $_SESSION['c_password']) { try { $Client = Client::Load($_SESSION['userid']); } catch(Excepiton $e){} if ($_SESSION['c_password'] == $Client->Password) { $sault = $Crypto->Sault();
function Report(Task $Task) { $Job = $Task->JobObject; // Generate CSV report $report_fname = tempnam(sys_get_temp_dir(), ""); $fp = fopen($report_fname, "w+"); // Put headers fputcsv($fp, array("status", "domain", "period", "registrant", "admin", "tech", "billing", "ns1", "ns2", "extra", "error")); // For each tld take domains and generate report foreach ($Job->tlds as $tld) { // Get all domains in task of $tld $targets = $this->GetTargetsForTld($Task->GetAllTargets(), $tld); foreach ($targets as $Target) { // Format extra data if ($Job->extra[$tld]) { $extra = array(); foreach ($Job->extra[$tld] as $k => $v) { $extra[] = "{$k}: {$v}"; } $extra = join("\n", $extra); } else { $extra = ""; } // Make status if ($Target->status == TargetStatus::OK) { if ($Target->action_result == RegisterDomainAction_Result::INVOICE_GENERATED) { $status = "invoice issued"; } else { if ($Target->action_result == RegisterDomainAction_Result::PENDING) { $status = "pending"; } else { $status = "ok"; } } } else { $status = "fail"; } // Add row to report $row = array($status, $Target->target, $Job->periods[$tld], $Job->contact_list[$tld]["registrant"], $Job->contact_list[$tld]["admin"], $Job->contact_list[$tld]["tech"], $Job->contact_list[$tld]["billing"], $Job->ns_list[0], $Job->ns_list[1], $extra, $Target->fail_reason); fputcsv($fp, $row, ',', '"'); } } fclose($fp); $Mailer = Core::GetPHPSmartyMailerInstance(); // Attach report file $Mailer->ClearAttachments(); $Mailer->AddAttachment($report_fname, "report.csv"); // Send email $Client = Client::Load($Task->userid); mailer_send("bulk_registration.eml", array("Client" => $Client), $Client->Email, $Client->Name); // Clear attachments for future send $Mailer->ClearAttachments(); unlink($report_fname); }
CoreUtils::Redirect("users_view.php"); } } elseif($post_action == "mail") { // Resend registration email $i = 0; foreach ((array)$post_id as $k=>$v) { $info = $db->GetRow("SELECT * FROM users WHERE id='{$v}'"); $password = $Crypto->Sault(10); $db->Execute("UPDATE users SET password='******' WHERE id='{$v}'"); $args = array("client" => $info, "login"=>$info["login"], "password"=>$password); mailer_send("signup.eml", $args, $info["email"], $info["name"]); $i++; } $okmsg = "{$i} email messages sent"; CoreUtils::Redirect("users_view.php"); } } $display["authHash"] = $_SESSION["admin_hash"]; $display["load_extjs"] = true; require_once ("src/append.inc.php"); ?>