| 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 | |
|---|
| 25 | // --------------- page variables |
|---|
| 26 | |
|---|
| 27 | $_page['name_index'] = 44; |
|---|
| 28 | $_page['css_name'] = 'vkiss.css'; |
|---|
| 29 | |
|---|
| 30 | $logged['member'] = member_auth(0, false); |
|---|
| 31 | |
|---|
| 32 | $_page['header'] = _t("_Send virtual kiss"); |
|---|
| 33 | |
|---|
| 34 | // --------------- page components |
|---|
| 35 | |
|---|
| 36 | $_ni = $_page['name_index']; |
|---|
| 37 | $_page_cont[$_ni]['page_main_code'] = PageCompPageMainCode(); |
|---|
| 38 | $_page_cont[$_ni]['body_onload'] = ''; |
|---|
| 39 | // --------------- [END] page components |
|---|
| 40 | |
|---|
| 41 | PageCode(); |
|---|
| 42 | |
|---|
| 43 | // --------------- page components functions |
|---|
| 44 | |
|---|
| 45 | /** |
|---|
| 46 | * page code function |
|---|
| 47 | */ |
|---|
| 48 | function PageCompPageMainCode() |
|---|
| 49 | { |
|---|
| 50 | global $_page; |
|---|
| 51 | global $oTemplConfig; |
|---|
| 52 | |
|---|
| 53 | $ret = ""; |
|---|
| 54 | |
|---|
| 55 | $member['ID'] = (int)$_COOKIE['memberID']; |
|---|
| 56 | $member['Password'] = $_COOKIE['memberPassword']; |
|---|
| 57 | $recipientID = getID( $_REQUEST['sendto'], 0 ); |
|---|
| 58 | $recipient = getProfileInfo( $recipientID ); //db_arr( "SELECT `ID`, `Status`, `Email` FROM `Profiles` WHERE `ID` = '" . $recipientID . "' LIMIT 1;" ); |
|---|
| 59 | $contact_allowed = contact_allowed($member['ID'], $recipientID); |
|---|
| 60 | |
|---|
| 61 | if ( $_REQUEST['ConfCode'] && $_REQUEST['from'] && |
|---|
| 62 | ( strcmp( $_REQUEST['ConfCode'], base64_encode( base64_encode( crypt( $_REQUEST['from'], "vkiss_secret_string" ) ) ) ) == 0 ) ) |
|---|
| 63 | { |
|---|
| 64 | $member['ID'] = (int)$_REQUEST['from']; |
|---|
| 65 | } |
|---|
| 66 | |
|---|
| 67 | // |
|---|
| 68 | // Check if member can send messages |
|---|
| 69 | $check_res = checkAction( $member['ID'], ACTION_ID_SEND_VKISS ); |
|---|
| 70 | if ( $check_res[CHECK_ACTION_RESULT] != CHECK_ACTION_RESULT_ALLOWED |
|---|
| 71 | && !$contact_allowed ) |
|---|
| 72 | { |
|---|
| 73 | $_page['header_text'] = _t("_Send virtual kiss3"); |
|---|
| 74 | $ret = " |
|---|
| 75 | <table width=\"100%\" cellpadding=\"4\" cellspacing=\"4\" border=\"0\"> |
|---|
| 76 | <tr> |
|---|
| 77 | <td align=center class=text2>". $check_res[CHECK_ACTION_MESSAGE] ."</td> |
|---|
| 78 | </tr> |
|---|
| 79 | </table>\n"; |
|---|
| 80 | return $ret; |
|---|
| 81 | } |
|---|
| 82 | |
|---|
| 83 | $action_result = ""; |
|---|
| 84 | |
|---|
| 85 | // Check if recipient found |
|---|
| 86 | if( !$recipient ) |
|---|
| 87 | { |
|---|
| 88 | $_page['header_text'] = _t("_Send virtual kiss3"); |
|---|
| 89 | $ret = " |
|---|
| 90 | <table width=\"100%\" cellpadding=\"4\" cellspacing=\"4\"> |
|---|
| 91 | <tr> |
|---|
| 92 | <td align=center class=text2> |
|---|
| 93 | <form method=\"GET\" action=\"{$_SERVER['PHP_SELF']}\"> |
|---|
| 94 | <input class=no size=15 type=\"text\" name=\"sendto\"> <input class=no type=\"submit\" value=\"". _t("_Send kiss") ."!\"> |
|---|
| 95 | </form> |
|---|
| 96 | </td> |
|---|
| 97 | </tr> |
|---|
| 98 | </table>\n"; |
|---|
| 99 | return $ret; |
|---|
| 100 | } |
|---|
| 101 | |
|---|
| 102 | // Perform sending |
|---|
| 103 | $send_result = MemberSendVKiss( $member, $recipient ); |
|---|
| 104 | switch ( $send_result ) |
|---|
| 105 | { |
|---|
| 106 | case 1: |
|---|
| 107 | $action_result .= _t_err( "_VKISS_BAD" ); |
|---|
| 108 | break; |
|---|
| 109 | case 7: |
|---|
| 110 | $action_result .= _t_err( "_VKISS_BAD_COUSE_B" ); |
|---|
| 111 | break; |
|---|
| 112 | case 10: |
|---|
| 113 | $action_result .= _t_err( "_VKISS_BAD_COUSE_C" ); |
|---|
| 114 | break; |
|---|
| 115 | case 13: |
|---|
| 116 | $action_result .= _t_err( "_VKISS_BAD_COUSE_A3" ); |
|---|
| 117 | break; |
|---|
| 118 | case 23: |
|---|
| 119 | $action_result .= _t_err( "_VKISS_BAD_COUSE_X" ); |
|---|
| 120 | break; |
|---|
| 121 | case 24: |
|---|
| 122 | $action_result .= _t_err( "_VKISS_BAD_COUSE_Y" ); |
|---|
| 123 | break; |
|---|
| 124 | default: |
|---|
| 125 | $action_result .= _t( "_VKISS_OK" ); |
|---|
| 126 | break; |
|---|
| 127 | } |
|---|
| 128 | if ( $send_result == 0 ) |
|---|
| 129 | $_page['header_text'] = _t("_Send virtual kiss2"); |
|---|
| 130 | else |
|---|
| 131 | $_page['header_text'] = _t("_Send virtual kiss3"); |
|---|
| 132 | |
|---|
| 133 | $ret = " |
|---|
| 134 | <table width=\"100%\" cellpadding=\"4\" cellspacing=\"4\"> |
|---|
| 135 | <tr> |
|---|
| 136 | <td align=center class=text2> |
|---|
| 137 | {$action_result}<br /> |
|---|
| 138 | </td> |
|---|
| 139 | </tr> |
|---|
| 140 | </table>\n"; |
|---|
| 141 | return DesignBoxContent( _t("_Send virtual kiss"), $ret, $oTemplConfig -> PageVkiss_db_num ); |
|---|
| 142 | } |
|---|
| 143 | |
|---|
| 144 | /** |
|---|
| 145 | * Send virtual kiss |
|---|
| 146 | */ |
|---|
| 147 | function MemberSendVKiss( $member, $recipient ) |
|---|
| 148 | { |
|---|
| 149 | global $site; |
|---|
| 150 | global $logged; |
|---|
| 151 | |
|---|
| 152 | // Check if recipient is active |
|---|
| 153 | if( 'Active' != $recipient['Status'] ) |
|---|
| 154 | { |
|---|
| 155 | return 7; |
|---|
| 156 | } |
|---|
| 157 | |
|---|
| 158 | // block members |
|---|
| 159 | if ( db_arr( "SELECT `ID`, `Profile` FROM `BlockList` WHERE `ID` = {$recipient['ID']} AND `Profile` = {$member['ID']}", 0 ) ) |
|---|
| 160 | { |
|---|
| 161 | return 24; |
|---|
| 162 | } |
|---|
| 163 | |
|---|
| 164 | // Get sender info |
|---|
| 165 | $sender = getProfileInfo( $member['ID'] ); //db_arr( "SELECT `NickName` FROM `Profiles` WHERE `ID` = {$member['ID']}" ); |
|---|
| 166 | |
|---|
| 167 | // Send email notification |
|---|
| 168 | $message = $logged['member'] ? getParam( "t_VKiss" ) : getParam( "t_VKiss_visitor" ); |
|---|
| 169 | $subject = getParam('t_VKiss_subject'); |
|---|
| 170 | |
|---|
| 171 | $ConfCode = urlencode( base64_encode( base64_encode( crypt( $recipient['ID'], "vkiss_secret_string" ) ) ) ); |
|---|
| 172 | |
|---|
| 173 | $aPlus = array(); |
|---|
| 174 | $aPlus['ConfCode'] = $ConfCode; |
|---|
| 175 | $aPlus['ProfileReference'] = $sender ? '<a href="' . getProfileLink($member['ID']) . '">' . $sender['NickName'] . ' (' . getProfileLink($member['ID']) . ') </a>' : '<b>' . _t("_Visitor") . '</b>'; |
|---|
| 176 | $aPlus['VKissLink'] = $sender ? '<a href="' . $site['url'] . 'greet.php?sendto=' . $member['ID'] . '&from=' . $recipient['ID'] . '&ConfCode=' . $ConfCode . '">' . $site['url'] . 'greet.php?sendto=' . $member['ID'] . '&from=' . $recipient['ID'] . '&ConfCode=' . $ConfCode . '</a>' : '<a href="' . $site['url'] . 'contacts.php">' . $site['url'] . 'contacts.php</a>'; |
|---|
| 177 | |
|---|
| 178 | $mail_ret = sendMail( $recipient['Email'], $subject, $message, $recipient['ID'], $aPlus ); |
|---|
| 179 | |
|---|
| 180 | if ( !$mail_ret ) |
|---|
| 181 | { |
|---|
| 182 | return 10; |
|---|
| 183 | } |
|---|
| 184 | |
|---|
| 185 | // Insert kiss into database |
|---|
| 186 | $kiss_arr = db_arr( "SELECT `ID` FROM `VKisses` WHERE `ID` = {$member['ID']} AND `Member` = {$recipient['ID']} LIMIT 1", 0 ); |
|---|
| 187 | if ( !$kiss_arr ) |
|---|
| 188 | $result = db_res( "INSERT INTO `VKisses` ( `ID`, `Member`, `Number`, `Arrived`, `New` ) VALUES ( {$member['ID']}, {$recipient['ID']}, 1, NOW(), '1' )", 0 ); |
|---|
| 189 | else |
|---|
| 190 | $result = db_res( "UPDATE `VKisses` SET `Number` = `Number` + 1, `New` = '1' WHERE `ID` = {$member['ID']} AND `Member` = {$recipient['ID']}", 0 ); |
|---|
| 191 | |
|---|
| 192 | // If success then perform actions |
|---|
| 193 | if ( $result ) |
|---|
| 194 | checkAction( $member['ID'], ACTION_ID_SEND_VKISS, true ); |
|---|
| 195 | else |
|---|
| 196 | return 1; |
|---|
| 197 | |
|---|
| 198 | return 0; |
|---|
| 199 | } |
|---|
| 200 | |
|---|
| 201 | ?> |
|---|