<?php
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
$document =& JFactory::getDocument();
$document->addStyleSheet(JURI::root() . 'modules/formulario_contacto/css/style.css');
//Email Parameters
$recipient = $params->get('email_recipient', '');
$fromName = @$params->get('from_name');
$fromEmail = @$params->get('from_email', '
[email protected]');
// Text Parameters
$myNameLabel = $params->get('name_label', 'Name:');
$myEmailLabel = $params->get('email_label', 'Email:');
$myTelephoneLabel = $params->get('telephone_label', 'Telephone:');
$mySubjectLabel = $params->get('subject_label', 'Subject:');
$myMessageLabel = $params->get('message_label', 'Message:');
$buttonText = $params->get('button_text', 'Send Message');
$pageText = $params->get('page_text', 'Thank you for your contact.');
$errorText = $params->get('error_text', 'Your message could not be sent. Please try again.');
$noEmail = $params->get('no_email', 'Please write your email');
$invalidEmail = $params->get('invalid_email', 'Please write a valid email');
$pre_text = $params->get('pre_text', '');
// Size and Color Parameters
$label_pos = $params->get('label_pos', '0');
// URL Parameters
$exact_url = $params->get('exact_url', true);
$disable_https = $params->get('disable_https', true);
$fixed_url = $params->get('fixed_url', true);
$myFixedURL = $params->get('fixed_url_address', '');
// Module Class Suffix Parameter
$mod_class_suffix = $params->get('moduleclass_sfx', '');
if ($fixed_url) {
$url = $myFixedURL;
}
else {
if (!$exact_url) {
$url = JURI::current();
}
else {
if (!$disable_https) {
$url = (!empty($_SERVER['HTTPS'])) ? "https://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'] : "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
}
else {
$url = "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
}
}
}
$url = htmlentities($url, ENT_COMPAT, "UTF-8");
$myError = '';
$CORRECT_NAME = '';
$CORRECT_EMAIL = '';
$CORRECT_SUBJECT = '';
$CORRECT_MESSAGE = '';
if (isset($_POST["rp_email"])) {
$CORRECT_SUBJECT = htmlentities($_POST["rp_subject"], ENT_COMPAT, "UTF-8");
$CORRECT_MESSAGE = htmlentities($_POST["rp_message"], ENT_COMPAT, "UTF-8");
$CORRECT_NAME = htmlentities($_POST["rp_name"], ENT_COMPAT, "UTF-8");
// check email
if ($_POST["rp_email"] === "") {
$myError = '<div class="pop-up">' . '<p>' . $noEmail . '</p>' . '</div>';
}
if (!preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/", strtolower($_POST["rp_email"]))) {
$myError = '<div class="pop-up">' . '<p>' . $invalidEmail . '</p>' . '</div>';
}
else {
$CORRECT_EMAIL = htmlentities($_POST["rp_email"], ENT_COMPAT, "UTF-8");
}
if ($myError == '') {
$mySubject = $_POST["rp_subject"];
$myMessage = 'Remitente: '. $_POST["rp_name"] ."\n\n" . 'E-Mail: '. $_POST["rp_email"] ."\n\n". 'Telf.: '. $_POST["rp_telephone"] ."\n\n". $_POST["rp_message"];
$mailSender = &JFactory::getMailer();
$mailSender->addRecipient($recipient);
$mailSender->setSender(array($fromEmail,$fromName));
$mailSender->addReplyTo(array( $_POST["rp_email"], '' ));
$mailSender->setSubject($mySubject);
$mailSender->setBody($myMessage);
if ($mailSender->Send() !== true) {
$myReplacement = '<div class="pop-up">' . '<p>' . $errorText . '</p>' . '</div>';
print $myReplacement;
return true;
}
else {
$myReplacement = '<div class="pop-up">' . '<p>' . $pageText . '</p>' . '</div>';
print $myReplacement;
}
}
} // end if posted
// check recipient
if ($recipient === "") {
$myReplacement = '<div class="pop-up">' . '<p>No se ha especificado destinatario</p>' . '</div>';
print $myReplacement;
return true;
}
print '<style type="text/css"><!--' . $addcss . '--></style>';
print '<div class="rapid_contact ' . $mod_class_suffix . '"><form action="' . $url . '" method="post">' . "\n" .
'<div class="rapid_contact intro_text ' . $mod_class_suffix . '">'.$pre_text.'</div>' . "\n";
if ($myError != '') {
print $myError;
}
print '<div id="forminfe">';
// print name input
print '<div class="forminfe">' . '<label for="name">' . $myNameLabel . '</label>' . '<input class="rapid_contact inputbox ' . $mod_class_suffix . '" type="text" name="rp_name" size="' . '" value="'.$CORRECT_NAME.'"/></div>' . "\n";
// print email input
print '<div class="forminfe">' . '<label for="email">' . $myEmailLabel . '</label>' . '<input class="rapid_contact inputbox ' . $mod_class_suffix . '" type="text" name="rp_email" value="'.$CORRECT_EMAIL.'"/></div>' . "\n";
// print name input
print '<div class="forminfe">' . '<label for="telephone">' . $myTelephoneLabel . '</label>' . '<input class="rapid_contact inputbox ' . $mod_class_suffix . '" type="text" name="rp_telephone"' . '"/></div>' . "\n";
// print subject input
print '<div class="forminfe">' . '<label for="name">' . $mySubjectLabel . '</label>' . '<input class="rapid_contact inputbox ' . $mod_class_suffix . '" type="text" name="rp_subject"' . '" value="'.$CORRECT_SUBJECT.'"/></div>' . "\n";
// print message input
print '<div class="forminfe">' . '<label for="mensaje">' . $myMessageLabel . '</label>' . '<textarea class="rapid_contact textarea ' . $mod_class_suffix . '" name="rp_message"' . '" rows="4">'.$CORRECT_MESSAGE.'</textarea></div>' . "\n";
// print button
print '<div class="forminfe"><input class="rapid_contact button ' . $mod_class_suffix . '" type="submit" value="' . $buttonText . '"/></div></div></form></div>' . "\n";
return true;