/** * do the plugin action * @return number of records updated */ function process(&$data) { $app = JFactory::getApplication(); jimport('joomla.mail.helper'); $params = $this->getParams(); $msg = $params->get('message'); $to = $params->get('to'); $w = new FabrikWorker(); $MailFrom = $app->getCfg('mailfrom'); $FromName = $app->getCfg('fromname'); $subject = $params->get('subject', 'Fabrik cron job'); $eval = $params->get('cronemail-eval'); $condition = $params->get('cronemail_condition', ''); $updates = array(); foreach ($data as $group) { if (is_array($group)) { foreach ($group as $row) { if (!empty($condition)) { $this_condition = $w->parseMessageForPlaceHolder($condition, $row); if (eval($this_condition === false)) { continue; } } $row = JArrayHelper::fromObject($row); $thisto = $w->parseMessageForPlaceHolder($to, $row); if (JMailHelper::isEmailAddress($thisto)) { $thismsg = $w->parseMessageForPlaceHolder($msg, $row); if ($eval) { $thismsg = eval($thismsg); } $thissubject = $w->parseMessageForPlaceHolder($subject, $row); $res = JUTility::sendMail( $MailFrom, $FromName, $thisto, $thissubject, $thismsg, true); } $updates[] = $row['__pk_val']; } } } $field = $params->get('cronemail-updatefield'); if (!empty( $updates) && trim($field ) != '') { //do any update found $listModel = JModel::getInstance('list', 'FabrikFEModel'); $listModel->setId($params->get('table')); $table = $listModel->getTable(); $connection = $params->get('connection'); $field = $params->get('cronemail-updatefield'); $value = $params->get('cronemail-updatefield-value'); $field = str_replace("___", ".", $field); $query = "UPDATE $table->db_table_name set $field = " . $fabrikDb->Quote($value) . " WHERE $table->db_primary_key IN (" . implode(',', $updates) . ")"; $fabrikDb = $listModel->getDb(); $fabrikDb->setQuery($query); $fabrikDb->query(); } return count($updates); }
public function submitAction() { $recipientEmail = $this->params->get('email', ''); $post = JRequest::get('post'); $post["username"] = $post["name"]; $subject = $post["src_title"]; $body = $this->renderpart(JModuleHelper::getLayoutPath(self::$moduleName, 'email'), $post, true); JUTility::sendMail($post["email"], $post["name"], $recipientEmail, $subject, $body, true); print "ok"; jexit(); }
function sendMail(&$email) { JRequest::checkToken() or die('Invalid Token'); // First, make sure the form was posted from a browser. // For basic web-forms, we don't care about anything // other than requests from a browser: if (!isset($_SERVER['HTTP_USER_AGENT'])) { JError::raiseError(500, JText::_('JERROR_ALERTNOAUTHOR')); } // Make sure the form was indeed POST'ed: // (requires your html form to use: action="post") if (!$_SERVER['REQUEST_METHOD'] == 'POST') { JError::raiseError(500, JText::_('JERROR_ALERTNOAUTHOR')); } // Attempt to defend against header injections: $badStrings = array('Content-Type:', 'MIME-Version:', 'Content-Transfer-Encoding:', 'bcc:', 'cc:'); // Loop through each POST'ed value and test if it contains // one of the $badStrings: foreach ($_POST as $k => $v) { foreach ($badStrings as $v2) { if (JString::strpos($v, $v2) !== false) { JError::raiseError(500, JText::_('JERROR_ALERTNOAUTHOR')); } } } // Made it past spammer test, free up some memory // and continue rest of script: unset($k, $v, $v2, $badStrings); $email = JRequest::getVar('email', ''); $yourname = JRequest::getVar('yourname', ''); $youremail = JRequest::getVar('youremail', ''); $subject_default = JText::sprintf('Email from', $yourname); $subject = JRequest::getVar('subject', $subject_default); jimport('joomla.mail.helper'); if (!$email || !$youremail || JMailHelper::isEmailAddress($email) == false || JMailHelper::isEmailAddress($youremail) == false) { JError::raiseError(500, JText::_('EMAIL_ERR_NOINFO')); } $config = JFactory::getConfig(); $sitename = $config->getValue('sitename'); // link sent in email $link = JRequest::getVar('referrer'); // message text $msg = JText::sprintf('COM_FABRIK_EMAIL_MSG', $sitename, $yourname, $youremail, $link); // mail function JUTility::sendMail($youremail, $yourname, $email, $subject, $msg); }
function save_claims($option) { global $mtconf, $mainframe; $database =& JFactory::getDBO(); $claims = JRequest::getVar('claim', '', 'post'); $admin_notes = JRequest::getVar('admin_note', '', 'post'); foreach ($claims as $claim_id => $user_id) { $claim_id = intval($claim_id); $user_id = intval($user_id); if ($user_id > 0) { $database->setQuery('SELECT c.link_id, l.link_name FROM (#__mt_claims AS c, #__mt_links AS l) WHERE claim_id = ' . $database->quote($claim_id) . ' AND c.link_id = l.link_id'); $link = $database->loadObject(); $database->setQuery('SELECT email FROM #__users WHERE id = ' . $database->quote($user_id)); $email = $database->loadResult(); $database->setQuery('UPDATE #__mt_links SET user_id = ' . $database->quote($user_id) . ' WHERE link_id = ' . $database->quote($link->link_id) . ' LIMIT 1'); $database->query(); $database->setQuery('DELETE FROM #__mt_claims WHERE claim_id = ' . $database->quote($claim_id)); $database->query(); $subject = JText::_('Claim approved subject'); $body = sprintf(JText::_('Claim approved msg'), $link->link_name, $mtconf->getjconf('live_site') . "/index.php?option=com_mtree&task=viewlink&link_id={$link->link_id}"); JUTility::sendMail($mtconf->getjconf('mailfrom'), $mtconf->getjconf('fromname'), $email, $subject, $body); } else { if ($user_id == -1) { $database->setQuery('DELETE FROM #__mt_claims WHERE claim_id = ' . $database->quote($claim_id)); $database->query(); } else { if ($user_id == 0) { if (@isset($admin_notes) && @array_key_exists($claim_id, $admin_notes)) { $database->setQuery('UPDATE #__mt_claims SET admin_note = ' . $database->quote($admin_notes[$claim_id]) . ' WHERE claim_id = ' . $database->quote($claim_id)); $database->query(); } } } } } $mainframe->redirect("index2.php?option={$option}&task=listpending_claims"); }
function mosMail($from, $fromname, $recipient, $subject, $body, $mode = 0, $cc = NULL, $bcc = NULL, $attachment = NULL, $replyto = NULL, $replytoname = NULL) { //return JUTility::sendMail($from, $fromname, $recipient, $subject, $body, $mode, $cc, $bcc, $attachment, $replyto, $replytoname ); if (version_compare(JVERSION, '3.0.0', 'lt')) { return JUTility::sendMail($from, $fromname, $recipient, $subject, $body, $mode, $cc, $bcc, $attachment, $replyto, $replytoname); } else { $a = JMail::getInstance(); $a->sendMail($from, $fromname, $recipient, $subject, $body, $mode, $cc, $bcc, $attachment, $replyto, $replytoname); } }
public function doEmail($tableModel) { $app =& JFactory::getApplication(); jimport('joomla.mail.helper'); if (!$this->_upload()) { return false; } $tableModel->setId(JRequest::getInt('id', 0)); $w = new FabrikWorker(); $config =& JFactory::getConfig(); $this->_type = 'table'; $params =& $tableModel->getParams(); $to = JRequest::getVar('email_to'); $renderOrder = JRequest::getInt('renderOrder'); $merge_emails = $params->get('emailtable_mergemessages', 0); if (is_array($merge_emails)) { $merge_emails = (int) JArrayHelper::getValue($merge_emails, $renderOrder, 0); } $toHow = $params->get('emailtable_to_how', 'single'); if (is_array($toHow)) { $toHow = JArrayHelper::getValue($toHow, $renderOrder, 'single'); } $toType = $params->get('emailtable_to_type', 'list'); if (is_array($toType)) { $toType = JArrayHelper::getValue($toType, $renderOrder, 'list'); } if ($toType == 'list') { $to = str_replace('.', '___', $to); } else { if (is_array($to)) { // $$$ hugh - if using a table selection type, allow specifying a default in // the "emailtable_to" field. if ($toType != 'field') { $emailtable_to = $params->get('emailtable_to', ''); if (is_array($emailtable_to)) { $emailtable_to = JArrayHelper::getValue($emailtable_to, $renderOrder, ''); } if (!empty($emailtable_to)) { if (!in_array($emailtable_to, $to)) { $to[] = $emailtable_to; } } } $to = implode(',', $to); } } $fromUser = $params->get('emailtable_from_user'); if (is_array($fromUser)) { $fromUser = JArrayHelper::getValue($fromUser, $renderOrder, ''); } $emailTemplate = $params->get('emailtable_template', ''); if (is_array($emailTemplate)) { $emailTemplate = JArrayHelper::getValue($emailTemplate, $renderOrder, ''); } if (!empty($emailTemplate)) { $emailTemplate = JPath::clean(JPATH_SITE . DS . 'components' . DS . 'com_fabrik' . DS . 'plugins' . DS . 'table' . DS . 'emailtable' . DS . 'tmpl' . DS . $emailTemplate); } $contentTemplate = $params->get('emailtable_template_content', ''); if (is_array($contentTemplate)) { $contentTemplate = JArrayHelper::getValue($contentTemplate, $renderOrder, ''); } if ($contentTemplate != '') { $content = $this->_getConentTemplate($contentTemplate); } else { $content = ''; } $php_msg = false; if (JFile::exists($emailTemplate)) { if (JFile::getExt($emailTemplate) == 'php') { // $message = $this->_getPHPTemplateEmail($emailTemplate); $message = ''; $php_msg = true; } else { $message = $this->_getTemplateEmail($emailTemplate); } $message = str_replace('{content}', $content, $message); } else { if ($contentTemplate != '') { $message = $content; } else { $message = ''; } } $subject = JRequest::getVar('subject'); $cover_message = JRequest::getVar('message', '', 'post', 'string', 4); $old_style = false; if (empty($message) && !$php_msg) { $old_style = true; //$message = $cover_message; } $recordids = explode(',', JRequest::getVar('recordids')); $data = $this->getRecords('recordids', true); if ($fromUser) { $my =& JFactory::getUser(); $email_from = $my->get('email'); // $$$ rob - erm $ ema isn't used anywhere - do we need it????? $fromname = $my->get('name'); } else { $config =& JFactory::getConfig(); $email_from = $config->getValue('mailfrom'); $fromname = $config->getValue('fromname'); } $cc = null; $bcc = null; $sent = 0; $notsent = 0; $updated = array(); $merged_msg = ''; $first_row = array(); foreach ($data as $group) { foreach ($group as $row) { if ($merge_emails) { if (empty($first_row)) { $first_row = $row; // used for placeholders in subject when merging mail } $thismsg = ''; if ($old_style) { $thismsg = $w->parseMessageForPlaceHolder($cover_message, $row); } else { if ($php_msg) { $thismsg = $this->_getPHPTemplateEmail($emailTemplate, $row, $tableModel); } else { $thismsg = $w->parseMessageForPlaceHolder($message, $row); } } $merged_msg .= $thismsg; $updated[] = $row->__pk_val; } else { if ($toType == 'list') { $process = isset($row->{$to}); $mailto = $row->{$to}; } else { $process = true; $mailto = $to; } if ($process) { $res = false; $mailtos = explode(',', $mailto); if ($toHow == 'single') { foreach ($mailtos as $tokey => $thisto) { $thisto = $w->parseMessageForPlaceholder($thisto, $row); if (!JMailHelper::isEmailAddress($thisto)) { unset($mailtos[$tokey]); $notsent++; } else { $mailtos[$tokey] = $thisto; } } if ($notsent > 0) { $mailtos = array_values($mailtos); } $sent = sizeof($mailtos); if ($sent > 0) { $thissubject = $w->parseMessageForPlaceholder($subject, $row); $thismsg = ''; $thismsg = $cover_message; if (!$old_style) { if ($php_msg) { $thismsg .= $this->_getPHPTemplateEmail($emailTemplate, $row, $tableModel); } else { $thismsg .= $message; } } $thismsg = $w->parseMessageForPlaceholder($thismsg, $row); $res = JUtility::sendMail($email_from, $fromname, $mailtos, $thissubject, $thismsg, 1, $cc, $bcc, $this->filepath); } } else { foreach ($mailtos as $mailto) { $mailto = $w->parseMessageForPlaceholder($mailto, $row); if (JMailHelper::isEmailAddress($mailto)) { $thissubject = $w->parseMessageForPlaceholder($subject, $row); $thismsg = ''; $thismsg = $cover_message; if (!$old_style) { if ($php_msg) { $thismsg .= $this->_getPHPTemplateEmail($emailTemplate, $row, $tableModel); } else { $thismsg .= $message; } } $thismsg = $w->parseMessageForPlaceholder($thismsg, $row); $res = JUtility::sendMail($email_from, $fromname, $mailto, $thissubject, $thismsg, 1, $cc, $bcc, $this->filepath); if ($res) { $sent++; } else { $notsent++; } } else { $notsent++; } } } if ($res) { $updated[] = $row->__pk_val; } } else { $notsent++; } } } } if ($merge_emails) { // arbitrarily use first row for placeholders if ($toType == 'list') { $mailto = $first_row->{$to}; } else { $mailto = $to; } $thistos = explode(',', $w->parseMessageForPlaceHolder($mailto, $first_row)); $thissubject = $w->parseMessageForPlaceHolder($subject, $first_row); $preamble = $params->get('emailtable_message_preamble', ''); $preamble = is_array($preamble) ? JArrayHelper::getValue($preamble, $renderOrder, '') : $preamble; $postamble = $params->get('emailtable_message_postamble', ''); $postamble = is_array($postamble) ? JArrayHelper::getValue($postamble, $renderOrder, '') : $postamble; $merged_msg = $preamble . $merged_msg . $postamble; if (!$old_style) { $merged_msg = $cover_message . $merged_msg; } if ($toHow == 'single') { foreach ($thistos as $tokey => $thisto) { $thisto = $w->parseMessageForPlaceholder($thisto, $first_row); if (!JMailHelper::isEmailAddress($thisto)) { unset($thistos[$tokey]); $notsent++; } else { $mailtos[$tokey] = $thisto; } } if ($notsent > 0) { $thistos = array_values($thistos); } $sent = sizeof($thistos); if ($sent > 0) { $res = JUTility::sendMail($email_from, $fromname, $thistos, $thissubject, $merged_msg, true, $cc, $bcc, $this->filepath); } } else { foreach ($thistos as $thisto) { if (JMailHelper::isEmailAddress($thisto)) { $res = JUTility::sendMail($email_from, $fromname, $thisto, $thissubject, $merged_msg, true, $cc, $bcc, $this->filepath); if ($res) { $sent++; } else { $notsent++; } } else { $notsent++; } } } } $updateField = $params->get('emailtable_update_field'); $updateField = is_array($updateField) ? JArrayHelper::getValue($updateField, $renderOrder, '') : $updateField; if (!empty($updateField) && !empty($updated)) { $updateVal = $params->get('emailtable_update_value'); $updateVal = is_array($updateVal) ? JArrayHelper::getValue($updateVal, $renderOrder, '') : $updateVal; $tableModel->updateRows($updated, $updateField, $updateVal); } // $$$ hugh - added second update field for Bea $updateField = $params->get('emailtable_update_field2'); $updateField = is_array($updateField) ? JArrayHelper::getValue($updateField, $renderOrder, '') : $updateField; if (!empty($updateField) && !empty($updated)) { $updateVal = $params->get('emailtable_update_value2'); $updateVal = is_array($updateVal) ? JArrayHelper::getValue($updateVal, $renderOrder, '') : $updateVal; $tableModel->updateRows($updated, $updateField, $updateVal); } $app->enqueueMessage(JText::sprintf('%s emails sent', $sent)); if ($notsent != 0) { JError::raiseWarning(E_NOTICE, JText::sprintf('%s emails not sent', $notsent)); } }
/** * Mail function (uses phpMailer) * * @param string $from From e-mail address * @param string $fromName From name * @param mixed $recipient Recipient e-mail address(es) * @param string $subject E-mail subject * @param string $body Message body * @param bool|int $mode false = plain text, true = HTML * @param mixed $cc CC e-mail address(es) * @param mixed $bcc BCC e-mail address(es) * @param mixed $attachment Attachment file name(s) * @param mixed $replyTo Reply to email address(es) * @param mixed $replyToName Reply to name(s) * @return boolean True on success */ public static function send($from, $fromName, $recipient, $subject, $body, $mode = 0, $cc = NULL, $bcc = NULL, $attachment = NULL, $replyTo = NULL, $replyToName = NULL) { if (JCOMMENTS_JVERSION == '1.5') { return JUTility::sendMail($from, $fromName, $recipient, $subject, $body, $mode, $cc, $bcc, $attachment, $replyTo, $replyToName); } else { if (JCOMMENTS_JVERSION == '1.7') { $mailer = JFactory::getMailer(); return $mailer->sendMail($from, $fromName, $recipient, $subject, $body, $mode, $cc, $bcc, $attachment, $replyTo, $replyToName); } } return mosMail($from, $fromName, $recipient, $subject, $body, $mode, $cc, $bcc, $attachment, $replyTo, $replyToName); }
function _emailPublisher($sectionid, $catid, $default_action) { $user =& JFactory::getUser(); $db =& JFactory::getDBO(); $query = "SELECT DISTINCT `a`.`id`, `a`.`name`, `a`.`email` FROM `#__users` AS `a`, `#__community_acl_user_params` AS `b` " . " WHERE `a`.`gid` > 20 AND `b`.`user_id` = `a`.`id` AND `b`.`name` = 'publisher_notification' AND `b`.`value` = '1' "; $db->setQuery($query); $users = $db->loadObjectList(); $message = ''; $subject = ''; if (is_array($users) && count($users) > 0) { foreach ($users as $usr) { $user_id = $usr->id; $query = "SELECT `function_id` FROM `#__community_acl_users` WHERE `user_id` = '{$user_id}'"; $db->setQuery($query); $functions = $db->loadResultArray(); $bingo = false; if (is_array($functions) && count($functions) > 0) { $query = "SELECT `item_type`, `item_id` FROM `#__community_acl_content_actions` WHERE `func_id` IN ('" . implode("','", $functions) . "') AND `action` = 'publish'"; $db->setQuery($query); $items = $db->loadObjectList(); if (is_array($items) && count($items) > 0) { foreach ($items as $item) { switch ($item->item_type) { case 'section': if ($item->item_id == $sectionid) { $bingo = true; } break; case 'category': if ($item->item_id == $catid) { $bingo = true; } break; case 'content': if ($item->item_id == $id) { $bingo = true; } break; } } } } if ($default_action == 'allow' && !$bingo || $default_action == 'deny' && $bingo) { if ($message == '' && $subject == '') { $message = JText::_('MAILBODY'); $subject = JText::_('MAILSUBJECT'); $query = "SELECT `a`.`title` AS `section`, `b`.`title` AS `category` FROM `#__sections` AS `a`, `#__categories` AS `b` WHERE `a`.`id` = '{$sectionid}' AND `b`.`id` = '{$catid}'"; $db->setQuery($query); $titles = null; $titles = $db->loadObject(); if (!(is_object($titles) && $titles->section != '' && $titles->category != '')) { $titles = new StdClass(); $titles->section = JText::_('Uncategorized'); $titles->category = JText::_('Uncategorized'); } $article = JRequest::getVar('title', '', 'default', 'string'); $message = sprintf($message, $user->get('name') . ' (' . $user->get('email') . ')', $article, $titles->section, $titles->category); $subject = sprintf($subject, $titles->section, $titles->category); $config = new JConfig(); } JUTility::sendMail($config->mailfrom, $config->fromname, $usr->email, $subject, $message, 0, NULL, NULL, NULL, NULL, NULL); } } } }
function mosMailToAdmin($subject, $body, $mode = 0) { global $mtconf; if (strpos($mtconf->get('admin_email'), ',') === false) { $recipient_emails = array($mtconf->get('admin_email')); } else { $recipient_emails = explode(',', $mtconf->get('admin_email')); } for ($i = 0; $i < count($recipient_emails); $i++) { $recipient_emails[$i] = trim($recipient_emails[$i]); } // Input validation if (!validateInputs($recipient_emails, $subject, $body)) { $document =& JFactory::getDocument(); JError::raiseWarning(0, $document->getError()); return false; } JUTility::sendMail($mtconf->getjconf('mailfrom'), $mtconf->getjconf('fromname'), $recipient_emails, $subject, wordwrap($body), $mode); return true; }
function save() { global $mainframe, $Itemid, $DT_mailfrom, $DT_fromname, $frontendEventNotification; $row = $this->getModel('event')->table; $data = JRequest::getVar('data'); $error = false; if ($data['event']['slabId'] != "") { $row->load($data['event']['slabId']); if (!$row->validDateChange($data)) { $this->error = JText::_("DT_REPTITIONS_NOT_VALID"); $error = true; } } if ($error) { DT_Session::set('event.data', $data); $files = JRequest::getVar('event_files', null, 'files', 'array'); DT_Session::set('event.event_files', $files); $this->view->setLayout('warning'); $this->view->assign('message', JText::_("DT_REPEAT_DELETE_WARNING")); $this->view->display(); } else { if ($row->save($data) !== false) { global $eventListOrder; $conf = DtrModel::getInstance('config', 'DtregisterModel'); $conf->updateEventorder($eventListOrder); $subject = JText::_('DT_EVENT_EDIT_SUBJECT'); $message = JText::_('DT_EVENT_EDIT_MESSAGE'); $user = $this->getModel('user')->table; $Tagparser = new Tagparser(); if (isset($data['event']['slabId']) && $data['event']['slabId'] > 0) { $token_subject = JText::_('DT_EVENT_EDIT_SUBJECT'); $token_msg = ""; $token_msg .= '<p>' . JText::_('DT_EVENT_EDIT_MESSAGE') . '</p><p>' . JText::_('DT_EVENT_NAME') . ': [EVENT_NAME]'; $token_msg .= '<br />' . JText::_('DT_EVENT_DATE') . ': [EVENT_DATE]'; $token_msg .= '<br />' . JText::_('DT_EVENT_TIME') . ': [EVENT_TIME]'; $token_msg .= '<br />' . JText::_('DT_LOCATION') . ': [LOCATION]</p>'; } else { $token_subject = JText::_('DT_EVENT_CREATE_SUBJECT'); $token_msg = ""; $token_msg .= '<p>' . JText::_('DT_EVENT_CREATE_MESSAGE') . '</p><p>' . JText::_('DT_EVENT_NAME') . ': [EVENT_NAME]'; $token_msg .= '<br />' . JText::_('DT_EVENT_DATE') . ': [EVENT_DATE]'; $token_msg .= '<br />' . JText::_('DT_EVENT_TIME') . ': [EVENT_TIME]'; $token_msg .= '<br />' . JText::_('DT_LOCATION') . ': [LOCATION]</p>'; } $user->eventId = $row->slabId; $user->load(0); $message = $Tagparser->parsetags($token_msg, $user); $subject = $Tagparser->parsetags($token_subject, $user); $email = $frontendEventNotification; $emails = explode(";", $email); foreach ($emails as $email) { JUTility::sendMail($DT_mailfrom, $DT_fromname, $email, $subject, $message, 1); } } else { $mainframe->redirect("index.php?option=com_dtregister&controller=eventmanage&Itemid={$Itemid}&task=edit&cid[]=" . $row->slabId, $row->error); } $mainframe->redirect("index.php?option=com_dtregister&controller=eventmanage&Itemid={$Itemid}"); } }
function _writeLogs($log_detailed, $send_report_only_to_admin = false) { if ($send_report_only_to_admin) { $title_email = "jNews report for mailing:"; } else { $title_email = "jNews mailing report"; } $HTMLSent = 0; $TextSent = 0; $HTMLSentAll = $this->sentHTML; $TextSentAll = $this->sentText; if (!empty($HTMLSentAll)) { foreach ($HTMLSentAll as $oneList) { $HTMLSent = $HTMLSent + $oneList; } //enforeach } $TextSent = 0; if (!empty($TextSentAll)) { foreach ($TextSentAll as $oneList) { $TextSent = $TextSent + $oneList; } //enforeach } // $timeNow = jnews::getNow( 0, true ); $timeNow = time(); $totalstr = $timeNow - $this->startTime; $log_simple = 'Time to send: ' . $totalstr . ' ' . _JNEWS_SECONDS . "\r\n"; $log_simple .= 'Number of subscribers: ' . ($HTMLSent + $TextSent) . "\r\n"; $log_simple .= 'HTML format: ' . $HTMLSent . "\r\n"; $log_simple .= 'Text format: ' . $TextSent . "\r\n"; $format = defined('_DATE_FORMAT_LC') ? _DATE_FORMAT_LC : JText::_('DATE_FORMAT_LC'); if (version_compare(JVERSION, '3.0.0', '<')) { $log_detailed = "\r\n" . "\r\n" . '*** ' . JHTML::_('date', 'now', $format) . ' ***' . "\r\n" . $log_detailed; } else { $log_detailed = "\r\n" . "\r\n" . '*** ' . JHtml::_('date', 'now', $format) . ' ***' . "\r\n" . $log_detailed; } if ($send_report_only_to_admin) { $log_detailed = "Hello,\r\n" . $log_detailed . "\r\n"; } else { $log_detailed = $log_simple . 'Details: ' . "\r\n" . $log_detailed . "\r\n"; } if ($send_report_only_to_admin) { $send = $log_detailed; } else { if ($GLOBALS[JNEWS . 'send_log_simple']) { $send = $log_simple; } else { $send = $log_detailed; } } if (version_compare(JVERSION, '1.6.0', '<')) { //j15 $this->db->setQuery("SELECT * FROM `#__users` WHERE `gid` = 25 ORDER BY `id` ASC LIMIT 1"); } else { $this->db->setQuery("SELECT * FROM `#__users` AS U LEFT JOIN `#__user_usergroup_map` AS UGM ON U.id =UGM.user_id WHERE `group_id` = 8 ORDER BY `id` ASC LIMIT 1"); } $admin = $this->db->loadObject(); if (version_compare(JVERSION, '3.0.0', '>=')) { $class_for_mail = JMail::getInstance(); } if ($GLOBALS[JNEWS . 'send_log']) { if (!empty($GLOBALS[JNEWS . 'send_log_email'])) { $listOfAdminA = explode(',', $GLOBALS[JNEWS . 'send_log_email']); if (!empty($listOfAdminA)) { foreach ($listOfAdminA as $oneAdmin) { if (empty($oneAdmin)) { continue; } if (version_compare(JVERSION, '3.0.0', '<')) { JUTility::sendMail($oneAdmin, $oneAdmin, $oneAdmin, $title_email, $send); } else { $class_for_mail->sendMail($oneAdmin, $oneAdmin, $oneAdmin, $title_email, $send); } } } else { if (version_compare(JVERSION, '3.0.0', '<')) { JUTility::sendMail($admin->email, $admin->name, $admin->email, $title_email, $send); } else { $class_for_mail->sendMail($admin->email, $admin->name, $admin->email, $title_email, $send); } } } else { if (version_compare(JVERSION, '3.0.0', '<')) { JUTility::sendMail($admin->email, $admin->name, $admin->email, $title_email, $send); } else { $class_for_mail->sendMail($admin->email, $admin->name, $admin->email, $title_email, $send); } } } elseif ($GLOBALS[JNEWS . 'send_log_closed'] == 1 && connection_aborted()) { if (!empty($GLOBALS[JNEWS . 'send_log_email'])) { $listOfAdminA = explode(',', $GLOBALS[JNEWS . 'send_log_email']); if (!empty($listOfAdminA)) { foreach ($listOfAdminA as $oneAdmin) { if (empty($oneAdmin)) { continue; } if (version_compare(JVERSION, '3.0.0', '<')) { JUTility::sendMail($oneAdmin, $oneAdmin, $oneAdmin, $title_email, $send); } else { $class_for_mail->sendMail($oneAdmin, $oneAdmin, $oneAdmin, $title_email, $send); } } } else { if (version_compare(JVERSION, '3.0.0', '<')) { JUTility::sendMail($admin->email, $admin->name, $admin->email, $title_email, $send); } else { $class_for_mail->sendMail($admin->email, $admin->name, $admin->email, $title_email, $send); } } } else { if (version_compare(JVERSION, '3.0.0', '<')) { JUTility::sendMail($admin->email, $admin->name, $admin->email, $title_email, $send); } else { $class_for_mail->sendMail($admin->email, $admin->name, $admin->email, $title_email, $send); } } } if ($GLOBALS[JNEWS . 'save_log'] && !$send_report_only_to_admin) { if ($GLOBALS[JNEWS . 'save_log_simple']) { @file_put_contents(JNEWS_JPATH_ROOT_NO_ADMIN . $GLOBALS[JNEWS . 'save_log_file'], $log_simple, FILE_APPEND); } else { @file_put_contents(JNEWS_JPATH_ROOT_NO_ADMIN . $GLOBALS[JNEWS . 'save_log_file'], $log_detailed, FILE_APPEND); } } }
function sendEmail($gid) { DOCMAN_token::check() or die('Invalid Token'); // this is a generic mass mail sender to groups members. // From frontend you will find a email to group function specific for a document. $database = JFactory::getDBO(); $my = JFactory::getUser(); $mainframe = JFactory::getApplication(); $this_index = 'index.php?option=com_docman§ion=groups'; $message = JRequest::getString("mm_message", '', 'post'); $subject = JRequest::getString("mm_subject", '', 'post'); $leadin = JRequest::getString("mm_leadin", '', 'post'); if (!$message || !$subject) { $mainframe->redirect($this_index . '&task=emailgroup&gid=' . $gid, _DML_FILL_FORM); } $usertmp = trim(strtolower($my->usertype)); if ($usertmp != "super administrator" && $usertmp != "superadministrator" && $usertmp != "manager") { $mainframe->redirect("index.php", _DML_ONLY_ADMIN_EMAIL); } // Get the 'TO' list of addresses $database->setQuery("SELECT * " . "\n FROM #__docman_groups " . "\n WHERE groups_id=" . (int) $gid); $email_group = $database->loadObjectList(); $database->setQuery("SELECT id,name,username,email " . "\n FROM #__users" . "\n WHERE id in ( " . $email_group[0]->groups_members . ")" . "\n AND email !=''"); $listofusers = $database->loadObjectList(); if (!count($listofusers)) { $mainframe->redirect($this_index, _DML_NO_TARGET_EMAIL . " " . $email_groups[0]->name); } // Get 'FROM' sending email address (Use default) if (!$mainframe->getCfg('mailfrom')) { $database->setQuery("SELECT email " . "\n FROM #__users " . "\n WHERE id=" . $my->id); $my->email = $database->loadResult(); echo $database->getErrorMsg(); $mainframe->setCfg('mailfrom', $my->email); } // Build e-mail message format $message = ($leadin ? stripslashes($leadin) . "\r\n\r\n" : '') . stripslashes($message); $subject = stripslashes($subject); // ------- Obsolete: ...kept for historical purposes.... // $headers = "MIME-Version: 1.0\r\n" // . "From: " .$mosConfig_sitename." <".$my->email.">\r\n" // . "Reply-To: ".$mosConfig_sitename." <".$my->email.">\r\n" // . "X-Priority: 3\r\n" // . "X-MSMail-Priority: Low\r\n" // . "X-Mailer: DOCman\r\n" // ; // mail($emailtosend->email, $subject, $message, $headers); // TO: SUBJECT: (message) Headers // ------------ Send email using standard mosMail function foreach ($listofusers as $emailtosend) { JUTility::sendMail($mainframe->getCfg('mailfrom'), $mainframe->getCfg('fromname'), $emailtosend->email, $subject, $message); } $mainframe->redirect($this_index, _DML_EMAIL_SENT_TO . " " . count($listofusers) . " " . _DML_USERS); }
function registrationemail() { global $DT_mailfrom, $DT_fromname, $thanksmsg, $admin_registrationemail, $admin_notification, $subject_admin_registrationemail, $admin_email_from_user; if (isset($this->sendemail)) { if ($this->sendemail == false) { return; } } $this->load($this->userId); $this->TableEvent->load($this->eventId); if ($this->TableEvent->event_admin_email_set) { $DT_mailfrom = $this->TableEvent->event_admin_email_from_email; $DT_fromname = $this->TableEvent->event_admin_email_from_name; } $this->registrantemail(); if ($this->TableEvent->admin_notification_set) { $admin_notification = $this->TableEvent->admin_notification; } else { $admin_notification = $admin_registrationemail; } // prd($admin_notification); $Tagparser = new Tagparser(); $groupmsg = $Tagparser->getTagcontent('GROUP_MEMBER', $admin_notification); $memberdata = ""; if ($this->type == 'G') { foreach ($this->members as $member) { $memberdata .= $Tagparser->parsetags($groupmsg, $member); } } $usermsg = $Tagparser->replaceTagContent('GROUP_MEMBER', $admin_notification, $memberdata); $adminmsg = $Tagparser->parsetags($usermsg, $this); $adminemails = $this->TableEvent->email; $adminemails = explode(";", $adminemails); $subadmin = $Tagparser->parsetags($subject_admin_registrationemail, $this); $admin_attachments = $this->getAttachments(); foreach ($adminemails as $email) { if ($admin_email_from_user) { $DT_mailfrom = $this->getFieldByName('email'); $DT_fromname = $Tagparser->name($this); } JUTility::sendMail($DT_mailfrom, strip_tags(html_entity_decode($DT_fromname)), $email, strip_tags(html_entity_decode($subadmin)), $adminmsg, 1, null, null, $admin_attachments); } }
function send() { global $mosConfig_fromname, $mosConfig_mailfrom; $config =& JFactory::getConfig(); $eventId = JRequest::getInt('event_id', 0, 'post'); $subject = JRequest::getString('subject'); $message = JRequest::get(null, JREQUEST_ALLOWRAW); $message = $message['content']; $fromName = JRequest::getString('from_name'); $fromEmail = JRequest::getVar('from_email'); if (!$fromName) { $fromName = $mosConfig_fromname; } if (!$fromEmail) { $fromEmail = $mosConfig_mailfrom; } $this->TableEvent = $this->getModel('event')->table; $this->TableEvent->load($this->eventId); if ($this->TableEvent->event_admin_email_set) { $fromEmail = $this->TableEvent->event_admin_email_from_email; $fromName = $this->TableEvent->event_admin_email_from_name; } $bcc = JRequest::getVar('bcc', array(), 'post'); $bcc = explode(";", $bcc); if (is_array($bcc)) { foreach ($bcc as $bccemail) { if ($bccemail != "" && $message != "") { JUTility::sendMail($fromEmail, $fromName, $bccemail, $subject, $message, 1); } } } $mUser = $this->getModel('user'); // $users = $mUser->table->find("eventId=".$eventId); $search_params = array(); if (isset($_REQUEST['search']['status'])) { $search_params['status'] = $_REQUEST['search']['status']; } if (isset($_REQUEST['search']['attend']) && in_array($_REQUEST['search']['attend'], array(0, 1))) { $search_params['attend'] = $_REQUEST['search']['attend']; } if (isset($_REQUEST['search']['fee_status'])) { if ($_REQUEST['search']['fee_status'] == 1) { $search_params['condition'] = " f.status=1 "; } elseif ($_REQUEST['search']['fee_status'] == 0) { $search_params['condition'] = " f.status=0 "; } elseif ($_REQUEST['search']['fee_status'] == 2) { $search_params['condition'] = " (f.status=0 or f.status=1) "; } } if (isset($_REQUEST['search']['free'])) { $search_params['condition'] = "( " . $search_params['condition'] . " or f.fee=0 )"; } else { $search_params['condition'] = "( " . $search_params['condition'] . " and f.fee <> 0 )"; } $search_params['eventId'] = $eventId; $users = $mUser->getUsers($search_params, $filter_order = " name ", $filter_order_Dir = " asc ", null, null); if ($users) { $Tagparser = new Tagparser(); if (is_array($users)) { foreach ($users as $user) { $mUser->table->load($user->userId); $email = $mUser->table->getFieldByName('email'); $content = $Tagparser->parsetags($message, $mUser->table); $mailsubject = $Tagparser->parsetags($subject, $mUser->table); if ($email != "" && $content != "") { JUTility::sendMail($fromEmail, $fromName, $email, $mailsubject, $content, 1); } if ($mUser->table->type == 'G') { if (is_array($this->members)) { foreach ($this->members as $member) { if (!isset($member->email) || $member->email == "") { continue; } $content = $Tagparser->parsetags($message, $member); JUTility::sendMail($DT_mailfrom, $DT_fromname, $member->email, $mailsubject, $content, 1); } } } } } } global $mainframe; $mainframe->redirect("index.php?option=com_dtregister&controller=registrantemail", JText::_("DT_ALERT_EMAIL_SENT")); }
/** * Run right at the end of the form processing * form needs to be set to record in database for this to hook to be called * * @param object $params plugin params * @param object &$formModel form model * * @return bool */ public function onAfterProcess($params, &$formModel) { if ($params->get('ask-receipt')) { $post = JRequest::get('post'); if (!array_key_exists('fabrik_email_copy', $post)) { return; } } $config = JFactory::getConfig(); $w = new FabrikWorker(); $this->formModel = $formModel; $form = $formModel->getForm(); $aData = array_merge($this->getEmailData(), $formModel->_formData); $message = $params->get('receipt_message'); $editURL = COM_FABRIK_LIVESITE . "index.php?option=com_fabrik&view=form&fabrik=" . $formModel->get('id') . "&rowid=" . JRequest::getVar('rowid'); $viewURL = COM_FABRIK_LIVESITE . "index.php?option=com_fabrik&view=details&fabrik=" . $formModel->get('id') . "&rowid=" . JRequest::getVar('rowid'); $editlink = "<a href=\"{$editURL}\">" . JText::_('EDIT') . "</a>"; $viewlink = "<a href=\"{$viewURL}\">" . JText::_('VIEW') . "</a>"; $message = str_replace('{fabrik_editlink}', $editlink, $message); $message = str_replace('{fabrik_viewlink}', $viewlink, $message); $message = str_replace('{fabrik_editurl}', $editURL, $message); $message = str_replace('{fabrik_viewurl}', $viewURL, $message); $message = $w->parseMessageForPlaceHolder($message, $aData, false); $to = $w->parseMessageForPlaceHolder($params->get('receipt_to'), $aData, false); if (empty($to)) { /* $$$ hugh - not much point trying to send if we don't have a To address * (happens frequently if folk don't properly validate their form inputs and are using placeholders) * @TODO - might want to add some feedback about email not being sent */ return; } $subject = html_entity_decode($params->get('receipt_subject', '')); $subject = $w->parseMessageForPlaceHolder($subject, null, false); $from = $config->get('mailfrom'); $fromname = $config->get('fromname'); // Darn silly hack for poor joomfish settings where lang parameters are set to overide joomla global config but not mail translations entered $rawconfig = new JConfig(); if ($from === '') { $from = $rawconfig->mailfrom; } if ($fromname === '') { $fromname = $rawconfig->fromname; } $res = JUTility::sendMail($from, $fromname, $to, $subject, $message, true); }
/** * process the plugin, called when form is submitted * * @param object $params * @param object form */ function onAfterProcess($params, &$formModel) { if ($params->get('ask-receipt')) { $post = JRequest::get('post'); if (!array_key_exists('fabrik_email_copy', $post)) { return; } } $config = JFactory::getConfig(); $w = new FabrikWorker(); $this->formModel = $formModel; $form = $formModel->getForm(); //getEmailData returns correctly formatted {tablename___elementname} keyed results //_formData is there for legacy and may allow you to use {elementname} only placeholders for simple forms $aData = array_merge($this->getEmailData(), $formModel->_formData); $message = $params->get('receipt_message'); $editURL = COM_FABRIK_LIVESITE . "index.php?option=com_fabrik&view=form&fabrik=".$formModel->get('id')."&rowid=".JRequest::getVar('rowid'); $viewURL = COM_FABRIK_LIVESITE . "index.php?option=com_fabrik&view=details&fabrik=".$formModel->get('id')."&rowid=".JRequest::getVar('rowid'); $editlink = "<a href=\"$editURL\">" . JText::_('EDIT') . "</a>"; $viewlink = "<a href=\"$viewURL\">" . JText::_('VIEW') . "</a>"; $message = str_replace('{fabrik_editlink}', $editlink, $message); $message = str_replace('{fabrik_viewlink}', $viewlink, $message); $message = str_replace('{fabrik_editurl}', $editURL, $message); $message = str_replace('{fabrik_viewurl}', $viewURL, $message); $message = $w->parseMessageForPlaceHolder($message, $aData, false); $to = $w->parseMessageForPlaceHolder($params->get('receipt_to'), $aData, false); if (empty($to)) { // $$$ hugh - not much point trying to send if we don't have a To address // (happens frequently if folk don't properly validate their form inputs and are using placeholders) // @TODO - might want to add some feedback about email not being sent return; } /* // $$$ hugh - this code doesn't seem to be used? // it sets $email, which is then never referenced? $receipt_email = $params->get('receipt_to'); if (!$form->record_in_database) { foreach ($aData as $key=>$val) { $aBits = explode('___', $key); $newKey = array_pop( $aBits); if ($newKey == $receipt_email) { $email = $val; } } } */ $subject = html_entity_decode($params->get('receipt_subject', '')); $subject = $w->parseMessageForPlaceHolder($subject, null, false); $from = $config->getValue('mailfrom'); $fromname = $config->getValue('fromname'); //darn silly hack for poor joomfish settings where lang parameters are set to overide joomla global config but not mail translations entered $rawconfig = new JConfig(); if ($from === '') { $from = $rawconfig->mailfrom; } if ($fromname === '') { $fromname= $rawconfig->fromname; } $res = JUTility::sendMail( $from, $fromname, $to, $subject, $message, true); }
static function sendMail($sender, $sender_name, $recipient, $subject, $message, $html = null, $cc = null, $bcc = null, $attach = null) { JUTility::sendMail($sender, $sender_name, $recipient, $subject, $message, $html, $cc, $bcc, $attach); }
function writeLogs($list, $log_simple, $log_detailed) { if (ACA_CMSTYPE) { $database =& JFactory::getDBO(); } else { global $database; } //endif if ($GLOBALS[ACA . 'send_log_simple']) { $send = $log_simple; } else { $send = $log_detailed; } if (lisType::sendLogs($list->list_type)) { $database->setQuery("SELECT * FROM `#__users` WHERE `gid` = 25 LIMIT 1"); if (ACA_CMSTYPE) { // joomla 15 $admin = $database->loadObject(); $owner = subscribers::getSubscriberInfoFromUserId($list->owner); if ($GLOBALS[ACA . 'send_log'] == 1) { if (!empty($owner->email)) { JUTility::sendMail($admin->email, $admin->username, $owner->email, 'Acajoom mailing report', $send); } else { JUTility::sendMail($admin->email, $admin->username, $admin->email, 'Acajoom mailing report', $send); } } else { if ($GLOBALS[ACA . 'send_log_closed'] == 1 && connection_aborted()) { if (!empty($owner->email)) { JUTility::sendMail($admin->email, $admin->username, $owner->email, 'Acajoom mailing report', $send); } else { JUTility::sendMail($admin->email, $admin->username, $admin->email, 'Acajoom mailing report', $send); } } } } else { //joomla 1x $database->loadObject($admin); $owner = subscribers::getSubscriberInfoFromUserId($list->owner); if ($GLOBALS[ACA . 'send_log'] == 1) { if (!empty($owner->email)) { mosMail($admin->email, $admin->username, $owner->email, 'Acajoom mailing report', $send); } else { mosMail($admin->email, $admin->username, $admin->email, 'Acajoom mailing report', $send); } } else { if ($GLOBALS[ACA . 'send_log_closed'] == 1 && connection_aborted()) { if (!empty($owner->email)) { mosMail($admin->email, $admin->username, $owner->email, 'Acajoom mailing report', $send); } else { mosMail($admin->email, $admin->username, $admin->email, 'Acajoom mailing report', $send); } } } } //endif } if ($GLOBALS[ACA . 'save_log']) { if ($GLOBALS[ACA . 'save_log_simple']) { @file_put_contents(ACA_JPATH_ROOT_NO_ADMIN . $GLOBALS[ACA . 'save_log_file'], $log_simple, FILE_APPEND); } else { @file_put_contents(ACA_JPATH_ROOT_NO_ADMIN . $GLOBALS[ACA . 'save_log_file'], $log_detailed, FILE_APPEND); } } }
/** * TuiyoDocument::addJSDefines() * * @return void */ public function addJSDefines() { //add JQuery to the site! $doc =& JFactory::getDocument(); $headData = array("livePath" => TUIYO_LIVE_PATH, "index" => TUIYO_INDEX, "ajaxIMG_16" => TUIYO_LIVE_PATH . '/client/default/images/loading.gif'); $TuiyoDefines = $this->parseTmpl("TuiyoDefines", TUIYO_SYSTEM_JS, $headData, "js"); $TuiyoDefineFile = JPATH_CACHE . DS . "js.defines." . JFactory::getUser()->id . ".js"; $TuiyoDefineFileL = JURI::root() . "cache/js.defines." . JFactory::getUser()->id . ".js"; $TuiyoDefinneFileH = fopen($TuiyoDefineFile, 'w'); if (!$TuiyoDefinneFileH) { trigger_error(_("Cannot create js.defines"), E_USER_ERROR); return false; } //write to the file fwrite($TuiyoDefinneFileH, $TuiyoDefines); //close the file fclose($TuiyoDefinneFileH); //include the script; $doc->addScript($TuiyoDefineFileL); //Add secured data in metaTags $GLOBALS['mainframe']->addMetaTag("_token", JUTility::getToken()); //$GLOBALS['mainframe']->addMetaTag( "_token" , JUTility::getToken() ); //Search URL $hashURL = JRoute::_("index.php?option=com_search&view=search&task=find" . "&areas[1]=groups&areas[2]=articles&areas[3]=applications&areas[0]=profiles" . "&areas[4]=photos&areas[5]=resources&areas[6]=content&areas[7]=web"); $GLOBALS['mainframe']->addMetaTag("_searchurl", $hashURL); return true; }
function uddeIMmosMail($from, $fromname, $recipient, $subject, $body, $mode=0, $cc=NULL, $bcc=NULL, $attachment=NULL, $replyto=NULL, $replytoname=NULL ) { return JUTility::sendMail($from, $fromname, $recipient, $subject, $body, $mode, $cc, $bcc, $attachment, $replyto, $replytoname ); }
/** * Do the plugin action * * @param array &$data data * * @return int number of records updated */ public function process(&$data) { $app = JFactory::getApplication(); jimport('joomla.mail.helper'); $params = $this->getParams(); $msg = $params->get('message'); $to = $params->get('to'); $w = new FabrikWorker(); $MailFrom = $app->getCfg('mailfrom'); $FromName = $app->getCfg('fromname'); $subject = $params->get('subject', 'Fabrik cron job'); $eval = $params->get('cronemail-eval'); $condition = $params->get('cronemail_condition', ''); $updates = array(); $this->log = ''; foreach ($data as $group) { if (is_array($group)) { foreach ($group as $row) { if (!empty($condition)) { $this_condition = $w->parseMessageForPlaceHolder($condition, $row); if (eval($this_condition) === false) { continue; } } $row = JArrayHelper::fromObject($row); $thisto = $w->parseMessageForPlaceHolder($to, $row); if (JMailHelper::isEmailAddress($thisto)) { $thismsg = $w->parseMessageForPlaceHolder($msg, $row); if ($eval) { $thismsg = eval($thismsg); } $thissubject = $w->parseMessageForPlaceHolder($subject, $row); $res = JUTility::sendMail($MailFrom, $FromName, $thisto, $thissubject, $thismsg, true); if (!$res) { $this->log .= "\n failed sending to {$thisto}"; } } else { $this->log .= "\n {$thisto} is not an email address"; } $updates[] = $row['__pk_val']; } } } $field = $params->get('cronemail-updatefield'); if (!empty($updates) && trim($field) != '') { // Do any update found $listModel = JModel::getInstance('list', 'FabrikFEModel'); $listModel->setId($params->get('table')); $table = $listModel->getTable(); $connection = $params->get('connection'); $field = $params->get('cronemail-updatefield'); $value = $params->get('cronemail-updatefield-value'); if ($params->get('cronemail-updatefield-eval', '0') == '1') { $value = @eval($value); } $field = str_replace('___', '.', $field); $fabrikDb = $listModel->getDb(); $query = $fabrikDb->getQuery(true); $query->update($table->db_table_name)->set($field . ' = ' . $fabrikDb->quote($value))->where($table->db_primary_key . ' IN (' . implode(',', $updates) . ')'); $this->log .= "\n update query: {$query}"; $fabrikDb->setQuery($query); $fabrikDb->query(); } $this->log .= "\n updates " . count($updates) . " records"; return count($updates); }
function ppIpn() { $app = JFactory::getApplication('site'); jimport('joomla.utilities.utility'); require JPATH_COMPONENT_ADMINISTRATOR . DS . 'config.datsogallery.php'; $post = JRequest::get('post', JREQUEST_ALLOWRAW); if (!empty($post)) { $req = 'cmd=_notify-validate'; foreach ($post as $key => $value) { $value = urlencode(stripslashes($value)); $req .= "&{$key}={$value}"; } $header = "POST /cgi-bin/webscr HTTP/1.0\r\n"; $header .= "Content-Type: application/x-www-form-urlencoded\r\n"; $header .= "Content-Length: " . strlen($req) . "\r\n\r\n"; $url = $ad_pp_mode ? 'ssl://www.paypal.com' : 'ssl://www.sandbox.paypal.com'; $fp = fsockopen($url, 443, $errno, $errstr, 30); $payment_status = JRequest::getVar('payment_status', null, 'post'); $txn_id = JRequest::getVar('txn_id', null, 'post'); $receiver_email = JRequest::getVar('receiver_email', null, 'post'); $payer_email = JRequest::getVar('payer_email', null, 'post'); $custom = urldecode(JRequest::getVar('custom', null, 'post')); $item_number = JRequest::getVar('item_number', null, 'post'); if ($custom != '') { list($user_id, $user_ip) = explode('|', $custom); } if (!$fp) { } else { fputs($fp, $header . $req); while (!feof($fp)) { $res = fgets($fp, 1024); if (strcmp($res, "VERIFIED") == 0) { if ($payment_status == 'Completed') { $db = JFactory::getDBO(); $user = JFactory::getUser($user_id); $db->setQuery('SELECT a.*, c.image_id' . ' FROM #__datsogallery AS a,' . ' #__datsogallery_basket AS c' . ' WHERE a.id = c.image_id' . ' AND c.user_id = ' . $user->get('id')); $rows = $db->loadObjectList(); if (count($rows)) { foreach ($rows as $row) { $db->setQuery('INSERT INTO #__datsogallery_purchases' . ' VALUES (' . $db->Quote('') . ', ' . $db->Quote($item_number) . ', ' . $row->image_id . ', ' . $user->get('id') . ', ' . $db->Quote($user_ip) . ', NOW(), ' . $db->Quote($payment_status) . ', ' . $db->Quote($txn_id) . ')'); $db->query() or die($db->stderr()); } } $db->setQuery('DELETE FROM #__datsogallery_basket' . ' WHERE user_id = ' . $user->get('id')); $db->query() or die($db->stderr()); $menu = JSite::getMenu(); $ids = $menu->getItems('link', 'index.php?option=com_datsogallery&view=datsogallery'); $itemid = isset($ids[0]) ? '&Itemid=' . $ids[0]->id : ''; $juri =& JURI::getInstance(); $root = $juri->toString(array('scheme', 'host', 'port')); $from = $app->getCfg('mailfrom'); $fromname = $app->getCfg('fromname'); $subject = $fromname . ': ' . JText::_('DatsoGallery Shopping Cart'); $purchases_link = '<a href="' . $root . JRoute::_('index.php?option=com_datsogallery&task=purchases' . $itemid) . '">' . JText::_('COM_DATSOGALLERY_MY_PURCHASES') . '</a>'; $site_link = '<a href="' . $root . '">' . $root . '</a>'; $text = sprintf(JText::_('COM_DATSOGALLERY_MAIL_AFTER_PURCHASE'), $user->get('name'), $purchases_link, $app->getCfg('sitename'), $site_link); JUTility::sendMail($from, $fromname, $user->get('email'), $subject, $text, true); } else { return; } } else { if (strcmp($res, "INVALID") == 0) { } } } fclose($fp); } } }
function sendNotificationMail($user) { $config = JFactory::getConfig(); $mail_from = $config->getValue("mailfrom"); $sitename = $config->getValue("sitename"); JTheFactoryHelper::modelIncludePath('payments'); $balancemodel = JModel::getInstance('Balance', 'JTheFactoryModel'); $balance = $balancemodel->getUserBalance($user->id); $r = $this->loadPricingObject(); $params = new JParameter($r->params); $email_text = base64_decode($params->get('email_text')); $link = JURI::root() . '/index.php?option=' . APP_EXTENSION . '&task=paycomission'; $email_text = str_replace('%USERNAME%', $user->username, $email_text); $email_text = str_replace('%NAME%', $user->name, $email_text); $email_text = str_replace('%BALANCE%', $balance->balance . " " . $balance->currency, $email_text); $email_text = str_replace('%LINK%', $link, $email_text); JUTility::sendMail($mail_from, $sitename, $user->email, JText::_("COM_BIDS_COMISION_PAYMENT_NOTIFICATION"), $email_text, true); }
function approveReview($approve = 1, $rev_id = 0) { global $mainframe, $mtconf; $MailFrom = $mainframe->getCfg('mailfrom'); $FromName = $mainframe->getCfg('fromname'); # Determine which Review ID to use. If none, return false. if ($this->rev_id > 0) { $rid = (int) $this->rev_id; } elseif ($rev_id > 0) { $rid = (int) $rev_id; } else { return false; } $this->_db->setQuery("UPDATE #__mt_reviews SET rev_approved = '" . intval($approve) . "' WHERE rev_id = '" . $rid . "'"); if (!$this->_db->query()) { echo "<script> alert('" . $this->_db->getErrorMsg() . "'); window.history.go(-1); </script>\n"; return false; } else { $this->_db->setQuery("UPDATE #__mt_reviews SET admin_note = '' WHERE rev_id = '" . $rid . "'"); $this->_db->query(); if ($approve == 1) { // Send approval notification to reviewer if ($mtconf->get('notifyuser_review_approved') == 1) { $this->_db->setQuery("SELECT u.email, l.link_name, l.link_id FROM #__mt_reviews AS r" . "\nLEFT JOIN #__users AS u ON u.id = r.user_id" . "\nLEFT JOIN #__mt_links AS l ON l.link_id = r.link_id" . "\nWHERE r.rev_id = '" . $rid . "' LIMIT 1"); $row = $this->_db->loadObject(); $link_url = $mainframe->getSiteURL() . 'index.php?option=com_mtree&task=viewlink&link_id=' . $row->link_id; if ($row->email != '') { $subject = JText::_('Review approved subject'); $body = sprintf(JText::_('Review approved msg'), $row->link_name, $link_url); JUTility::sendMail($MailFrom, $FromName, $row->email, $subject, $body); } } // Send notification to listing owner if ($mtconf->get('notifyowner_review_added') == 1) { // Notification can only be sent when this listing is owned by a registered user $this->_db->setQuery('SELECT u.email, l.link_name, l.link_id FROM #__mt_reviews AS r' . ' LEFT JOIN #__mt_links AS l ON l.link_id = r.link_id' . ' LEFT JOIN #__users AS u ON u.id = l.user_id' . ' WHERE r.rev_id = ' . $rid . ' LIMIT 1'); $row = $this->_db->loadObject(); $link_url = $mainframe->getSiteURL() . 'index.php?option=com_mtree&task=viewlink&link_id=' . $row->link_id; if ($row->email != '') { $subject = sprintf(JText::_('Review added subject'), $row->link_name); $body = sprintf(JText::_('Review added msg'), $row->link_name, $link_url); JUTility::sendMail($MailFrom, $FromName, $row->email, $subject, $body); } } } return true; } }
function lendBeforeEndNotify($option) { PHP_booklibrary::addTitleAndMetaTags(); global $database, $booklibrary_configuration, $Itemid, $mosConfig_mailfrom; $send_email = 0; if ($booklibrary_configuration['lend_before_end_notify'] && trim($booklibrary_configuration['lend_before_end_notify_email']) != "" && is_numeric($booklibrary_configuration['lend_before_end_notify_days'])) { $send_email = 1; } if ($send_email) { $mail_to = explode(",", $booklibrary_configuration['lend_before_end_notify_email']); $zapros = "SELECT c.id, c.bookid, c.title, d.lend_from,d.lend_until,d.user_name,d.user_email " . " FROM #__booklibrary as c " . " left join #__booklibrary_lend as d on d.fk_bookid = c.id " . " WHERE d.lend_return IS NULL and TIMESTAMPDIFF(DAY, now(),lend_until ) = " . $booklibrary_configuration['lend_before_end_notify_days'] . " ; "; $database->setQuery($zapros); $item_book = $database->loadObjectList(); echo $database->getErrorMsg(); $message = "So books lend expire soon (in " . $booklibrary_configuration['lend_before_end_notify_days'] . " days):<br /><br />"; foreach ($item_book as $item) { $message .= 'Lend User: '******'(' . $item->user_email . ')<br /> ' . 'Book: ' . $item->title . ' <br />' . 'ID: ' . $item->id . ' <br />' . 'BookID: ' . $item->bookid . ' <hr /><br />'; } if (count($item_book) > 0) { JUTility::sendMail($mosConfig_mailfrom, "Lend expire Notice", $mail_to, 'Lend expire Notice!', $message, true); } } }
/** * do the plugin action * @return number of records updated */ function process(&$data) { $app =& JFactory::getApplication(); jimport('joomla.mail.helper'); $params =& $this->getParams(); $msg = $params->get('message'); $to = $params->get('to'); $w = new FabrikWorker(); $MailFrom = $app->getCfg('mailfrom'); $FromName = $app->getCfg('fromname'); $subject = $params->get('subject', 'Fabrik cron job'); $eval = $params->get('cronemail-eval'); $condition = trim($params->get('cronemail_condition', '')); $merge_emails = (int) $params->get('cronemail_mergemessages', 0); $merged_msg = ''; $updates = array(); $first_row = array(); foreach ($data as $group) { if (is_array($group)) { foreach ($group as $row) { $row = JArrayHelper::fromObject($row); if (empty($first_row)) { $first_row = $row; // used for placeholders in subject when merging mail } if (!empty($condition)) { $this_condition = $w->parseMessageForPlaceHolder($condition, $row); if (eval($this_condition) === false) { $this->logMsg .= "\n condition returned false: {$this_condition}\n"; continue; } } if (!$merge_emails) { $thistos = explode(',', $w->parseMessageForPlaceHolder($to, $row)); $thismsg = $w->parseMessageForPlaceHolder($msg, $row); if ($eval) { $thismsg = eval($thismsg); } $thissubject = $w->parseMessageForPlaceHolder($subject, $row); foreach ($thistos as $thisto) { if (JMailHelper::isEmailAddress($thisto)) { $res = JUTility::sendMail($MailFrom, $FromName, $thisto, $thissubject, $thismsg, true); $this->logMsg .= "\n {$thisto}: "; $this->logMsg .= $res ? ' sent ' : ' not sent \\n'; } else { $this->logMsg .= "\n {$thisto} not an email\n"; } } } else { $thismsg = $w->parseMessageForPlaceHolder($msg, $row); if ($eval) { $thismsg = eval($thismsg); } $merged_msg .= $thismsg; } $updates[] = $row['__pk_val']; } } } if ($merge_emails) { // arbitrarily use first row for placeholders $thistos = explode(',', $w->parseMessageForPlaceHolder($to, $first_row)); $thissubject = $w->parseMessageForPlaceHolder($subject, $first_row); $merged_msg = $params->get('cronemail_message_preamble', '') . $merged_msg . $params->get('cronemail_message_postamble', ''); foreach ($thistos as $thisto) { if (JMailHelper::isEmailAddress($thisto)) { $res = JUTility::sendMail($MailFrom, $FromName, $thisto, $thissubject, $merged_msg, true); $this->logMsg .= "\n {$thisto}: "; $this->logMsg .= $res ? ' sent ' : ' not sent \\n'; } else { $this->logMsg .= "\n {$thisto} not an email\n"; } } } $field = $params->get('cronemail-updatefield'); if (!empty($updates) && trim($field) != '') { //do any update found $tableModel =& JModel::getInstance('table', 'FabrikModel'); $tableModel->setId($params->get('table')); $table =& $tableModel->getTable(); $connection = $params->get('connection'); $field = $params->get('cronemail-updatefield'); $value = $params->get('cronemail-updatefield-value'); $noquotes = $params->get('cronemail-updatefield-no-quotes'); $field = str_replace("___", ".", $field); $fabrikDb =& $tableModel->getDb(); $query = "UPDATE {$table->db_table_name} set {$field} = " . ($noquotes ? $value : $fabrikDb->Quote($value)) . " WHERE {$table->db_primary_key} IN (" . implode(',', $updates) . ")"; $fabrikDb->setQuery($query); $fabrikDb->query(); } return count($updates); }
/** * Mail function (uses phpMailer) * * @param string $from From e-mail address * @param string $fromName From name * @param mixed $recipient Recipient e-mail address(es) * @param string $subject E-mail subject * @param string $body Message body * @param boolean $mode false = plain text, true = HTML * @param mixed $cc CC e-mail address(es) * @param mixed $bcc BCC e-mail address(es) * @param mixed $attachment Attachment file name(s) * @param mixed $replyTo Reply to email address(es) * @param mixed $replyToName Reply to name(s) * @return boolean True on success */ function send($from, $fromName, $recipient, $subject, $body, $mode = 0, $cc = NULL, $bcc = NULL, $attachment = NULL, $replyTo = NULL, $replyToName = NULL) { if (JCOMMENTS_JVERSION == '1.5') { return JUTility::sendMail($from, $fromName, $recipient, $subject, $body, $mode, $cc, $bcc, $attachment, $replyTo, $replyToName); } return mosMail($from, $fromName, $recipient, $subject, $body, $mode, $cc, $bcc, $attachment, $replyTo, $replyToName); }