0) {
$iVisitorID = (isMember() || isAdmin()) ? (int)$_COOKIE['memberID'] : 0;
if($iVisitorID > 0) {
$aVisitorInfo = getProfileInfo($iVisitorID);
$sVisitorName = $aVisitorInfo['NickName'];
$sVisitorEmail = $aVisitorInfo['Email'];
}
}
// --------------- GET/POST actions
$tell_friend_text = '';
if($_POST['submit_send']) {
$tell_friend_text = SendTellFriend() ? MsgBox(_t("_Email was successfully sent")) : MsgBox(_t("_Email sent failed"));
}
// --------------- page components
$sYEmlNotValidC = _t('_Incorrect Email');
$sFEmlNotValidC = $sYEmlNotValidC . ' (' . _t('_Friend email') . ')';
$sCaption = ($profileID) ? _t('_TELLAFRIEND2', $site['title']) : _t('_TELLAFRIEND', $site['title']);
$aForm = array(
'form_attrs' => array(
'id' => 'invite_friend',
'name' => 'invite_friend',
'action' => $_SERVER['PHP_SELF'],
'method' => 'post',
'enctype' => 'multipart/form-data',
'onsubmit' => "var feml = document.forms['invite_friend'].friends_emails; var yeml = document.forms['invite_friend'].email; var bRet = true; if(emailCheck(yeml.value)==false) { alert('{$sYEmlNotValidC}'); bRet = false; } if (emailCheck(feml.value)==false) { alert('{$sFEmlNotValidC}'); bRet = false; } return bRet; "
),
'inputs' => array (
'header1' => array(
'type' => 'block_header',
'caption' => $sCaption,
),
'id' => array(
'type' => 'hidden',
'name' => 'ID',
'value' => $profileID
),
'name' => array(
'type' => 'text',
'name' => 'name',
'caption' => _t("_Your name"),
'value' => $sVisitorName
),
'email' => array(
'type' => 'text',
'name' => 'email',
'caption' => _t("_Your email"),
'value' => $sVisitorEmail
),
'friends_emails' => array(
'type' => 'text',
'name' => 'friends_emails',
'caption' => _t("_Friend email"),
'value' => ''
),
'submit_send' => array(
'type' => 'submit',
'name' => 'submit_send',
'value' => _t("_Send Letter"),
),
)
);
$oForm = new BxTemplFormView($aForm);
$_ni = $_page['name_index'];
$_page_cont[$_ni]['page_code'] = $tell_friend_text . $oForm->getCode();
// --------------- [END] page components
PageCode();
// --------------- page components functions
/**
* send "tell a friend" email
*/
function SendTellFriend() {
global $profileID;
$iVisitorID = (isMember() || isAdmin()) ? (int)$_COOKIE['memberID'] : 0;
if ( strlen( trim($_POST['friends_emails']) ) <= 0 )
return 0;
if ( strlen( trim($_POST['email']) ) <= 0 )
return 0;
$rEmailTemplate = new BxDolEmailTemplates();
if ( $profileID )
{
$aTemplate = $rEmailTemplate -> getTemplate( 't_TellFriendProfile', $profileID ) ;
}
else
{
$aTemplate = $rEmailTemplate -> getTemplate( 't_TellFriend' ) ;
}
$recipient = $_POST['friends_emails'];
$headers .= "From: =?UTF-8?B?" . base64_encode( $_POST['name'] ) . "?= <{$_POST['email']}>";
$headers = "MIME-Version: 1.0\r\n" . "Content-type: text/html; charset=UTF-8\r\n" . $headers;
$headers2 .= "-f{$_POST['email']}";
$sLinkAdd = ($iVisitorID) ? 'idFriend='. $iVisitorID : '';
if ( $profileID )
$Link = getProfileLink($profileID, $sLinkAdd);
else
$Link = BX_DOL_URL_ROOT . ( $sLinkAdd ? "?{$sLinkAdd}" : '' );
$message = $aTemplate['Body'];
$message = str_replace( "", $Link, $message );
$message = str_replace( "", $_POST['name'], $message );
return mail( $recipient, $aTemplate['Subject'], $message, $headers, $headers2 );
}
?>