Пример #1
0
function ew_SendTemplateEmail($sTemplate, $sSender, $sRecipient, $sCcEmail, $sBccEmail, $sSubject, $arContent)
{
    if ($sSender != "" && $sRecipient != "") {
        $Email = new cEmail();
        $Email->Load($sTemplate);
        $Email->ReplaceSender($sSender);
        // Replace Sender
        $Email->ReplaceRecipient($sRecipient);
        // Replace Recipient
        if ($sCcEmail != "") {
            $Email->AddCc($sCcEmail);
        }
        // Add Cc
        if ($sBccEmail != "") {
            $Email->AddBcc($sBccEmail);
        }
        // Add Bcc
        if ($sSubject != "") {
            $Email->ReplaceSubject($sSubject);
        }
        // Replace subject
        if (is_array($arContent)) {
            foreach ($arContent as $key => $value) {
                $Email->ReplaceContent($key, $value);
            }
        }
        return $Email->Send();
    }
    return FALSE;
}
Пример #2
0
 function Page_Main()
 {
     global $conn, $Security, $Language, $gsFormError, $objForm;
     global $Breadcrumb;
     // Set up Breadcrumb
     $Breadcrumb = new cBreadcrumb();
     $Breadcrumb->Add("register", "<span id=\"ewPageCaption\">" . $Language->Phrase("RegisterPage") . "</span>", ew_CurrentUrl());
     $bUserExists = FALSE;
     if (@$_POST["a_register"] != "") {
         // Get action
         $this->CurrentAction = $_POST["a_register"];
         $this->LoadFormValues();
         // Get form values
         // Validate form
         if (!$this->ValidateForm()) {
             $this->CurrentAction = "I";
             // Form error, reset action
             $this->setFailureMessage($gsFormError);
         }
     } else {
         $this->CurrentAction = "I";
         // Display blank record
         $this->LoadDefaultValues();
         // Load default values
     }
     // Handle email activation
     if (@$_GET["action"] != "") {
         $sAction = $_GET["action"];
         $sEmail = @$_GET["email"];
         $sCode = @$_GET["token"];
         @(list($sApprovalCode, $sUsr, $sPwd) = explode(",", $sCode, 3));
         $sApprovalCode = ew_Decrypt($sApprovalCode);
         $sUsr = ew_Decrypt($sUsr);
         $sPwd = ew_Decrypt($sPwd);
         if ($sEmail == $sApprovalCode) {
             if (strtolower($sAction) == "confirm") {
                 // Email activation
                 if ($this->ActivateEmail($sEmail)) {
                     // Activate this email
                     if ($this->getSuccessMessage() == "") {
                         $this->setSuccessMessage($Language->Phrase("ActivateAccount"));
                     }
                     // Set up message acount activated
                     $this->Page_Terminate("cciaglogin.php");
                     // Go to login page
                 }
             }
         }
         if ($this->getFailureMessage() == "") {
             $this->setFailureMessage($Language->Phrase("ActivateFailed"));
         }
         // Set activate failed message
         $this->Page_Terminate("cciaglogin.php");
         // Go to login page
     }
     switch ($this->CurrentAction) {
         case "I":
             // Blank record, no action required
             break;
         case "A":
             // Add
             // Check for duplicate User ID
             $sFilter = str_replace("%u", ew_AdjustSql($this->usuario->CurrentValue), EW_USER_NAME_FILTER);
             // Set up filter (SQL WHERE clause) and get return SQL
             // SQL constructor in usuario class, usuarioinfo.php
             $this->CurrentFilter = $sFilter;
             $sUserSql = $this->SQL();
             if ($rs = $conn->Execute($sUserSql)) {
                 if (!$rs->EOF) {
                     $bUserExists = TRUE;
                     $this->RestoreFormValues();
                     // Restore form values
                     $this->setFailureMessage($Language->Phrase("UserExists"));
                     // Set user exist message
                 }
                 $rs->Close();
             }
             if (!$bUserExists) {
                 $this->SendEmail = TRUE;
                 // Send email on add success
                 if ($this->AddRow()) {
                     // Add record
                     // Load user email
                     $sReceiverEmail = $this->_email->CurrentValue;
                     if ($sReceiverEmail == "") {
                         // Send to recipient directly
                         $sReceiverEmail = EW_RECIPIENT_EMAIL;
                         $sBccEmail = "";
                     } else {
                         // Bcc recipient
                         $sBccEmail = EW_RECIPIENT_EMAIL;
                     }
                     // Set up email content
                     if ($sReceiverEmail != "") {
                         $Email = new cEmail();
                         $Email->Load("phptxt/cciagregister.txt");
                         $Email->ReplaceSender(EW_SENDER_EMAIL);
                         // Replace Sender
                         $Email->ReplaceRecipient($sReceiverEmail);
                         // Replace Recipient
                         if ($sBccEmail != "") {
                             $Email->AddBcc($sBccEmail);
                         }
                         // Add Bcc
                         $Email->ReplaceContent('<!--FieldCaption_email-->', $this->_email->FldCaption());
                         $Email->ReplaceContent('<!--email-->', strval($this->_email->FormValue));
                         $sActivateLink = ew_FullUrl() . "?action=confirm";
                         $sActivateLink .= "&email=" . $this->_email->CurrentValue;
                         $sToken = ew_Encrypt($this->_email->CurrentValue) . "," . ew_Encrypt($this->usuario->CurrentValue) . "," . ew_Encrypt($this->contrasenia->FormValue);
                         $sActivateLink .= "&token=" . $sToken;
                         $Email->ReplaceContent("<!--ActivateLink-->", $sActivateLink);
                         $Email->Charset = EW_EMAIL_CHARSET;
                         // Get new recordset
                         $this->CurrentFilter = $this->KeyFilter();
                         $sSql = $this->SQL();
                         $rsnew = $conn->Execute($sSql);
                         $Args = array();
                         $Args["rs"] = $rsnew->fields;
                         $bEmailSent = FALSE;
                         if ($this->Email_Sending($Email, $Args)) {
                             $bEmailSent = $Email->Send();
                         }
                         // Send email failed
                         if (!$bEmailSent) {
                             $this->setFailureMessage($Email->SendErrDescription);
                         }
                     }
                     if ($this->getSuccessMessage() == "") {
                         $this->setSuccessMessage($Language->Phrase("RegisterSuccessActivate"));
                     }
                     // Activate success
                     $this->Page_Terminate("cciaglogin.php");
                     // Return
                 } else {
                     $this->RestoreFormValues();
                     // Restore form values
                 }
             }
     }
     // Render row
     if ($this->CurrentAction == "F") {
         // Confirm page
         $this->RowType = EW_ROWTYPE_VIEW;
         // Render view
     } else {
         $this->RowType = EW_ROWTYPE_ADD;
         // Render add
     }
     $this->ResetAttrs();
     $this->RenderRow();
 }