Cheetah
freemail.php
Go to the documentation of this file.
1 <?php
2 
8 require_once( 'inc/header.inc.php' );
9 require_once( CH_DIRECTORY_PATH_INC . 'design.inc.php' );
10 require_once( CH_DIRECTORY_PATH_INC . 'profiles.inc.php' );
11 require_once( CH_DIRECTORY_PATH_CLASSES . 'ChWsbEmailTemplates.php' );
12 
13 // --------------- page variables and login
14 
15 $_page['name_index'] = 44;
16 $_page['css_name'] = 'freemail.css';
17 
18 $_page['header'] = _t( "_FREEMAIL_H" );
19 
20 $logged['member'] = member_auth(0, false);
21 
22 // --------------- page components
23 
24 $_ni = $_page['name_index'];
25 $_page_cont[$_ni]['page_main_code'] = DesignBoxContent( $_page['header'], PageCompPageMainCode(), 1);
26 $_page_cont[$_ni]['body_onload'] = '';
27 
28 // --------------- [END] page components
29 
30 PageCode();
31 
32 // --------------- page components functions
33 
38 {
39  global $_page;
40 
41  //define ajax mode
42  $bAjxMod = isset($_SERVER['HTTP_X_REQUESTED_WITH'])
43  && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest' ? true : false;
44 
45  $member['ID'] = getLoggedId();
46  if (!isset($_POST['ID']))
47  return _t_err( "_No member specified" );
48 
49  $ID = getID($_POST['ID'], 0);
50  if(!$ID)
51  return _t_err("_PROFILE_NOT_AVAILABLE");
52 
53  $profile = getProfileInfo( $ID );
54 
55  // Check if member can get email ADD CART CHECK HERE
56  $check_res = checkAction( $member['ID'], ACTION_ID_GET_EMAIL );
58  if($bAjxMod)
60 
61  return '<div class="soundPop">' . $check_res[CHECK_ACTION_MESSAGE] . '</div>';
62  }
63 
64  // Check if profile found
65 
66  if( !$profile ) {
67  $ret = _t_err("_PROFILE_NOT_AVAILABLE");
68  return $ret;
69  }
70 
71  $action_result = "";
72  $get_result = MemberFreeEmail( $member['ID'], $profile );
73 
74  switch ( $get_result ) {
75  case 7:
76  $action_result = _t_err( "_PROFILE_NOT_AVAILABLE" );
77  break;
78  case 13:
79  $action_result = _t_err( "_YOUR PROFILE_IS_NOT_ACTIVE" );
80  break;
81  case 20:
82  $action_result = _t_err( "_FREEMAIL_NOT_ALLOWED" );
83  break;
84  case 21:
85  $action_result = _t_err( "_FREEMAIL_ALREADY_SENT", $ID );
86  break;
87  case 25:
88  $action_result = _t_err( "_FREEMAIL_BLOCK", $ID );
89  break;
90  case 44:
91  $action_result = _t_err( "_FREEMAIL_NOT_KISSED", $ID );
92  break;
93  case 45:
94  $action_result = _t_err("_FREEMAIL_ERROR");
95  break;
96  default:
97  $action_result = _t( "_FREEMAIL_SENT", $profile['NickName'] );
98  break;
99  }
100 
101  if ( $get_result ) {
102  $_page['header_text'] = _t( "_Contact information not sent" );
103  } else {
104  $_page['header_text'] = _t( "_Contact information sent" );
105  }
106 
107  $ret = '<div class="soundPop">' . $action_result . '</div>' . "\n";
108 
109  if($bAjxMod)
110  showAjaxModeResult($action_result, $ID);
111 
112  return $ret;
113 }
115 {
116  header('Content-Type: text/html; charset=utf-8');
118  exit;
119 }
120 function MemberFreeEmail( $recipientID, $profile )
121 {
122  global $site;
123  $anon_mode = getParam('anon_mode');
124 
125  $recipientID = (int)$recipientID;
126  $aRecipientArr = db_arr( "SELECT `Email` FROM `Profiles` WHERE `ID` = '$recipientID' AND `Status` = 'Active'", 0 );
127 
128  if (isBlocked($profile['ID'], $recipientID)) {
129  return 25;
130  }
131 
132  if ( !db_arr( "SELECT `ID` FROM `Profiles` WHERE `ID` = '{$profile['ID']}' AND `Status` = 'Active'", 0 ) ) {
133  return 7;
134  }
135 
136  if ($anon_mode) {
137  return 20;
138  }
139 
140  $rEmailTemplate = new ChWsbEmailTemplates();
141  $aTemplate = $rEmailTemplate -> getTemplate( 't_FreeEmail', $recipientID ) ;
142 
143  if ( $recipientID ) {
144  $recipient = $aRecipientArr['Email'];
145  } else {
146  if ( $_GET['Email'] )
147  $recipient = $_GET['Email'];
148  else
149  return 45;
150  }
151 
152  $contact_info = "Email: {$profile['Email']}";
153  if ( strlen( $profile['Phone'] ) )
154  $contact_info .= "\nPhone: {$profile['Phone']}";
155  if ( strlen( $profile['HomeAddress'] ) )
156  $contact_info .= "\nHomeAddress: {$profile['HomeAddress']}";
157  if ( strlen( $profile['HomePage'] ) )
158  $contact_info .= "\nHomePage: {$profile['HomePage']}";
159  if ( strlen( $profile['IcqUIN'] ) )
160  $contact_info .= "\nICQ: {$profile['IcqUIN']}";
161 
162  $aPlus = array();
163  $aPlus['profileContactInfo'] = $contact_info;
164  $aPlus['profileNickName'] = getNickName($profile['ID']);
165  $aPlus['profileID'] = $profile['ID'];
166 
167  $mail_ret = sendMail( $aRecipientArr['Email'], $aTemplate['Subject'], $aTemplate['Body'], $recipientID, $aPlus, 'html', false, true );
168 
169  if ( $mail_ret )
170  // Perform action
172  else
173  return 10;
174 
175  return 0;
176 }
header
</code > Be careful enabling this directive if you have a redirector script that does not use the< code > Location</code > HTTP header
Definition: URI.MungeResources.txt:10
$sMessage
$sMessage
Definition: actions.inc.php:17
true
if(!defined("TRUE_VAL")) define("TRUE_VAL" true
Definition: constants.inc.php:8
MemberFreeEmail
MemberFreeEmail( $recipientID, $profile)
Definition: freemail.php:120
MsgBox
MsgBox($sText, $iTimer=0)
Definition: design.inc.php:175
$member
$member['ID']
Definition: member.php:33
CHECK_ACTION_RESULT_ALLOWED
const CHECK_ACTION_RESULT_ALLOWED
Definition: membership_levels.inc.php:60
$ret
$ret
Definition: index.php:39
ChWsbEmailTemplates
Definition: ChWsbEmailTemplates.php:11
CHECK_ACTION_RESULT
const CHECK_ACTION_RESULT
Definition: membership_levels.inc.php:54
sendMail
sendMail( $sRecipientEmail, $sMailSubject, $sMailBody, $iRecipientID=0, $aPlus=array(), $sEmailFlag='html', $isDisableAlert=false, $bForceSend=false)
Definition: utils.inc.php:461
CHECK_ACTION_MESSAGE
const CHECK_ACTION_MESSAGE
Definition: membership_levels.inc.php:55
showAjaxModeResult
showAjaxModeResult($sMessage, $iId)
Definition: freemail.php:114
php
$iId
$iId
Definition: license.php:15
$memberID
$memberID
Definition: profile.php:20
db_arr
db_arr($query, $bindings=[])
Definition: db.inc.php:76
exit
exit
Definition: cart.php:21
$_GET
$_GET['debug']
Definition: index.php:67
ACTION_ID_GET_EMAIL
const ACTION_ID_GET_EMAIL
Definition: membership_levels.inc.php:39
getParam
getParam($sParamName, $bUseCache=true)
Definition: db.inc.php:130
getLoggedId
getLoggedId()
Definition: profiles.inc.php:32
$logged
$logged['member']
Definition: freemail.php:20
getNickName
getNickName( $ID='')
Definition: profiles.inc.php:461
$site
$site['ver']
Definition: version.inc.php:8
$_page
$_page['name_index']
Definition: freemail.php:15
_t_err
_t_err( $str, $arg0="", $arg1="", $arg2="")
Definition: languages.inc.php:504
global
if(!defined("GLOBAL_MODULE")) define("GLOBAL_MODULE" global
Definition: header.inc.php:25
_t
_t($key, $arg0="", $arg1="", $arg2="")
Definition: languages.inc.php:509
PageCode
PageCode($oTemplate=null)
Definition: design.inc.php:91
member_auth
member_auth($member=0, $error_handle=true, $bAjx=false)
Definition: admin.inc.php:262
$bAjxMod
$bAjxMod
Definition: greet.php:21
PageCompPageMainCode
PageCompPageMainCode()
Definition: freemail.php:37
checkAction
checkAction($iMemberId, $actionID, $performAction=false, $iForcedProfID=0, $isCheckMemberStatus=true)
Definition: membership_levels.inc.php:313
isBlocked
isBlocked($iFirstProfile, $iSecondProfile)
Definition: utils.inc.php:128
genAjaxyPopupJS
genAjaxyPopupJS($iTargetID, $sDivID='ajaxy_popup_result_div', $sRedirect='')
Definition: design.inc.php:242
getID
getID( $str, $with_email=1)
Definition: admin.inc.php:139
getProfileInfo
getProfileInfo($iProfileID=0, $checkActiveStatus=false, $forceCache=false)
Definition: profiles.inc.php:249
$_ni
$_ni
Definition: freemail.php:24
$ID
$ID
Definition: click.php:11
DesignBoxContent
DesignBoxContent($title, $content, $db_num=0, $caption_item='', $bottom_item='')
Definition: design.inc.php:78
$_page_cont
$_page_cont[$_ni]['page_main_code']
Definition: freemail.php:25