private function _seedSettings()
 {
     GeneralSettings::truncate();
     SmtpSettings::truncate();
     PaypalSettings::truncate();
     GeneralSettings::insert(['idle_timeout' => 0, 'self_signup' => 0]);
     SmtpSettings::insert(['status' => 0]);
     PaypalSettings::insert(['status' => 0, 'sandbox' => 0]);
     DirecpaySetting::insert(['status' => 0, 'sandbox' => 0]);
 }
 public function postSmtp()
 {
     if (!Input::has('id')) {
         return Redirect::route('setting.smtp')->with('error', 'Required parameter(s) missing.');
     }
     try {
         $input = Input::all();
         $setting = SmtpSettings::find($input['id']);
         $setting->fill($input);
         $this->flash($setting->save());
         return Redirect::route('setting.smtp');
     } catch (Illuminate\Database\Eloquent\ModelNotFoundException $e) {
         App::abort(404);
     }
 }
Ejemplo n.º 3
0
 /**
  * Send a invitation mail to the created user.
  * It used the old mail function
  * 
  * @param string $generatedPassword
  */
 protected function sendUserAccountInvitationMail($generatedPassword)
 {
     $objUserMail = \FWUser::getFWUserObject()->getMail();
     if (($objUserMail->load('user_account_invitation', $_LANGID) || $objUserMail->load('user_account_invitation')) && \Env::get('ClassLoader')->loadFile(ASCMS_LIBRARY_PATH . '/phpmailer/class.phpmailer.php') && ($objMail = new \PHPMailer()) !== false) {
         if ($_CONFIG['coreSmtpServer'] > 0 && \Env::get('ClassLoader')->loadFile(ASCMS_CORE_PATH . '/SmtpSettings.class.php')) {
             if (($arrSmtp = \SmtpSettings::getSmtpAccount($_CONFIG['coreSmtpServer'])) !== false) {
                 $objMail->IsSMTP();
                 $objMail->Host = $arrSmtp['hostname'];
                 $objMail->Port = $arrSmtp['port'];
                 $objMail->SMTPAuth = true;
                 $objMail->Username = $arrSmtp['username'];
                 $objMail->Password = $arrSmtp['password'];
             }
         }
         $objMail->CharSet = CONTREXX_CHARSET;
         $objMail->From = $objUserMail->getSenderMail();
         $objMail->FromName = $objUserMail->getSenderName();
         $objMail->AddReplyTo($objUserMail->getSenderMail());
         $objMail->Subject = $objUserMail->getSubject();
         $placeholders = array('[[WEBSITE]]', '[[FIRSTNAME]]', '[[LASTNAME]]', '[[EMAIL]]', '[[PASSWORD]]', '[[LINK]]', '[[SENDER]]');
         $domainRepository = new \Cx\Core\Net\Model\Repository\DomainRepository();
         $mainDomain = $domainRepository->getMainDomain()->getName();
         $placeholdersVal = array($mainDomain, contrexx_raw2xhtml($this->getProfileAttribute('firstname')), contrexx_raw2xhtml($this->getProfileAttribute('lastname')), $this->getEmail(), $generatedPassword, ASCMS_PROTOCOL . '://' . $mainDomain . \Cx\Core\Core\Controller\Cx::getBackendFolderName(), contrexx_raw2xhtml($objUserMail->getSenderName()));
         if (in_array($objUserMail->getFormat(), array('multipart', 'text'))) {
             $objUserMail->getFormat() == 'text' ? $objMail->IsHTML(false) : false;
             $objMail->{($objUserMail->getFormat() == 'text' ? '' : 'Alt') . 'Body'} = str_replace($placeholders, $placeholdersVal, $objUserMail->getBodyText());
         }
         if (in_array($objUserMail->getFormat(), array('multipart', 'html'))) {
             $objUserMail->getFormat() == 'html' ? $objMail->IsHTML(true) : false;
             $objMail->Body = str_replace($placeholders, $placeholdersVal, $objUserMail->getBodyHtml());
         }
         $objMail->AddAddress($this->getEmail());
         $objMail->Send();
     }
 }
 /**
  * Reports a possible intrusion attempt to the administrator
  * @param   $type    The type of intrusion attempt to report.
  * @param   $file    The file requesting the report (defaults to "Filename not available")
  * @param   $line    The line number requesting the report (defaults to "Linenumber not available")
  **/
 function reportIntrusion($type, $file = "Filename not available", $line = "Linenumber not available")
 {
     $objDatabase = \Env::get('db');
     $config = \Env::get('config');
     $remoteaddr = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : "Not set";
     $httpxforwardedfor = isset($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : "Not set";
     $httpvia = isset($_SERVER['HTTP_VIA']) ? $_SERVER['HTTP_VIA'] : "Not set";
     $httpclientip = isset($_SERVER['HTTP_CLIENT_IP']) ? $_SERVER['HTTP_CLIENT_IP'] : "Not set";
     $gethostbyname = gethostbyname($remoteaddr);
     if ($gethostbyname == $remoteaddr) {
         $gethostbyname = "No matching hostname";
     }
     // Add all the user's info to $user
     $user = "******" . "HTTP_X_FORWARDED_FOR : {$httpxforwardedfor}\r\n" . "HTTP_VIA : {$httpvia}\r\n" . "HTTP_CLIENT_IP : {$httpclientip}\r\n" . "GetHostByName : {$gethostbyname}\r\n";
     // Add all requested information
     foreach ($this->criticalServerVars as $serverVar) {
         $_SERVERlite[$serverVar] = $_SERVER[$serverVar];
     }
     $httpheaders = function_exists('getallheaders') ? getallheaders() : null;
     $gpcs = "";
     $gpcs .= $this->getRequestInfo($httpheaders, "HTTP HEADER");
     $gpcs .= $this->getRequestInfo($_REQUEST, "REQUEST");
     $gpcs .= $this->getRequestInfo($_GET, "GET");
     $gpcs .= $this->getRequestInfo($_POST, "POST");
     $gpcs .= $this->getRequestInfo($_SERVERlite, "SERVER");
     $gpcs .= $this->getRequestInfo($_COOKIE, "COOKIE");
     $gpcs .= $this->getRequestInfo($_FILES, "FILES");
     $gpcs .= $this->getRequestInfo($_SESSION, "SESSION");
     // Get the data to insert in the database
     $cdate = time();
     $dbuser = htmlspecialchars(addslashes($user), ENT_QUOTES, CONTREXX_CHARSET);
     $dbuser = contrexx_raw2db($dbuser);
     $dbgpcs = htmlspecialchars(addslashes($gpcs), ENT_QUOTES, CONTREXX_CHARSET);
     $dbgpcs = contrexx_raw2db($dbgpcs);
     $where = addslashes("{$file} : {$line}");
     $where = contrexx_raw2db($where);
     // Insert the intrusion in the database
     $objDatabase->Execute("INSERT INTO " . DBPREFIX . "ids (timestamp, type, remote_addr, http_x_forwarded_for, http_via, user, gpcs, file)\n                VALUES(" . $cdate . ", '" . $type . "', '" . $remoteaddr . "', '" . $httpxforwardedfor . "', '" . $httpvia . "', '" . $dbuser . "', '" . $dbgpcs . "', '" . $where . "')");
     // The headers for the e-mail
     $emailto = $config['coreAdminName'] . " <" . $config['coreAdminEmail'] . ">";
     // The message to send
     $message = "DATE : {$cdate}\r\nFILE : {$where}\r\n\r\n{$user}\r\n\r\n{$gpcs}";
     // Send the e-mail to the administrator
     if (\Env::get('ClassLoader')->loadFile(ASCMS_LIBRARY_PATH . '/phpmailer/class.phpmailer.php')) {
         $objMail = new \phpmailer();
         if ($config['coreSmtpServer'] > 0 && \Env::get('ClassLoader')->loadFile(ASCMS_CORE_PATH . '/SmtpSettings.class.php')) {
             if (($arrSmtp = \SmtpSettings::getSmtpAccount($config['coreSmtpServer'])) !== false) {
                 $objMail->IsSMTP();
                 $objMail->Host = $arrSmtp['hostname'];
                 $objMail->Port = $arrSmtp['port'];
                 $objMail->SMTPAuth = true;
                 $objMail->Username = $arrSmtp['username'];
                 $objMail->Password = $arrSmtp['password'];
             }
         }
         $objMail->CharSet = CONTREXX_CHARSET;
         $objMail->SetFrom($config['coreAdminEmail'], $config['coreAdminName']);
         $objMail->Subject = $_SERVER['HTTP_HOST'] . " : {$type}";
         $objMail->IsHTML(false);
         $objMail->Body = $message;
         $objMail->AddAddress($emailto);
         $objMail->Send();
     }
 }
Ejemplo n.º 5
0
 /**
  * Send Recommendation
  *
  * Send an email if the input is valid. Otherwise
  * Show some error messages and the form again
  */
 function _sendRecomm()
 {
     global $_ARRAYLANG, $_CONFIG, $_LANGID, $_CORELANG;
     if (empty($_POST['receivername'])) {
         $this->_pageMessage .= $_ARRAYLANG['TXT_STATUS_RECEIVER_NAME'] . ' ' . $_ARRAYLANG['TXT_IS_EMPTY'] . '<br />';
     }
     if (empty($_POST['receivermail'])) {
         $this->_pageMessage .= $_ARRAYLANG['TXT_STATUS_RECEIVER_MAIL'] . ' ' . $_ARRAYLANG['TXT_IS_EMPTY'] . '<br />';
     } elseif (!$this->isEmail($_POST['receivermail'])) {
         $this->_pageMessage .= $_ARRAYLANG['TXT_STATUS_RECEIVER_MAIL'] . ' ' . $_ARRAYLANG['TXT_IS_INVALID'] . '<br />';
     }
     if (empty($_POST['sendername'])) {
         $this->_pageMessage .= $_ARRAYLANG['TXT_STATUS_SENDER_NAME'] . ' ' . $_ARRAYLANG['TXT_IS_EMPTY'] . '<br />';
     }
     if (empty($_POST['sendermail'])) {
         $this->_pageMessage .= $_ARRAYLANG['TXT_STATUS_SENDER_MAIL'] . ' ' . $_ARRAYLANG['TXT_IS_EMPTY'] . '<br />';
     } elseif (!$this->isEmail($_POST['sendermail'])) {
         $this->_pageMessage .= $_ARRAYLANG['TXT_STATUS_SENDER_MAIL'] . ' ' . $_ARRAYLANG['TXT_IS_INVALID'] . '<br />';
     }
     if (empty($_POST['comment'])) {
         $this->_pageMessage .= $_ARRAYLANG['TXT_STATUS_COMMENT'] . ' ' . $_ARRAYLANG['TXT_IS_EMPTY'] . '<br />';
     }
     $receivername = $_POST['receivername'];
     $receivermail = $_POST['receivermail'];
     $sendername = $_POST['sendername'];
     $sendermail = $_POST['sendermail'];
     $comment = $_POST['comment'];
     if (!empty($this->_pageMessage) || !\Cx\Core_Modules\Captcha\Controller\Captcha::getInstance()->check()) {
         //something's missing or wrong
         $this->_objTpl->setVariable('RECOM_STATUS', '<div class="text-danger">' . $this->_pageMessage . '</div>');
         $this->_objTpl->setCurrentBlock('recommend_form');
         $this->_objTpl->setVariable(array('RECOM_SCRIPT' => $this->getJs(), 'RECOM_RECEIVER_NAME' => stripslashes($receivername), 'RECOM_RECEIVER_MAIL' => stripslashes($receivermail), 'RECOM_SENDER_NAME' => stripslashes($sendername), 'RECOM_SENDER_MAIL' => stripslashes($sendermail), 'RECOM_COMMENT' => stripslashes($comment), 'RECOM_PREVIEW' => $this->getMessageBody($_LANGID), 'RECOM_FEMALE_SALUTATION_TEXT' => $this->getFemaleSalutation($_LANGID), 'RECOM_MALE_SALUTATION_TEXT' => $this->getMaleSalutation($_LANGID)));
         $this->_objTpl->setVariable(array('RECOM_TXT_RECEIVER_NAME' => $_ARRAYLANG['TXT_RECEIVERNAME_FRONTEND'], 'RECOM_TXT_RECEIVER_MAIL' => $_ARRAYLANG['TXT_RECEIVERMAIL_FRONTEND'], 'RECOM_TXT_GENDER' => $_ARRAYLANG['TXT_GENDER_FRONTEND'], 'RECOM_TXT_SENDER_NAME' => $_ARRAYLANG['TXT_SENDERNAME_FRONTEND'], 'RECOM_TXT_SENDER_MAIL' => $_ARRAYLANG['TXT_SENDERMAIL_FRONTEND'], 'RECOM_TXT_COMMENT' => $_ARRAYLANG['TXT_COMMENT_FRONTEND'], 'RECOM_TXT_PREVIEW' => $_ARRAYLANG['TXT_PREVIEW_FRONTEND'], 'RECOM_TXT_FEMALE' => $_ARRAYLANG['TXT_FEMALE_FRONTEND'], 'RECOM_TXT_MALE' => $_ARRAYLANG['TXT_MALE_FRONTEND'], 'RECOM_TEXT' => $_ARRAYLANG['TXT_INTRODUCTION'], 'TXT_RECOMMEND_SEND' => $_ARRAYLANG['TXT_RECOMMEND_SEND'], 'TXT_RECOMMEND_DELETE' => $_ARRAYLANG['TXT_RECOMMEND_DELETE']));
         $this->_objTpl->setVariable(array('RECOM_TXT_CAPTCHA' => $_CORELANG['TXT_CORE_CAPTCHA'], 'RECOM_CAPTCHA_CODE' => \Cx\Core_Modules\Captcha\Controller\Captcha::getInstance()->getCode()));
         if ($this->_objTpl->blockExists('recommend_captcha')) {
             $this->_objTpl->parse('recommend_captcha');
         } else {
             $this->_objTpl->hideBlock('recommend_captcha');
         }
         $this->_objTpl->parseCurrentBlock('recommend_form');
         $this->_objTpl->parse();
     } else {
         //data is valid
         if (empty($_POST['uri'])) {
             $url = ASCMS_PROTOCOL . '://' . $_SERVER['HTTP_HOST'] . ASCMS_PATH_OFFSET;
         } else {
             $url = $_POST['uri'];
         }
         if ($_POST['gender'] == 'male') {
             $salutation = $this->getMaleSalutation($_LANGID);
         } else {
             $salutation = $this->getFemaleSalutation($_LANGID);
         }
         $body = $this->getMessageBody($_LANGID);
         $body = preg_replace('/<SENDER_NAME>/', $sendername, $body);
         $body = preg_replace('/<SENDER_MAIL>/', $sendermail, $body);
         $body = preg_replace('/<RECEIVER_NAME>/', $receivername, $body);
         $body = preg_replace('/<RECEIVER_MAIL>/', $receivermail, $body);
         $body = preg_replace('/<URL>/', $url, $body);
         $body = preg_replace('/<COMMENT>/', $comment, $body);
         $body = preg_replace('/<SALUTATION>/', $salutation, $body);
         $subject = $this->getMessageSubject($_LANGID);
         $subject = preg_replace('/<SENDER_NAME>/', $sendername, $subject);
         $subject = preg_replace('/<SENDER_MAIL>/', $sendermail, $subject);
         $subject = preg_replace('/<RECEIVER_NAME>/', $receivername, $subject);
         $subject = preg_replace('/<RECEIVER_MAIL>/', $receivermail, $subject);
         $subject = preg_replace('/<URL>/', $url, $subject);
         $subject = preg_replace('/<COMMENT>/', $comment, $subject);
         $subject = preg_replace('/<SALUTATION>/', $salutation, $subject);
         if (@(include_once ASCMS_LIBRARY_PATH . '/phpmailer/class.phpmailer.php')) {
             $objMail = new \phpmailer();
             if ($_CONFIG['coreSmtpServer'] > 0) {
                 if (($arrSmtp = \SmtpSettings::getSmtpAccount($_CONFIG['coreSmtpServer'])) !== false) {
                     $objMail->IsSMTP();
                     $objMail->Host = $arrSmtp['hostname'];
                     $objMail->Port = $arrSmtp['port'];
                     $objMail->SMTPAuth = true;
                     $objMail->Username = $arrSmtp['username'];
                     $objMail->Password = $arrSmtp['password'];
                 }
             }
             $objMail->CharSet = CONTREXX_CHARSET;
             $objMail->SetFrom($sendermail, $sendername);
             $objMail->Subject = $subject;
             $objMail->IsHTML(false);
             $objMail->Body = $body;
             $objMail->AddAddress($receivermail);
             $objMail->Send();
             $objMail->ClearAddresses();
             $objMail->AddAddress($_CONFIG['contactFormEmail']);
             $objMail->Send();
         }
         $this->_objTpl->setVariable('RECOM_STATUS', $_ARRAYLANG['TXT_SENT_OK']);
         $this->_objTpl->parse();
     }
 }
 /**
  * Send the email
  * @param      int $UserID
  * @param      int $NewsletterID
  * @param      string $TargetEmail
  * @param      string $type
  */
 function SendEmail($UserID, $NewsletterID, $TargetEmail, $TmpEntry, $type = self::USER_TYPE_NEWSLETTER)
 {
     global $objDatabase, $_ARRAYLANG, $_DBCONFIG;
     require_once ASCMS_LIBRARY_PATH . '/phpmailer/class.phpmailer.php';
     $newsletterValues = $this->getNewsletterValues($NewsletterID);
     if ($newsletterValues !== false) {
         $subject = $newsletterValues['subject'];
         $template = $newsletterValues['template'];
         $content = $newsletterValues['content'];
         $priority = $newsletterValues['priority'];
         $sender_email = $newsletterValues['sender_email'];
         $sender_name = $newsletterValues['sender_name'];
         $return_path = $newsletterValues['return_path'];
         $count = $newsletterValues['count'];
         $smtpAccount = $newsletterValues['smtp_server'];
     }
     $break = $this->getSetting('txt_break_after');
     $break = intval($break) == 0 ? 80 : $break;
     $HTML_TemplateSource = $this->GetTemplateSource($template, 'html');
     // TODO: Unused
     //        $TEXT_TemplateSource = $this->GetTemplateSource($template, 'text');
     $newsletterUserData = $this->getNewsletterUserData($UserID, $type);
     $testDelivery = !$TmpEntry;
     $NewsletterBody_HTML = $this->ParseNewsletter($subject, $content, $HTML_TemplateSource, '', $TargetEmail, $newsletterUserData, $NewsletterID, $testDelivery);
     \LinkGenerator::parseTemplate($NewsletterBody_HTML, true);
     $NewsletterBody_TEXT = $this->ParseNewsletter('', '', '', 'text', '', $newsletterUserData, $NewsletterID, $testDelivery);
     \LinkGenerator::parseTemplate($NewsletterBody_TEXT, true);
     $mail = new \phpmailer();
     if ($smtpAccount > 0) {
         if (($arrSmtp = \SmtpSettings::getSmtpAccount($smtpAccount)) !== false) {
             $mail->IsSMTP();
             $mail->Host = $arrSmtp['hostname'];
             $mail->Port = $arrSmtp['port'];
             $mail->SMTPAuth = $arrSmtp['username'] == '-' ? false : true;
             $mail->Username = $arrSmtp['username'];
             $mail->Password = $arrSmtp['password'];
         }
     }
     $mail->CharSet = CONTREXX_CHARSET;
     $mail->AddReplyTo($return_path);
     $mail->SetFrom($sender_email, $sender_name);
     $mail->Subject = $subject;
     $mail->Priority = $priority;
     $mail->Body = $NewsletterBody_HTML;
     $mail->AltBody = $NewsletterBody_TEXT;
     $queryATT = "SELECT newsletter, file_name FROM " . DBPREFIX . "module_newsletter_attachment where newsletter=" . $NewsletterID . "";
     $objResultATT = $objDatabase->Execute($queryATT);
     if ($objResultATT !== false) {
         while (!$objResultATT->EOF) {
             $mail->AddAttachment(\Cx\Core\Core\Controller\Cx::instanciate()->getWebsiteImagesAttachPath() . "/" . $objResultATT->fields['file_name'], $objResultATT->fields['file_name']);
             $objResultATT->MoveNext();
         }
     }
     $mail->AddAddress($TargetEmail);
     if ($UserID) {
         // mark recipient as in-action to prevent multiple tries of sending the newsletter to the same recipient
         $query = "UPDATE " . DBPREFIX . "module_newsletter_tmp_sending SET sendt=2 where email='" . $TargetEmail . "' AND newsletter=" . $NewsletterID . " AND sendt=0";
         if ($objDatabase->Execute($query) === false || $objDatabase->Affected_Rows() == 0) {
             return $count;
         }
     }
     if ($mail->Send()) {
         // && $UserID == 0) {
         $ReturnVar = $count++;
         if ($TmpEntry == 1) {
             // Insert TMP-ENTRY Sended Email & Count++
             $query = "UPDATE " . DBPREFIX . "module_newsletter_tmp_sending SET sendt=1 where email='" . $TargetEmail . "' AND newsletter=" . $NewsletterID . "";
             if ($objDatabase->Execute($query) === false) {
                 if ($_DBCONFIG['dbType'] == 'mysql' && $objDatabase->ErrorNo() == 2006) {
                     @$objDatabase->Connect($_DBCONFIG['host'], $_DBCONFIG['user'], $_DBCONFIG['password'], $_DBCONFIG['database'], true);
                     if ($objDatabase->Execute($query) === false) {
                         return false;
                     }
                 }
             }
             $objDatabase->Execute("\n                    UPDATE " . DBPREFIX . "module_newsletter\n                       SET count=count+1\n                     WHERE id={$NewsletterID}");
             $queryCheck = "SELECT 1 FROM " . DBPREFIX . "module_newsletter_tmp_sending where newsletter=" . $NewsletterID . " and sendt=0";
             $objResultCheck = $objDatabase->SelectLimit($queryCheck, 1);
             if ($objResultCheck->RecordCount() == 0) {
                 $objDatabase->Execute("\n                        UPDATE " . DBPREFIX . "module_newsletter\n                           SET status=1\n                         WHERE id={$NewsletterID}");
             }
         }
         /*elseif ($mail->error_count) {
               if (strstr($mail->ErrorInfo, 'authenticate')) {
                   self::$strErrMessage .= sprintf($_ARRAYLANG['TXT_NEWSLETTER_MAIL_AUTH_FAILED'], htmlentities($arrSmtp['name'], ENT_QUOTES, CONTREXX_CHARSET)).'<br />';
                   $ReturnVar = false;
               }
           } */
     } else {
         $performRejectedMailOperation = false;
         if (strstr($mail->ErrorInfo, 'authenticate')) {
             // -> smtp error
             self::$strErrMessage .= sprintf($_ARRAYLANG['TXT_NEWSLETTER_MAIL_AUTH_FAILED'], htmlentities($arrSmtp['name'], ENT_QUOTES, CONTREXX_CHARSET)) . '<br />';
         } elseif (strstr($mail->ErrorInfo, 'from_failed')) {
             // -> mail error
             self::$strErrMessage .= sprintf($_ARRAYLANG['TXT_NEWSLETTER_FROM_ADDR_REJECTED'], htmlentities($sender_email, ENT_QUOTES, CONTREXX_CHARSET)) . '<br />';
         } elseif (strstr($mail->ErrorInfo, 'recipients_failed')) {
             // -> recipient error
             $performRejectedMailOperation = true;
             self::$strErrMessage .= sprintf($_ARRAYLANG['TXT_NEWSLETTER_RECIPIENT_FAILED'], htmlentities($TargetEmail, ENT_QUOTES, CONTREXX_CHARSET)) . '<br />';
         } elseif (strstr($mail->ErrorInfo, 'instantiate')) {
             // -> php error
             self::$strErrMessage .= $_ARRAYLANG['TXT_NEWSLETTER_LOCAL_SMTP_FAILED'] . '<br />';
         } elseif (strstr($mail->ErrorInfo, 'connect_host')) {
             // -> smtp error
             self::$strErrMessage .= $_ARRAYLANG['TXT_NEWSLETTER_CONNECT_SMTP_FAILED'] . '<br />';
         } else {
             // -> mail error
             self::$strErrMessage .= $mail->ErrorInfo . '<br />';
         }
         $ReturnVar = false;
         if ($TmpEntry == 1) {
             $arrSettings = $this->_getSettings();
             if ($performRejectedMailOperation && $arrSettings['rejected_mail_operation']['setvalue'] != 'ignore') {
                 switch ($arrSettings['rejected_mail_operation']['setvalue']) {
                     case 'deactivate':
                         // Remove temporary data from the module
                         if ($objDatabase->Execute("DELETE FROM `" . DBPREFIX . "module_newsletter_tmp_sending` WHERE `email` ='" . addslashes($TargetEmail) . "'") !== false) {
                             switch ($type) {
                                 case self::USER_TYPE_CORE:
                                     // do nothing with system users
                                     break;
                                 case self::USER_TYPE_ACCESS:
                                     // TODO: Remove newsletter subscription for access_user
                                     break;
                                 case self::USER_TYPE_NEWSLETTER:
                                 default:
                                     // Deactivate user
                                     $objDatabase->Execute("UPDATE `" . DBPREFIX . "module_newsletter_user` SET `status` = 0 WHERE `id` = " . $UserID);
                                     break;
                             }
                         }
                         break;
                     case 'delete':
                         switch ($type) {
                             case self::USER_TYPE_CORE:
                                 // do nothing with system users
                                 break;
                             case self::USER_TYPE_ACCESS:
                                 // TODO: Remove newsletter subscription for access_user
                                 break;
                             case self::USER_TYPE_NEWSLETTER:
                             default:
                                 // Remove user data from the module
                                 $this->_deleteRecipient($UserID);
                                 break;
                         }
                         break;
                     case 'inform':
                         $this->informAdminAboutRejectedMail($NewsletterID, $UserID, $TargetEmail, $type, $newsletterUserData);
                         break;
                 }
             }
             $ReturnVar = $count;
         }
     }
     $mail->ClearAddresses();
     $mail->ClearAttachments();
     return $ReturnVar;
 }
Ejemplo n.º 7
0
 /**
  * Get details of a SMTP account
  *
  * Returns the details of the SMTP account specified by $accountId.
  * If $accountId is either FALSE or not a valid account ID then FALSE will
  * be returned instead.
  * @see _getSmtpAccount()
  * @param   integer $accountId  The ID of the account settings
  * @param boolean $getPassword
  * @return  mixed           Array with the details of the requested account
  *                          on success, false otherwise
  * @static
  */
 static function getSmtpAccount($accountId = 0, $getPassword = true)
 {
     global $objDatabase;
     return SmtpSettings::_getSmtpAccount($accountId, $getPassword);
 }
Ejemplo n.º 8
0
 function _smtpModify()
 {
     global $objTemplate, $_ARRAYLANG;
     $error = false;
     $id = !empty($_REQUEST['id']) ? intval($_REQUEST['id']) : 0;
     if (isset($_POST['settings_smtp_save'])) {
         $arrSmtp = array('name' => !empty($_POST['settings_smtp_account']) ? contrexx_stripslashes(trim($_POST['settings_smtp_account'])) : '', 'hostname' => !empty($_POST['settings_smtp_hostname']) ? contrexx_stripslashes(trim($_POST['settings_smtp_hostname'])) : '', 'port' => !empty($_POST['settings_smtp_port']) ? intval($_POST['settings_smtp_port']) : 25, 'username' => !empty($_POST['settings_smtp_username']) ? contrexx_stripslashes(trim($_POST['settings_smtp_username'])) : '', 'password' => !empty($_POST['settings_smtp_password']) ? contrexx_stripslashes($_POST['settings_smtp_password']) : '');
         if (!$arrSmtp['port']) {
             $arrSmtp['port'] = 25;
         }
         if (empty($arrSmtp['name'])) {
             $error = true;
             $this->strErrMessage[] = $_ARRAYLANG['TXT_SETTINGS_EMPTY_ACCOUNT_NAME_TXT'];
         } elseif (!\SmtpSettings::_isUniqueSmtpAccountName($arrSmtp['name'], $id)) {
             $error = true;
             $this->strErrMessage[] = sprintf($_ARRAYLANG['TXT_SETTINGS_NOT_UNIQUE_SMTP_ACCOUNT_NAME'], htmlentities($arrSmtp['name']));
         }
         if (empty($arrSmtp['hostname'])) {
             $error = true;
             $this->strErrMessage[] = $_ARRAYLANG['TXT_SETTINGS_EMPTY_SMTP_HOST_TXT'];
         }
         if (!$error) {
             if ($id) {
                 if (\SmtpSettings::_updateSmtpAccount($id, $arrSmtp)) {
                     $this->strOkMessage .= sprintf($_ARRAYLANG['TXT_SETTINGS_SMTP_ACCOUNT_UPDATE_SUCCEED'], $arrSmtp['name']) . '<br />';
                     return $this->_smtpOverview();
                 } else {
                     $this->strErrMessage[] = sprintf($_ARRAYLANG['TXT_SETTINGS_SMTP_ACCOUNT_UPDATE_FAILED'], $arrSmtp['name']);
                 }
             } else {
                 if (\SmtpSettings::_addSmtpAccount($arrSmtp)) {
                     $this->strOkMessage .= sprintf($_ARRAYLANG['TXT_SETTINGS_SMTP_ACCOUNT_ADD_SUCCEED'], $arrSmtp['name']) . '<br />';
                     return $this->_smtpOverview();
                 } else {
                     $this->strErrMessage[] = $_ARRAYLANG['TXT_SETTINGS_SMTP_ACCOUNT_ADD_FAILED'];
                 }
             }
         }
     } else {
         $arrSmtp = \SmtpSettings::getSmtpAccount($id, false);
         if ($arrSmtp === false) {
             $id = 0;
             $arrSmtp = array('name' => '', 'hostname' => '', 'port' => 25, 'username' => '', 'password' => 0);
         }
     }
     $objTemplate->addBlockfile('ADMIN_CONTENT', 'settings_smtp_modify', 'settings_smtp_modify.html');
     $this->strPageTitle = $id ? $_ARRAYLANG['TXT_SETTINGS_MODIFY_SMTP_ACCOUNT'] : $_ARRAYLANG['TXT_SETTINGS_ADD_NEW_SMTP_ACCOUNT'];
     $objTemplate->setVariable(array('TXT_SETTINGS_ACCOUNT' => $_ARRAYLANG['TXT_SETTINGS_ACCOUNT'], 'TXT_SETTINGS_NAME_OF_ACCOUNT' => $_ARRAYLANG['TXT_SETTINGS_NAME_OF_ACCOUNT'], 'TXT_SETTINGS_SMTP_SERVER' => $_ARRAYLANG['TXT_SETTINGS_SMTP_SERVER'], 'TXT_SETTINGS_HOST' => $_ARRAYLANG['TXT_SETTINGS_HOST'], 'TXT_SETTINGS_PORT' => $_ARRAYLANG['TXT_SETTINGS_PORT'], 'TXT_SETTINGS_AUTHENTICATION' => $_ARRAYLANG['TXT_SETTINGS_AUTHENTICATION'], 'TXT_SETTINGS_USERNAME' => $_ARRAYLANG['TXT_SETTINGS_USERNAME'], 'TXT_SETTINGS_PASSWORD' => $_ARRAYLANG['TXT_SETTINGS_PASSWORD'], 'TXT_SETTINGS_SMTP_AUTHENTICATION_TXT' => $_ARRAYLANG['TXT_SETTINGS_SMTP_AUTHENTICATION_TXT'], 'TXT_SETTINGS_BACK' => $_ARRAYLANG['TXT_SETTINGS_BACK'], 'TXT_SETTINGS_SAVE' => $_ARRAYLANG['TXT_SETTINGS_SAVE']));
     $objTemplate->setVariable(array('SETTINGS_SMTP_TITLE' => $id ? $_ARRAYLANG['TXT_SETTINGS_MODIFY_SMTP_ACCOUNT'] : $_ARRAYLANG['TXT_SETTINGS_ADD_NEW_SMTP_ACCOUNT'], 'SETTINGS_SMTP_ID' => $id, 'SETTINGS_SMTP_ACCOUNT' => htmlentities($arrSmtp['name'], ENT_QUOTES, CONTREXX_CHARSET), 'SETTINGS_SMTP_HOST' => htmlentities($arrSmtp['hostname'], ENT_QUOTES, CONTREXX_CHARSET), 'SETTINGS_SMTP_PORT' => $arrSmtp['port'], 'SETTINGS_SMTP_USERNAME' => htmlentities($arrSmtp['username'], ENT_QUOTES, CONTREXX_CHARSET), 'SETTINGS_SMTP_PASSWORD' => str_pad('', $arrSmtp['password'], ' ')));
     $objTemplate->parse('settings_smtp_modify');
     return true;
 }
Ejemplo n.º 9
0
 /**
  * Initialize the mail functionality to the recipient
  *
  * @param \Cx\Modules\Calendar\Controller\CalendarEvent $event          Event instance
  * @param integer                                       $actionId       Mail action id
  * @param integer                                       $regId          Registration id
  * @param string                                        $mailTemplate   Mail template id
  */
 function sendMail(CalendarEvent $event, $actionId, $regId = null, $mailTemplate = null)
 {
     global $objDatabase, $_ARRAYLANG, $_CONFIG;
     $this->mailList = array();
     // Loads the mail template which needs for this action
     $this->loadMailList($actionId, $mailTemplate);
     if (!empty($this->mailList)) {
         $objRegistration = null;
         if (!empty($regId)) {
             $objRegistration = new \Cx\Modules\Calendar\Controller\CalendarRegistration($event->registrationForm, $regId);
             list($registrationDataText, $registrationDataHtml) = $this->getRegistrationData($objRegistration);
             $query = 'SELECT `v`.`value`, `n`.`default`, `f`.`type`
                       FROM ' . DBPREFIX . 'module_' . $this->moduleTablePrefix . '_registration_form_field_value AS `v`
                       INNER JOIN ' . DBPREFIX . 'module_' . $this->moduleTablePrefix . '_registration_form_field_name AS `n`
                       ON `v`.`field_id` = `n`.`field_id`
                       INNER JOIN ' . DBPREFIX . 'module_' . $this->moduleTablePrefix . '_registration_form_field AS `f`
                       ON `v`.`field_id` = `f`.`id`
                       WHERE `v`.`reg_id` = ' . $regId . '
                       AND (
                              `f`.`type` = "salutation"
                           OR `f`.`type` = "firstname"
                           OR `f`.`type` = "lastname"
                           OR `f`.`type` = "mail"
                       )';
             $objResult = $objDatabase->Execute($query);
             $arrDefaults = array();
             $arrValues = array();
             if ($objResult !== false) {
                 while (!$objResult->EOF) {
                     if (!empty($objResult->fields['default'])) {
                         $arrDefaults[$objResult->fields['type']] = explode(',', $objResult->fields['default']);
                     }
                     $arrValues[$objResult->fields['type']] = $objResult->fields['value'];
                     $objResult->MoveNext();
                 }
             }
             $regSalutation = !empty($arrValues['salutation']) ? $arrDefaults['salutation'][$arrValues['salutation'] - 1] : '';
             $regFirstname = !empty($arrValues['firstname']) ? $arrValues['firstname'] : '';
             $regLastname = !empty($arrValues['lastname']) ? $arrValues['lastname'] : '';
             $regMail = !empty($arrValues['mail']) ? $arrValues['mail'] : '';
             $regType = $objRegistration->type == 1 ? $_ARRAYLANG['TXT_CALENDAR_REG_REGISTRATION'] : $_ARRAYLANG['TXT_CALENDAR_REG_SIGNOFF'];
             $regSearch = array('[[REGISTRATION_TYPE]]', '[[REGISTRATION_SALUTATION]]', '[[REGISTRATION_FIRSTNAME]]', '[[REGISTRATION_LASTNAME]]', '[[REGISTRATION_EMAIL]]');
             $regReplace = array($regType, $regSalutation, $regFirstname, $regLastname, $regMail);
         }
         $domain = ASCMS_PROTOCOL . "://" . $_CONFIG['domainUrl'] . ASCMS_PATH_OFFSET . "/";
         $date = $this->format2userDateTime(new \DateTime());
         $startDate = $event->startDate;
         $endDate = $event->endDate;
         $eventTitle = $event->title;
         $eventStart = $event->all_day ? $this->format2userDate($startDate) : $this->formatDateTime2user($startDate, $this->getDateFormat() . ' (H:i:s)');
         $eventEnd = $event->all_day ? $this->format2userDate($endDate) : $this->formatDateTime2user($endDate, $this->getDateFormat() . ' (H:i:s)');
         $placeholder = array('[[TITLE]]', '[[START_DATE]]', '[[END_DATE]]', '[[LINK_EVENT]]', '[[LINK_REGISTRATION]]', '[[USERNAME]]', '[[FIRSTNAME]]', '[[LASTNAME]]', '[[URL]]', '[[DATE]]');
         $recipients = $this->getSendMailRecipients($actionId, $event, $regId, $objRegistration);
         $objMail = new \phpmailer();
         if ($_CONFIG['coreSmtpServer'] > 0) {
             $arrSmtp = \SmtpSettings::getSmtpAccount($_CONFIG['coreSmtpServer']);
             if ($arrSmtp !== false) {
                 $objMail->IsSMTP();
                 $objMail->Host = $arrSmtp['hostname'];
                 $objMail->Port = $arrSmtp['port'];
                 $objMail->SMTPAuth = true;
                 $objMail->Username = $arrSmtp['username'];
                 $objMail->Password = $arrSmtp['password'];
             }
         }
         $objMail->CharSet = CONTREXX_CHARSET;
         $objMail->SetFrom($_CONFIG['coreAdminEmail'], $_CONFIG['coreGlobalPageTitle']);
         foreach ($recipients as $mailAdress => $langId) {
             if (!empty($mailAdress)) {
                 $langId = $this->getSendMailLangId($actionId, $mailAdress, $langId);
                 if ($objUser = \FWUser::getFWUserObject()->objUser->getUsers($filter = array('email' => $mailAdress, 'is_active' => true))) {
                     $userNick = $objUser->getUsername();
                     $userFirstname = $objUser->getProfileAttribute('firstname');
                     $userLastname = $objUser->getProfileAttribute('lastname');
                 } else {
                     $userNick = $mailAdress;
                     if (!empty($regId) && $mailAdress == $regMail) {
                         $userFirstname = $regFirstname;
                         $userLastname = $regLastname;
                     } else {
                         $userFirstname = '';
                         $userLastname = '';
                     }
                 }
                 $mailTitle = $this->mailList[$langId]['mail']->title;
                 $mailContentText = !empty($this->mailList[$langId]['mail']->content_text) ? $this->mailList[$langId]['mail']->content_text : strip_tags($this->mailList[$langId]['mail']->content_html);
                 $mailContentHtml = !empty($this->mailList[$langId]['mail']->content_html) ? $this->mailList[$langId]['mail']->content_html : $this->mailList[$langId]['mail']->content_text;
                 // actual language of selected e-mail template
                 $contentLanguage = $this->mailList[$langId]['lang_id'];
                 if ($actionId == self::MAIL_NOTFY_NEW_APP && $event->arrSettings['confirmFrontendEvents'] == 1) {
                     $eventLink = $domain . "/cadmin/index.php?cmd={$this->moduleName}&act=modify_event&id={$event->id}&confirm=1";
                 } else {
                     $eventLink = \Cx\Core\Routing\Url::fromModuleAndCmd($this->moduleName, 'detail', $contentLanguage, array('id' => $event->id, 'date' => $event->startDate->getTimestamp()))->toString();
                 }
                 $regLink = \Cx\Core\Routing\Url::fromModuleAndCmd($this->moduleName, 'register', $contentLanguage, array('id' => $event->id, 'date' => $event->startDate->getTimestamp()))->toString();
                 $replaceContent = array($eventTitle, $eventStart, $eventEnd, $eventLink, $regLink, $userNick, $userFirstname, $userLastname, $domain, $date);
                 $mailTitle = str_replace($placeholder, $replaceContent, $mailTitle);
                 $mailContentText = str_replace($placeholder, $replaceContent, $mailContentText);
                 $mailContentHtml = str_replace($placeholder, $replaceContent, $mailContentHtml);
                 if (!empty($regId)) {
                     $mailTitle = str_replace($regSearch, $regReplace, $mailTitle);
                     $mailContentText = str_replace($regSearch, $regReplace, $mailContentText);
                     $mailContentHtml = str_replace($regSearch, $regReplace, $mailContentHtml);
                     $mailContentText = str_replace('[[REGISTRATION_DATA]]', $registrationDataText, $mailContentText);
                     $mailContentHtml = str_replace('[[REGISTRATION_DATA]]', $registrationDataHtml, $mailContentHtml);
                 }
                 /*echo "send to: ".$mailAdress."<br />";
                   echo "send title: ".$mailTitle."<br />";*/
                 $objMail->Subject = $mailTitle;
                 $objMail->Body = $mailContentHtml;
                 $objMail->AltBody = $mailContentText;
                 $objMail->AddAddress($mailAdress);
                 $objMail->Send();
                 $objMail->ClearAddresses();
             }
         }
     }
 }
Ejemplo n.º 10
0
 /**
  * send notification email
  *
  */
 function sendNotificationMail($fromId, $toId)
 {
     global $_CONFIG;
     if (@\Env::get('ClassLoader')->loadFile(ASCMS_LIBRARY_PATH . '/phpmailer/class.phpmailer.php')) {
         $objMail = new \phpmailer();
         if ($_CONFIG['coreSmtpServer'] > 0) {
             $objSmtpSettings = new SmtpSettings();
             if (($arrSmtp = $objSmtpSettings->getSmtpAccount($_CONFIG['coreSmtpServer'])) !== false) {
                 $objMail->IsSMTP();
                 $objMail->Host = $arrSmtp['hostname'];
                 $objMail->Port = $arrSmtp['port'];
                 $objMail->SMTPAuth = true;
                 $objMail->Username = $arrSmtp['username'];
                 $objMail->Password = $arrSmtp['password'];
             }
         }
         $strName = $this->_getName($fromId);
         $strReceiverName = $this->_getName($toId);
         $toEmail = $this->_getEmail($toId);
         $from = $this->_getEmailFromDetails();
         $subject = $this->_getEmailSubjectDetails();
         $messageContent = $this->_getEmailMessageDetails();
         $strMailSubject = str_replace(array('[senderName]', '[receiverName]', '[domainName]'), array($strName['username'], $strReceiverName['username'], $_CONFIG['domainUrl']), $subject['subject']);
         $strMailBody = str_replace(array('[senderName]', '[receiverName]', '[domainName]'), array($strName['username'], $strReceiverName['username'], $_CONFIG['domainUrl']), $messageContent['email_message']);
         $objMail->CharSet = CONTREXX_CHARSET;
         $objMail->SetFrom($_CONFIG['coreAdminEmail'], $from['from']);
         $objMail->AddAddress($toEmail['email']);
         $objMail->Subject = $strMailSubject;
         //$strMailSubject;
         $objMail->IsHTML(true);
         $objMail->Body = $strMailBody;
         $objMail->Send();
     }
 }
Ejemplo n.º 11
0
 /**
  * Inform the admin about a reject
  *
  * If an email could not be sent, inform the administrator
  * about that (only if the option to do so was set)
  * @author      Stefan Heinemann <*****@*****.**>
  * @param       int $newsletterID
  * @param       int $userID
  * @param       string $email
  * @param       const
  */
 protected function informAdminAboutRejectedMail($newsletterID, $userID, $email, $type)
 {
     // Get the current user's email address
     $addy = \FWUser::getFWUserObject()->objUser->getEmail();
     \Env::get('ClassLoader')->loadFile(ASCMS_LIBRARY_PATH . '/phpmailer/class.phpmailer.php');
     $mail = new \phpmailer();
     $newsletterValues = $this->getNewsletterValues($newsletterID);
     if ($newsletterValues['smtp_server'] > 0) {
         if (($arrSmtp = \SmtpSettings::getSmtpAccount($newsletterValues['smtp_server'])) !== false) {
             $mail->IsSMTP();
             $mail->Host = $arrSmtp['hostname'];
             $mail->Port = $arrSmtp['port'];
             $mail->SMTPAuth = $arrSmtp['username'] == '-' ? false : true;
             $mail->Username = $arrSmtp['username'];
             $mail->Password = $arrSmtp['password'];
         }
     }
     $mail->CharSet = CONTREXX_CHARSET;
     $mail->From = $newsletterValues['sender_email'];
     $mail->FromName = $newsletterValues['sender_name'];
     $mail->AddReplyTo($newsletterValues['return_path']);
     $mail->Subject = $newsletterValues['subject'];
     $mail->Priority = $newsletterValues['priority'];
     $mail->Body = $this->getInformMailBody($userID, $email, $type);
     $mail->AddAddress($addy);
     $mail->send();
 }
Ejemplo n.º 12
0
 /**
  * Show the form when someone is interested
  * @return unknown
  */
 function _showInterestForm()
 {
     global $objDatabase, $_ARRAYLANG, $_CONFIG;
     require_once ASCMS_LIBRARY_PATH . DIRECTORY_SEPARATOR . 'phpmailer' . DIRECTORY_SEPARATOR . "class.phpmailer.php";
     if (!empty($_REQUEST['immoid'])) {
         $this->_objTpl->setVariable('IMMO_ID', intval($_REQUEST['immoid']));
     }
     if (!empty($_REQUEST['submitContactForm'])) {
         $immoid = intval($_REQUEST['contactFormField_immoid']);
         //hidden field: immoid
         $name = !empty($_REQUEST['contactFormField_name']) ? contrexx_addslashes(contrexx_strip_tags($_REQUEST['contactFormField_name'])) : '';
         $firstname = !empty($_REQUEST['contactFormField_vorname']) ? contrexx_addslashes(contrexx_strip_tags($_REQUEST['contactFormField_vorname'])) : '';
         $street = !empty($_REQUEST['contactFormField_strasse']) ? contrexx_addslashes(contrexx_strip_tags($_REQUEST['contactFormField_strasse'])) : '';
         $zip = !empty($_REQUEST['contactFormField_postleitzahl']) ? contrexx_addslashes(contrexx_strip_tags($_REQUEST['contactFormField_postleitzahl'])) : '';
         $location = !empty($_REQUEST['contactFormField_ortschaft']) ? contrexx_addslashes(contrexx_strip_tags($_REQUEST['contactFormField_ortschaft'])) : '';
         $email = !empty($_REQUEST['contactFormField_email']) ? contrexx_addslashes(contrexx_strip_tags($_REQUEST['contactFormField_email'])) : '';
         $phone_office = !empty($_REQUEST['contactFormField_fongeschaeft']) ? contrexx_addslashes(contrexx_strip_tags($_REQUEST['contactFormField_fongeschaeft'])) : '';
         $phone_home = !empty($_REQUEST['contactFormField_fonprivat']) ? contrexx_addslashes(contrexx_strip_tags($_REQUEST['contactFormField_fonprivat'])) : '';
         $phone_mobile = !empty($_REQUEST['contactFormField_fonmobil']) ? contrexx_addslashes(contrexx_strip_tags($_REQUEST['contactFormField_fonmobil'])) : '';
         $doc_via_mail = !empty($_REQUEST['contactFormField_dokuperpost']) ? contrexx_addslashes(contrexx_strip_tags($_REQUEST['contactFormField_dokuperpost'])) : '';
         $funding_advice = !empty($_REQUEST['contactFormField_beratungfinanzierung']) ? contrexx_addslashes(contrexx_strip_tags($_REQUEST['contactFormField_beratungfinanzierung'])) : '';
         $inspection = !empty($_REQUEST['contactFormField_besichtigung']) ? contrexx_addslashes(contrexx_strip_tags($_REQUEST['contactFormField_besichtigung'])) : '';
         $contact_via_phone = !empty($_REQUEST['contactFormField_kontakttelefon']) ? contrexx_addslashes(contrexx_strip_tags($_REQUEST['contactFormField_kontakttelefon'])) : '';
         $comment = !empty($_REQUEST['contactFormField_bemerkungen']) ? contrexx_addslashes(contrexx_strip_tags($_REQUEST['contactFormField_bemerkungen'])) : '';
         $query = "\n                INSERT INTO " . DBPREFIX . "module_immo_interest VALUES (\n                       NULL, {$immoid}, '{$name}', '{$firstname}',\n                       '{$street}', '{$zip}', '{$location}', '{$email}',\n                       '{$phone_office}', '{$phone_home}', '{$phone_mobile}',\n                       '{$doc_via_mail}', '{$funding_advice}', '{$inspection}',\n                       '{$contact_via_phone}', '{$comment}', " . mktime() . ")";
         if (!$objDatabase->Execute($query)) {
             $this->_objTpl->setVariable('CONTACT_FEEDBACK_TEXT', $_ARRAYLANG['TXT_IMMO_DATABASE_ERROR']);
             return false;
         }
         $query = "\n                SELECT reference, ref_nr_note\n                  FROM " . DBPREFIX . "module_immo\n                 WHERE id={$immoid}";
         $objRS = $objDatabase->Execute($query);
         if ($objRS) {
             $reference = $objRS->fields['reference'];
             $ref_note = $objRS->fields['ref_nr_note'];
         }
         //set immo ID for _getFieldFromText function
         $this->_getFieldNames($immoid);
         $this->_currFieldID = $immoid;
         $address = $this->_getFieldFromText('adresse');
         $location = $this->_getFieldFromText('ort');
         $mailer = new PHPMailer();
         $objRS = $objDatabase->Execute('
             SELECT setvalue
               FROM ' . DBPREFIX . 'module_immo_settings
              WHERE setname="contact_receiver"');
         //set recipients
         $emails = explode(',', $objRS->fields['setvalue']);
         foreach ($emails as $email) {
             $mailer->AddAddress($email);
         }
         if ($_CONFIG['coreSmtpServer'] > 0 && @(include_once ASCMS_CORE_PATH . '/SmtpSettings.class.php')) {
             if (($arrSmtp = SmtpSettings::getSmtpAccount($_CONFIG['coreSmtpServer'])) !== false) {
                 $mailer->IsSMTP();
                 $mailer->Host = $arrSmtp['hostname'];
                 $mailer->Port = $arrSmtp['port'];
                 $mailer->SMTPAuth = true;
                 $mailer->Username = $arrSmtp['username'];
                 $mailer->Password = $arrSmtp['password'];
             }
         }
         $mailer->CharSet = CONTREXX_CHARSET;
         $mailer->SetFrom(contrexx_addslashes($_REQUEST['contactFormField_email']), 'Interessent');
         $mailer->Subject = 'Neuer Interessent für ' . $ref_note . ' Ref-Nr.: ' . $reference;
         $mailer->IsHTML(false);
         $mailer->Body = 'Jemand interessiert sich für das Objekt ' . $ref_note . ' Ref-Nr.: ' . $reference . "\n \nhttp://" . $_CONFIG['domainUrl'] . ASCMS_PATH_OFFSET . "/admin/index.php?cmd=immo&act=stats\n";
         $mailer->Body .= $_ARRAYLANG['TXT_IMMO_E_MAIL'] . ': ' . contrexx_addslashes($_REQUEST['contactFormField_email']) . "\n";
         $mailer->Body .= $_ARRAYLANG['TXT_IMMO_NAME'] . ': ' . $name . "\n";
         $mailer->Body .= $_ARRAYLANG['TXT_IMMO_FIRSTNAME'] . ': ' . $firstname . "\n";
         $mailer->Body .= $_ARRAYLANG['TXT_IMMO_STREET'] . ': ' . $street . "\n";
         $mailer->Body .= $_ARRAYLANG['TXT_IMMO_LOCATION'] . ': ' . $location . "\n";
         $mailer->Body .= $_ARRAYLANG['TXT_IMMO_TELEPHONE'] . ': ' . $phone_home . "\n";
         $mailer->Body .= $_ARRAYLANG['TXT_IMMO_TELEPHONE_OFFICE'] . ': ' . $phone_office . "\n";
         $mailer->Body .= $_ARRAYLANG['TXT_IMMO_TELEPHONE_MOBILE'] . ': ' . $phone_mobile . "\n";
         $mailer->Body .= $_ARRAYLANG['TXT_IMMO_DOC_VIA_MAIL'] . ': ' . ($doc_via_mail ? $_ARRAYLANG['TXT_IMMO_YES'] : $_ARRAYLANG['TXT_IMMO_NO']) . "\n";
         $mailer->Body .= $_ARRAYLANG['TXT_IMMO_FUNDING_ADVICE'] . ': ' . ($funding_advice ? $_ARRAYLANG['TXT_IMMO_YES'] : $_ARRAYLANG['TXT_IMMO_NO']) . "\n";
         $mailer->Body .= $_ARRAYLANG['TXT_IMMO_CONTACT_FOR_INSPECTION'] . ': ' . ($inspection ? $_ARRAYLANG['TXT_IMMO_YES'] : $_ARRAYLANG['TXT_IMMO_NO']) . "\n";
         $mailer->Body .= $_ARRAYLANG['TXT_IMMO_CONTACT_VIA_PHONE'] . ': ' . ($contact_via_phone ? $_ARRAYLANG['TXT_IMMO_YES'] : $_ARRAYLANG['TXT_IMMO_NO']) . "\n";
         $mailer->Body .= $_ARRAYLANG['TXT_IMMO_COMMENTS'] . ': ' . $comment . "\n";
         $mailer->Send();
         //mail for interested customer
         $mailer->ClearAddresses();
         $mailer->SetFrom($this->arrSettings['sender_email'], $this->arrSettings['sender_name']);
         $mailer->AddAddress($_REQUEST['contactFormField_email']);
         $mailer->Subject = $this->arrSettings['interest_confirm_subject'];
         $message = str_replace('[[IMMO_OBJECT]]', $address . ', ' . $location . " (Ref.Nr.: {$reference})", $this->arrSettings['interest_confirm_message']);
         $mailer->Body = $message;
         $mailer->Send();
         $this->_objTpl->setVariable('CONTACT_FEEDBACK_TEXT', $_ARRAYLANG['TXT_IMMO_CONTACT_SUCCESSFUL']);
     }
     return true;
 }
Ejemplo n.º 13
0
 function sendMail($entryId)
 {
     global $objDatabase, $_ARRAYLANG, $_CORELANG, $_CONFIG;
     //entrydata
     $objResult = $objDatabase->Execute("SELECT id, title, name, userid, email FROM " . DBPREFIX . "module_market WHERE id='" . contrexx_addslashes($entryId) . "' LIMIT 1");
     if ($objResult !== false) {
         while (!$objResult->EOF) {
             $entryMail = $objResult->fields['email'];
             $entryName = $objResult->fields['name'];
             $entryTitle = $objResult->fields['title'];
             $entryUserid = $objResult->fields['userid'];
             $objResult->MoveNext();
         }
     }
     //assesuserdata
     $objResult = $objDatabase->Execute("SELECT email, username FROM " . DBPREFIX . "access_users WHERE id='" . $entryUserid . "' LIMIT 1");
     if ($objResult !== false) {
         while (!$objResult->EOF) {
             // TODO: Never used
             //                $userMail            = $objResult->fields['email'];
             $userUsername = $objResult->fields['username'];
             $objResult->MoveNext();
         }
     }
     //get mail content n title
     $objResult = $objDatabase->Execute("SELECT title, content, active, mailcc FROM " . DBPREFIX . "module_market_mail WHERE id='1'");
     if ($objResult !== false) {
         while (!$objResult->EOF) {
             $mailTitle = $objResult->fields['title'];
             $mailContent = $objResult->fields['content'];
             $mailCC = $objResult->fields['mailcc'];
             $mailOn = $objResult->fields['active'];
             $objResult->MoveNext();
         }
     }
     if ($mailOn == 1) {
         $array = explode('; ', $mailCC);
         $url = $_SERVER['SERVER_NAME'] . ASCMS_PATH_OFFSET;
         $link = "http://" . $url . "/index.php?section=Market&cmd=detail&id=" . $entryId;
         $now = date(ASCMS_DATE_FORMAT);
         //replase placeholder
         $array_1 = array('[[EMAIL]]', '[[NAME]]', '[[TITLE]]', '[[ID]]', '[[LINK]]', '[[URL]]', '[[DATE]]', '[[USERNAME]]');
         $array_2 = array($entryMail, $entryName, $entryTitle, $entryId, $link, $url, $now, $userUsername);
         for ($x = 0; $x < 8; $x++) {
             $mailTitle = str_replace($array_1[$x], $array_2[$x], $mailTitle);
         }
         for ($x = 0; $x < 8; $x++) {
             $mailContent = str_replace($array_1[$x], $array_2[$x], $mailContent);
         }
         //create mail
         $to = $entryMail;
         $fromName = $_CONFIG['coreAdminName'] . " - " . $url;
         $fromMail = $_CONFIG['coreAdminEmail'];
         $subject = $mailTitle;
         $message = $mailContent;
         if (\Env::get('ClassLoader')->loadFile(ASCMS_LIBRARY_PATH . '/phpmailer/class.phpmailer.php')) {
             $objMail = new \phpmailer();
             if ($_CONFIG['coreSmtpServer'] > 0) {
                 if (($arrSmtp = \SmtpSettings::getSmtpAccount($_CONFIG['coreSmtpServer'])) !== false) {
                     $objMail->IsSMTP();
                     $objMail->Host = $arrSmtp['hostname'];
                     $objMail->Port = $arrSmtp['port'];
                     $objMail->SMTPAuth = true;
                     $objMail->Username = $arrSmtp['username'];
                     $objMail->Password = $arrSmtp['password'];
                 }
             }
             $objMail->CharSet = CONTREXX_CHARSET;
             $objMail->SetFrom($fromMail, $fromName);
             $objMail->Subject = $subject;
             $objMail->IsHTML(false);
             $objMail->Body = $message;
             $objMail->AddAddress($to);
             $objMail->Send();
             $objMail->ClearAddresses();
             foreach ($array as $toCC) {
                 // Email message
                 if (!empty($toCC)) {
                     $objMail->AddAddress($toCC);
                     $objMail->Send();
                     $objMail->ClearAddresses();
                 }
             }
         }
     }
 }
Ejemplo n.º 14
0
 /**
  * Insert a new comment for a message into database, if the function is activated. Furthermore, all input values are validated.
  * Sends also the notification mail to the administrator, if it is enabled in options.
  *
  * @global  ADONewConnection
  * @global  array
  * @global  array
  */
 function addComment()
 {
     global $objDatabase, $_ARRAYLANG, $_CONFIG;
     \Cx\Core\Csrf\Controller\Csrf::check_code();
     $this->initUserId();
     //Check for activated function
     if (!$this->_arrSettings['blog_comments_activated']) {
         $this->_strErrorMessage = $_ARRAYLANG['TXT_BLOG_FRONTEND_DETAILS_COMMENT_INSERT_ERROR_ACTIVATED'];
         return;
     }
     if ($this->hasUserJustCommented()) {
         $this->_strErrorMessage = str_replace('[SECONDS]', intval($this->_arrSettings['blog_comments_timeout']), $_ARRAYLANG['TXT_BLOG_FRONTEND_DETAILS_COMMENT_INSERT_ERROR_TIMEOUT']);
         return;
     }
     //Create validator-object
     $objValidator = new \FWValidator();
     //Get general-input
     $intMessageId = intval($_POST['frmAddComment_MessageId']);
     $strSubject = contrexx_addslashes(strip_tags($_POST['frmAddComment_Subject']));
     $strComment = \Cx\Core\Wysiwyg\Wysiwyg::prepareBBCodeForDb($_POST['frmAddComment_Comment']);
     //Get specified-input
     if ($this->_intCurrentUserId == 0) {
         $intUserId = 0;
         $strName = contrexx_addslashes(strip_tags($_POST['frmAddComment_Name']));
         $strEMail = contrexx_addslashes(strip_tags($_POST['frmAddComment_EMail']));
         $strWWW = contrexx_addslashes(strip_tags($objValidator->getUrl($_POST['frmAddComment_WWW'])));
     } else {
         $intUserId = $this->_intCurrentUserId;
         $strName = '';
         $strEMail = '';
         $strWWW = '';
     }
     //Get options
     $intIsActive = intval($this->_arrSettings['blog_comments_autoactivate']);
     $intIsNotification = intval($this->_arrSettings['blog_comments_notification']);
     //Validate general-input
     if ($intMessageId <= 0) {
         $this->_strErrorMessage .= $this->getFormError($_ARRAYLANG['TXT_BLOG_FRONTEND_DETAILS_COMMENT_INSERT_MID']);
     }
     if (empty($strSubject)) {
         $this->_strErrorMessage .= $this->getFormError($_ARRAYLANG['TXT_BLOG_FRONTEND_DETAILS_COMMENT_ADD_SUBJECT']);
     }
     if (empty($strComment)) {
         $this->_strErrorMessage .= $this->getFormError($_ARRAYLANG['TXT_BLOG_FRONTEND_DETAILS_COMMENT_ADD_COMMENT']);
     }
     //Validate specified-input
     if ($this->_intCurrentUserId == 0) {
         if (empty($strName)) {
             $this->_strErrorMessage .= $this->getFormError($_ARRAYLANG['TXT_BLOG_FRONTEND_DETAILS_COMMENT_ADD_NAME']);
         }
         if (!$objValidator->isEmail($strEMail)) {
             $this->_strErrorMessage .= $this->getFormError($_ARRAYLANG['TXT_BLOG_FRONTEND_DETAILS_COMMENT_ADD_EMAIL']);
         }
     }
     $captchaCheck = true;
     if (!\FWUser::getFWUserObject()->objUser->login() && !\Cx\Core_Modules\Captcha\Controller\Captcha::getInstance()->check()) {
         $captchaCheck = false;
     }
     //Now check error-string
     if (empty($this->_strErrorMessage) && $captchaCheck) {
         //No errors, insert entry
         $objDatabase->Execute(' INSERT INTO ' . DBPREFIX . 'module_blog_comments
                                 SET     message_id = ' . $intMessageId . ',
                                         lang_id = ' . $this->_intLanguageId . ',
                                         is_active = "' . $intIsActive . '",
                                         time_created = ' . time() . ',
                                         ip_address = "' . $_SERVER['REMOTE_ADDR'] . '",
                                         user_id = ' . $intUserId . ',
                                         user_name = "' . $strName . '",
                                         user_mail = "' . $strEMail . '",
                                         user_www = "' . $strWWW . '",
                                         subject = "' . $strSubject . '",
                                         comment = "' . $strComment . '"
                             ');
         //Set a cookie with the current timestamp. Avoids flooding.
         setcookie('BlogCommentLast', time(), 0, ASCMS_PATH_OFFSET . '/');
         $this->_strStatusMessage = $_ARRAYLANG['TXT_BLOG_FRONTEND_DETAILS_COMMENT_INSERT_SUCCESS'];
         $this->writeCommentRSS();
         if ($intIsNotification) {
             //Send notification to administrator
             if (\Env::get('ClassLoader')->loadFile(ASCMS_LIBRARY_PATH . '/phpmailer/class.phpmailer.php')) {
                 $objMail = new \phpmailer();
                 if ($_CONFIG['coreSmtpServer'] > 0) {
                     if (($arrSmtp = \SmtpSettings::getSmtpAccount($_CONFIG['coreSmtpServer'])) !== false) {
                         $objMail->IsSMTP();
                         $objMail->Host = $arrSmtp['hostname'];
                         $objMail->Port = $arrSmtp['port'];
                         $objMail->SMTPAuth = true;
                         $objMail->Username = $arrSmtp['username'];
                         $objMail->Password = $arrSmtp['password'];
                     }
                 }
                 if ($this->_intCurrentUserId > 0) {
                     $objFWUser = \FWUser::getFWUserObject();
                     $strName = htmlentities($objFWUser->objUser->getUsername(), ENT_QUOTES, CONTREXX_CHARSET);
                 }
                 $strMailSubject = str_replace('[SUBJECT]', $strSubject, $_ARRAYLANG['TXT_BLOG_FRONTEND_DETAILS_COMMENT_INSERT_MAIL_SUBJECT']);
                 $strMailBody = str_replace('[USERNAME]', $strName, $_ARRAYLANG['TXT_BLOG_FRONTEND_DETAILS_COMMENT_INSERT_MAIL_BODY']);
                 $strMailBody = str_replace('[DOMAIN]', ASCMS_PROTOCOL . '://' . $_CONFIG['domainUrl'] . ASCMS_PATH_OFFSET, $strMailBody);
                 $strMailBody = str_replace('[SUBJECT]', $strSubject, $strMailBody);
                 $strMailBody = str_replace('[COMMENT]', $strComment, $strMailBody);
                 $objMail->CharSet = CONTREXX_CHARSET;
                 $objMail->SetFrom($_CONFIG['coreAdminEmail'], $_CONFIG['coreGlobalPageTitle']);
                 $objMail->AddAddress($_CONFIG['coreAdminEmail']);
                 $objMail->Subject = $strMailSubject;
                 $objMail->IsHTML(false);
                 $objMail->Body = $strMailBody;
                 $objMail->Send();
             }
         }
     }
 }
Ejemplo n.º 15
0
 /**
  * Set up and send an email from the shop.
  * @static
  * @param   string    $mailTo           Recipient mail address
  * @param   string    $mailFrom         Sender mail address
  * @param   string    $mailSender       Sender name
  * @param   string    $mailSubject      Message subject
  * @param   string    $mailBody         Message body
  * @return  boolean                     True if the mail could be sent,
  *                                      false otherwise
  * @author  Reto Kohli <*****@*****.**>
  */
 static function send($mailTo, $mailFrom, $mailSender, $mailSubject, $mailBody)
 {
     die("Mail::send(): Obsolete method called!");
     global $_CONFIG;
     if (!@(include_once \Cx\Core\Core\Controller\Cx::instanciate()->getCodeBaseLibraryPath() . '/phpmailer/class.phpmailer.php')) {
         return false;
     }
     $objMail = new \phpmailer();
     if (isset($_CONFIG['coreSmtpServer']) && $_CONFIG['coreSmtpServer'] > 0 && @(include_once \Cx\Core\Core\Controller\Cx::instanciate()->getCodeBaseCorePath() . '/SmtpSettings.class.php')) {
         if (($arrSmtp = \SmtpSettings::getSmtpAccount($_CONFIG['coreSmtpServer'])) !== false) {
             $objMail->IsSMTP();
             $objMail->Host = $arrSmtp['hostname'];
             $objMail->Port = $arrSmtp['port'];
             $objMail->SMTPAuth = true;
             $objMail->Username = $arrSmtp['username'];
             $objMail->Password = $arrSmtp['password'];
         }
     }
     $objMail->CharSet = CONTREXX_CHARSET;
     $from = preg_replace('/\\015\\012/', '', $mailFrom);
     $fromName = preg_replace('/\\015\\012/', '', $mailSender);
     //$objMail->AddReplyTo($_CONFIG['coreAdminEmail']);
     $objMail->SetFrom($from, $fromName);
     $objMail->Subject = $mailSubject;
     $objMail->IsHTML(false);
     $objMail->Body = preg_replace('/\\015\\012/', "\n", $mailBody);
     $objMail->AddAddress($mailTo);
     if ($objMail->Send()) {
         return true;
     }
     return false;
 }
Ejemplo n.º 16
0
 function sendMail()
 {
     global $_ARRAYLANG, $_CONFIG;
     if (\Env::get('ClassLoader')->loadFile(\Cx\Core\Core\Controller\Cx::instanciate()->getCodeBaseLibraryPath() . '/phpmailer/class.phpmailer.php')) {
         $objMail = new \phpmailer();
         if ($_CONFIG['coreSmtpServer'] > 0 && \Env::get('ClassLoader')->loadFile(\Cx\Core\Core\Controller\Cx::instanciate()->getCodeBaseCorePath() . '/SmtpSettings.class.php')) {
             $arrSmtp = \SmtpSettings::getSmtpAccount($_CONFIG['coreSmtpServer']);
             if ($arrSmtp !== false) {
                 $objMail->IsSMTP();
                 $objMail->Host = $arrSmtp['hostname'];
                 $objMail->Port = $arrSmtp['port'];
                 $objMail->SMTPAuth = true;
                 $objMail->Username = $arrSmtp['username'];
                 $objMail->Password = $arrSmtp['password'];
             }
         }
         $objMail->CharSet = CONTREXX_CHARSET;
         $objMail->SetFrom($_CONFIG['coreAdminEmail'], $_CONFIG['coreGlobalPageTitle']);
         $objMail->Subject = $this->strTitle;
         $objMail->IsHTML(false);
         $objMail->Body = $this->strTemplate;
         foreach ($this->arrRecipients as $key => $strMailAdress) {
             if (!empty($strMailAdress)) {
                 $objMail->AddAddress($strMailAdress);
                 $objMail->Send();
                 $objMail->ClearAddresses();
             }
         }
     }
 }
Ejemplo n.º 17
0
 /**
  * Send confirmation email.
  *
  * @access      private
  * @param       string      $recipient      recipient
  * @param       array       $arrMail        title and content
  */
 private function sendConfirmationMail($recipient, $arrMail)
 {
     global $_ARRAYLANG, $_CONFIG;
     $objPHPMailer = new \phpmailer();
     if ($_CONFIG['coreSmtpServer'] > 0 && @(include_once ASCMS_CORE_PATH . '/SmtpSettings.class.php')) {
         if (($arrSmtp = \SmtpSettings::getSmtpAccount($_CONFIG['coreSmtpServer'])) !== false) {
             $objPHPMailer->IsSMTP();
             $objPHPMailer->Host = $arrSmtp['hostname'];
             $objPHPMailer->Port = $arrSmtp['port'];
             $objPHPMailer->SMTPAuth = true;
             $objPHPMailer->Username = $arrSmtp['username'];
             $objPHPMailer->Password = $arrSmtp['password'];
         }
     }
     $objPHPMailer->CharSet = CONTREXX_CHARSET;
     $objPHPMailer->IsHTML(true);
     $objPHPMailer->Subject = $arrMail['title'];
     $objPHPMailer->SetFrom($_CONFIG['contactFormEmail'], $_CONFIG['domainUrl']);
     $objPHPMailer->AddAddress($recipient);
     $objPHPMailer->Body = $arrMail['content'];
     $objPHPMailer->Send();
 }
Ejemplo n.º 18
0
 private function notifyUserAboutAccountStatusChange($objUser)
 {
     global $_ARRAYLANG, $_CORELANG, $_CONFIG, $_LANGID;
     $objFWUser = \FWUser::getFWUserObject();
     $objUserMail = $objFWUser->getMail();
     $mail2load = $objUser->getActiveStatus() ? 'user_activated' : 'user_deactivated';
     if (($objUserMail->load($mail2load, $_LANGID) || $objUserMail->load($mail2load)) && \Env::get('ClassLoader')->loadFile(ASCMS_LIBRARY_PATH . '/phpmailer/class.phpmailer.php') && ($objMail = new \PHPMailer()) !== false) {
         if ($_CONFIG['coreSmtpServer'] > 0 && \Env::get('ClassLoader')->loadFile(ASCMS_CORE_PATH . '/SmtpSettings.class.php')) {
             if (($arrSmtp = \SmtpSettings::getSmtpAccount($_CONFIG['coreSmtpServer'])) !== false) {
                 $objMail->IsSMTP();
                 $objMail->Host = $arrSmtp['hostname'];
                 $objMail->Port = $arrSmtp['port'];
                 $objMail->SMTPAuth = true;
                 $objMail->Username = $arrSmtp['username'];
                 $objMail->Password = $arrSmtp['password'];
             }
         }
         $objMail->CharSet = CONTREXX_CHARSET;
         $objMail->SetFrom($objUserMail->getSenderMail(), $objUserMail->getSenderName());
         $objMail->Subject = $objUserMail->getSubject();
         if (in_array($objUserMail->getFormat(), array('multipart', 'text'))) {
             $objUserMail->getFormat() == 'text' ? $objMail->IsHTML(false) : false;
             $objMail->{($objUserMail->getFormat() == 'text' ? '' : 'Alt') . 'Body'} = str_replace(array('[[HOST]]', '[[USERNAME]]', '[[SENDER]]'), array($_CONFIG['domainUrl'], $objUser->getUsername(), $objUserMail->getSenderName()), $objUserMail->getBodyText());
         }
         if (in_array($objUserMail->getFormat(), array('multipart', 'html'))) {
             $objUserMail->getFormat() == 'html' ? $objMail->IsHTML(true) : false;
             $objMail->Body = str_replace(array('[[HOST]]', '[[USERNAME]]', '[[SENDER]]'), array($_CONFIG['domainUrl'], htmlentities($objUser->getUsername(), ENT_QUOTES, CONTREXX_CHARSET), htmlentities($objUserMail->getSenderName(), ENT_QUOTES, CONTREXX_CHARSET)), $objUserMail->getBodyHtml());
         }
         $objMail->AddAddress($objUser->getEmail());
         if ($objMail->Send()) {
             return true;
         }
     }
     $userEmail = '<a href="mailto:' . $objUser->getEmail() . '?subject=' . ($objUser->getActiveStatus() ? $_CORELANG['TXT_ACCESS_USER_ACCOUNT_ACTIVATED'] : $_CORELANG['TXT_ACCESS_USER_ACCOUNT_DEACTIVATED']) . '" title="' . $objUser->getEmail() . '">' . $objUser->getEmail() . '</a>';
     self::$arrStatusMsg['error'][] = str_replace(array('%USER%', '%EMAIL%'), array(contrexx_raw2xhtml($objUser->getUsername()), $userEmail), $_ARRAYLANG['TXT_ACCESS_COULD_NOT_NOTIFY_USER_ABOUT_STATUS_CHANGE']);
     return false;
 }
Ejemplo n.º 19
0
 /**
  * @return void
  * @desc Sends a notification email to the administrator
  */
 function sendNotificationEmail($forename, $name, $comment, $email = null)
 {
     global $_ARRAYLANG, $_CONFIG;
     $message = $_ARRAYLANG['TXT_CHECK_GUESTBOOK_ENTRY'] . "\n\n";
     $message .= $_ARRAYLANG['TXT_ENTRY_READS'] . "\n" . $forename . " " . $name . "\n" . html_entity_decode($comment, ENT_QUOTES, CONTREXX_CHARSET);
     $mailto = $_CONFIG['coreAdminEmail'];
     $subject = $_ARRAYLANG['TXT_NEW_GUESTBOOK_ENTRY'] . " " . $_CONFIG['domainUrl'];
     if (@(include_once ASCMS_LIBRARY_PATH . '/phpmailer/class.phpmailer.php')) {
         $objMail = new \phpmailer();
         if ($_CONFIG['coreSmtpServer'] > 0 && @(include_once ASCMS_CORE_PATH . '/SmtpSettings.class.php')) {
             if (($arrSmtp = \SmtpSettings::getSmtpAccount($_CONFIG['coreSmtpServer'])) !== false) {
                 $objMail->IsSMTP();
                 $objMail->Host = $arrSmtp['hostname'];
                 $objMail->Port = $arrSmtp['port'];
                 $objMail->SMTPAuth = true;
                 $objMail->Username = $arrSmtp['username'];
                 $objMail->Password = $arrSmtp['password'];
             }
         }
         $objMail->CharSet = CONTREXX_CHARSET;
         $from = isset($email) ? $email : $mailto;
         $objMail->SetFrom($from);
         $objMail->Subject = $subject;
         $objMail->IsHTML(false);
         $objMail->Body = $message;
         $objMail->AddAddress($mailto);
         if ($objMail->Send()) {
             return true;
         }
     }
     return false;
 }
Ejemplo n.º 20
0
 /**
  * Update the order status and send the confirmation mail
  * according to the settings
  *
  * The resulting javascript code displays a message box or
  * does some page redirect.
  * @param   integer   $order_id       The order ID
  * @return  string                    Javascript code
  * @static
  */
 static function updateOrder($order_id, $newStatus = 1)
 {
     global $_ARRAYLANG, $_CONFIG;
     $product_id = self::getOrderValue('order_product', $order_id);
     if (empty($product_id)) {
         return 'alert("' . $_ARRAYLANG['TXT_EGOV_ERROR_UPDATING_ORDER'] . '");' . "\n";
     }
     // Has this order been updated already?
     $orderStatus = self::GetOrderValue('order_state', $order_id);
     if ($orderStatus != 0) {
         // Do not resend mails!
         return '';
     }
     $arrFields = self::getOrderValues($order_id);
     $FormValue4Mail = '';
     $arrMatch = array();
     foreach ($arrFields as $name => $value) {
         // If the value matches a calendar date, prefix the string with
         // the day of the week
         if (preg_match('/^(\\d\\d?)\\.(\\d\\d?)\\.(\\d\\d\\d\\d)$/', $value, $arrMatch)) {
             // ISO-8601 numeric representation of the day of the week
             // 1 (for Monday) through 7 (for Sunday)
             $dotwNumber = date('N', mktime(1, 1, 1, $arrMatch[2], $arrMatch[1], $arrMatch[3]));
             $dotwName = $_ARRAYLANG['TXT_EGOV_DAYNAME_' . $dotwNumber];
             $value = "{$dotwName}, {$value}";
         }
         $FormValue4Mail .= html_entity_decode($name) . ': ' . html_entity_decode($value) . "\n";
     }
     // Bestelleingang-Benachrichtigung || Mail f�r den Administrator
     $recipient = self::GetProduktValue('product_target_email', $product_id);
     if (empty($recipient)) {
         $recipient = self::GetSettings('set_orderentry_recipient');
     }
     if (!empty($recipient)) {
         $SubjectText = str_replace('[[PRODUCT_NAME]]', html_entity_decode(self::GetProduktValue('product_name', $product_id)), self::GetSettings('set_orderentry_subject'));
         $SubjectText = html_entity_decode($SubjectText);
         $BodyText = str_replace('[[ORDER_VALUE]]', $FormValue4Mail, self::GetSettings('set_orderentry_email'));
         $BodyText = html_entity_decode($BodyText);
         $replyAddress = self::GetEmailAdress($order_id);
         if (empty($replyAddress)) {
             $replyAddress = self::GetSettings('set_orderentry_sender');
         }
         if (@(include_once ASCMS_LIBRARY_PATH . '/phpmailer/class.phpmailer.php')) {
             $objMail = new \phpmailer();
             if (!empty($_CONFIG['coreSmtpServer'])) {
                 if (($arrSmtp = \SmtpSettings::getSmtpAccount($_CONFIG['coreSmtpServer'])) !== false) {
                     $objMail->IsSMTP();
                     $objMail->Host = $arrSmtp['hostname'];
                     $objMail->Port = $arrSmtp['port'];
                     $objMail->SMTPAuth = true;
                     $objMail->Username = $arrSmtp['username'];
                     $objMail->Password = $arrSmtp['password'];
                 }
             }
             $objMail->CharSet = CONTREXX_CHARSET;
             $from = self::GetSettings('set_orderentry_sender');
             $fromName = self::GetSettings('set_orderentry_name');
             $objMail->AddReplyTo($replyAddress);
             $objMail->SetFrom($from, $fromName);
             $objMail->Subject = $SubjectText;
             $objMail->Priority = 3;
             $objMail->IsHTML(false);
             $objMail->Body = $BodyText;
             $objMail->AddAddress($recipient);
             $objMail->Send();
         }
     }
     // Update 29.10.2006 Statusmail automatisch abschicken || Produktdatei
     if (self::GetProduktValue('product_electro', $product_id) == 1 || self::GetProduktValue('product_autostatus', $product_id) == 1) {
         self::updateOrderStatus($order_id, $newStatus);
         $TargetMail = self::GetEmailAdress($order_id);
         if ($TargetMail != '') {
             $FromEmail = self::GetProduktValue('product_sender_email', $product_id);
             if ($FromEmail == '') {
                 $FromEmail = self::GetSettings('set_sender_email');
             }
             $FromName = self::GetProduktValue('product_sender_name', $product_id);
             if ($FromName == '') {
                 $FromName = self::GetSettings('set_sender_name');
             }
             $SubjectDB = self::GetProduktValue('product_target_subject', $product_id);
             if ($SubjectDB == '') {
                 $SubjectDB = self::GetSettings('set_state_subject');
             }
             $SubjectText = str_replace('[[PRODUCT_NAME]]', html_entity_decode(self::GetProduktValue('product_name', $product_id)), $SubjectDB);
             $SubjectText = html_entity_decode($SubjectText);
             $BodyDB = self::GetProduktValue('product_target_body', $product_id);
             if ($BodyDB == '') {
                 $BodyDB = self::GetSettings('set_state_email');
             }
             $BodyText = str_replace('[[ORDER_VALUE]]', $FormValue4Mail, $BodyDB);
             $BodyText = str_replace('[[PRODUCT_NAME]]', html_entity_decode(self::GetProduktValue('product_name', $product_id)), $BodyText);
             $BodyText = html_entity_decode($BodyText);
             if (@(include_once ASCMS_LIBRARY_PATH . '/phpmailer/class.phpmailer.php')) {
                 $objMail = new \phpmailer();
                 if ($_CONFIG['coreSmtpServer'] > 0) {
                     if (($arrSmtp = \SmtpSettings::getSmtpAccount($_CONFIG['coreSmtpServer'])) !== false) {
                         $objMail->IsSMTP();
                         $objMail->Host = $arrSmtp['hostname'];
                         $objMail->Port = $arrSmtp['port'];
                         $objMail->SMTPAuth = true;
                         $objMail->Username = $arrSmtp['username'];
                         $objMail->Password = $arrSmtp['password'];
                     }
                 }
                 $objMail->CharSet = CONTREXX_CHARSET;
                 $objMail->SetFrom($FromEmail, $FromName);
                 $objMail->Subject = $SubjectText;
                 $objMail->Priority = 3;
                 $objMail->IsHTML(false);
                 $objMail->Body = $BodyText;
                 $objMail->AddAddress($TargetMail);
                 if (self::GetProduktValue('product_electro', $product_id) == 1) {
                     $objMail->AddAttachment(ASCMS_PATH . self::GetProduktValue('product_file', $product_id));
                 }
                 $objMail->Send();
             }
         }
     }
     return '';
 }
Ejemplo n.º 21
0
 /**
  * Send a confirmation e-mail to the address specified in the form,
  * if any.
  * @param $id
  * @param unknown_type $email
  * @return unknown
  */
 function sendMail($feedId, $email)
 {
     global $_CONFIG, $objDatabase, $_ARRAYLANG, $objInit;
     $feedId = intval($feedId);
     $languageId = null;
     // Get the user ID and entry information
     $objResult = $objDatabase->Execute("\n            SELECT addedby, title, language\n              FROM " . DBPREFIX . "module_directory_dir\n             WHERE id='{$feedId}'");
     if ($objResult && !$objResult->EOF) {
         $userId = $objResult->fields['addedby'];
         $feedTitle = $objResult->fields['title'];
         $languageId = $objResult->fields['language'];
     }
     // Get user data
     if (is_numeric($userId)) {
         $objFWUser = new \FWUser();
         if ($objFWUser->objUser->getUser($userId)) {
             $userMail = $objFWUser->objUser->getEmail();
             $userFirstname = $objFWUser->objUser->getProfileAttribute('firstname');
             $userLastname = $objFWUser->objUser->getProfileAttribute('lastname');
             $userUsername = $objFWUser->objUser->getUsername();
         }
     }
     if (!empty($email)) {
         $sendTo = $email;
         $mailId = 2;
     } else {
         // FIXED:  The mail addresses may *both* be empty!
         // Adding the entry was sucessful, however.  So we can probably assume
         // that it was a success anyway?
         // Added:
         if (empty($userMail)) {
             return true;
         }
         // ...and a boolean return value below.
         $sendTo = $userMail;
         $mailId = 1;
     }
     //get mail content n title
     $objResult = $objDatabase->Execute("\n            SELECT title, content\n              FROM " . DBPREFIX . "module_directory_mail\n             WHERE id='{$mailId}'");
     if ($objResult && !$objResult->EOF) {
         $subject = $objResult->fields['title'];
         $message = $objResult->fields['content'];
     }
     if ($objInit->mode == 'frontend') {
         $link = "http://" . $_CONFIG['domainUrl'] . CONTREXX_SCRIPT_PATH . "?section=Directory&cmd=detail&id=" . $feedId;
     } else {
         $link = "http://" . $_CONFIG['domainUrl'] . ASCMS_PATH_OFFSET . '/' . \FWLanguage::getLanguageParameter($languageId, 'lang') . '/' . CONTREXX_DIRECTORY_INDEX . "?section=Directory&cmd=detail&id=" . $feedId;
     }
     // replace placeholders
     $array_1 = array('[[USERNAME]]', '[[FIRSTNAME]]', '[[LASTNAME]]', '[[TITLE]]', '[[LINK]]', '[[URL]]', '[[DATE]]');
     $array_2 = array($userUsername, $userFirstname, $userLastname, $feedTitle, $link, $_CONFIG['domainUrl'] . ASCMS_PATH_OFFSET, date(ASCMS_DATE_FORMAT));
     $subject = str_replace($array_1, $array_2, $subject);
     $message = str_replace($array_1, $array_2, $message);
     $sendTo = explode(';', $sendTo);
     if (@\Env::get('ClassLoader')->loadFile(ASCMS_LIBRARY_PATH . '/phpmailer/class.phpmailer.php')) {
         $objMail = new \phpmailer();
         if ($_CONFIG['coreSmtpServer'] > 0 && @\Env::get('ClassLoader')->loadFile(ASCMS_CORE_PATH . '/SmtpSettings.class.php')) {
             $arrSmtp = SmtpSettings::getSmtpAccount($_CONFIG['coreSmtpServer']);
             if ($arrSmtp !== false) {
                 $objMail->IsSMTP();
                 $objMail->Host = $arrSmtp['hostname'];
                 $objMail->Port = $arrSmtp['port'];
                 $objMail->SMTPAuth = true;
                 $objMail->Username = $arrSmtp['username'];
                 $objMail->Password = $arrSmtp['password'];
             }
         }
         $objMail->CharSet = CONTREXX_CHARSET;
         $objMail->From = $_CONFIG['coreAdminEmail'];
         $objMail->FromName = $_CONFIG['coreAdminName'];
         $objMail->AddReplyTo($_CONFIG['coreAdminEmail']);
         $objMail->Subject = $subject;
         $objMail->IsHTML(false);
         $objMail->Body = $message;
         foreach ($sendTo as $mailAdress) {
             $objMail->ClearAddresses();
             $objMail->AddAddress($mailAdress);
             $objMail->Send();
         }
     }
     return true;
 }
Ejemplo n.º 22
0
 function _sendNotificationEmail($action, $recipientId)
 {
     global $_CONFIG, $_ARRAYLANG, $objDatabase;
     //action: 1 = subscribe | 2 = unsubscribe
     $objSettings = $objDatabase->Execute("SELECT `setname`, `setvalue` FROM `" . DBPREFIX . "module_newsletter_settings` WHERE `setname` = 'notificationSubscribe' OR  `setname` = 'notificationUnsubscribe' ");
     if ($objSettings !== false) {
         while (!$objSettings->EOF) {
             $arrSettings[$objSettings->fields['setname']] = $objSettings->fields['setvalue'];
             $objSettings->MoveNext();
         }
     }
     if ($arrSettings['notificationSubscribe'] == 1 && $action == 1 || $arrSettings['notificationUnsubscribe'] == 1 && $action == 2) {
         if (!@(include_once ASCMS_LIBRARY_PATH . '/phpmailer/class.phpmailer.php')) {
             return false;
         }
         $objRecipient = $objDatabase->SelectLimit("SELECT sex, salutation, lastname, firstname, email FROM " . DBPREFIX . "module_newsletter_user WHERE id=" . $recipientId, 1);
         if ($objRecipient !== false) {
             $arrRecipient['sex'] = $objRecipient->fields['sex'];
             $arrRecipient['salutation'] = $objRecipient->fields['salutation'];
             $arrRecipient['lastname'] = $objRecipient->fields['lastname'];
             $arrRecipient['firstname'] = $objRecipient->fields['firstname'];
             $arrRecipient['email'] = $objRecipient->fields['email'];
         }
         $objRecipientTitle = $objDatabase->SelectLimit("SELECT title FROM " . DBPREFIX . "module_newsletter_user_title WHERE id=" . $arrRecipient['salutation'], 1);
         if ($objRecipientTitle !== false) {
             $arrRecipientTitle = $objRecipientTitle->fields['title'];
         }
         $objNotificationMail = $objDatabase->SelectLimit("SELECT title, content, recipients FROM " . DBPREFIX . "module_newsletter_confirm_mail WHERE id='3'", 1);
         if ($action == 1) {
             $txtAction = $_ARRAYLANG['TXT_NEWSLETTER_NOTIFICATION_SUBSCRIBE'];
         } else {
             $txtAction = $_ARRAYLANG['TXT_NEWSLETTER_NOTIFICATION_UNSUBSCRIBE'];
             $objNotificationAdressesFromLists = $objDatabase->Execute('SELECT notification_email FROM ' . DBPREFIX . 'module_newsletter_category AS c 
                                                                     INNER JOIN ' . DBPREFIX . 'module_newsletter_rel_user_cat AS r ON r.category = c.id
                                                                     WHERE r.user = '******',', $objNotificationAdressesFromLists->fields['notification_email']) as $mail) {
                         if (!in_array($mail, $notifyMails)) {
                             array_push($notifyMails, trim($mail));
                         }
                     }
                     $objNotificationAdressesFromLists->MoveNext();
                 }
             }
         }
         $arrParsedTxts = str_replace(array('[[action]]', '[[url]]', '[[date]]', '[[sex]]', '[[title]]', '[[lastname]]', '[[firstname]]', '[[e-mail]]'), array($txtAction, $_CONFIG['domainUrl'], date(ASCMS_DATE_FORMAT), $arrRecipient['sex'], $arrRecipientTitle, $arrRecipient['lastname'], $arrRecipient['firstname'], $arrRecipient['email']), array($objNotificationMail->fields['title'], $objNotificationMail->fields['content']));
         $arrRecipients = explode(',', $objNotificationMail->fields['recipients']);
         $arrSettings =& $this->_getSettings();
         $objMail = new \phpmailer();
         if ($_CONFIG['coreSmtpServer'] > 0 && @(include_once ASCMS_CORE_PATH . '/SmtpSettings.class.php')) {
             if (($arrSmtp = \SmtpSettings::getSmtpAccount($_CONFIG['coreSmtpServer'])) !== false) {
                 $objMail->IsSMTP();
                 $objMail->Host = $arrSmtp['hostname'];
                 $objMail->Port = $arrSmtp['port'];
                 $objMail->SMTPAuth = true;
                 $objMail->Username = $arrSmtp['username'];
                 $objMail->Password = $arrSmtp['password'];
             }
         }
         $objMail->CharSet = CONTREXX_CHARSET;
         $objMail->From = $arrSettings['sender_mail']['setvalue'];
         $objMail->FromName = $arrSettings['sender_name']['setvalue'];
         $objMail->AddReplyTo($arrSettings['reply_mail']['setvalue']);
         $objMail->Subject = $arrParsedTxts[0];
         $objMail->Priority = 3;
         $objMail->IsHTML(false);
         $objMail->Body = $arrParsedTxts[1];
         foreach ($arrRecipients as $key => $recipientEmail) {
             $objMail->AddAddress($recipientEmail);
         }
         foreach ($notifyMails as $mail) {
             $objMail->AddAddress($mail);
         }
         if ($objMail->Send()) {
             return true;
         }
     }
     // TODO: This used to return *nothing* when notifications were turned off.
     // Probably true should be returned in this case instead.
     // -- See the condition way above.
     return false;
 }
Ejemplo n.º 23
0
 /**
  * Set up and send an email from the shop.
  * @static
  * @param   string    $mailTo           Recipient mail address
  * @param   string    $mailFrom         Sender mail address
  * @param   string    $mailSender       Sender name
  * @param   string    $mailSubject      Message subject
  * @param   string    $mailBody         Message body
  * @return  boolean                     True if the mail could be sent,
  *                                      false otherwise
  * @author  Reto Kohli <*****@*****.**>
  */
 static function send($mailTo, $mailFrom, $mailSender, $mailSubject, $mailBody)
 {
     global $_CONFIG;
     if (@(include_once ASCMS_LIBRARY_PATH . '/phpmailer/class.phpmailer.php')) {
         $objMail = new phpmailer();
         if (isset($_CONFIG['coreSmtpServer']) && $_CONFIG['coreSmtpServer'] > 0 && @(include_once ASCMS_CORE_PATH . '/SmtpSettings.class.php')) {
             if (($arrSmtp = SmtpSettings::getSmtpAccount($_CONFIG['coreSmtpServer'])) !== false) {
                 $objMail->IsSMTP();
                 $objMail->Host = $arrSmtp['hostname'];
                 $objMail->Port = $arrSmtp['port'];
                 $objMail->SMTPAuth = true;
                 $objMail->Username = $arrSmtp['username'];
                 $objMail->Password = $arrSmtp['password'];
             }
         }
         $objMail->CharSet = CONTREXX_CHARSET;
         $from = preg_replace('/\\015\\012/', '', $mailFrom);
         $fromName = preg_replace('/\\015\\012/', '', $mailSender);
         $objMail->SetFrom($from, $fromName);
         $objMail->Subject = $mailSubject;
         $objMail->IsHTML(false);
         $objMail->Body = preg_replace('/\\015\\012/', "\n", $mailBody);
         $objMail->AddAddress($mailTo);
         if ($objMail->Send()) {
             return true;
         }
     }
     return false;
 }
Ejemplo n.º 24
0
 function send()
 {
     global $objDatabase, $_ARRAYLANG, $_CONFIG;
     $this->_objTpl->setTemplate($this->pageContent);
     // Initialize variables
     $code = substr(md5(rand()), 1, 10);
     $url = \Cx\Core\Routing\Url::fromModuleAndCmd('Ecard', 'show', '', array('code' => $code))->toString();
     // Initialize POST variables
     $id = intval($_POST['selectedEcard']);
     $message = contrexx_addslashes($_POST['ecardMessage']);
     $recipientSalutation = contrexx_stripslashes($_POST['ecardRecipientSalutation']);
     $senderName = contrexx_stripslashes($_POST['ecardSenderName']);
     $senderEmail = \FWValidator::isEmail($_POST['ecardSenderEmail']) ? $_POST['ecardSenderEmail'] : '';
     $recipientName = contrexx_stripslashes($_POST['ecardRecipientName']);
     $recipientEmail = \FWValidator::isEmail($_POST['ecardRecipientEmail']) ? $_POST['ecardRecipientEmail'] : '';
     if (empty($senderEmail) || empty($recipientEmail)) {
         $this->_objTpl->setVariable(array('STATUS_MESSAGE' => $_ARRAYLANG['TXT_ECARD_SENDING_ERROR']));
         return false;
     }
     $query = "\n            SELECT `setting_name`, `setting_value`\n              FROM " . DBPREFIX . "module_ecard_settings";
     $objResult = $objDatabase->Execute($query);
     while (!$objResult->EOF) {
         switch ($objResult->fields['setting_name']) {
             case 'validdays':
                 $validdays = $objResult->fields['setting_value'];
                 break;
                 // Never used
                 //                case 'greetings':
                 //                    $greetings = $objResult->fields['setting_value'];
                 //                    break;
             // Never used
             //                case 'greetings':
             //                    $greetings = $objResult->fields['setting_value'];
             //                    break;
             case 'subject':
                 $subject = $objResult->fields['setting_value'];
                 break;
             case 'emailText':
                 $emailText = strip_tags($objResult->fields['setting_value']);
                 break;
         }
         $objResult->MoveNext();
     }
     $timeToLife = $validdays * 86400;
     // Replace placeholders with used in notification mail with user data
     $emailText = str_replace('[[ECARD_RECIPIENT_SALUTATION]]', $recipientSalutation, $emailText);
     $emailText = str_replace('[[ECARD_RECIPIENT_NAME]]', $recipientName, $emailText);
     $emailText = str_replace('[[ECARD_RECIPIENT_EMAIL]]', $recipientEmail, $emailText);
     $emailText = str_replace('[[ECARD_SENDER_NAME]]', $senderName, $emailText);
     $emailText = str_replace('[[ECARD_SENDER_EMAIL]]', $senderEmail, $emailText);
     $emailText = str_replace('[[ECARD_VALID_DAYS]]', $validdays, $emailText);
     $emailText = str_replace('[[ECARD_URL]]', $url, $emailText);
     $body = $emailText;
     // Insert ecard to DB
     $query = "\n            INSERT INTO `" . DBPREFIX . "module_ecard_ecards` (\n                code, date, TTL, salutation,\n                senderName, senderEmail,\n                recipientName, recipientEmail,\n                message\n            ) VALUES (\n                '" . $code . "',\n                '" . time() . "',\n                '" . $timeToLife . "',\n                '" . addslashes($recipientSalutation) . "',\n                '" . addslashes($senderName) . "',\n                '" . $senderEmail . "',\n                '" . addslashes($recipientName) . "',\n                '" . $recipientEmail . "',\n                '" . $message . "');";
     if ($objDatabase->Execute($query)) {
         $query = "\n                SELECT setting_value\n                  FROM " . DBPREFIX . "module_ecard_settings\n                 WHERE setting_name='motive_{$id}'";
         $objResult = $objDatabase->SelectLimit($query, 1);
         // Copy motive to new file with $code as filename
         $fileExtension = preg_replace('/^.+(\\.[^\\.]+)$/', '$1', $objResult->fields['setting_value']);
         $fileName = $objResult->fields['setting_value'];
         $objFile = new \File();
         if ($objFile->copyFile(ASCMS_ECARD_OPTIMIZED_PATH . '/', $fileName, ASCMS_ECARD_SEND_ECARDS_PATH . '/', $code . $fileExtension)) {
             $objMail = new \phpmailer();
             // Check e-mail settings
             if ($_CONFIG['coreSmtpServer'] > 0 && @(include_once ASCMS_CORE_PATH . '/SmtpSettings.class.php')) {
                 $objSmtpSettings = new \SmtpSettings();
                 if (($arrSmtp = $objSmtpSettings->getSmtpAccount($_CONFIG['coreSmtpServer'])) !== false) {
                     $objMail->IsSMTP();
                     $objMail->Host = $arrSmtp['hostname'];
                     $objMail->Port = $arrSmtp['port'];
                     $objMail->SMTPAuth = true;
                     $objMail->Username = $arrSmtp['username'];
                     $objMail->Password = $arrSmtp['password'];
                 }
             }
             // Send notification mail to ecard-recipient
             $objMail->CharSet = CONTREXX_CHARSET;
             $objMail->SetFrom($senderEmail, $senderName);
             $objMail->Subject = $subject;
             $objMail->IsHTML(false);
             $objMail->Body = $body;
             $objMail->AddAddress($recipientEmail);
             if ($objMail->Send()) {
                 $this->_objTpl->setVariable(array('STATUS_MESSAGE' => $_ARRAYLANG['TXT_ECARD_HAS_BEEN_SENT']));
             } else {
                 $this->_objTpl->setVariable(array('STATUS_MESSAGE' => $_ARRAYLANG['TXT_ECARD_MAIL_SENDING_ERROR']));
             }
         }
     } else {
         $this->_objTpl->setVariable(array('STATUS_MESSAGE' => $_ARRAYLANG['TXT_ECARD_SENDING_ERROR']));
     }
 }
Ejemplo n.º 25
0
 /**
  * Validates the submitted comment data and writes it to the databse if valid.
  * Additionally, a notification is send out to the administration about the comment
  * by e-mail (only if the corresponding configuration option is set to do so). 
  *
  * @param   integer News message ID for which the comment shall be stored
  * @param   string  Title of the news message for which the comment shall be stored.
  *                  The title will be used in the notification e-mail
  * @param   string  The poster's name of the comment
  * @param   string  The comment's title
  * @param   string  The comment's message text
  * @global    ADONewConnection
  * @global    array
  * @global    array
  * @global    array
  * @return  array   Returns an array of two elements. The first is either TRUE on success or FALSE on failure.
  *                  The second element contains an error message on failure.  
  */
 private function storeMessageComment($newsMessageId, $newsMessageTitle, $name, $title, $message)
 {
     global $objDatabase, $_ARRAYLANG, $_CORELANG, $_CONFIG;
     if (!isset($_SESSION['news'])) {
         $_SESSION['news'] = array();
         $_SESSION['news']['comments'] = array();
     }
     // just comment
     if ($this->checkForCommentFlooding($newsMessageId)) {
         return array(false, sprintf($_ARRAYLANG['TXT_NEWS_COMMENT_INTERVAL_MSG'], $this->arrSettings['news_comments_timeout']));
     }
     if (empty($title)) {
         return array(false, $_ARRAYLANG['TXT_NEWS_MISSING_COMMENT_TITLE']);
     }
     if (empty($message)) {
         return array(false, $_ARRAYLANG['TXT_NEWS_MISSING_COMMENT_MESSAGE']);
     }
     $date = time();
     $userId = 0;
     if (\FWUser::getFWUserObject()->objUser->login()) {
         $userId = \FWUser::getFWUserObject()->objUser->getId();
         $name = \FWUser::getParsedUserTitle($userId);
     } elseif ($this->arrSettings['news_comments_anonymous'] == '1') {
         // deny comment if the poster did not specify his name
         if (empty($name)) {
             return array(false, $_ARRAYLANG['TXT_NEWS_POSTER_NAME_MISSING']);
         }
         // check CAPTCHA for anonymous posters
         if (!\Cx\Core_Modules\Captcha\Controller\Captcha::getInstance()->check()) {
             return array(false, null);
         }
     } else {
         // Anonymous comments are not allowed
         return array(false, null);
     }
     $isActive = $this->arrSettings['news_comments_autoactivate'];
     $ipAddress = contrexx_input2raw($_SERVER['REMOTE_ADDR']);
     $objResult = $objDatabase->Execute("\n            INSERT INTO `" . DBPREFIX . "module_news_comments` \n                    SET `title` = '" . contrexx_raw2db($title) . "',\n                        `text` = '" . contrexx_raw2db($message) . "',\n                        `newsid` = '" . contrexx_raw2db($newsMessageId) . "',\n                        `date` = '" . contrexx_raw2db($date) . "',\n                        `poster_name` = '" . contrexx_raw2db($name) . "',\n                        `userid` = '" . contrexx_raw2db($userId) . "',\n                        `ip_address` = '" . contrexx_raw2db($ipAddress) . "',\n                        `is_active` = '" . contrexx_raw2db($isActive) . "'");
     if (!$objResult) {
         return array(false, $_ARRAYLANG['TXT_NEWS_COMMENT_SAVE_ERROR']);
     }
     /* Prevent comment flooding from same user:
        Either user is authenticated or had to validate a CAPTCHA.
        In either way, a Contrexx session had been initialized,
        therefore we are able to use the $_SESSION to log this comment */
     $_SESSION['news']['comments'][$newsMessageId] = $date;
     // Don't send a notification e-mail to the administrator
     if (!$this->arrSettings['news_comments_notification']) {
         return array(true, null);
     }
     // Send a notification e-mail to administrator
     if (!@(include_once ASCMS_LIBRARY_PATH . '/phpmailer/class.phpmailer.php')) {
         \DBG::msg('Unable to send e-mail notification to admin');
         //DBG::stack();
         return array(true, null);
     }
     $objMail = new \phpmailer();
     if ($_CONFIG['coreSmtpServer'] > 0 && @(include_once ASCMS_CORE_PATH . '/SmtpSettings.class.php')) {
         if (($arrSmtp = \SmtpSettings::getSmtpAccount($_CONFIG['coreSmtpServer'])) !== false) {
             $objMail->IsSMTP();
             $objMail->Host = $arrSmtp['hostname'];
             $objMail->Port = $arrSmtp['port'];
             $objMail->SMTPAuth = true;
             $objMail->Username = $arrSmtp['username'];
             $objMail->Password = $arrSmtp['password'];
         }
     }
     $objMail->CharSet = CONTREXX_CHARSET;
     $objMail->From = $_CONFIG['coreAdminEmail'];
     $objMail->FromName = $_CONFIG['coreGlobalPageTitle'];
     $objMail->IsHTML(false);
     $objMail->Subject = sprintf($_ARRAYLANG['TXT_NEWS_COMMENT_NOTIFICATION_MAIL_SUBJECT'], $newsMessageTitle);
     $manageCommentsUrl = ASCMS_PROTOCOL . '://' . $_CONFIG['domainUrl'] . ($_SERVER['SERVER_PORT'] == 80 ? NULL : ':' . intval($_SERVER['SERVER_PORT'])) . ASCMS_ADMIN_WEB_PATH . '/index.php?cmd=News&act=comments&newsId=' . $newsMessageId;
     $activateCommentTxt = $this->arrSettings['news_comments_autoactivate'] ? '' : sprintf($_ARRAYLANG['TXT_NEWS_COMMENT_NOTIFICATION_MAIL_LINK'], $manageCommentsUrl);
     $objMail->Body = sprintf($_ARRAYLANG['TXT_NEWS_COMMENT_NOTIFICATION_MAIL_BODY'], $_CONFIG['domainUrl'], $newsMessageTitle, \FWUser::getParsedUserTitle($userId, $name), $title, nl2br($message), $activateCommentTxt);
     $objMail->AddAddress($_CONFIG['coreAdminEmail']);
     if (!$objMail->Send()) {
         \DBG::msg('Sending of notification e-mail failed');
         //DBG::stack();
     }
     return array(true, null);
 }
Ejemplo n.º 26
0
 function handleSignUp($objUser)
 {
     global $_ARRAYLANG, $_CONFIG, $_LANGID;
     $objFWUser = \FWUser::getFWUserObject();
     $objUserMail = $objFWUser->getMail();
     $arrSettings = \User_Setting::getSettings();
     if ($arrSettings['user_activation']['status']) {
         $mail2load = 'reg_confirm';
         $mail2addr = $objUser->getEmail();
     } else {
         $mail2load = 'new_user';
         $mail2addr = $arrSettings['notification_address']['value'];
     }
     if (($objUserMail->load($mail2load, $_LANGID) || $objUserMail->load($mail2load)) && \Env::get('ClassLoader')->loadFile(ASCMS_LIBRARY_PATH . '/phpmailer/class.phpmailer.php') && ($objMail = new \PHPMailer()) !== false) {
         if ($_CONFIG['coreSmtpServer'] > 0 && \Env::get('ClassLoader')->loadFile(ASCMS_CORE_PATH . '/SmtpSettings.class.php')) {
             if (($arrSmtp = \SmtpSettings::getSmtpAccount($_CONFIG['coreSmtpServer'])) !== false) {
                 $objMail->IsSMTP();
                 $objMail->Host = $arrSmtp['hostname'];
                 $objMail->Port = $arrSmtp['port'];
                 $objMail->SMTPAuth = true;
                 $objMail->Username = $arrSmtp['username'];
                 $objMail->Password = $arrSmtp['password'];
             }
         }
         $objMail->CharSet = CONTREXX_CHARSET;
         $objMail->From = $objUserMail->getSenderMail();
         $objMail->FromName = $objUserMail->getSenderName();
         $objMail->AddReplyTo($objUserMail->getSenderMail());
         $objMail->Subject = $objUserMail->getSubject();
         if (in_array($objUserMail->getFormat(), array('multipart', 'text'))) {
             $objUserMail->getFormat() == 'text' ? $objMail->IsHTML(false) : false;
             $objMail->{($objUserMail->getFormat() == 'text' ? '' : 'Alt') . 'Body'} = str_replace(array('[[HOST]]', '[[USERNAME]]', '[[ACTIVATION_LINK]]', '[[HOST_LINK]]', '[[SENDER]]', '[[LINK]]'), array($_CONFIG['domainUrl'], $objUser->getUsername(), 'http://' . $_CONFIG['domainUrl'] . CONTREXX_SCRIPT_PATH . '?section=Access&cmd=signup&u=' . $objUser->getId() . '&k=' . $objUser->getRestoreKey(), 'http://' . $_CONFIG['domainUrl'], $objUserMail->getSenderName(), 'http://' . $_CONFIG['domainUrl'] . ASCMS_PATH_OFFSET . ASCMS_BACKEND_PATH . '/index.php?cmd=Access&act=user&tpl=modify&id=' . $objUser->getId()), $objUserMail->getBodyText());
         }
         if (in_array($objUserMail->getFormat(), array('multipart', 'html'))) {
             $objUserMail->getFormat() == 'html' ? $objMail->IsHTML(true) : false;
             $objMail->Body = str_replace(array('[[HOST]]', '[[USERNAME]]', '[[ACTIVATION_LINK]]', '[[HOST_LINK]]', '[[SENDER]]', '[[LINK]]'), array($_CONFIG['domainUrl'], htmlentities($objUser->getUsername(), ENT_QUOTES, CONTREXX_CHARSET), 'http://' . $_CONFIG['domainUrl'] . CONTREXX_SCRIPT_PATH . '?section=Access&cmd=signup&u=' . $objUser->getId() . '&k=' . $objUser->getRestoreKey(), 'http://' . $_CONFIG['domainUrl'], htmlentities($objUserMail->getSenderName(), ENT_QUOTES, CONTREXX_CHARSET), 'http://' . $_CONFIG['domainUrl'] . ASCMS_PATH_OFFSET . ASCMS_BACKEND_PATH . '/index.php?cmd=Access&act=user&tpl=modify&id=' . $objUser->getId()), $objUserMail->getBodyHtml());
         }
         $objMail->AddAddress($mail2addr);
         if ($objMail->Send()) {
             $this->arrStatusMsg['ok'][] = $_ARRAYLANG['TXT_ACCESS_ACCOUNT_SUCCESSFULLY_CREATED'];
             if ($arrSettings['user_activation']['status']) {
                 $timeoutStr = '';
                 if ($arrSettings['user_activation_timeout']['status']) {
                     if ($arrSettings['user_activation_timeout']['value'] > 1) {
                         $timeoutStr = $arrSettings['user_activation_timeout']['value'] . ' ' . $_ARRAYLANG['TXT_ACCESS_HOURS_IN_STR'];
                     } else {
                         $timeoutStr = ' ' . $_ARRAYLANG['TXT_ACCESS_HOUR_IN_STR'];
                     }
                     $timeoutStr = str_replace('%TIMEOUT%', $timeoutStr, $_ARRAYLANG['TXT_ACCESS_ACTIVATION_TIMEOUT']);
                 }
                 $this->arrStatusMsg['ok'][] = str_replace('%TIMEOUT%', $timeoutStr, $_ARRAYLANG['TXT_ACCESS_ACTIVATION_BY_USER_MSG']);
             } else {
                 $this->arrStatusMsg['ok'][] = str_replace("%HOST%", $_CONFIG['domainUrl'], $_ARRAYLANG['TXT_ACCESS_ACTIVATION_BY_SYSTEM']);
             }
             return true;
         }
     }
     $mailSubject = str_replace("%HOST%", "http://" . $_CONFIG['domainUrl'], $_ARRAYLANG['TXT_ACCESS_COULD_NOT_SEND_ACTIVATION_MAIL']);
     $adminEmail = '<a href="mailto:' . $_CONFIG['coreAdminEmail'] . '?subject=' . $mailSubject . '" title="' . $_CONFIG['coreAdminEmail'] . '">' . $_CONFIG['coreAdminEmail'] . '</a>';
     $this->arrStatusMsg['error'][] = str_replace("%EMAIL%", $adminEmail, $_ARRAYLANG['TXT_ACCESS_COULD_NOT_SEND_EMAIL']);
     return false;
 }
Ejemplo n.º 27
0
 /**
  * send a mail to the email with the message
  *
  * @static
  * @param integer $uploadId the upload id
  * @param string $subject the subject of the mail for the recipient
  * @param string $email the recipient's mail address
  * @param null|string $message the message for the recipient
  */
 public static function sendMail($uploadId, $subject, $emails, $message = null)
 {
     global $objDatabase, $_CONFIG;
     /**
      * get all file ids from the last upload
      */
     $objResult = $objDatabase->Execute("SELECT `id` FROM " . DBPREFIX . "module_filesharing WHERE `upload_id` = '" . intval($uploadId) . "'");
     if ($objResult !== false && $objResult->RecordCount() > 0) {
         while (!$objResult->EOF) {
             $files[] = $objResult->fields["id"];
             $objResult->MoveNext();
         }
     }
     if (!is_int($uploadId) && empty($files)) {
         $files[] = $uploadId;
     }
     /**
      * init mail data. Mail template, Mailsubject and PhpMailer
      */
     $objMail = $objDatabase->SelectLimit("SELECT `subject`, `content` FROM " . DBPREFIX . "module_filesharing_mail_template WHERE `lang_id` = " . FRONTEND_LANG_ID, 1, -1);
     $content = str_replace(array(']]', '[['), array('}', '{'), $objMail->fields["content"]);
     if (empty($subject)) {
         $subject = $objMail->fields["subject"];
     }
     $cx = \Cx\Core\Core\Controller\Cx::instanciate();
     if (\Env::get('ClassLoader')->loadFile($cx->getCodeBaseLibraryPath() . '/phpmailer/class.phpmailer.php')) {
         $objMail = new \phpmailer();
         /**
          * Load mail template and parse it
          */
         $objTemplate = new \Cx\Core\Html\Sigma('.');
         $objTemplate->setErrorHandling(PEAR_ERROR_DIE);
         $objTemplate->setTemplate($content);
         $objTemplate->setVariable(array("DOMAIN" => $_CONFIG["domainUrl"], 'MESSAGE' => $message));
         if ($objTemplate->blockExists('filesharing_file')) {
             foreach ($files as $file) {
                 $objTemplate->setVariable(array('FILE_DOWNLOAD' => self::getDownloadLink($file)));
                 $objTemplate->parse('filesharing_file');
             }
         }
         if ($_CONFIG['coreSmtpServer'] > 0 && \Env::get('ClassLoader')->loadFile($cx->getCodeBaseCorePath() . '/SmtpSettings.class.php')) {
             if (($arrSmtp = SmtpSettings::getSmtpAccount($_CONFIG['coreSmtpServer'])) !== false) {
                 $objMail->IsSMTP();
                 $objMail->Host = $arrSmtp['hostname'];
                 $objMail->Port = $arrSmtp['port'];
                 $objMail->SMTPAuth = true;
                 $objMail->Username = $arrSmtp['username'];
                 $objMail->Password = $arrSmtp['password'];
             }
         }
         $objMail->CharSet = CONTREXX_CHARSET;
         $objMail->SetFrom($_CONFIG['coreAdminEmail'], $_CONFIG['coreGlobalPageTitle']);
         $objMail->Subject = $subject;
         $objMail->Body = $objTemplate->get();
         foreach ($emails as $email) {
             $objMail->AddAddress($email);
             $objMail->Send();
             $objMail->ClearAddresses();
         }
     }
 }
Ejemplo n.º 28
0
 function sendMessage($id)
 {
     global $objDatabase, $_ARRAYLANG, $_CORELANG, $_CONFIG;
     $this->_objTpl->setTemplate($this->pageContent, true, true);
     //get erntry
     $this->getEntries('', 'id', $id);
     if (isset($id) && count($this->entries) != 0) {
         //get search
         $this->getSearch();
         //get navigatin
         $this->getNavigation($this->entries[$id]['catid']);
         if ($_POST['title'] != '' && $_POST['message'] != '') {
             //create mail
             $sendTo = $this->entries[$id]['email'];
             $fromName = $_POST['name'];
             $fromMail = $_POST['email'];
             $subject = $_POST['title'];
             $newPrice = $_POST['newprice'] != '' ? "\n\n" . $_ARRAYLANG['TXT_PRICE_EXPECTATION'] . "\n" . $_POST['newprice'] : '';
             $oldPrice = $_POST['price'] != '' ? "\n\n" . $_ARRAYLANG['TXT_MARKET_MESSAGE_PRICE'] . "\n" . $_POST['price'] : '';
             $message = $_POST['message'] . $oldPrice . $newPrice;
             if (\Env::get('ClassLoader')->loadFile(ASCMS_LIBRARY_PATH . '/phpmailer/class.phpmailer.php')) {
                 $objMail = new \phpmailer();
                 if ($_CONFIG['coreSmtpServer'] > 0 && \Env::get('ClassLoader')->loadFile(ASCMS_CORE_PATH . '/SmtpSettings.class.php')) {
                     if (($arrSmtp = \SmtpSettings::getSmtpAccount($_CONFIG['coreSmtpServer'])) !== false) {
                         $objMail->IsSMTP();
                         $objMail->Host = $arrSmtp['hostname'];
                         $objMail->Port = $arrSmtp['port'];
                         $objMail->SMTPAuth = true;
                         $objMail->Username = $arrSmtp['username'];
                         $objMail->Password = $arrSmtp['password'];
                     }
                 }
                 $objMail->CharSet = CONTREXX_CHARSET;
                 $objMail->From = $fromMail;
                 $objMail->FromName = $fromName;
                 $objMail->AddReplyTo($fromMail);
                 $objMail->Subject = $subject;
                 $objMail->IsHTML(false);
                 $objMail->Body = $message;
                 $objMail->AddAddress($sendTo);
                 $objMail->Send();
             }
             // set variables
             $this->_objTpl->setVariable(array('MARKET_TITLE' => $_ARRAYLANG['TXT_MARKET_MESSAGE_SUCCESS_TITLE'], 'MARKET_MSG_SEND' => $_ARRAYLANG['TXT_MARKET_MESSAGE_SUCCESS_BODY'], 'TXT_MARKET_BACK' => $_CORELANG['TXT_BACK']));
         }
     } else {
         \Cx\Core\Csrf\Controller\Csrf::header('Location: ?section=Market');
     }
 }
Ejemplo n.º 29
0
 /**
  * Sends an email with the contact details to the responsible persons
  *
  * This methode sends an email to all email addresses that are defined in the
  * option "Receiver address(es)" of the requested contact form.
  * @access private
  * @global array
  * @global array
  * @param array Details of the contact request
  * @see _getEmailAdressOfString(), phpmailer::From, phpmailer::FromName, phpmailer::AddReplyTo(), phpmailer::Subject, phpmailer::IsHTML(), phpmailer::Body, phpmailer::AddAddress(), phpmailer::Send(), phpmailer::ClearAddresses()
  */
 private function sendMail($arrFormData)
 {
     global $_ARRAYLANG, $_CONFIG;
     $plaintextBody = '';
     $replyAddress = '';
     $firstname = '';
     $lastname = '';
     $senderName = '';
     $isHtml = $arrFormData['htmlMail'] == 1 ? true : false;
     // stop send process in case no real data had been submitted
     if (!isset($arrFormData['data']) && !isset($arrFormData['uploadedFiles'])) {
         return false;
     }
     // check if we shall send the email as multipart (text/html)
     if ($isHtml) {
         // setup html mail template
         $objTemplate = new \Cx\Core\Html\Sigma('.');
         $objTemplate->setErrorHandling(PEAR_ERROR_DIE);
         $objTemplate->setTemplate($arrFormData['mailTemplate']);
         $objTemplate->setVariable(array('DATE' => date(ASCMS_DATE_FORMAT, $arrFormData['meta']['time']), 'HOSTNAME' => contrexx_raw2xhtml($arrFormData['meta']['host']), 'IP_ADDRESS' => contrexx_raw2xhtml($arrFormData['meta']['ipaddress']), 'BROWSER_LANGUAGE' => contrexx_raw2xhtml($arrFormData['meta']['lang']), 'BROWSER_VERSION' => contrexx_raw2xhtml($arrFormData['meta']['browser'])));
     }
     // TODO: check if we have to excape $arrRecipients later in the code
     $arrRecipients = $this->getRecipients(intval($_GET['cmd']));
     // calculate the longest field label.
     // this will be used to correctly align all user submitted data in the plaintext e-mail
     // TODO: check if the label of upload-fields are taken into account as well
     $maxlength = 0;
     foreach ($arrFormData['fields'] as $arrField) {
         $length = strlen($arrField['lang'][FRONTEND_LANG_ID]['name']);
         $maxlength = $maxlength < $length ? $length : $maxlength;
     }
     // try to fetch a user submitted e-mail address to which we will send a copy to
     if (!empty($arrFormData['fields'])) {
         foreach ($arrFormData['fields'] as $fieldId => $arrField) {
             // check if field validation is set to e-mail
             if ($arrField['check_type'] == '2') {
                 $mail = trim($arrFormData['data'][$fieldId]);
                 if (\FWValidator::isEmail($mail)) {
                     $replyAddress = $mail;
                     break;
                 }
             }
             if ($arrField['type'] == 'special') {
                 switch ($arrField['special_type']) {
                     case 'access_firstname':
                         $firstname = trim($arrFormData['data'][$fieldId]);
                         break;
                     case 'access_lastname':
                         $lastname = trim($arrFormData['data'][$fieldId]);
                         break;
                     default:
                         break;
                 }
             }
         }
     }
     if ($arrFormData['useEmailOfSender'] == 1 && (!empty($firstname) || !empty($lastname))) {
         $senderName = trim($firstname . ' ' . $lastname);
     } else {
         $senderName = $_CONFIG['coreGlobalPageTitle'];
     }
     // a recipient mail address which has been picked by sender
     $chosenMailRecipient = null;
     // fill the html and plaintext body with the submitted form data
     foreach ($arrFormData['fields'] as $fieldId => $arrField) {
         if ($fieldId == 'unique_id') {
             //generated for uploader. no interesting mail content.
             continue;
         }
         $htmlValue = '';
         $plaintextValue = '';
         $textAreaKeys = array();
         switch ($arrField['type']) {
             case 'label':
             case 'fieldset':
                 // TODO: parse TH row instead
             // TODO: parse TH row instead
             case 'horizontalLine':
                 // TODO: add visual horizontal line
                 // we need to use a 'continue 2' here to first break out of the switch and then move over to the next iteration of the foreach loop
                 continue 2;
                 break;
             case 'file':
             case 'multi_file':
                 $htmlValue = "";
                 $plaintextValue = "";
                 if (isset($arrFormData['uploadedFiles'][$fieldId])) {
                     $htmlValue = "<ul>";
                     foreach ($arrFormData['uploadedFiles'][$fieldId] as $file) {
                         $htmlValue .= "<li><a href='" . ASCMS_PROTOCOL . "://" . $_CONFIG['domainUrl'] . \Env::get('cx')->getWebsiteOffsetPath() . contrexx_raw2xhtml($file['path']) . "' >" . contrexx_raw2xhtml($file['name']) . "</a></li>";
                         $plaintextValue .= ASCMS_PROTOCOL . "://" . $_CONFIG['domainUrl'] . \Env::get('cx')->getWebsiteOffsetPath() . $file['path'] . "\r\n";
                     }
                     $htmlValue .= "</ul>";
                 }
                 break;
             case 'checkbox':
                 $plaintextValue = !empty($arrFormData['data'][$fieldId]) ? $_ARRAYLANG['TXT_CONTACT_YES'] : $_ARRAYLANG['TXT_CONTACT_NO'];
                 $htmlValue = $plaintextValue;
                 break;
             case 'recipient':
                 // TODO: check for XSS
                 $plaintextValue = $arrRecipients[$arrFormData['data'][$fieldId]]['lang'][FRONTEND_LANG_ID];
                 $htmlValue = $plaintextValue;
                 $chosenMailRecipient = $arrRecipients[$arrFormData['data'][$fieldId]]['email'];
                 break;
             case 'textarea':
                 //we need to know all textareas - they're indented differently then the rest of the other field types
                 $textAreaKeys[] = $fieldId;
             default:
                 $plaintextValue = isset($arrFormData['data'][$fieldId]) ? $arrFormData['data'][$fieldId] : '';
                 $htmlValue = contrexx_raw2xhtml($plaintextValue);
                 break;
         }
         $fieldLabel = $arrField['lang'][FRONTEND_LANG_ID]['name'];
         // try to fetch an e-mail address from submitted form date in case we were unable to fetch one from an input type with e-mail validation
         if (empty($replyAddress)) {
             $mail = $this->_getEmailAdressOfString($plaintextValue);
             if (\FWValidator::isEmail($mail)) {
                 $replyAddress = $mail;
             }
         }
         // parse html body
         if ($isHtml) {
             if (!empty($htmlValue)) {
                 if ($objTemplate->blockExists('field_' . $fieldId)) {
                     // parse field specific template block
                     $objTemplate->setVariable(array('FIELD_' . $fieldId . '_LABEL' => contrexx_raw2xhtml($fieldLabel), 'FIELD_' . $fieldId . '_VALUE' => $htmlValue));
                     $objTemplate->parse('field_' . $fieldId);
                 } elseif ($objTemplate->blockExists('form_field')) {
                     // parse regular field template block
                     $objTemplate->setVariable(array('FIELD_LABEL' => contrexx_raw2xhtml($fieldLabel), 'FIELD_VALUE' => $htmlValue));
                     $objTemplate->parse('form_field');
                 }
             } elseif ($objTemplate->blockExists('field_' . $fieldId)) {
                 // hide field specific template block, if present
                 $objTemplate->hideBlock('field_' . $fieldId);
             }
         }
         // parse plaintext body
         $tabCount = $maxlength - strlen($fieldLabel);
         $tabs = $tabCount == 0 ? 1 : $tabCount + 1;
         // TODO: what is this all about? - $value is undefined
         if ($arrFormData['fields'][$fieldId]['type'] == 'recipient') {
             $value = $arrRecipients[$value]['lang'][FRONTEND_LANG_ID];
         }
         if (in_array($fieldId, $textAreaKeys)) {
             // we're dealing with a textarea, don't indent value
             $plaintextBody .= $fieldLabel . ":\n" . $plaintextValue . "\n";
         } else {
             $plaintextBody .= $fieldLabel . str_repeat(" ", $tabs) . ": " . $plaintextValue . "\n";
         }
     }
     $arrSettings = $this->getSettings();
     // TODO: this is some fixed plaintext message data -> must be ported to html body
     $message = $_ARRAYLANG['TXT_CONTACT_TRANSFERED_DATA_FROM'] . " " . $_CONFIG['domainUrl'] . "\n\n";
     if ($arrSettings['fieldMetaDate']) {
         $message .= $_ARRAYLANG['TXT_CONTACT_DATE'] . " " . date(ASCMS_DATE_FORMAT, $arrFormData['meta']['time']) . "\n\n";
     }
     $message .= $plaintextBody . "\n\n";
     if ($arrSettings['fieldMetaHost']) {
         $message .= $_ARRAYLANG['TXT_CONTACT_HOSTNAME'] . " : " . contrexx_raw2xhtml($arrFormData['meta']['host']) . "\n";
     }
     if ($arrSettings['fieldMetaIP']) {
         $message .= $_ARRAYLANG['TXT_CONTACT_IP_ADDRESS'] . " : " . contrexx_raw2xhtml($arrFormData['meta']['ipaddress']) . "\n";
     }
     if ($arrSettings['fieldMetaLang']) {
         $message .= $_ARRAYLANG['TXT_CONTACT_BROWSER_LANGUAGE'] . " : " . contrexx_raw2xhtml($arrFormData['meta']['lang']) . "\n";
     }
     $message .= $_ARRAYLANG['TXT_CONTACT_BROWSER_VERSION'] . " : " . contrexx_raw2xhtml($arrFormData['meta']['browser']) . "\n";
     if (@(include_once \Env::get('cx')->getCodeBaseLibraryPath() . '/phpmailer/class.phpmailer.php')) {
         $objMail = new \phpmailer();
         if ($_CONFIG['coreSmtpServer'] > 0 && @(include_once \Env::get('cx')->getCodeBaseCorePath() . '/SmtpSettings.class.php')) {
             if (($arrSmtp = \SmtpSettings::getSmtpAccount($_CONFIG['coreSmtpServer'])) !== false) {
                 $objMail->IsSMTP();
                 $objMail->Host = $arrSmtp['hostname'];
                 $objMail->Port = $arrSmtp['port'];
                 $objMail->SMTPAuth = true;
                 $objMail->Username = $arrSmtp['username'];
                 $objMail->Password = $arrSmtp['password'];
             }
         }
         $objMail->CharSet = CONTREXX_CHARSET;
         $objMail->From = $_CONFIG['coreAdminEmail'];
         $objMail->FromName = $senderName;
         if (!empty($replyAddress)) {
             $objMail->AddReplyTo($replyAddress);
             if ($arrFormData['sendCopy'] == 1) {
                 $objMail->AddAddress($replyAddress);
             }
             if ($arrFormData['useEmailOfSender'] == 1) {
                 $objMail->From = $replyAddress;
             }
         }
         $objMail->Subject = $arrFormData['subject'];
         if ($isHtml) {
             $objMail->Body = $objTemplate->get();
             $objMail->AltBody = $message;
         } else {
             $objMail->IsHTML(false);
             $objMail->Body = $message;
         }
         // attach submitted files to email
         if (count($arrFormData['uploadedFiles']) > 0 && $arrFormData['sendAttachment'] == 1) {
             foreach ($arrFormData['uploadedFiles'] as $arrFilesOfField) {
                 foreach ($arrFilesOfField as $file) {
                     $objMail->AddAttachment(\Env::get('cx')->getWebsiteDocumentRootPath() . $file['path'], $file['name']);
                 }
             }
         }
         if ($chosenMailRecipient !== null) {
             if (!empty($chosenMailRecipient)) {
                 $objMail->AddAddress($chosenMailRecipient);
                 $objMail->Send();
                 $objMail->ClearAddresses();
             }
         } else {
             foreach ($arrFormData['emails'] as $sendTo) {
                 if (!empty($sendTo)) {
                     $objMail->AddAddress($sendTo);
                     $objMail->Send();
                     $objMail->ClearAddresses();
                 }
             }
         }
     }
     return true;
 }
Ejemplo n.º 30
0
 protected function sendRestorePasswordEmail($objUser)
 {
     global $_CONFIG, $_LANGID;
     $objUserMail = $this->getMail();
     if (!$objUserMail->load('reset_pw', $_LANGID) && !$objUserMail->load('reset_pw')) {
         return false;
     }
     $objMail = new PHPMailer();
     if (!$objMail) {
         return false;
     }
     if ($_CONFIG['coreSmtpServer'] > 0 && @(include_once ASCMS_CORE_PATH . '/SmtpSettings.class.php')) {
         if (($arrSmtp = SmtpSettings::getSmtpAccount($_CONFIG['coreSmtpServer'])) !== false) {
             $objMail->IsSMTP();
             $objMail->Host = $arrSmtp['hostname'];
             $objMail->Port = $arrSmtp['port'];
             $objMail->SMTPAuth = true;
             $objMail->Username = $arrSmtp['username'];
             $objMail->Password = $arrSmtp['password'];
         }
     }
     $objMail->CharSet = CONTREXX_CHARSET;
     $objMail->SetFrom($objUserMail->getSenderMail(), $objUserMail->getSenderName());
     $objMail->Subject = $objUserMail->getSubject();
     $restoreLink = self::getPasswordRestoreLink($this->isBackendMode(), $objUser);
     if (in_array($objUserMail->getFormat(), array('multipart', 'text'))) {
         $objUserMail->getFormat() == 'text' ? $objMail->IsHTML(false) : false;
         $objMail->{($objUserMail->getFormat() == 'text' ? '' : 'Alt') . 'Body'} = str_replace(array('[[USERNAME]]', '[[URL]]', '[[SENDER]]'), array($objUser->getUsername(), $restoreLink, $objUserMail->getSenderName()), $objUserMail->getBodyText());
     }
     if (in_array($objUserMail->getFormat(), array('multipart', 'html'))) {
         $objUserMail->getFormat() == 'html' ? $objMail->IsHTML(true) : false;
         $objMail->Body = str_replace(array('[[USERNAME]]', '[[URL]]', '[[SENDER]]'), array(htmlentities($objUser->getUsername(), ENT_QUOTES, CONTREXX_CHARSET), $restoreLink, htmlentities($objUserMail->getSenderName(), ENT_QUOTES, CONTREXX_CHARSET)), $objUserMail->getBodyHtml());
     }
     $objMail->AddAddress($objUser->getEmail());
     return $objMail->Send();
 }