| 1 | <? |
|---|
| 2 | |
|---|
| 3 | /*************************************************************************** |
|---|
| 4 | * Dolphin Smart Community Builder |
|---|
| 5 | * ----------------- |
|---|
| 6 | * begin : Mon Mar 23 2006 |
|---|
| 7 | * copyright : (C) 2006 BoonEx Group |
|---|
| 8 | * website : http://www.boonex.com/ |
|---|
| 9 | * This file is part of Dolphin - Smart Community Builder |
|---|
| 10 | * |
|---|
| 11 | * Dolphin is free software. This work is licensed under a Creative Commons Attribution 3.0 License. |
|---|
| 12 | * http://creativecommons.org/licenses/by/3.0/ |
|---|
| 13 | * |
|---|
| 14 | * Dolphin is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
|---|
| 15 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|---|
| 16 | * See the Creative Commons Attribution 3.0 License for more details. |
|---|
| 17 | * You should have received a copy of the Creative Commons Attribution 3.0 License along with Dolphin, |
|---|
| 18 | * see license.txt file; if not, write to marketing@boonex.com |
|---|
| 19 | ***************************************************************************/ |
|---|
| 20 | |
|---|
| 21 | require_once( 'inc/header.inc.php' ); |
|---|
| 22 | require_once( BX_DIRECTORY_PATH_INC . 'design.inc.php' ); |
|---|
| 23 | require_once( BX_DIRECTORY_PATH_INC . 'profiles.inc.php' ); |
|---|
| 24 | require_once( BX_DIRECTORY_PATH_INC . 'utils.inc.php' ); |
|---|
| 25 | |
|---|
| 26 | // --------------- page variables and login |
|---|
| 27 | |
|---|
| 28 | $_page['name_index'] = 29; |
|---|
| 29 | $_page['css_name'] = 'tellfriend.css'; |
|---|
| 30 | |
|---|
| 31 | $logged['member'] = member_auth( 0, false ); |
|---|
| 32 | |
|---|
| 33 | $_page['header'] = _t("_Tell a friend"); |
|---|
| 34 | $_page['header_text'] = _t("_Tell a friend"); |
|---|
| 35 | |
|---|
| 36 | $profileID = (int)($_GET['ID'] ? $_GET['ID'] : $_POST['ID']); |
|---|
| 37 | |
|---|
| 38 | if ( $profileID > 0 ) |
|---|
| 39 | { |
|---|
| 40 | $yourID = (int)$_COOKIE['memberID']; |
|---|
| 41 | |
|---|
| 42 | if ( $yourID > 0 ) |
|---|
| 43 | { |
|---|
| 44 | $your_arr = getProfileInfo( $yourID ); //db_arr("SELECT `NickName`, `Email` FROM `Profiles` WHERE `ID` = $yourID", 0); |
|---|
| 45 | $yourName = $your_arr['NickName']; |
|---|
| 46 | $yourEmail = $your_arr['Email']; |
|---|
| 47 | } |
|---|
| 48 | } |
|---|
| 49 | |
|---|
| 50 | |
|---|
| 51 | // --------------- GET/POST actions |
|---|
| 52 | |
|---|
| 53 | if ( $_POST['submit'] ) |
|---|
| 54 | { |
|---|
| 55 | if ( SendTellFriend() ) |
|---|
| 56 | { |
|---|
| 57 | $tell_friend_text = "<b>"._t("_Email was successfully sent")."</b>"; |
|---|
| 58 | } |
|---|
| 59 | else |
|---|
| 60 | { |
|---|
| 61 | $tell_friend_text = "<b style=\"color:red;\">"._t("_Email sent failed")."</b>"; |
|---|
| 62 | } |
|---|
| 63 | } |
|---|
| 64 | else |
|---|
| 65 | { |
|---|
| 66 | if ( $profileID > 0) |
|---|
| 67 | $tell_friend_text = _t("_TELLAFRIEND2", $site['title']); |
|---|
| 68 | else |
|---|
| 69 | $tell_friend_text = '';//_t("_TELLAFRIEND", $site['title']); |
|---|
| 70 | } |
|---|
| 71 | |
|---|
| 72 | |
|---|
| 73 | // --------------- page components |
|---|
| 74 | |
|---|
| 75 | $_ni = $_page['name_index']; |
|---|
| 76 | $_page_cont[$_ni]['invite_friend_text'] = $tell_friend_text; |
|---|
| 77 | $_page_cont[$_ni]['id'] = $profileID; |
|---|
| 78 | $_page_cont[$_ni]['your_name'] = _t("_Your name"); |
|---|
| 79 | $_page_cont[$_ni]['your_name_val'] = $yourName; |
|---|
| 80 | $_page_cont[$_ni]['your_email'] = _t("_Your email"); |
|---|
| 81 | $_page_cont[$_ni]['your_email_val'] = $yourEmail; |
|---|
| 82 | $_page_cont[$_ni]['friend_email'] = _t("_Friend email"); |
|---|
| 83 | $_page_cont[$_ni]['send_letter'] = _t("_Send Letter"); |
|---|
| 84 | |
|---|
| 85 | $sYEmlNotValidC = _t('_Incorrect Email'); |
|---|
| 86 | $sFEmlNotValidC = $sYEmlNotValidC . ' (' . _t('_Friend email') . ')'; |
|---|
| 87 | |
|---|
| 88 | $_page_cont[$_ni]['onsubmit'] = <<<EOF |
|---|
| 89 | onsubmit=" var feml = document.getElementById('friends_emails'); var yeml = document.getElementById('email'); var bRet = true; if (emailCheck(yeml.value)==false) { alert('{$sYEmlNotValidC}'); bRet = false; } if (emailCheck(feml.value)==false) { alert('{$sFEmlNotValidC}'); bRet = false; } return bRet; " |
|---|
| 90 | EOF; |
|---|
| 91 | |
|---|
| 92 | // --------------- [END] page components |
|---|
| 93 | |
|---|
| 94 | PageCode(); |
|---|
| 95 | |
|---|
| 96 | // --------------- page components functions |
|---|
| 97 | |
|---|
| 98 | /** |
|---|
| 99 | * send "tell a friend" email |
|---|
| 100 | */ |
|---|
| 101 | |
|---|
| 102 | function SendTellFriend() |
|---|
| 103 | { |
|---|
| 104 | global $site; |
|---|
| 105 | global $profileID; |
|---|
| 106 | global $yourID; |
|---|
| 107 | global $yourEmail; |
|---|
| 108 | global $yourName; |
|---|
| 109 | global $logged; |
|---|
| 110 | |
|---|
| 111 | if ( strlen( trim($_POST['friends_emails']) ) <= 0 ) |
|---|
| 112 | return 0; |
|---|
| 113 | if ( strlen( trim($_POST['email']) ) <= 0 ) |
|---|
| 114 | return 0; |
|---|
| 115 | |
|---|
| 116 | // Get notification email and subject from global settings. |
|---|
| 117 | if ( $profileID ) |
|---|
| 118 | { |
|---|
| 119 | $message = getParam( "t_TellFriendProfile" ); |
|---|
| 120 | $subject = getParam('t_TellFriendProfile_subject'); |
|---|
| 121 | } |
|---|
| 122 | else |
|---|
| 123 | { |
|---|
| 124 | $message = getParam( "t_TellFriend" ); |
|---|
| 125 | $subject = getParam('t_TellFriend_subject'); |
|---|
| 126 | } |
|---|
| 127 | |
|---|
| 128 | $recipient = $_POST['friends_emails']; |
|---|
| 129 | |
|---|
| 130 | $headers .= "From: =?UTF-8?B?" . base64_encode( $_POST['name'] ) . "?= <{$_POST['email']}>"; |
|---|
| 131 | $headers = "MIME-Version: 1.0\r\n" . "Content-type: text/html; charset=UTF-8\r\n" . $headers; |
|---|
| 132 | $headers2 .= "-f{$_POST['email']}"; |
|---|
| 133 | |
|---|
| 134 | $sLinkAdd = $logged['member'] ? 'idFriend='. (int)$_COOKIE['memberID'] : ''; |
|---|
| 135 | |
|---|
| 136 | if ( $profileID ) |
|---|
| 137 | $Link = getProfileLink($profileID, $sLinkAdd); |
|---|
| 138 | else |
|---|
| 139 | $Link = "{$site['url']}" . ( $sLinkAdd ? "?{$sLinkAdd}" : '' ); |
|---|
| 140 | |
|---|
| 141 | $subject = '=?UTF-8?B?' . base64_encode( $subject ) . '?='; |
|---|
| 142 | |
|---|
| 143 | $message = str_replace( "<Link>", $Link, $message ); |
|---|
| 144 | $message = str_replace( "<FromName>", $_POST['name'], $message ); |
|---|
| 145 | |
|---|
| 146 | return mail( $recipient, $subject, $message, $headers, $headers2 ); |
|---|
| 147 | } |
|---|
| 148 | |
|---|
| 149 | ?> |
|---|