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] ) ? "
" . $dfcontact["pageTitle"][$langId] . "
\n\n" : "" ); # Start content echo "
\n\n"; # Check existance of destination mail if ( empty( $dfcontact["destinationMail"] ) ) { echo '

' . JText::_( 'COM_DFCONTACT_FORM_NO_DESTINATION_MAIL') . "

\n\n"; } # Start sending process if there is data elseif ( !empty( $_REQUEST["submit"] ) ) { // create backlink $backlink = '
' . "\n"; $dfcontact['field'] = ( is_array( $dfcontact['field'] ) ? $dfcontact['field'] : array() ); reset( $dfcontact['field'] ); while ( list( $key, $value ) = each( $dfcontact['field'] ) ) { if ( empty( $value['display'] ) ) { continue; } $backlink .= '' . "\n"; } $backlink .= '' . "\n"; $backlink .= '' . "\n"; $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_' . strtoupper($key) ) . '
  • ' . "\n"; } } # captcha if (DFCONTACT_CAPTCHA_ENABLED) { $captchaValid = null; if ( $dfcontact['captcha'] == 'com_securityimages' ) { $captchaTest = JRequest::getVar('captcha', false, '', 'CMD'); $app = &JFactory::getApplication(); $app->triggerEvent('onSecurityImagesCheck', array($captchaTest, &$captchaValid)); } else if ( $dfcontact['captcha'] == 'recaptcha' ) { require_once( JPATH_SITE . DS . 'components' . DS . 'com_dfcontact' . DS . 'recaptcha' . DS . 'recaptchalib.php' ); $resp = recaptcha_check_answer ($dfcontact['recaptcha_private_key'], $_SERVER["REMOTE_ADDR"], $_REQUEST["recaptcha_challenge_field"], $_REQUEST["recaptcha_response_field"] ); $captchaValid = $resp->is_valid; } if ( !$captchaValid ) { $missingFields .= '
  • ' . JTEXT::_( 'COM_DFCONTACT_FORM_CAPTCHA_ERROR') . "
  • \n"; } } # display errors if ( $missingFields ) { echo '

    ' . JText::_( 'COM_DFCONTACT_FORM_MISSING_FIELDS') . '

    ' . "\n"; echo "\n"; echo $backlink; } elseif ( !empty( $_REQUEST['email'] ) && !dfcontact_validMail( $_REQUEST['email'] ) ) { echo '

    ' . JText::_( 'COM_DFCONTACT_FORM_ENTER_VALID_MAIL') . '

    ' . "\n"; echo $backlink; } else { # create html with user vars $sentVars = ''; $dfcontact['field'] = ( is_array( $dfcontact['field'] ) ? $dfcontact['field'] : array() ); reset( $dfcontact['field'] ); while( list( $key, $value ) = each( $dfcontact['field'] )) { if ( empty( $value['display'] ) || ( empty( $_REQUEST[$key] ) && $key != 'checkbox' ) ) { continue; } $sentVars .= ''; $sentVars .= '' . "\n"; $sentVars .= '' . "\n"; $sentVars .= '' . "\n"; } $sentVars .= '
    ' . JText::_( 'COM_DFCONTACT_' . strtoupper($key) ) . ':' . nl2br( htmlspecialchars( stripslashes( $key == 'checkbox' ? ( !empty( $_REQUEST[$key] ) && $_REQUEST[$key] ? JText::_( 'COM_DFCONTACT_YES') : JText::_( 'COM_DFCONTACT_NO') ) : ( !empty( $_REQUEST[$key]) ? $_REQUEST[$key] : '' ) ) ) ) . '
    '; # create html with server vars $serverVars = array( JText::_( 'COM_DFCONTACT_FORM_DATE') => date( JText::_( 'COM_DFCONTACT_FORM_DATE_FORMAT') ), JText::_( 'COM_DFCONTACT_FORM_SENT_URL') => (!empty($_SERVER['SERVER_NAME']) && !empty($_SERVER['REQUEST_URI']) ? '' . 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'] . '' : ''), JText::_( 'COM_DFCONTACT_FORM_USERAGENT') => (!empty($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ''), JText::_( 'COM_DFCONTACT_FORM_HOST') => (!empty($_SERVER['REMOTE_NAME']) ? $_SERVER['REMOTE_NAME'] : @gethostbyaddr( (!empty($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '') )), JText::_( 'COM_DFCONTACT_FORM_IP') => (!empty($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : ''), JText::_( 'COM_DFCONTACT_FORM_PORT') => (!empty($_SERVER['REMOTE_PORT']) ? $_SERVER['REMOTE_PORT'] : ''), ); $sentVarsHidden = ''; reset( $serverVars ); while( list( $key, $value ) = each( $serverVars ) ) { $sentVarsHidden .= ''; $sentVarsHidden .= '' . "\n"; $sentVarsHidden .= '' . "\n"; $sentVarsHidden .= '' . "\n"; } $sentVarsHidden .= '
    ' . ucfirst( nl2br( htmlspecialchars( stripslashes( $key ) ) ) ) . ':' . nl2br( stripslashes( $value ) ) . '
    '; # create html part $html = "\n"; $html .= "\n"; $html .= "\n"; $html .= '

    ' . 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"; echo "\n"; // address ob_start(); $addressFormat = trim( $dfcontact['addressFormat']['templates'][$dfcontact['addressFormat']['selected']] ); $addressFormatSplit = preg_split('/\n/', $addressFormat); $lastCellEmpty = false; reset($addressFormatSplit); while (list($key, $line) = each($addressFormatSplit)) { // extract placeholders and get template string $placeholders = array(); if (!preg_match_all('/\[([^\]]*)\]/', $line, $placeholders)) { if (!$lastCellEmpty) { $lastCellEmpty = true; echo "\n"; } continue; } $placeholders = $placeholders[1]; $line = preg_replace("/\{[^\}]*\}/", '', $line); // keys $keyCell = ''; $nonDisplayableKeys = array( 'company', 'title', 'name', 'position', 'addition', 'street', 'streetno', 'postbox', 'zip', 'city', 'state', 'country', ); $keys = array(); foreach ($placeholders as $ph) { $ph = strtolower($ph); if (!in_array($ph, $nonDisplayableKeys)) { array_push($keys, trim(JText::_('COM_DFCONTACT_'.strtoupper($ph)))); } } $keyCell = join('/', $keys); // values foreach ($placeholders as $ph) { $item = ''; if (!empty($dfcontact['field'][strtolower($ph)]['value'])) { $item = trim($dfcontact['field'][strtolower($ph)]['value']); } // special fields if ($item) { switch ($ph) { case 'EMAIL': $item = ( !empty( $dfcontact['links']) ? '' . dfcontact_asciiEncodeString( $dfcontact['field']['email']['value'] ) . '' : dfcontact_asciiEncodeString( $dfcontact['field']['email']['value'] ) ); break; case 'ICQ': $item = ( !empty( $dfcontact['links']) ? '' . dfcontact_asciiEncodeString( $dfcontact['field']['icq']['value'] ) . '' : dfcontact_asciiEncodeString( $dfcontact['field']['icq']['value'] ) ) . ( !empty($dfcontact['onlineStatus']) ? ' ' : ''); break; case 'AIM': $item = ( !empty( $dfcontact['links'] ) ? '' . dfcontact_asciiEncodeString( $dfcontact['field']['aim']['value'] ) . '' : dfcontact_asciiEncodeString( $dfcontact['field']['aim']['value'] ) ); break; case 'YAHOO': $item = ( !empty( $dfcontact['links']) ? '' . dfcontact_asciiEncodeString( $dfcontact['field']['yahoo']['value'] ) . '' : dfcontact_asciiEncodeString( $dfcontact['field']['yahoo']['value'] ) ) . ( !empty($dfcontact['onlineStatus']) ? ' ' : ''); break; case 'MSN': $item = dfcontact_asciiEncodeString( $dfcontact['field']['msn']['value'] ); break; case 'SKYPE': $item = ( !empty( $dfcontact['links']) ? '' . dfcontact_asciiEncodeString( $dfcontact['field']['skype']['value'] ) . '' : dfcontact_asciiEncodeString( $dfcontact['field']['skype']['value'] ) ) . ( !empty($dfcontact['onlineStatus']) ? ' My status' : ''); break; case 'LINKEDIN': $item = ( !empty( $dfcontact['links'] ) ? '' . dfcontact_asciiEncodeString( $dfcontact['field']['linkedin']['value'] ) . '' : dfcontact_asciiEncodeString( $dfcontact['field']['linkedin']['value'] ) ); break; case 'XING': $item = ( !empty( $dfcontact['links'] ) ? '' . dfcontact_asciiEncodeString( $dfcontact['field']['xing']['value'] ) . '' : dfcontact_asciiEncodeString( $dfcontact['field']['xing']['value'] ) ); break; case 'FACEBOOK': $item = ( !empty( $dfcontact['links'] ) ? '' . dfcontact_asciiEncodeString( $dfcontact['field']['facebook']['value'] ) . '' : dfcontact_asciiEncodeString( $dfcontact['field']['facebook']['value'] ) ); break; case 'GOOGLEPLUS': $item = ( !empty( $dfcontact['links'] ) ? '' . dfcontact_asciiEncodeString( $dfcontact['field']['googleplus']['value'] ) . '' : dfcontact_asciiEncodeString( $dfcontact['field']['googleplus']['value'] ) ); break; case 'TWITTER': $item = ( !empty( $dfcontact['links'] ) ? '' . dfcontact_asciiEncodeString( $dfcontact['field']['twitter']['value'] ) . '' : dfcontact_asciiEncodeString( $dfcontact['field']['twitter']['value'] ) ); break; } } $line = str_replace("[$ph]", $item, $line); } $valueCell = trim($line); $valueCellClean = str_replace(array('.',',',';'), "", $valueCell); // display line if ( !empty( $valueCellClean ) ) { $lastCellEmpty = false; echo "\n"; echo '\n"; echo '\n"; echo "\n"; } } // prevent empty last row $emptyLine = ''; $buffer = trim(ob_get_contents()); if (substr($buffer, strlen($buffer) - strlen($emptyLine)) == $emptyLine) { $buffer = substr($buffer, 0, strlen($buffer) - strlen($emptyLine)); } ob_end_clean(); echo $buffer; echo '' . "\n"; // form text if ( !empty( $dfcontact['formText'] ) && !empty( $dfcontact['formText'][$langId] ) ) { echo '' . "\n"; echo '' . "\n"; } // contact form $mandatoryFields = 0; $lastCellEmpty = false; reset($addressFormatSplit); while (list($key, $line) = each($addressFormatSplit)) { // extract placeholders and get template string $placeholders = array(); if (!preg_match_all('/\[([^\]]*)\](\{.?\})?/', $line, $placeholders)) { if (!$lastCellEmpty) { $lastCellEmpty = true; echo "\n\n"; } continue; } $sizes = $placeholders[2]; $placeholders = $placeholders[1]; // keys $keyCell = ''; $nonDisplayableKeys = array( 'message', 'checkbox', 'mandatory', ); $keys = array(); foreach ($placeholders as $ph) { $ph = strtolower($ph); if (!in_array($ph, $nonDisplayableKeys)) { array_push($keys, '')); } } $keyCell = join('/', $keys); // calculate field sizes $fields = 0; $normalFields = 0; $specialsSizes = 0; $fullSize = 15; for ($i = 0; $i < sizeof($placeholders); $i++) { $ph = strtolower($placeholders[$i]); $specialSize = str_replace('{', '', str_replace('}', '', $sizes[$i])); if (!empty($dfcontact['field'][$ph]['display']) && !$specialSize) { $normalFields++; $fields++; } else if (!empty($dfcontact['field'][$ph]['display'])) { $specialsSizes += $specialSize; $fields++; } } if ($normalFields) { $normalSize = ($fullSize - $specialsSizes - (($fields - 1) * (strpos($_SERVER["HTTP_USER_AGENT"], 'Firefox') > 0 ? 0.3 : 0.4))) / $normalFields; $normalSize = number_format($normalSize, 2, ".", ""); } else { $normalSize = 15; } // values $phs = array(); $line = ''; for ($i = 0; $i < sizeof($placeholders); $i++) { $ph = strtolower($placeholders[$i]); $specialSize = str_replace('{', '', str_replace('}', '', $sizes[$i])); if (!empty($dfcontact['field'][$ph]['display'])) { array_push($phs, $ph); if ( !empty( $dfcontact['field'][$ph]['duty'] ) ) { $mandatoryFields++; } switch($ph) { case 'message' : $line .= '' . ( !empty( $dfcontact['field'][$ph]['duty'] ) ? '*' : ''); break; case 'checkbox' : $line .= '' . ( !empty( $dfcontact['field'][$ph]['duty'] ) ? ' *' : ''); break; default: $line .= '' . ( !empty( $dfcontact['field'][$ph]['duty'] ) ? '*' : ''); if ($ph == 'geocoordinates') { $line .= ''; $line .= ''; } } } elseif ( $ph == 'captcha' && DFCONTACT_CAPTCHA_ENABLED ) { array_push($phs, $ph); $mandatoryFields++; $line .= JTEXT::_( 'COM_DFCONTACT_FORM_CAPTCHA_INFO') . '
    '; if ( $dfcontact['captcha'] == 'com_securityimages' ) { $captchaImageUrl = 'index.php?option=com_dfcontact&displayCaptcha=true'; $line .= '
    *'; } else if ( $dfcontact['captcha'] == 'recaptcha' ) { $line .= ''; require_once( JPATH_SITE . DS . 'components' . DS . 'com_dfcontact' . DS . 'recaptcha' . DS . 'recaptchalib.php' ); $line .= recaptcha_get_html($dfcontact['recaptcha_public_key']); } } elseif ( $ph == 'mandatory' ) { $line .= JText::_( 'COM_DFCONTACT_FORM_MANDATORY'); } } $valueCell = trim($line); // display line if ($valueCell) { $lastCellEmpty = false; echo "\n"; echo '\n"; echo '\n"; echo "\n"; } } // submit button & form end echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo '' . "\n"; echo "\n"; echo "
     " . trim($line) . "
    ' . $keyCell . " ' . $valueCell . "
     
     
     
    ' . $dfcontact['formText'][$langId] . '
     
     " . trim($line) . "
    ' . $keyCell . " ' . $valueCell; foreach ($phs as $ph) { echo "\n"; } echo "
     
    \n"; echo '' . "\n"; echo "
    \n"; ?> Created using the Joomla DFContact component. \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; } ?>