getValue('config.language'); // no direct access defined('_JEXEC') or die('Restricted access'); // Load configuration data include( JPATH_SITE . DS . 'administrator' . DS . 'components' . DS . 'com_dfcontact' . DS . 'config.dfcontact.php' ); # Display com_securityimages captcha define('DFCONTACT_CAPTCHA_ENABLED' , !empty( $dfcontact['captcha'] ) && ( ( $dfcontact['captcha'] == 'com_securityimages' && file_exists( JPATH_SITE . DS . 'administrator' . DS . 'components' . DS . 'com_securityimages' ) ) || ($dfcontact['captcha'] == 'recaptcha' && file_exists( JPATH_SITE . DS . 'components' . DS . 'com_dfcontact' . DS . 'recaptcha' . DS . 'recaptchalib.php' ) ) ) ); if ( DFCONTACT_CAPTCHA_ENABLED && !empty( $_REQUEST["displayCaptcha"] ) ) { $check = null; $app = &JFactory::getApplication(); $app->triggerEvent('onSecurityImagesDisplay', array($check)); if (!$check) { echo "Creation of captcha failed!"; } exit; } # Display title echo ( !empty( $dfcontact["pageTitle"] ) && !empty( $dfcontact["pageTitle"][$langId] ) ? "
' . JText::_( 'COM_DFCONTACT_FORM_NO_DESTINATION_MAIL') . "
\n\n"; } # Start sending process if there is data elseif ( !empty( $_REQUEST["submit"] ) ) { // create backlink $backlink = '' . "\n"; # check for neccessary vars $missingFields = ''; $dfcontact['field'] = ( !empty( $dfcontact['field'] ) && is_array( $dfcontact['field'] ) ? $dfcontact['field'] : array() ); reset( $dfcontact['field'] ); while ( list( $key, $value ) = each ( $dfcontact['field'] )) { if ( !empty( $value['display'] ) && !empty( $value['duty'] ) && empty( $_REQUEST[$key] ) ) { $missingFields .= '' . JText::_( 'COM_DFCONTACT_FORM_MISSING_FIELDS') . '
' . "\n"; echo "' . JText::_( 'COM_DFCONTACT_FORM_ENTER_VALID_MAIL') . '
' . "\n"; echo $backlink; } else { # create html with user vars $sentVars = '| ' . JText::_( 'COM_DFCONTACT_' . strtoupper($key) ) . ': | ' . "\n"; $sentVars .= '' . nl2br( htmlspecialchars( stripslashes( $key == 'checkbox' ? ( !empty( $_REQUEST[$key] ) && $_REQUEST[$key] ? JText::_( 'COM_DFCONTACT_YES') : JText::_( 'COM_DFCONTACT_NO') ) : ( !empty( $_REQUEST[$key]) ? $_REQUEST[$key] : '' ) ) ) ) . ' | ' . "\n"; $sentVars .= '
|---|
| ' . ucfirst( nl2br( htmlspecialchars( stripslashes( $key ) ) ) ) . ': | ' . "\n"; $sentVarsHidden .= '' . nl2br( stripslashes( $value ) ) . ' | ' . "\n"; $sentVarsHidden .= '
|---|
' . JText::_( 'COM_DFCONTACT_FORM_MAIL_TEXT') . '
' . "\n\n"; $html .= "$sentVars\n"; if ( !empty( $dfcontact['addServerData'] ) ) { $html .= '' . JText::_( 'COM_DFCONTACT_FORM_MAIL_TEXT_SERVER_VARS') . '
' . "\n\n"; $html .= "$sentVarsHidden\n"; } $html .= "\n"; $html .= ""; # create text part $text = trim( strip_tags( $html ) ); $text = str_replace("\n ", "\n", $text); $text = "\n" . $text; function escapeSubject($string, $prefix="=?UTF-8?Q?", $postfix="?=") { $crlf = "\n\t"; $string = preg_replace('!(\r\n|\r|\n)!', $crlf, $string) . $crlf ; $f[] = '/([\000-\010\013\014\016-\037\075\177-\377])/e' ; $r[] = "'=' . sprintf('%02X', ord('\\1'))" ; $f[] = '/([\011\040])' . $crlf . '/e' ; $r[] = "'=' . sprintf('%02X', ord('\\1')) . '" . $crlf . "'" ; $string = preg_replace($f, $r, $string); return $prefix.trim(wordwrap($string, 70 - strlen($prefix) - strlen($postfix), ' ' . $postfix . $crlf . $prefix, true)).$postfix; } # header vars $name = preg_replace('/[\r\n\t\f]/', '', ( !empty( $_REQUEST['name'] ) ? $_REQUEST['name'] : '' ) ); $email = preg_replace('/[\r\n\t\f]/', '', ( !empty( $_REQUEST['email'] ) ? $_REQUEST['email'] : '' ) ); $subject = ( function_exists( 'html_entity_decode') ? html_entity_decode( JText::_( 'COM_DFCONTACT_FORM_MAIL_SUBJECT'), ENT_COMPAT, "UTF-8" ) : JText::_( 'COM_DFCONTACT_FORM_MAIL_SUBJECT') ) . ' (' . preg_replace('/[\r\n\t\f]/', '', $_SERVER['SERVER_NAME']) . ')'; $subject = escapeSubject($subject); $name = escapeSubject($name); # load internal mail class jimport('joomla.mail.mail'); $mail = new JMail(); $app = &JFactory::getApplication(); switch ( $app->getCfg('mailer') ) { case 'smtp': $mail->useSMTP( $app->getCfg('smtpauth'), $app->getCfg('smtphost'), $app->getCfg('smtpuser'), $app->getCfg('smtppass') ); break; case 'sendmail': $mail->useSendmail( $app->getCfg('sendmail') ); break; default: break; } # Fill mail object with data $destinationEmails = preg_split('/[ ,;]/', $dfcontact['destinationMail']); foreach ( $destinationEmails as $destinationMail ) { if ( $destinationMail != '' ) { $mail->addRecipient( $destinationMail ); } } $mail->setSender( array( $app->getCfg('mailfrom'), $app->getCfg('fromname') ) ); if ( !empty( $email ) ) { $mail->addReplyTo( array($email, $name) ); } $mail->setSubject( $subject ); # Set mail body if ( !empty( $dfcontact['htmlMails'] ) ) { $mail->isHTML( true ); $mail->Body = $html; $mail->AltBody = $text; } else { $mail->Body = $text; } # Try to send email and display result $sendResult = $mail->Send(); if ( is_bool($sendResult) && $sendResult == true ) { echo '' . JText::_( 'COM_DFCONTACT_FORM_MAIL_SUCCESS') . '
' . "\n"; if ( !empty( $dfcontact['displayUserInput'] ) ) { echo '' . JText::_( 'COM_DFCONTACT_FORM_MAIL_SUBMITTED_VARS') . '
' . "\n"; echo $sentVars; } } else { echo '' . JText::_( 'COM_DFCONTACT_FORM_MAIL_ERROR') . '
' . "\n"; echo $backlink; } } } else { // info text if ( !empty( $dfcontact['infoText'] ) && !empty( $dfcontact['infoText'][$langId] ) ) { echo '' . $dfcontact['infoText'][$langId] . '
' . "\n"; } echo '\n"; ?> \n"; /** * Encodes a string into it's asci-entities. * * @static * @access public * @param string $string * @return string * @date 13:42 13.10.2005 * @version 1.0 * @status Complete */ function dfcontact_asciiEncodeString( $string ) { $result = ""; for ( $i = 0; $i < strlen( $string ); $i++ ) { $result .= "" . ord( $string[$i] ) . ";"; } return $result; } /** * Returns whether an email-adress or * a list of comma-separated email-adresses * is valid and has a valid tld (optional). * * @static * @access public * @param string $eMail eMail * @param boolean $checkTLD Check TLD-Validity? * @return boolean * @date 16:20 01.07.2005 * @version 1.0 * @status Complete */ function dfcontact_validMail($eMail, $checkTLD = false) { # list taken from: http://data.iana.org/TLD/tlds-alpha-by-domain.txt # Version 1.2, Last Updated 2005-04-29 $tlds = array("AC", "AD", "AE", "AERO", "AF", "AG", "AI", "AL", "AM", "AN", "AO", "AQ", "AR", "ARPA", "AS", "AT", "AU", "AW", "AZ", "BA", "BB", "BD", "BE", "BF", "BG", "BH", "BI", "BIZ", "BJ", "BM", "BN", "BO", "BR", "BS", "BT", "BV", "BW", "BY", "BZ", "CA", "CC", "CD", "CF", "CG", "CH", "CI", "CK", "CL", "CM", "CN", "CO", "COM", "COOP", "CR", "CU", "CV", "CX", "CY", "CZ", "DE", "DJ", "DK", "DM", "DO", "DZ", "EC", "EDU", "EE", "EG", "ER", "ES", "ET", "EU", "FI", "FJ", "FK", "FM", "FO", "FR", "GA", "GB", "GD", "GE", "GF", "GG", "GH", "GI", "GL", "GM", "GN", "GOV", "GP", "GQ", "GR", "GS", "GT", "GU", "GW", "GY", "HK", "HM", "HN", "HR", "HT", "HU", "ID", "IE", "IL", "IM", "IN", "INFO", "INT", "IO", "IQ", "IR", "IS", "IT", "JE", "JM", "JO", "JP", "KE", "KG", "KH", "KI", "KM", "KN", "KR", "KW", "KY", "KZ", "LA", "LB", "LC", "LI", "LK", "LR", "LS", "LT", "LU", "LV", "LY", "MA", "MC", "MD", "MG", "MH", "MIL", "MK", "ML", "MM", "MN", "MO", "MP", "MQ", "MR", "MS", "MT", "MU", "MUSEUM", "MV", "MW", "MX", "MY", "MZ", "NA", "NAME", "NC", "NE", "NET", "NF", "NG", "NI", "NL", "NO", "NP", "NR", "NU", "NZ", "OM", "ORG", "PA", "PE", "PF", "PG", "PH", "PK", "PL", "PM", "PN", "PR", "PRO", "PS", "PT", "PW", "PY", "QA", "RE", "RO", "RU", "RW", "SA", "SB", "SC", "SD", "SE", "SG", "SH", "SI", "SJ", "SK", "SL", "SM", "SN", "SO", "SR", "ST", "SU", "SV", "SY", "SZ", "TC", "TD", "TF", "TG", "TH", "TJ", "TK", "TL", "TM", "TN", "TO", "TP", "TR", "TT", "TV", "TW", "TZ", "UA", "UG", "UK", "UM", "US", "UY", "UZ", "VA", "VC", "VE", "VG", "VI", "VN", "VU", "WF", "WS", "YE", "YT", "YU", "ZA", "ZM", "ZW"); $eMails = preg_split( '/,/', str_replace( ", ", ",", $eMail ) ); for ( $i = 0; $i < sizeof( $eMails ); $i++ ) { # check format if ( !preg_match( "/^([a-zA-Z0-9\\+\\-\\._])+@([a-zA-Z0-9������\\-]{2,255}\\.)+([a-zA-Z]){2,6}$/" , $eMails[$i] ) ) { return false; } # check tld if( $checkTLD && !in_array( strtoupper( substr( $eMails[$i], strrpos( $eMails[$i], "." ) + 1 ) ), $tlds ) ) { return false; } } return true; } ?>