示例#1
0
function sendUserEmail($option, $toId, $fromId, $emailName, $emailAddress, $subject, $message)
{
    global $ueConfig, $_CB_framework, $_POST, $_PLUGINS;
    $allowPublic = isset($ueConfig['allow_email_public']) ? (int) $ueConfig['allow_email_public'] : 0;
    // simple spoof check:
    cbSpoofCheck('emailuser');
    $errorMsg = cbAntiSpamCheck(false, $allowPublic);
    if ($_CB_framework->myId() == 0 && (!$allowPublic || $allowPublic && !$emailAddress) || $_CB_framework->myId() != $fromId || !$toId || $ueConfig['allow_email_display'] != 1 && $ueConfig['allow_email_display'] != 3 || !CBuser::getMyInstance()->authoriseView('profile', $toId)) {
        cbNotAuth(true);
        return;
    }
    $_PLUGINS->loadPluginGroup('user');
    $rowFrom = new UserTable();
    $rowFrom->load((int) $fromId);
    $rowTo = new UserTable();
    $rowTo->load((int) $toId);
    $emailName = stripslashes($emailName);
    // remove slashes added by cbGetParam
    $emailAddress = stripslashes($emailAddress);
    // remove slashes added by cbGetParam
    $subject = stripslashes($subject);
    // remove slashes added by cbGetParam
    $message = stripslashes($message);
    // remove slashes added by cbGetParam
    if (!$errorMsg) {
        $errorMsg = CBTxt::Th('UE_SESSIONTIMEOUT', 'Session timed out.') . ' ' . CBTxt::Th('UE_SENTEMAILFAILED', 'Your email failed to send! Please try again.');
        if (isset($_POST['protect'])) {
            $parts = explode('_', cbGetParam($_POST, 'protect', ''));
            if (count($parts) == 3 && $parts[0] == 'cbmv1' && strlen($parts[2]) == 16 && $parts[1] == md5($parts[2] . $rowTo->id . $rowTo->password . $rowTo->lastvisitDate . $rowFrom->password . $rowFrom->lastvisitDate)) {
                $errorMsg = null;
                $_PLUGINS->trigger('onBeforeEmailUser', array(&$rowFrom, &$rowTo, 1, &$emailName, &$emailAddress, &$subject, &$message));
                //$ui=1
                if ($_PLUGINS->is_errors()) {
                    $errorMsg = $_PLUGINS->getErrorMSG('<br />');
                } else {
                    $spamCheck = cbSpamProtect($_CB_framework->myId(), true, $allowPublic);
                    if ($spamCheck) {
                        $errorMsg = $spamCheck;
                    } else {
                        $cbNotification = new cbNotification();
                        if ($_CB_framework->myId()) {
                            $res = $cbNotification->sendUserEmail($toId, $fromId, $subject, $message, true);
                        } else {
                            $res = $cbNotification->sendUserEmailFromEmail($toId, $emailName, $emailAddress, $subject, $message, true);
                        }
                        if ($res) {
                            cbRedirectToProfile($rowTo->id, CBTxt::Th('UE_SENTEMAILSUCCESS', 'Your email was sent successfully!'));
                            return;
                        } else {
                            $errorMsg = CBTxt::Th('UE_SENTEMAILFAILED', 'Your email failed to send! Please try again.');
                        }
                    }
                }
            }
        }
    }
    if ($errorMsg) {
        $_CB_framework->enqueueMessage($errorMsg, 'error');
    }
    HTML_comprofiler::emailUser($option, $rowFrom, $rowTo, $allowPublic, $emailName, $emailAddress, $subject, $message);
}
示例#2
0
function sendUserEmail( $option, $toid, $fromid, $subject, $message ) {
	global $ueConfig, $_CB_framework, $_CB_database, $_POST, $_PLUGINS;

	// simple spoof check security
	cbSpoofCheck( 'emailUser' );
	$errorMsg	=	cbAntiSpamCheck( false );

	if (($_CB_framework->myId() == 0) || ($_CB_framework->myId() != $fromid) || ( ! $toid ) || ($ueConfig['allow_email_display']!=1 && $ueConfig['allow_email_display']!=3)) {
		cbNotAuth();
		return;
	}

	$rowFrom = new moscomprofilerUser( $_CB_database );
	$rowFrom->load( (int) $fromid );

	$rowTo = new moscomprofilerUser( $_CB_database );
	$rowTo->load( (int) $toid );

	$subject	=	stripslashes( $subject );		// cbGetParam() adds slashes...remove'em...
	$message	=	stripslashes( $message );

	if ( ! $errorMsg ) {
		$errorMsg	=	_UE_SESSIONTIMEOUT . " " . _UE_SENTEMAILFAILED;
		if ( isset( $_POST["protect"] ) ) {
			$parts	=	explode( '_', cbGetParam( $_POST, 'protect', '' ) );
			if ( ( count( $parts ) == 3 ) && ( $parts[0] == 'cbmv1' ) && ( strlen( $parts[2] ) == 16 ) && ( $parts[1] == md5($parts[2].$rowTo->id.$rowTo->password.$rowTo->lastvisitDate.$rowFrom->password.$rowFrom->lastvisitDate) ) ) {
				$errorMsg	=	null;
				$_PLUGINS->loadPluginGroup('user');
				$pluginResults = $_PLUGINS->trigger( 'onBeforeEmailUser', array( &$rowFrom, &$rowTo, 1 ));	//$ui=1
				if ($_PLUGINS->is_errors()) {
					$errorMsg	=	$_PLUGINS->getErrorMSG( '<br />') . "\n";
				} else {
					$spamCheck = cbSpamProtect( $_CB_framework->myId(), true );
					if ( $spamCheck ) {
						$errorMsg	=	$spamCheck;
					} else {
						$cbNotification	=	new cbNotification();
						$res			=	$cbNotification->sendUserEmail($toid,$fromid,$subject,$message, true);

						if ($res) {
							echo _UE_SENTEMAILSUCCESS;
							if (is_array($pluginResults)) {
								echo implode( "<br />", $pluginResults );
							}
							return;
						}
						else {
							$errorMsg	=	_UE_SENTEMAILFAILED;
						}
					}
				}
			}
		}
	}
	echo '<div class="error">' . $errorMsg . '</div>';
	HTML_comprofiler::emailUser( $option, $rowFrom, $rowTo, $subject, $message );
}
示例#3
0
	function awUserActivated($user, $success) {
		global $_CB_framework, $ueConfig;
		
		if (!$success) return false;
		
        // get CBUser so we can use replaceUserVars() from CBAPI
        $awCBuser =&  CBUser::getInstance((int) $user->id);
        
		$res_wpms = true;
		$res_wemail = true;		
		$res_wconnect = true;
		
		$plugparams=$this->_awGetPlugParameters();
		
		$testNotifications = new cbNotification();
	
		if ($plugparams["awautomessageenable"]) {
			switch ($plugparams["awmessagemethod"]) {
				case 0: // PMS
					$cbawNotification = new cbNotification();
					$res_wpms = $cbawNotification->sendUserPMSmsg((int) $user->id,
						$plugparams["awpmsfromuserid"],
                        $awCBuser->replaceUserVars( $plugparams["awpmsmessagesubject"] ),
						$awCBuser->replaceUserVars( $plugparams["awpmsmessagebody"] ), 
						true);
					if (!$res_wpms) {
						$this->_setErrorMSG("Auto-Welcome plugin failed to send PMS welcome message");
					}
					break;
				case 1: // Email
					$cbawNotification = new cbNotification();
					$res_wemail=$cbawNotification->sendUserEmail((int) $user->id,
						$plugparams["awemailfromuserid"],
						$awCBuser->replaceUserVars( $plugparams["awemailmessagesubject"] ),
						$awCBuser->replaceUserVars( $plugparams["awemailmessagebody"] ),
						$plugparams["awemailfromuserid"]);	//reveal email
					if (!$res_wemail) {
						$this->_setErrorMSG("Auto-Welcome plugin failed to send Email welcome message");
					}			
					break;
				case 2: // Email and PMS
					$cbawNotification = new cbNotification();
					$res_wpms = $cbawNotification->sendUserPMSmsg((int) $user->id,
						$plugparams["awpmsfromuserid"],
						$awCBuser->replaceUserVars( $plugparams["awpmsmessagesubject"] ),
						$awCBuser->replaceUserVars( $plugparams["awpmsmessagebody"] ), 
						true);
					if (!$res_wpms) {
						$this->_setErrorMSG("Auto-Welcome plugin failed to send PMS welcome message");
					}
					$res_wemail=$cbawNotification->sendUserEmail((int) $user->id,
						$plugparams["awemailfromuserid"],
						$awCBuser->replaceUserVars( $plugparams["awemailmessagesubject"] ),
						$awCBuser->replaceUserVars( $plugparams["awemailmessagebody"] ),
						$plugparams["awpmsfromuserid"]);	//reveal email				
					if (!$res_wemail) {
						$this->_setErrorMSG("Auto-Welcome plugin failed to send Email welcome message");
					}			
					break;
				default:
					break;
			}		
		}
	
		if ($plugparams["awautoconnectenable"] && $ueConfig['allowConnections']) {
		
			$awkeyuserid_count = substr_count($plugparams["awkeyuserid"],',');
			$res_wconnect = true;
			$awkeyuserid_item = explode(",",$plugparams["awkeyuserid"]);
			
			if ($plugparams["awautoconnectdirection"]==0) { // connect new user to key users
				$cbawCon=new cbConnection( (int) $user->id);
				for ($aw_i=0;$aw_i<=$awkeyuserid_count;$aw_i++) {
					$res_wconnect = $res_wconnect && $cbawCon->addConnection((int) $awkeyuserid_item[$aw_i],
						$awCBuser->replaceUserVars( $plugparams["awautoconnectmessage"] ));
				}
				if (!$res_wconnect) {
					$this->_setErrorMSG("Auto-Welcome plugin failed to initiate auto-connection");
				}
				unset($cbawCon); // cleanup			
			} else { // connect key users to new user
				for ($aw_i=0;$aw_i<=$awkeyuserid_count;$aw_i++) {
					$cbawCon=new cbConnection((int) $awkeyuserid_item[$aw_i]);
					$res_wconnect = $res_wconnect && $cbawCon->addConnection((int) $user->id,
						$awCBuser->replaceUserVars( $plugparams["awautoconnectmessage"] ));
					unset($cbawCon); // cleanup
				}
				if (!$res_wconnect) {
					$this->_setErrorMSG("Auto-Welcome plugin failed to initiate auto-connection");
				}
			}
		}
		
		if (!($res_wemail && $res_wpms && $res_wconnect)) {
			$this->raiseError(0);
		}
		
		return $res_wemail && $res_wpms && $res_wconnect;
	}