sTinyMceEditorCompactJS; // --------------- page components $_ni = $_page['name_index']; $_page_cont[$_ni]['page_main_code'] = DesignBoxContent( '', PageCompPageMainCode(), $oTemplConfig -> PageCompose_db_num ); // --------------- [END] page components PageCode(); // --------------- page components functions /** * page code function */ function PageCompPageMainCode() { global $site; $ret = ''; $en_inbox_notify = getParam("enable_inbox_notify"); $en_dest_choice = getParam("enable_msg_dest_choice"); $free_mode = getParam( "free_mode" ); $member['ID'] = (int)$_COOKIE['memberID']; $member['Password'] = $_COOKIE['memberPassword']; $recipientID = getID( $_REQUEST['ID'], 0 ); $recipient = getProfileInfo( $recipientID ); $contact_allowed = contact_allowed($member['ID'], $recipientID); // Check if member can send messages $check_res = checkAction( $member['ID'], ACTION_ID_SEND_MESSAGE ); if ( $check_res[CHECK_ACTION_RESULT] != CHECK_ACTION_RESULT_ALLOWED && !$contact_allowed ) { $ret = '
' . $check_res[CHECK_ACTION_MESSAGE] . '
'; return $ret; } //ob_start(); $ret = ''; if ( $_POST['action'] == "send" && strlen($_POST['text']) ) { $action_result = ""; // Check if recipient found if( !$recipient ) { $ret = "
". _t("_COMPOSE_REJECT_MEMBER_NOT_FOUND") ."
\n"; return $ret; } // Perform sending $send_result = MemberSendMessage( $member, $recipient ); switch ( $send_result ) { case 1: $action_result .= _t_err( "_FAILED_TO_SEND_MESSAGE" ); $hide_form = '0'; break; case 3: $action_result .= _t_err( "_You have to wait for PERIOD minutes before you can write another message!", 1 ); $hide_form = '1'; break; case 5: $action_result .= _t_err( "_FAILED_TO_SEND_MESSAGE_BLOCK" ); $hide_form = '0'; break; case 10: $action_result .= _t_err( "_FAILED_TO_SEND_MESSAGE_NOT_ACTIVE" ); $hide_form = '0'; break; default: $action_result .= _t_action( "_MESSAGE_SENT" ); $hide_form = '1'; break; } } $ret .= '
'; if ( strlen($action_result) ) { $ret .= $action_result; } if ( $recipient && $hide_form != '1' ) { $ret .= '
'; $ret .= ProfileDetails( $recipient['ID'] ); $ret .= '
'; } if( '1' != $hide_form ) { $sSubject = (isset($_REQUEST['subject'])) ? 'Re: '.process_pass_data($_REQUEST['subject']) : ''; ob_start() ?>
" onsubmit="return checkForm();">
:
:
  />
  /> />
  />
" />
' . _t('_to_compose_new_message', $recipient['NickName'], $recipient['ID'], $site['url'] ) . '
'; } $ret .= ''; return $ret; } /** * Send message */ function MemberSendMessage( $member, $recipient ) { global $site; $en_dest_choice = getParam( "enable_msg_dest_choice" ); $max_message_size = getParam( "max_inbox_message_size" ); $max_messages = getParam( "max_inbox_messages" ); // Check if recipient is active if( 'Active' != $recipient['Status'] ) { return 10; } // Check if member is blocked if ( db_arr( "SELECT `ID`, `Profile` FROM `BlockList` WHERE `Profile` = {$member['ID']} AND `ID` = '{$recipient['ID']}';" ) ) { return 5; } // antispam )) if ( db_arr("SELECT `ID` FROM `Messages` WHERE `Sender` = {$member[ID]} AND date_add(`Date`, INTERVAL 1 MINUTE) > Now()") ) { return 3; } // Get sender info $sender = getProfileInfo( $member['ID'] ); $aPlus = array(); $aPlus['ProfileReference'] = $sender ? '' . $sender['NickName'] . ' (' . getProfileLink($member['ID']) . ') ' : ''. _t("_Visitor") .''; // Don't send notification if message is sending to email if ( $_POST['notify'] && !($_POST['sendto'] == "email" || $_POST['sendto'] == "both") ) { $message_text = getParam("t_Compose"); $subject = getParam('t_Compose_subject'); $aPlus['senderNickName'] = $sender ? $sender['NickName'] : _t("_Visitor"); $notify_res = sendMail( $recipient['Email'], $subject, $message_text, $recipient['ID'], $aPlus ); if ( !$notify_res ) echo "
". _t("_Notification send failed") ."

\n"; } // Send message to email if ( $en_dest_choice && ($_POST['sendto'] == "email" || $_POST['sendto'] == "both") ) { $message_text = getParam("t_Message"); $subject = process_pass_data( $_POST['mes_subject'] ); $aPlus['MessageText'] = strmaxtextlen( clear_xss( replace_full_uris( process_pass_data( $_POST['text'] ) ) ), $max_message_size); $result = sendMail( $recipient['Email'], $subject, $message_text, $recipient['ID'], $aPlus ); } // Send message to communicator if ( $_POST['sendto'] == "lovemail" || $_POST['sendto'] == "both" ) { // Restrict with total messages count $messages_count = db_arr( "SELECT COUNT(*) AS `mess_count` FROM `Messages` WHERE `Recipient` = '{$recipient['ID']}'" ); $messages_count = $messages_count['mess_count']; if ( ($messages_count - 1) > $max_messages ) { $del_res = db_res( "SELECT `ID` FROM `Messages` WHERE `Recipient` = '{$recipient['ID']}' ORDER BY `Date` ASC LIMIT ". ($messages_count - $max_messages + 1) ); while ( $del_arr = mysql_fetch_array($del_res) ) db_res( "DELETE FROM `Messages` WHERE `ID` = {$del_arr['ID']}" ); } // Insert message into database $message_text = strmaxtextlen( addslashes( clear_xss( process_pass_data( $_POST['text'] ) ) ), $max_message_size ); $message_subject = strmaxwordlen( process_db_input( $_POST['mes_subject'] ), 30); $result = db_res( "INSERT INTO `Messages` ( `Date`, `Sender`, `Recipient`, `Text`, `Subject`, `New` ) VALUES ( NOW(), {$member['ID']}, {$recipient['ID']}, '$message_text', '$message_subject', '1' )" ); } // If sending successful then mark as performed action if ( $result ) { checkAction( $member['ID'], ACTION_ID_SEND_MESSAGE, true ); } else return 1; return 0; } ?>