File manager - Edit - /home/jardides/www/Jardi-design/j37/plugins/pagebuilderck/contact/contacthelper.php
Back
<?php /** * @copyright Copyright (C) 2016 Cédric KEIFLIN alias ced1870 * http://www.template-creator.com * http://www.joomlack.fr * @license GNU/GPL * */ defined('_JEXEC') or die('Restricted access'); jimport('joomla.event.plugin'); require_once JPATH_SITE . '/components/com_contact/models/category.php'; require_once JPATH_SITE . '/components/com_contact/models/contact.php'; class plgPagebuilderckContactHelper { public static function processSubmit() { // Check for request forgeries. JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); $app = JFactory::getApplication(); $input = $app->input; JPluginHelper::importPlugin('captcha'); // check for the captcha validation $params = JComponentHelper::getParams('com_contact'); $plugin = JFactory::getApplication()->getParams()->get('captcha', JFactory::getConfig()->get('captcha')); $captcha = JCaptcha::getInstance($plugin, array('namespace' => 'plg_pagebuilderck_contact')); if ($captcha != null && $params->get('captcha') !== '0') { $dispatcher = JDispatcher::getInstance(); $result = $dispatcher->trigger('onCheckAnswer',$input->get('g-recaptcha-response')); if(!$result[0]){ $msg = JText::_('PLG_PAGBUILDERCK_CONTACT_INVALID_CAPTCHA'); $app->redirect(JUri::current(), $msg, 'error'); exit(); } } $model = JModelLegacy::getInstance('Contact', 'ContactModel', array('ignore_request' => true)); $stub = $input->getString('contactid'); $id = (int) $stub; // Load state from the request. // $pk = $app->input->getInt('contactid'); $model->setState('contact.id', $id); // Load the parameters. $contactparams = $app->getParams(); $model->setState('params', $contactparams); $data = $input->post->get('jform', array(), 'array'); $contact = $model->getItem($id); $params->merge($contact->params); if (!$params->get('custom_reply')) { $sent = self::_sendEmail($data, $contact, $params->get('show_email_copy')); } // Set the success message if it was a success if (!($sent instanceof Exception)) { $msg = JText::_('COM_CONTACT_EMAIL_THANKS'); } else { $msg = ''; } // Redirect if it is set in the parameters, otherwise redirect back to where we came from if ($contact->params->get('redirect')) { $app->redirect($contact->params->get('redirect'), $msg); } else { $app->redirect(JUri::current(), $msg); } } /** * Method to get a model object, loading it if required. * * @param array $data The data to send in the email. * @param stdClass $contact The user information to send the email to * @param boolean $copy_email_activated True to send a copy of the email to the user. * * @return boolean True on success sending the email, false on failure. * * @since 1.6.4 */ private static function _sendEmail($data, $contact, $copy_email_activated) { $app = JFactory::getApplication(); if ($contact->email_to == '' && $contact->user_id != 0) { $contact_user = JUser::getInstance($contact->user_id); $contact->email_to = $contact_user->get('email'); } $mailfrom = $app->get('mailfrom'); $fromname = $app->get('fromname'); $sitename = $app->get('sitename'); $name = $data['contact_name']; $email = JStringPunycode::emailToPunycode($data['contact_email']); $subject = $data['contact_subject']; $body = $data['contact_message']; // Prepare email body $prefix = JText::sprintf('COM_CONTACT_ENQUIRY_TEXT', JUri::base()); $body = $prefix . "\n" . $name . ' <' . $email . '>' . "\r\n\r\n" . stripslashes($body); $mail = JFactory::getMailer(); $mail->addRecipient($contact->email_to); $mail->addReplyTo($email, $name); $mail->setSender(array($mailfrom, $fromname)); $mail->setSubject($sitename . ': ' . $subject); $mail->setBody($body); $sent = $mail->Send(); // If we are supposed to copy the sender, do so. // Check whether email copy function activated if ($copy_email_activated == true && !empty($data['contact_email_copy'])) { $copytext = JText::sprintf('COM_CONTACT_COPYTEXT_OF', $contact->name, $sitename); $copytext .= "\r\n\r\n" . $body; $copysubject = JText::sprintf('COM_CONTACT_COPYSUBJECT_OF', $subject); $mail = JFactory::getMailer(); $mail->addRecipient($email); $mail->addReplyTo(array($email, $name)); $mail->setSender(array($mailfrom, $fromname)); $mail->setSubject($copysubject); $mail->setBody($copytext); $sent = $mail->Send(); } return $sent; } }
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0.04 |
proxy
|
phpinfo
|
Settings