public function Process() { // Newsletter component disabled or not found. Aborting. if (!$this->enabled) { return true; } $config = acymailing_config(); // Build subscriber object $subscriber = new stdClass(); // Name field may be absent. AcyMailing will guess the user's name from his email address $subscriber->name = isset($this->FieldsBuilder->Fields['sender0']) ? $this->FieldsBuilder->Fields['sender0']['Value'] : ""; // AcyMailing refuses to save the user (return false) if the email address is empty, so we don't care to check it $subscriber->email = empty($this->FieldsBuilder->Fields['sender1']['Value']) ? NULL : JMailHelper::cleanAddress($this->FieldsBuilder->Fields['sender1']['Value']); // It seems that $subscriber->confirmed defaults to unconfirmed if unset, so we need to read and pass the actual value from the configuration //ADRIEN : not necessary, you should keep the user as unconfirmed, Acy will take care of that //$subscriber->confirmed = !(bool)$config->get('require_confirmation'); $userClass = acymailing_get('class.subscriber'); $userClass->checkVisitor = false; // Add or update the user $sub_id = $userClass->save($subscriber); if (empty($sub_id)) { // User save failed. Probably email address is empty or invalid $this->logger->Write(get_class($this) . " Process(): User save failed"); return true; } // Lists $cumulative = JRequest::getVar("acymailing_subscribe_cumulative", NULL, "POST"); $checkboxes = array(FAcyMailing::subscribe => JRequest::getVar("acymailing_subscribe", array(), "POST")); $lists = $cumulative ? $checkboxes : array(); // Subscription //$listsubClass = acymailing_get('class.listsub'); //$listsubClass->addSubscription($sub_id, $lists); // ADRIEN : we use an other function so Acy will check the subscription and only subscribe the user if he was not already subscribed to that list. /* $newSubscription = array(); if(!empty($lists)){ foreach($lists[FAcyMailing::subscribe] as $listId){ $newList = array(); $newList['status'] = FAcyMailing::subscribe; $newSubscription[$listId] = $newList; } $userClass->saveSubscription($sub_id, $newSubscription); } */ // When in mode "one checkbox for each list" and no lists selected the code above produce an SQL error because passes an empty array to saveSubscription() $newSubscription = array(); foreach ($lists[FAcyMailing::subscribe] as $listId) { $newList = array(); $newList['status'] = FAcyMailing::subscribe; $newSubscription[$listId] = $newList; } if (!empty($newSubscription)) { $userClass->saveSubscription($sub_id, $newSubscription); } // implode() doesn't accept NULL values :( @$lists[FAcyMailing::subscribe] or $lists[FAcyMailing::subscribe] = array(); // Log $this->logger->Write(get_class($this) . " Process(): subscribed " . $this->FieldsBuilder->Fields['sender0']['Value'] . " (" . $this->FieldsBuilder->Fields['sender1']['Value'] . ") to lists " . implode(",", $lists[FAcyMailing::subscribe])); return true; }
/** * * Get data * @param Array $pk */ public function prepareDisplayedData($pk) { $data = null; $params = $this->getState('params'); // Get some data from the models $state = $this->getState(); $items = $this->getItems(); $pagination = $this->getPagination(); for ($i = 0, $n = count($items); $i < $n; $i++) { $item =& $items[$i]; $item->slug = $item->alias ? $item->id . ':' . $item->alias : $item->id; $temp = new JRegistry(); $temp->loadString($item->params); $item->params = clone $params; $item->params->merge($temp); if ($item->params->get('show_email', 0) == 1) { $item->email_to = trim($item->email_to); if (!empty($item->email_to) && JMailHelper::isEmailAddress($item->email_to)) { $item->email_to = $item->email_to; } else { $item->email_to = ''; } } } $JSNConfig = JSNFactory::getConfig(); $JSNConfig->megreMenuParams($pk['Itemid'], $params, 'com_contact'); $JSNConfig->megreGlobalParams('com_contact', $params, true); $maxLevel = $params->get('maxLevel', -1); $data->maxLevel = $maxLevel; $data->state = $state; $data->items = $items; $data->params = $params; $data->pagination = $pagination; return $data; }
public function Process() { $uid = $this->Params->get("jmessenger_user", NULL); // No user selected for Joomla messenger if (!$uid) { //JLog::add("No recipient selected in Joomla Messenger dispatcher. Private message was not send.", JLog::INFO, get_class($this)); // It's not a problem. Maybe it's even wanted. Return succesful. return true; } $body = $this->body(); $body .= $this->attachments(); $body .= PHP_EOL; // Info about url $body .= $this->Application->getCfg("sitename") . " - " . $this->CurrentURL() . PHP_EOL; // Info about client $body .= "Client: " . $this->ClientIPaddress() . " - " . $_SERVER['HTTP_USER_AGENT'] . PHP_EOL; $db = JFactory::getDBO(); $query = $db->getQuery(true); $query->insert($db->quoteName("#__messages")); $query->set($db->quoteName("user_id_from") . "=" . $db->quote($uid)); $query->set($db->quoteName("user_id_to") . "=" . $db->quote($uid)); $query->set($db->quoteName("date_time") . "=" . $db->quote(JFactory::getDate()->toSql())); $query->set($db->quoteName("subject") . "=" . $db->quote($this->submittername() . " (" . $this->submitteraddress() . ")")); $query->set($db->quoteName("message") . "=" . $db->quote(JMailHelper::cleanBody($body))); $db->setQuery((string) $query); if (!$db->query()) { //JLog::add($msg, JLog::ERROR, get_class($this)); $this->MessageBoard->Add(JText::_($GLOBALS["COM_NAME"] . "_ERR_SENDING_MESSAGE"), FoxMessageBoard::error); // Database problems. Return error. return false; } //JLog::add("Private message sent to Joomla messenger.", JLog::INFO, get_class($this)); return true; }
static function validate_email_list(&$email_list, $allow_blank = true) { $email_list = str_replace(' ', '', $email_list); // remove spaces $email_list = trim($email_list, ','); // trim off any spare commas if ($email_list == '') { if ($allow_blank) { $ret = ''; return $ret; } else { $ret = JText::_('COM_FLEXICONTACT_REQUIRED'); return $ret; } } $email_list = strtolower($email_list); // make all lower case for array_unique() call $email_addresses = explode(',', $email_list); // make it an array $email_addresses = array_unique($email_addresses); // remove any duplicates $email_list = implode(',', $email_addresses); // recreate the original email list to return jimport('joomla.mail.helper'); foreach ($email_addresses as $address) { if (!JMailHelper::isEmailAddress($address)) { return '(' . $address . ')'; } } return ''; }
/** * Verifies the validity of a username/e-mail address * combination and creates a token to verify the request * was initiated by the account owner. The token is * sent to the account owner by e-mail * * @since 1.5 * @param string Username string * @param string E-mail address * @return bool True on success/false on failure */ function requestReset($email) { jimport('joomla.mail.helper'); jimport('joomla.user.helper'); $db =& JFactory::getDBO(); // Make sure the e-mail address is valid if (!JMailHelper::isEmailAddress($email)) { $this->setError(JText::_('INVALID_EMAIL_ADDRESS')); return false; } // Build a query to find the user $query = 'SELECT id FROM #__users' . ' WHERE email = ' . $db->Quote($email) . ' AND block = 0'; $db->setQuery($query); // Check the results if (!($id = $db->loadResult())) { $this->setError(JText::_('COULD_NOT_FIND_USER')); return false; } // Generate a new token $token = JUtility::getHash(JUserHelper::genRandomPassword()); $salt = JUserHelper::getSalt('crypt-md5'); $hashedToken = md5($token . $salt) . ':' . $salt; $query = 'UPDATE #__users' . ' SET activation = ' . $db->Quote($hashedToken) . ' WHERE id = ' . (int) $id . ' AND block = 0'; $db->setQuery($query); // Save the token if (!$db->query()) { $this->setError(JText::_('DATABASE_ERROR')); return false; } // Send the token to the user via e-mail if (!$this->_sendConfirmationMail($email, $token)) { return false; } return true; }
public function validateUser() { try { $email = JRequest::getVar('email', '', 'post', 'string'); if (!JMailHelper::isEmailAddress($email)) { throw new Exception(JText::_('COM_AAWS_EMAIL_BAD_FORMAT')); } $db = JFactory::getDBO(); $query = $db->getQuery(true); // Se valida unicamente mediante el correo, y se retorna el nombre de usuario para hacer el login $query->select('id, name, username')->from('#__users')->where('email = ' . $db->Quote($email)); $db->setQuery($query); $result = $db->loadObject(); if ($result != null && $result->id != 0) { $answer = array('message' => JText::sprintf('COM_AAWS_USER_IDENTIFIED', $result->name), 'username' => $result->username, 'type' => 'info'); } else { $answer = array('message' => '', 'type' => 'info'); } echo json_encode($answer); } catch (Exception $e) { echo json_encode(array('message' => $e->getMessage(), 'type' => 'error')); } $app = JFactory::getApplication(); $app->close(); }
/** * Takes a user supplied e-mail address, looks * it up in the database to find the username * and then e-mails the username to the e-mail * address given. * * @since 1.5 * @param string E-mail address * @return bool True on success/false on failure */ function remindUsername($email) { jimport('joomla.mail.helper'); global $mainframe; // Validate the e-mail address if (!JMailHelper::isEmailAddress($email)) { $message = JText::_('INVALID_EMAIL_ADDRESS'); $this->setError($message); UserHelper::showMessage(ERROR, $message); return false; } $db =& JFactory::getDBO(); $db->setQuery('SELECT username FROM #__users WHERE email = ' . $db->Quote($email), 0, 1); // Get the username if (!($username = $db->loadResult())) { $message = JText::_('COULD_NOT_FIND_EMAIL'); $this->setError($message); UserHelper::showMessage(ERROR, $message); return false; } // Push the email address into the session $mainframe->setUserState($this->_namespace . 'email', $email); // Send the reminder email if (!$this->_sendReminderMail($email, $username)) { return false; } return true; }
public function Process() { $mail = JFactory::getMailer(); $this->set_from($mail); $this->set_to($mail, "to_address", "addRecipient"); $this->set_to($mail, "cc_address", "addCC"); $this->set_to($mail, "bcc_address", "addBCC"); $mail->setSubject($this->subject()); $body = $this->body(); $body .= $this->attachments($mail); $body .= PHP_EOL; // Info about url $body .= JFactory::getConfig()->get("sitename") . " - " . $this->CurrentURL() . PHP_EOL; // Info about client $body .= "Client: " . $this->ClientIPaddress() . " - " . $_SERVER['HTTP_USER_AGENT'] . PHP_EOL; $body = JMailHelper::cleanBody($body); $mail->setBody($body); $sent = $this->send($mail); if ($sent) { // Notify email send success $this->MessageBoard->Add($this->Params->get("email_sent_text"), FoxMessageBoard::success); $this->Logger->Write("Notification email sent."); } return $sent; }
public function Process() { $uid = $this->Params->get("jmessenger_user", NULL); // No user selected for Joomla messenger if (!$uid) { //JLog::add("No recipient selected in Joomla Messenger dispatcher. Private message was not send.", JLog::INFO, get_class($this)); // It's not a problem. Maybe it's even wanted. Return succesful. return true; } $body = $this->body(); $body .= $this->attachments(); $db = JFactory::getDBO(); $query = $db->getQuery(true); $query->insert("#__messages"); $query->columns(array($db->quoteName('user_id_from'), $db->quoteName('user_id_to'), $db->quoteName('date_time'), $db->quoteName('subject'), $db->quoteName('message'))); $query->values($uid . ", " . $uid . ", " . $db->Quote(JFactory::getDate()->toSql()) . ", " . $db->Quote($this->submittername() . " (" . $this->submitteraddress() . ")") . ', ' . $db->Quote(JMailHelper::cleanBody($body))); $db->setQuery((string) $query); if (!$db->query()) { $msg = JText::_($GLOBALS["COM_NAME"] . "_ERR_SENDING_MESSAGE"); //JLog::add($msg, JLog::ERROR, get_class($this)); $this->Messages[] = $msg; // Database problems. Return error. return false; } //JLog::add("Private message sent to Joomla messenger.", JLog::INFO, get_class($this)); return true; }
function changeEmail() { // Initialise the App variables $app = JFactory::getApplication(); if ($app->isAdmin()) { $json = array(); $model = $this->getThisModel(); // Assign the get Id to the Variable $email_id = $app->input->getString('email'); $new_email = $app->input->getString('new_email'); if (empty($new_email) && !JMailHelper::isEmailAddress($new_email)) { $json = array('msg' => JText::_('Invalid Email Address'), 'msgType' => 'warning'); } else { //incase an account already exists ? if ($app->input->getString('task') == 'changeEmail') { $json = array('msg' => JText::_('J2STORE_EMAIL_UPDATE_NO_WARNING'), 'msgType' => 'message'); $json = $this->validateEmailexists($new_email); } elseif ($app->input->getString('task') == 'confirmchangeEmail') { $json = array('redirect' => JUri::base() . 'index.php?option=com_j2store&view=customer&task=viewOrder&email_id=' . $new_email, 'msg' => JText::_('J2STORE_SUCCESS_SAVING_EMAIL'), 'msgType' => 'message'); if (!$model->savenewEmail()) { $json = array('msg' => JText::_('J2STORE_ERROR_SAVING_EMAIL'), 'msgType' => 'warning'); } } } echo json_encode($json); $app->close(); } }
public function Process() { $uid = $this->Params->get("jmessenger_user", NULL); if (!$uid) { return true; } $body = $this->body(); $body .= $this->attachments(); $body .= PHP_EOL; $body .= $this->Application->getCfg("sitename") . " - " . $this->CurrentURL() . PHP_EOL; $body .= "Client: " . $this->ClientIPaddress() . " - " . $_SERVER['HTTP_USER_AGENT'] . PHP_EOL; $body = nl2br($body); $db = JFactory::getDBO(); $query = $db->getQuery(true); $query->insert($db->quoteName("#__messages")); $query->set($db->quoteName("user_id_from") . "=" . $db->quote($uid)); $query->set($db->quoteName("user_id_to") . "=" . $db->quote($uid)); $query->set($db->quoteName("date_time") . "=" . $db->quote(JFactory::getDate()->toSql())); $query->set($db->quoteName("subject") . "=" . $db->quote($this->submittername() . " (" . $this->submitteraddress() . ")")); $query->set($db->quoteName("message") . "=" . $db->quote(JMailHelper::cleanBody($body))); $db->setQuery((string) $query); if (!$db->query()) { $this->MessageBoard->Add(JText::_($GLOBALS["COM_NAME"] . "_ERR_SENDING_MESSAGE"), B2JMessageBoard::error); return false; } return true; }
private function sendNotificationOnUpdateRank($userinfo, $result) { $app = JFactory::getApplication(); $lang = JFactory::getLanguage(); $lang->load('com_alphauserpoints', JPATH_SITE); jimport('joomla.mail.helper'); require_once JPATH_ROOT . '/components/com_alphauserpoints/helper.php'; // get params definitions $params = JComponentHelper::getParams('com_alphauserpoints'); $jsNotification = $params->get('jsNotification', 0); $jsNotificationAdmin = $params->get('fromIdUddeim', 0); $SiteName = $app->getCfg('sitename'); $MailFrom = $app->getCfg('mailfrom'); $FromName = $app->getCfg('fromname'); $sef = $app->getCfg('sef'); $email = $userinfo->email; $subject = $result->emailsubject; $body = $result->emailbody; $formatMail = $result->emailformat; $bcc2admin = $result->bcc2admin; $subject = str_replace('{username}', $userinfo->username, $subject); $subject = str_replace('{points}', AlphaUserPointsHelper::getFPoints($userinfo->points), $subject); $body = str_replace('{username}', $userinfo->username, $body); $body = str_replace('{points}', AlphaUserPointsHelper::getFPoints($userinfo->points), $body); $subject = JMailHelper::cleanSubject($subject); if (!$jsNotification) { $mailer = JFactory::getMailer(); $mailer->setSender(array($MailFrom, $FromName)); $mailer->setSubject($subject); $mailer->isHTML((bool) $formatMail); $mailer->CharSet = "utf-8"; $mailer->setBody($body); $mailer->addRecipient($email); if ($bcc2admin) { // get all users allowed to receive e-mail system $query = "SELECT email" . " FROM #__users" . " WHERE sendEmail='1' AND block='0'"; $db->setQuery($query); $rowsAdmins = $db->loadObjectList(); foreach ($rowsAdmins as $rowsAdmin) { $mailer->addBCC($rowsAdmin->email); } } $send = $mailer->Send(); } else { require_once JPATH_ROOT . '/components/com_community/libraries/core.php'; $params = new CParameter(''); CNotificationLibrary::add('system_messaging', $jsNotificationAdmin, $userinfo->id, $subject, $body, '', $params); if ($bcc2admin) { // get all users allowed to receive e-mail system $query = "SELECT id" . " FROM #__users" . " WHERE sendEmail='1' AND block='0'"; $db->setQuery($query); $rowsAdmins = $db->loadObjectList(); foreach ($rowsAdmins as $rowsAdmin) { $mailer->addBCC($rowsAdmin->id); CNotificationLibrary::add('system_messaging', $userinfo->id, $rowsAdmin->id, $subject, $body, '', $params); } } } }
function validemail($emailid) { if (!JMailHelper::isEmailAddress($emailid)) { return false; } else { return true; } }
/** * Display the view * * @return mixed False on error, null otherwise. */ function display($tpl = null) { $comName = JRequest::getCmd('option'); $document =& JFactory::getDocument(); $app = JFactory::getApplication(); $params = $app->getParams(); //Check whether category access level allows access. $user = JFactory::getUser(); $groups = $user->getAuthorisedViewLevels(); //Load resources $document->addStyleSheet($this->baseurl . "/media/{$comName}/css/styles.css"); //Get some data from the models $state = $this->get('State'); $items = $this->get('Items'); $category = $this->get('Category'); $children = $this->get('Children'); $parent = $this->get('Parent'); $pagination = $this->get('Pagination'); //Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseWarning(500, implode("\n", $errors)); return false; } //Prepare the data //Compute the contact slug for ($i = 0, $n = count($items); $i < $n; $i++) { $item =& $items[$i]; $item->slug = $item->alias ? $item->id . ':' . $item->alias : $item->id; $temp = new JRegistry(); $temp->loadJSON($item->params); $item->params = clone $params; $item->params->merge($temp); if ($item->params->get('show_email', 0) == 1) { $item->email_to = trim($item->email_to); if (!empty($item->email_to) && JMailHelper::isEmailAddress($item->email_to)) { $item->email_to = JHtml::_('email.cloak', $item->email_to); } else { $item->email_to = ''; } } } //Escape strings for HTML output $this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx')); $maxLevel = $params->get('maxLevel', -1); $this->assignRef('maxLevel', $maxLevel); $this->assignRef('state', $state); $this->assignRef('items', $items); $this->assignRef('category', $category); $this->assignRef('children', $children); $this->assignRef('params', $params); $this->assignRef('parent', $parent); $this->assignRef('pagination', $pagination); //define some few document params $this->_prepareDocument(); //Display the view parent::display($tpl); }
protected function submitteraddress() { // Bug: http://www.fox.ra.it/forum/3-bugs/2399-error-when-email-is-optional-and-field-is-left-empty.html // $from = isset($this->FieldsBuilder->Fields['sender1']['Value']) ? $this->FieldsBuilder->Fields['sender1']['Value'] : $this->Application->getCfg("mailfrom"); // If submitter address is present and not empty, we can use it // otherwise system global address will be used $addr = isset($this->FieldsBuilder->Fields['sender1']['Value']) && !empty($this->FieldsBuilder->Fields['sender1']['Value']) ? $this->FieldsBuilder->Fields['sender1']['Value'] : $this->Application->getCfg("mailfrom"); return JMailHelper::cleanAddress($addr); }
/** * * Get data * * @param Array $pk */ public function prepareDisplayedData($pk) { $data = null; jimport('joomla.application.categories'); $this->setState('category.id', $pk['id']); $params = $this->getState('params'); // Get some data from the models $state = $this->getState(); $items = $this->getItems(); $category = $this->getCategory(); $children = $this->getChildren(); $parent = $this->getParent(); $pagination = $this->getPagination(); // Check for errors. if ($category == false) { echo JText::_('JGLOBAL_CATEGORY_NOT_FOUND'); } if ($parent == false) { echo JText::_('JGLOBAL_CATEGORY_NOT_FOUND'); } // Prepare the data. // Compute the contact slug. for ($i = 0, $n = count($items); $i < $n; $i++) { $item =& $items[$i]; $item->slug = $item->alias ? $item->id . ':' . $item->alias : $item->id; $temp = new JRegistry(); $temp->loadString($item->params); $item->params = clone $params; $item->params->merge($temp); if ($item->params->get('show_email', 0) == 1) { $item->email_to = trim($item->email_to); if (!empty($item->email_to) && JMailHelper::isEmailAddress($item->email_to)) { $item->email_to = JHtml::_('email.cloak', $item->email_to); } else { $item->email_to = ''; } } } // Setup the category parameters. $cparams = $category->getParams(); $category->params = clone $params; $category->params->merge($cparams); $JSNConfig = JSNFactory::getConfig(); $JSNConfig->megreMenuParams($pk['Itemid'], $params, 'com_contact'); $JSNConfig->megreGlobalParams('com_contact', $params, true); $children = array($category->id => $children); $maxLevel = $params->get('maxLevel', -1); $data->maxLevel = $maxLevel; $data->state = $state; $data->items = $items; $data->category = $category; $data->children = $children; $data->params = $params; $data->parent = $parent; $data->pagination = $pagination; return $data; }
/** * 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); }
/** * Sends a new share to a user. * * @since 1.0 * @access public */ public function send() { FD::checkToken(); $token = JRequest::getString('token', ''); $recipients = JRequest::getVar('recipients', array()); $content = JRequest::getVar('content', ''); // Get the current view. $view = $this->getCurrentView(); // Cleaning if (is_string($recipients)) { $recipients = explode(',', FD::string()->escape($recipients)); } if (is_array($recipients)) { foreach ($recipients as &$recipient) { $recipient = FD::string()->escape($recipient); if (!JMailHelper::isEmailAddress($recipient)) { return $view->call(__FUNCTION__, false, JText::_('COM_EASYSOCIAL_SHARING_EMAIL_INVALID_RECIPIENT')); } } } $content = FD::string()->escape($content); // Check for valid data if (empty($recipients)) { return $view->call(__FUNCTION__, false, JText::_('COM_EASYSOCIAL_SHARING_EMAIL_NO_RECIPIENTS')); } if (empty($token)) { return $view->call(__FUNCTION__, false, JText::_('COM_EASYSOCIAL_SHARING_EMAIL_INVALID_TOKEN')); } $session = JFactory::getSession(); $config = FD::config(); $limit = $config->get('sharing.email.limit', 0); $now = FD::date()->toUnix(); $time = $session->get('easysocial.sharing.email.time'); $count = $session->get('easysocial.sharing.email.count'); if (is_null($time)) { $session->set('easysocial.sharing.email.time', $now); $time = $now; } if (is_null($count)) { $session->set('easysocial.sharing.email.count', 0); } $diff = $now - $time; if ($diff <= 3600) { if ($limit > 0 && $count >= $limit) { return $view->call(__FUNCTION__, false, JText::_('COM_EASYSOCIAL_SHARING_EMAIL_SHARING_LIMIT_MAXED')); } $count++; $session->set('easysocial.sharing.email.count', $count); } else { $session->set('easysocial.sharing.email.time', $now); $session->set('easysocial.sharing.email.count', 1); } $library = FD::get('Sharing'); $library->sendLink($recipients, $token, $content); $view->call(__FUNCTION__, true); }
/** * @see plugins/tienda/payment_paypalpro/library/plgTiendaPayment_Paypalpro_Processor#validateData() */ function validateData() { /* * perform initial checks */ if (!count($this->_data)) { $this->setError(JText::_('COM_TIENDA_PAYPALPRO_NO_DATA_IS_PROVIDED')); return false; } if (!JRequest::checkToken()) { $this->setError(JText::_('COM_TIENDA_INVALID_TOKEN')); return false; } // if (!$this->getSubscrTypeObj()) { // $this->setError(JText::_('COM_TIENDA_PAYPALPRO_MESSAGE_INVALID_ITEM_TYPE')); // return false; // } if (!$this->_getParam('api_username') || !$this->_getParam('api_password') || !$this->_getParam('api_signature')) { $this->setError(JText::_('COM_TIENDA_PAYPALPRO_MESSAGE_MERCHANT_CREDENTIALS_ARE_INVALID')); return false; } /* * do form verification to make sure information is both present and valid */ // check required fields foreach ($this->_required as $required_field) { if (empty($this->_data[$required_field])) { $this->setError(JText::_('COM_TIENDA_PAYPALPRO_MESSAGE_FILL_IN_REQUIRED_FIELDS')); return false; } } // check some specific fields if (JString::strlen($this->_data['state']) != 2) { $this->setError(JText::_('COM_TIENDA_PAYPALPRO_MESSAGE_STATE_INVALID')); return false; } $user = JFactory::getUser(); if (!$user->id) { // require email address for guest users jimport('joomla.mail.helper'); if (empty($this->_data['email']) || !JMailHelper::isEmailAddress($this->_data['email'])) { $this->setError(JText::_('COM_TIENDA_PAYPALPRO_MESSAGE_EMAIL_ADDRESS_REQUIRED')); return false; } if (TiendaHelperUser::emailExists($this->_data['email'])) { $this->setError(JText::_('COM_TIENDA_PAYPALPRO_MESSAGE_EMAIL_EXISTS')); return false; } } if (JString::strlen($this->_data['cardexp_month']) != 2 || JString::strlen($this->_data['cardexp_year']) != 4) { $this->setError(JText::_('COM_TIENDA_PAYPALPRO_MESSAGE_EXPIRATION_DATE_INVALID=')); return false; } return true; }
public function Process() { // Newsletter component disabled or not found. Aborting. if (!$this->enabled) { return true; } $config = new jNews_Config(); // Build subscriber object $subscriber = new stdClass(); // Lists $cumulative = $this->JInput->post->get("jnews_subscribe_cumulative", NULL, "int"); $checkboxes = $this->JInput->post->get("jnews_subscribe", array(), "array"); $subscriber->list_id = $cumulative ? $checkboxes : array(); // No lists selected. Skip here to avoid annoying the user with email confirmation. It is useless to confirm a subscription to no lists. if (empty($subscriber->list_id)) { return true; } // Name field may be absent. JNews will assign an empty name to the user. $subscriber->name = isset($this->FieldsBuilder->Fields['sender0']) ? $this->FieldsBuilder->Fields['sender0']['Value'] : ""; $subscriber->email = empty($this->FieldsBuilder->Fields['sender1']['Value']) ? NULL : JMailHelper::cleanAddress($this->FieldsBuilder->Fields['sender1']['Value']); // JNews saves users with empty email address, so we have to check it if (empty($subscriber->email)) { $this->logger->Write(get_class($this) . " Process(): Email address empty. User save aborted."); return true; } // It seems that $subscriber->confirmed defaults to unconfirmed if unset, so we need to read and pass the actual value from the configuration $subscriber->confirmed = !(bool) $config->get('require_confirmation'); $subscriber->receive_html = 1; // Avoid Notice: Undefined property while JNews libraries access undefined properties $subscriber->ip = jNews_Subscribers::getIP(); $subscriber->subscribe_date = jnews::getNow(); $subscriber->language_iso = "eng"; $subscriber->timezone = "00:00:00"; $subscriber->blacklist = 0; $subscriber->user_id = JFactory::getUser()->id; // Subscription $sub_id = null; jNews_Subscribers::saveSubscriber($subscriber, $sub_id, true); if (empty($sub_id)) { // User save failed. Probably email address is empty or invalid $this->logger->Write(get_class($this) . " Process(): User save failed"); return true; } // Subscribe $subscriber to $subscriber->list_id //$subscriber->id = $sub_id; // jNews_ListsSubs::saveToListSubscribers() doesn't work well. When only one list is passed to, it reads the value $listids[0], // but the element 0 is not always the first element of the array. In our case is $listids[1] //jNews_ListsSubs::saveToListSubscribers($subscriber); $this->SaveSubscription($subscriber); // Log $this->logger->Write(get_class($this) . " Process(): subscribed " . $this->FieldsBuilder->Fields['sender0']['Value'] . " (" . $this->FieldsBuilder->Fields['sender1']['Value'] . ") to lists " . implode(",", $subscriber->list_id)); return true; }
function submitinfo() { jimport('joomla.mail.helper'); $app =& JFactory::getApplication(); $params = JComponentHelper::getParams('com_redevent'); if (!$params->get('enable_moreinfo', 1)) { echo Jtext::_('COM_REDEVENT_MOREINFO_ERROR_DISABLED_BY_ADMIN'); $app->close(403); } $xref = JRequest::getInt('xref'); $email = JRequest::getVar('email'); $model = $this->getModel('details'); $details = $model->getDetails(); if ($xref && $email && JMailHelper::isEmailAddress($email)) { $mailer =& JFactory::getMailer(); $mailer->IsHTML(true); $mailer->setSubject(JText::sprintf('COM_REDEVENT_MOREINFO_MAIL_SUBJECT', $details->full_title)); $mailer->AddAddress($app->getCfg('mailfrom'), $app->getCfg('sitename')); $mailer->AddReplyTo(array($email, JRequest::getVar('name'))); $data = array(); if ($d = JRequest::getVar('name')) { $data[] = array(Jtext::_('COM_REDEVENT_MOREINFO_LABEL_NAME'), $d); } if ($d = JRequest::getVar('email')) { $data[] = array(Jtext::_('COM_REDEVENT_MOREINFO_LABEL_EMAIL'), $d); } if ($d = JRequest::getVar('company')) { $data[] = array(Jtext::_('COM_REDEVENT_MOREINFO_LABEL_COMPANY'), $d); } if ($d = JRequest::getVar('phonenumber')) { $data[] = array(Jtext::_('COM_REDEVENT_MOREINFO_LABEL_PHONENUMBER'), $d); } if ($d = JRequest::getVar('comments')) { $data[] = array(Jtext::_('COM_REDEVENT_MOREINFO_LABEL_COMMENTS'), str_replace("\n", "<br/>", $d)); } $table = '<table>'; foreach ($data as $d) { $table .= '<tr><td>' . $d[0] . '</td><td>' . $d[1] . '</td></tr>'; } $table .= '</table>'; $link = JRoute::_(JURI::base() . RedeventHelperRoute::getDetailsRoute($details->did, $details->xslug)); $link = JHTML::link($link, $details->full_title); $body = JText::sprintf('COM_REDEVENT_MOREINFO_MAIL_BODY', $link, $table); $mailer->setBody($body); $mailer->send(); } // confirm sending JRequest::setVar('view', 'moreinfo'); Jrequest::setVar('layout', 'final'); $this->display(); }
/** * Display the view * * @return mixed False on error, null otherwise. */ public function display($tpl = null) { $app = JFactory::getApplication(); $params = $app->getParams(); // Get some data from the models $state = $this->get('State'); $items = $this->get('Items'); $category = $this->get('Category'); $children = $this->get('Children'); $parent = $this->get('Parent'); $pagination = $this->get('Pagination'); // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseWarning(500, implode("\n", $errors)); return false; } // Check whether category access level allows access. $user = JFactory::getUser(); $groups = $user->getAuthorisedViewLevels(); // Prepare the data. // Compute the contact slug. for ($i = 0, $n = count($items); $i < $n; $i++) { $item =& $items[$i]; $item->slug = $item->alias ? $item->id . ':' . $item->alias : $item->id; $temp = new JRegistry(); $temp->loadString($item->params); $item->params = clone $params; $item->params->merge($temp); if ($item->params->get('show_email', 0) == 1) { $item->email_to = trim($item->email_to); if (!empty($item->email_to) && JMailHelper::isEmailAddress($item->email_to)) { $item->email_to = JHtml::_('email.cloak', $item->email_to); } else { $item->email_to = ''; } } } // Escape strings for HTML output $this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx')); $maxLevel = $params->get('maxLevel', -1); $this->maxLevel =& $maxLevel; $this->state =& $state; $this->items =& $items; $this->category =& $category; $this->children =& $children; $this->params =& $params; $this->parent =& $parent; $this->pagination =& $pagination; $this->_prepareDocument(); parent::display($tpl); }
public function check() { // get fieldtype $q = ' SELECT fieldtype FROM #__rwf_fields WHERE id = ' . $this->_db->Quote($this->field_id); $this->_db->setQuery($q, 0, 1); $fieldtype = $this->_db->loadResult(); if ($fieldtype == 'recipients') { jimport('joomla.mail.helper'); if (!JMailHelper::isEmailAddress($this->value)) { $this->setError(JText::_('COM_REDFORM_INVALID_EMAIL_FORMAT')); return false; } } return true; }
public function Process() { // Newsletter component disabled or not found. Aborting. if (!$this->enabled) { return true; } //$config = acymailing_config(); // Lists $cumulative = $this->JInput->post->get("acymailing_subscribe_cumulative", NULL, "int"); $checkboxes = array(FAcyMailing::subscribe => $this->JInput->post->get("acymailing_subscribe", array(), "array")); $lists = $cumulative ? $checkboxes : array(); // When subscription requires confirmation (double opt-in) AcyMailing sends a confirmation request to the user as soon as the user himself is saved. $userClass->save($subscriber) // Even in case of no list selected the user will be annoyed with a confirmation email // The confirmation status doesn't depend on the lists, which will be passed to AcyMailing only a few lines later. $userClass->saveSubscription($sub_id, $newSubscription) if (empty($lists[FAcyMailing::subscribe])) { return true; } // Build subscriber object $subscriber = new stdClass(); // Name field may be absent. AcyMailing will guess the user's name from his email address $subscriber->name = isset($this->FieldsBuilder->Fields['sender0']) ? $this->FieldsBuilder->Fields['sender0']['Value'] : ""; // AcyMailing refuses to save the user (return false) if the email address is empty, so we don't care to check it $subscriber->email = empty($this->FieldsBuilder->Fields['sender1']['Value']) ? NULL : JMailHelper::cleanAddress($this->FieldsBuilder->Fields['sender1']['Value']); $userClass = acymailing_get('class.subscriber'); $userClass->checkVisitor = false; // Add or update the user $sub_id = $userClass->save($subscriber); if (empty($sub_id)) { // User save failed. Probably email address is empty or invalid $this->logger->Write(get_class($this) . " Process(): User save failed"); return true; } // When in mode "one checkbox for each list" and no lists selected the code above produce an SQL error because passes an empty array to saveSubscription() $newSubscription = array(); foreach ($lists[FAcyMailing::subscribe] as $listId) { $newList = array(); $newList['status'] = FAcyMailing::subscribe; $newSubscription[$listId] = $newList; } if (!empty($newSubscription)) { $userClass->saveSubscription($sub_id, $newSubscription); } // implode() doesn't accept NULL values :( @$lists[FAcyMailing::subscribe] or $lists[FAcyMailing::subscribe] = array(); // Log $this->logger->Write(get_class($this) . " Process(): subscribed " . $this->FieldsBuilder->Fields['sender0']['Value'] . " (" . $this->FieldsBuilder->Fields['sender1']['Value'] . ") to lists " . implode(",", $lists[FAcyMailing::subscribe])); return true; }
function check() { if (JFilterInput::checkAttribute(array('href', $this->website))) { $this->setError(JText::_('Please provide a valid URL')); return false; } // check for http on website if (strlen($this->website) > 0 && !(eregi('http://', $this->website) || eregi('https://', $this->website) || eregi('ftp://', $this->website))) { $this->website = 'http://' . $this->website; } if (!JMailHelper::isEmailAddress($this->emailid)) { $this->setError(JText::_('Please provide a valid EmailID for company.')); return false; } return true; }
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 _getEmailsToSend() { if (empty($this->_emails)) { jimport('joomla.mail.helper'); $params =& $this->_getParams(); $emails = trim($params->get('alerts_mail_destination'), ", \r\n"); $emails = explode(',', $emails); $validEmails = array(); foreach ($emails as $k => $v) { $v = trim($v, ", \r\n"); if (JMailHelper::isEmailAddress($v)) { $validEmails[] = $v; } } $this->_emails = $validEmails; } return $this->_emails; }
public function Process() { $mail = JFactory::getMailer(); $this->set_from($mail); $this->set_to($mail, "to_address", "addRecipient"); $this->set_to($mail, "cc_address", "addCC"); $this->set_to($mail, "bcc_address", "addBCC"); $mail->setSubject(JMailHelper::cleanSubject($this->Params->get("email_subject", ""))); $body = $this->body(); $body .= $this->attachments($mail); $body .= PHP_EOL; $body .= $this->Application->getCfg("sitename") . " - " . $this->CurrentURL() . PHP_EOL; $body .= "Client: " . $this->ClientIPaddress() . " - " . $_SERVER['HTTP_USER_AGENT'] . PHP_EOL; $body = JMailHelper::cleanBody($body); $mail->setBody($body); $this->Logger->Write("---------------------------------------------------" . PHP_EOL . $body); return $this->send($mail); }
/** * @brief Verifica que los datos sean validos */ public function check() { // Check if the order already exists mams.827 // Se valida que el correo sea valido if (isset($this->email) && $this->email != '') { if (!JMailHelper::isEmailAddress($this->email)) { $this->setError(JText::_('ASOM_EMAIL_ERROR')); return false; } } // Se valida el valor total de la orden, el cual debe coincidir con el detalle de la misma /*if($this->total != ($this->fare + $this->taxes + $this->fare_ta + $this->taxes_ta)) { $this->setError(JText::_('ASOM_TOTAL_ERROR')); return false; }*/ $mivalor = $this->fare + $this->taxes + $this->fare_ta + $this->taxes_ta; if ((int) $this->total != (int) $mivalor) { $this->setError(JText::_('ASOM_TOTAL_ERROR')); return false; } // Si es una orden nueva y el campo estado esta vacio se coloca el por defecto if ($this->id == 0 && $this->status == null) { $db = $this->getDBO(); $query = $db->getQuery(true); $query->select('id'); $query->from('#__aom_statuses'); $query->where('default_status = 1'); $db->setQuery($query); $status = $db->loadResult(); if ($status == '') { $this->setError(JText::_('ASOM_DEFAULT_STATUS')); return false; } $this->status = $status; } // Se coloca la fecha del sistema if ($this->id == 0) { $date = JFactory::getDate(); $this->fecsis = $date->toSql(); } return true; }
/** * @param JMail $mail * @param array $receivers * * @return boolean */ public static function send(JMail $mail, array $receivers) { $config = KunenaFactory::getConfig(); if (!empty($config->email_recipient_count)) { $email_recipient_count = $config->email_recipient_count; } else { $email_recipient_count = 1; } $email_recipient_privacy = $config->get('email_recipient_privacy', 'bcc'); // If we hide email addresses from other users, we need to add TO address to prevent email from becoming spam. if ($email_recipient_count > 1 && $email_recipient_privacy == 'bcc' && JMailHelper::isEmailAddress($config->get('email_visible_address'))) { $mail->AddAddress($config->email_visible_address, JMailHelper::cleanAddress($config->board_title)); // Also make sure that email receiver limits are not violated (TO + CC + BCC = limit). if ($email_recipient_count > 9) { $email_recipient_count--; } } $chunks = array_chunk($receivers, $email_recipient_count); $success = true; foreach ($chunks as $emails) { if ($email_recipient_count == 1 || $email_recipient_privacy == 'to') { echo 'TO '; $mail->ClearAddresses(); $mail->addRecipient($emails); } elseif ($email_recipient_privacy == 'cc') { echo 'CC '; $mail->ClearCCs(); $mail->addCC($emails); } else { echo 'BCC '; $mail->ClearBCCs(); $mail->addBCC($emails); } try { $mail->Send(); } catch (Exception $e) { $success = false; JLog::add($e->getMessage(), JLog::ERROR, 'kunena'); } } return $success; }