Exemplo n.º 1
0
function Run_UserQuery($query)
{
    global $DB_ResponderID, $DB_ResponderName, $DB_OwnerEmail;
    global $DB_OwnerName, $DB_ReplyToEmail, $DB_MsgList, $DB_LastActivity;
    global $DB_result, $DB_LinkID, $DB_ResponderDesc, $DB_RespEnabled;
    global $Responder_ID, $action, $SearchCount;
    global $Search_EmailAddress, $Subscriber_ID, $SubsPerPage;
    global $DB_FirstName, $DB_LastName, $DB_IPaddy, $DB_Real_TimeJoined;
    if ($SubsPerPage != 0) {
        $Limitedquery = $query . " LIMIT {$SearchCount}, {$SubsPerPage}";
    } else {
        $Limitedquery = $query;
    }
    $DB_MaxList_result = mysql_query($query) or die("Invalid query: " . mysql_error());
    $DB_search_result = mysql_query($Limitedquery) or die("Invalid query: " . mysql_error());
    $Max_Results_Count = mysql_num_rows($DB_MaxList_result) - 1;
    # MOD display message if any
    if ($_SESSION['inf_resp'] != '') {
        inf_resp_message_box($_SESSION['inf_resp']);
        unset($_SESSION['inf_resp']);
    }
    if (mysql_num_rows($DB_search_result) > 0) {
        # User top template
        $alt = FALSE;
        include 'templates/listuser_top.admin.php';
        # Display the rows
        while ($search_query_result = mysql_fetch_assoc($DB_search_result)) {
            $DB_SubscriberID = $search_query_result['SubscriberID'];
            $DB_ResponderID = $search_query_result['ResponderID'];
            $DB_SentMsgs = $search_query_result['SentMsgs'];
            $DB_EmailAddress = $search_query_result['EmailAddress'];
            $DB_TimeJoined = $search_query_result['TimeJoined'];
            $DB_Real_TimeJoined = $search_query_result['Real_TimeJoined'];
            $CanReceiveHTML = $search_query_result['CanReceiveHTML'];
            $DB_LastActivity = $search_query_result['LastActivity'];
            $DB_FirstName = $search_query_result['FirstName'];
            $DB_LastName = $search_query_result['LastName'];
            $DB_IPaddy = $search_query_result['IP_Addy'];
            $DB_ReferralSource = $search_query_result['ReferralSource'];
            $DB_UniqueCode = $search_query_result['UniqueCode'];
            $DB_Confirmed = $search_query_result['Confirmed'];
            $Responder_ID = $DB_ResponderID;
            if (!ResponderExists($Responder_ID)) {
                admin_redirect();
            }
            $ResponderInfo = GetResponderInfo($Responder_ID);
            # User row template
            $alt = !$alt;
            include 'templates/listuser_row.admin.php';
        }
        # List bottom template
        include 'templates/listuser_bottom.admin.php';
        if ($SubsPerPage != 0) {
            $Search_Count_BackStr = $SearchCount - $SubsPerPage;
            $Search_Count_ForwardStr = $SearchCount + $SubsPerPage;
            if ($Search_Count_BackStr < 0) {
                $Search_Count_BackStr = 0;
            }
            if ($Search_Count_ForwardStr > $Max_Results_Count) {
                $Search_Count_ForwardStr = $Max_Results_Count;
            }
            # Back and forward buttons
            include 'templates/back_forward.admin.php';
        }
        # Add new user button
        include 'templates/addnew_button.admin.php';
    } else {
        if (!ResponderExists($Responder_ID)) {
            admin_redirect();
        }
        $ResponderInfo = GetResponderInfo($Responder_ID);
        $DB_ResponderName = $ResponderInfo['Name'];
        print "<br><center><font size=\"3\" color=\"#330000\">No subscriber(s) found for Responder '" . $DB_ResponderName . "'.</font></center><br>\n";
        print "<br>\n";
        # Add new user button
        include 'templates/addnew_button.admin.php';
    }
    # Back button
    // print "<br> \n";
    // print "<font size=\"4\" color=\"#666666\">Back to Main:</font><br>\n";
    $return_action = "list";
    include 'templates/back_button.admin.php';
}
     } else {
         $spam_filtered = 1;
     }
 }
 if (!UserIsSubscribed($Responder_ID, $Email_Address) && !isInBlacklist($Email_Address) && $spam_filtered == 0 && isEmail($Email_Address)) {
     if ($DB_HTML_YN == 1) {
         $Set_HTML = 1;
     } else {
         $Set_HTML = 0;
     }
     # Get responder info
     # MOD for updated GetResponder function
     if (!ResponderExists($Responder_ID)) {
         admin_redirect();
     }
     $ResponderInfo = GetResponderInfo($Responder_ID);
     // $DB_OptMethod = $ResponderInfo['OptinMethod'];
     // if ($DB_OptMethod == "Double") {$DB_Confirm_Join = '1'}
     // else {$DB_Confirm_Join = '0';}
     # Setup the data
     $DB_ResponderID = $Responder_ID;
     $DB_SentMsgs = '';
     $DB_EmailAddress = $Email_Address;
     $DB_TimeJoined = time();
     $DB_Real_TimeJoined = time();
     $CanReceiveHTML = $Set_HTML;
     $DB_LastActivity = time();
     $DB_FirstName = $FirstName;
     $DB_LastName = $LastName;
     $DB_IPaddy = $IPaddy;
     $DB_ReferralSource = "email join";
Exemplo n.º 3
0
function ProcessMessageTags($MessageInfo, $SubscriberInfo)
{
    global $MySQL_server, $MySQL_user, $MySQL_password, $MySQL_database;
    global $DB_LinkID, $cop, $newline, $blahtest, $table_prefix, $siteURL;
    $Responder_ID = $MessageInfo['ResponderID'];
    $Send_Subject = $MessageInfo['Subject'];
    $DB_MsgBodyHTML = $MessageInfo['BodyHTML'];
    $DB_MsgBodyText = $MessageInfo['BodyText'];
    // print_r($MessageInfo);
    // echo "<br>";
    $ResponderInfo = GetResponderInfo($Responder_ID);
    // print_r($ResponderInfo);
    // echo "<br>";
    $DB_ResponderName = $ResponderInfo['Name'];
    $DB_RespEnabled = $ResponderInfo['Enabled'];
    $DB_ResponderDesc = $ResponderInfo['Description'];
    $DB_OwnerEmail = $ResponderInfo['FromEmail'];
    $DB_OwnerName = $ResponderInfo['FromName'];
    $DB_ReplyToEmail = $ResponderInfo['ReplyEmail'];
    $DB_ResponderDesc = $ResponderInfo['Description'];
    $DB_MsgList = $ResponderInfo['MessageList'];
    $DB_OptMethod = $ResponderInfo['OptMethod'];
    $DB_OptInRedir = $ResponderInfo['OptinRedir'];
    $DB_OptOutRedir = $ResponderInfo['OptoutRedir'];
    $DB_OptInDisplay = $ResponderInfo['OptinDisp'];
    $DB_OptOutDisplay = $ResponderInfo['OptinDisp'];
    $DB_NotifyOnSub = $ResponderInfo['NotifyOnSub'];
    $DB_EmailAddress = $SubscriberInfo['EmailAddress'];
    $DB_SubscriberID = $SubscriberInfo['SubscriberID'];
    $DB_SentMsgs = $SubscriberInfo['SentMsgs'];
    $CanReceiveHTML = $SubscriberInfo['CanReceiveHTML'];
    $DB_TimeJoined = $SubscriberInfo['TimeJoined'];
    $DB_Real_TimeJoined = $SubscriberInfo['Real_TimeJoined'];
    $DB_LastActivity = $SubscriberInfo['LastActivity'];
    $DB_FirstName = $SubscriberInfo['FirstName'];
    $DB_LastName = $SubscriberInfo['LastName'];
    $DB_IPaddy = $SubscriberInfo['IP_Addy'];
    $DB_ReferralSource = $SubscriberInfo['ReferralSource'];
    $DB_UniqueCode = $SubscriberInfo['UniqueCode'];
    $DB_Confirmed = $SubscriberInfo['Confirmed'];
    // print_r($SubscriberInfo);
    // echo "<br>";
    # MOD New Address Field
    $infrespaddress = get_option('inf_resp_address');
    $infrespaddresshtml = str_replace(PHP_EOL, '<br>', $infrespaddress);
    $Pattern = '/%address%/i';
    $DB_MsgBodyText = preg_replace($Pattern, $infrespaddress, $DB_MsgBodyText);
    $DB_MsgBodyHTML = preg_replace($Pattern, $infrespaddresshtml, $DB_MsgBodyHTML);
    # MOD New Signature Field
    $infrespsignature = get_option('inf_resp_signature');
    $infrespsignaturehtml = str_replace(PHP_EOL, '<br>', $infrespaddress);
    $Pattern = '/%signature%/i';
    $DB_MsgBodyText = preg_replace($Pattern, $infrespsignature, $DB_MsgBodyText);
    $DB_MsgBodyHTML = preg_replace($Pattern, $infrespsignaturehtml, $DB_MsgBodyHTML);
    # Wednesday May 9, 2007
    # $date_format = 'l \t\h\e jS \of F\, Y';
    $date_format = 'F j\\, Y';
    if (is_numeric($DB_Real_TimeJoined)) {
        $Joined_Month = date("F", $DB_Real_TimeJoined);
        $Joined_MonthNum = date("n", $DB_Real_TimeJoined);
        $Joined_Year = date("Y", $DB_Real_TimeJoined);
        $Joined_Day = date("d", $DB_Real_TimeJoined);
    } else {
        $Joined_Month = "-=-Joined Month-=-";
        $Joined_MonthNum = "-=-Joined Month Num-=-";
        $Joined_Year = "-=-Joined Year-=-";
        $Joined_Day = "-=-Joined Day-=-";
    }
    if (is_numeric($DB_LastActivity)) {
        $LastActive_Month = date("F", $DB_LastActivity);
        $LastActive_MonthNum = date("n", $DB_LastActivity);
        $LastActive_Year = date("Y", $DB_LastActivity);
        $LastActive_Day = date("d", $DB_LastActivity);
    } else {
        $LastActive_Month = "-=-Last Active Month-=-";
        $LastActive_MonthNum = "-=-Last Active Month Num-=-";
        $LastActive_Year = "-=-Last Active Year-=-";
        $LastActive_Day = "-=-Last Active Day-=-";
    }
    $Pattern = '/%msg_subject%/i';
    $DB_MsgBodyHTML = preg_replace($Pattern, $DB_MsgSub, $DB_MsgBodyHTML);
    $DB_MsgBodyText = preg_replace($Pattern, $DB_MsgSub, $DB_MsgBodyText);
    $Send_Subject = preg_replace($Pattern, $DB_MsgSub, $Send_Subject);
    $unsubcode = "u" . $DB_UniqueCode;
    $UnsubURL = $siteURL . "/?infresp=s&c=" . $unsubcode;
    // echo "Unsub URL: ".$UnsubURL."<br>\n";
    $UnsubMSG_HTML = "{$newline}<br><br>------------------------------------------------<br>{$newline}";
    $UnsubMSG_HTML .= "<A HREF=\"{$UnsubURL}\">Unsubscribe</A><br>{$newline}";
    if ($cop != TRUE) {
        $UnsubMSG_HTML .= "Powered by <A HREF=\"http://pluginreview.net/wordpress-plugins/wp-infinity-responder\">WP Infinity Responder</A><br>{$newline}";
    }
    $UnsubMSG_Text = "{$newline}------------------------------------------------{$newline}";
    $UnsubMSG_Text .= "Unsubscribe: {$UnsubURL} {$newline}";
    if ($cop != TRUE) {
        $UnsubMSG_Text .= "Powered by WP Infinity Responder. {$newline}";
    }
    $Unsub_Pattern = '/%unsub_msg%/i';
    $DB_MsgBodyHTML = preg_replace($Unsub_Pattern, $UnsubMSG_HTML, $DB_MsgBodyHTML);
    $DB_MsgBodyText = preg_replace($Unsub_Pattern, $UnsubMSG_Text, $DB_MsgBodyText);
    # MOD New tag for unsub link only
    $Unsub_Link_Pattern = '/%unsub_link%/i';
    $DB_MsgBodyHTML = preg_replace($Unsub_Link_Pattern, $UnsubURL, $DB_MsgBodyHTML);
    $DB_MsgBodyText = preg_replace($Unsub_Link_Pattern, $UnsubURL, $DB_MsgBodyText);
    $Pattern = '/%RespDir%/i';
    $DB_MsgBodyHTML = preg_replace($Pattern, $ResponderDirectory, $DB_MsgBodyHTML);
    $DB_MsgBodyText = preg_replace($Pattern, $ResponderDirectory, $DB_MsgBodyText);
    $Send_Subject = preg_replace($Pattern, $ResponderDirectory, $Send_Subject);
    $Pattern = '/%SiteURL%/i';
    $DB_MsgBodyHTML = preg_replace($Pattern, "<A HREF=\"{$siteURL}\">{$siteURL}</A>", $DB_MsgBodyHTML);
    $DB_MsgBodyText = preg_replace($Pattern, $siteURL, $DB_MsgBodyText);
    $Send_Subject = preg_replace($Pattern, $siteURL, $Send_Subject);
    $Pattern = '/%subr_id%/i';
    $DB_MsgBodyHTML = preg_replace($Pattern, $DB_SubscriberID, $DB_MsgBodyHTML);
    $DB_MsgBodyText = preg_replace($Pattern, $DB_SubscriberID, $DB_MsgBodyText);
    $Send_Subject = preg_replace($Pattern, $DB_SubscriberID, $Send_Subject);
    $Pattern = '/%subr_emailaddy%/i';
    $DB_MsgBodyHTML = preg_replace($Pattern, $DB_EmailAddress, $DB_MsgBodyHTML);
    $DB_MsgBodyText = preg_replace($Pattern, $DB_EmailAddress, $DB_MsgBodyText);
    $Send_Subject = preg_replace($Pattern, $DB_EmailAddress, $Send_Subject);
    $Pattern = '/%subr_firstname%/i';
    $DB_MsgBodyHTML = preg_replace($Pattern, $DB_FirstName, $DB_MsgBodyHTML);
    $DB_MsgBodyText = preg_replace($Pattern, $DB_FirstName, $DB_MsgBodyText);
    $Send_Subject = preg_replace($Pattern, $DB_FirstName, $Send_Subject);
    $Pattern = '/%subr_lastname%/i';
    $DB_MsgBodyHTML = preg_replace($Pattern, $DB_LastName, $DB_MsgBodyHTML);
    $DB_MsgBodyText = preg_replace($Pattern, $DB_LastName, $DB_MsgBodyText);
    $Send_Subject = preg_replace($Pattern, $DB_LastName, $Send_Subject);
    $Pattern = '/%subr_firstname_fix%/i';
    $DB_MsgBodyHTML = preg_replace($Pattern, my_ucwords($DB_FirstName), $DB_MsgBodyHTML);
    $DB_MsgBodyText = preg_replace($Pattern, my_ucwords($DB_FirstName), $DB_MsgBodyText);
    $Send_Subject = preg_replace($Pattern, my_ucwords($DB_FirstName), $Send_Subject);
    # MOD %firstname% tag, copy of subr_firstname_fix for convenience
    $Pattern = '/%firstname%/i';
    $DB_MsgBodyHTML = preg_replace($Pattern, my_ucwords($DB_FirstName), $DB_MsgBodyHTML);
    $DB_MsgBodyText = preg_replace($Pattern, my_ucwords($DB_FirstName), $DB_MsgBodyText);
    $Send_Subject = preg_replace($Pattern, my_ucwords($DB_FirstName), $Send_Subject);
    $Pattern = '/%subr_lastname_fix%/i';
    $DB_MsgBodyHTML = preg_replace($Pattern, my_ucwords($DB_LastName), $DB_MsgBodyHTML);
    $DB_MsgBodyText = preg_replace($Pattern, my_ucwords($DB_LastName), $DB_MsgBodyText);
    $Send_Subject = preg_replace($Pattern, my_ucwords($DB_LastName), $Send_Subject);
    $Pattern = '/%subr_ipaddy%/i';
    $DB_MsgBodyHTML = preg_replace($Pattern, $DB_IPaddy, $DB_MsgBodyHTML);
    $DB_MsgBodyText = preg_replace($Pattern, $DB_IPaddy, $DB_MsgBodyText);
    $Send_Subject = preg_replace($Pattern, $DB_IPaddy, $Send_Subject);
    $Pattern = '/%subr_referralsource%/i';
    $DB_MsgBodyHTML = preg_replace($Pattern, $DB_ReferralSource, $DB_MsgBodyHTML);
    $DB_MsgBodyText = preg_replace($Pattern, $DB_ReferralSource, $DB_MsgBodyText);
    $Send_Subject = preg_replace($Pattern, $DB_ReferralSource, $Send_Subject);
    $Pattern = '/%resp_ownername%/i';
    $DB_MsgBodyHTML = preg_replace($Pattern, $DB_OwnerName, $DB_MsgBodyHTML);
    $DB_MsgBodyText = preg_replace($Pattern, $DB_OwnerName, $DB_MsgBodyText);
    $Send_Subject = preg_replace($Pattern, $DB_OwnerName, $Send_Subject);
    $Pattern = '/%resp_owneremail%/i';
    $DB_MsgBodyHTML = preg_replace($Pattern, $DB_OwnerEmail, $DB_MsgBodyHTML);
    $DB_MsgBodyText = preg_replace($Pattern, $DB_OwnerEmail, $DB_MsgBodyText);
    $Send_Subject = preg_replace($Pattern, $DB_OwnerEmail, $Send_Subject);
    $Pattern = '/%resp_replyto%/i';
    $DB_MsgBodyHTML = preg_replace($Pattern, $DB_ReplyToEmail, $DB_MsgBodyHTML);
    $DB_MsgBodyText = preg_replace($Pattern, $DB_ReplyToEmail, $DB_MsgBodyText);
    $Send_Subject = preg_replace($Pattern, $DB_ReplyToEmail, $Send_Subject);
    $Pattern = '/%resp_name%/i';
    $DB_MsgBodyHTML = preg_replace($Pattern, $DB_ResponderName, $DB_MsgBodyHTML);
    $DB_MsgBodyText = preg_replace($Pattern, $DB_ResponderName, $DB_MsgBodyText);
    $Send_Subject = preg_replace($Pattern, $DB_ResponderName, $Send_Subject);
    $Pattern = '/%resp_desc%/i';
    $DB_MsgBodyHTML = preg_replace($Pattern, $DB_ResponderDesc, $DB_MsgBodyHTML);
    $DB_MsgBodyText = preg_replace($Pattern, $DB_ResponderDesc, $DB_MsgBodyText);
    $Send_Subject = preg_replace($Pattern, $DB_ResponderDesc, $Send_Subject);
    $Pattern = '/%resp_optinredir%/i';
    $DB_MsgBodyHTML = preg_replace($Pattern, $DB_OptInRedir, $DB_MsgBodyHTML);
    $DB_MsgBodyText = preg_replace($Pattern, $DB_OptInRedir, $DB_MsgBodyText);
    $Send_Subject = preg_replace($Pattern, $DB_OptInRedir, $Send_Subject);
    $Pattern = '/%resp_optoutredir%/i';
    $DB_MsgBodyHTML = preg_replace($Pattern, $DB_OptOutRedir, $DB_MsgBodyHTML);
    $DB_MsgBodyText = preg_replace($Pattern, $DB_OptOutRedir, $DB_MsgBodyText);
    $Send_Subject = preg_replace($Pattern, $DB_OptOutRedir, $Send_Subject);
    $Pattern = '/%resp_optindisplay%/i';
    $DB_MsgBodyHTML = preg_replace($Pattern, $DB_OptInDisplay, $DB_MsgBodyHTML);
    $DB_MsgBodyText = preg_replace($Pattern, $DB_OptInDisplay, $DB_MsgBodyText);
    $Send_Subject = preg_replace($Pattern, $DB_OptInDisplay, $Send_Subject);
    $Pattern = '/%resp_optoutdisplay%/i';
    $DB_MsgBodyHTML = preg_replace($Pattern, $DB_OptOutDisplay, $DB_MsgBodyHTML);
    $DB_MsgBodyText = preg_replace($Pattern, $DB_OptOutDisplay, $DB_MsgBodyText);
    $Send_Subject = preg_replace($Pattern, $DB_OptOutDisplay, $Send_Subject);
    $Pattern = '/%Subr_UniqueCode%/i';
    $DB_MsgBodyHTML = preg_replace($Pattern, $DB_UniqueCode, $DB_MsgBodyHTML);
    $DB_MsgBodyText = preg_replace($Pattern, $DB_UniqueCode, $DB_MsgBodyText);
    $Send_Subject = preg_replace($Pattern, $DB_UniqueCode, $Send_Subject);
    $Pattern = '/%Subr_JoinedMonthNum%/i';
    $DB_MsgBodyHTML = preg_replace($Pattern, $Joined_MonthNum, $DB_MsgBodyHTML);
    $DB_MsgBodyText = preg_replace($Pattern, $Joined_MonthNum, $DB_MsgBodyText);
    $Send_Subject = preg_replace($Pattern, $Joined_MonthNum, $Send_Subject);
    $Pattern = '/%Subr_JoinedMonth%/i';
    $DB_MsgBodyHTML = preg_replace($Pattern, $Joined_Month, $DB_MsgBodyHTML);
    $DB_MsgBodyText = preg_replace($Pattern, $Joined_Month, $DB_MsgBodyText);
    $Send_Subject = preg_replace($Pattern, $Joined_Month, $Send_Subject);
    $Pattern = '/%Subr_JoinedYear%/i';
    $DB_MsgBodyHTML = preg_replace($Pattern, $Joined_Year, $DB_MsgBodyHTML);
    $DB_MsgBodyText = preg_replace($Pattern, $Joined_Year, $DB_MsgBodyText);
    $Send_Subject = preg_replace($Pattern, $Joined_Year, $Send_Subject);
    $Pattern = '/%Subr_JoinedDay%/i';
    $DB_MsgBodyHTML = preg_replace($Pattern, $Joined_Day, $DB_MsgBodyHTML);
    $DB_MsgBodyText = preg_replace($Pattern, $Joined_Day, $DB_MsgBodyText);
    $Send_Subject = preg_replace($Pattern, $Joined_Day, $Send_Subject);
    $Pattern = '/%Subr_LastActiveMonthNum%/i';
    $DB_MsgBodyHTML = preg_replace($Pattern, $LastActive_MonthNum, $DB_MsgBodyHTML);
    $DB_MsgBodyText = preg_replace($Pattern, $LastActive_MonthNum, $DB_MsgBodyText);
    $Send_Subject = preg_replace($Pattern, $LastActive_MonthNum, $Send_Subject);
    $Pattern = '/%Subr_LastActiveMonth%/i';
    $DB_MsgBodyHTML = preg_replace($Pattern, $LastActive_Month, $DB_MsgBodyHTML);
    $DB_MsgBodyText = preg_replace($Pattern, $LastActive_Month, $DB_MsgBodyText);
    $Send_Subject = preg_replace($Pattern, $LastActive_Month, $Send_Subject);
    $Pattern = '/%Subr_LastActiveYear%/i';
    $DB_MsgBodyHTML = preg_replace($Pattern, $LastActive_Year, $DB_MsgBodyHTML);
    $DB_MsgBodyText = preg_replace($Pattern, $LastActive_Year, $DB_MsgBodyText);
    $Send_Subject = preg_replace($Pattern, $LastActive_Year, $Send_Subject);
    $Pattern = '/%Subr_LastActiveDay%/i';
    $DB_MsgBodyHTML = preg_replace($Pattern, $LastActive_Day, $DB_MsgBodyHTML);
    $DB_MsgBodyText = preg_replace($Pattern, $LastActive_Day, $DB_MsgBodyText);
    $Send_Subject = preg_replace($Pattern, $LastActive_Day, $Send_Subject);
    $Pattern = '/%date_today%/i';
    $the_date = date($date_format, strtotime("today"));
    $DB_MsgBodyHTML = preg_replace($Pattern, $the_date, $DB_MsgBodyHTML);
    $DB_MsgBodyText = preg_replace($Pattern, $the_date, $DB_MsgBodyText);
    $Send_Subject = preg_replace($Pattern, $the_date, $Send_Subject);
    $Pattern = '/%date_yesterday%/i';
    $the_date = date($date_format, strtotime("yesterday"));
    $DB_MsgBodyHTML = preg_replace($Pattern, $the_date, $DB_MsgBodyHTML);
    $DB_MsgBodyText = preg_replace($Pattern, $the_date, $DB_MsgBodyText);
    $Send_Subject = preg_replace($Pattern, $the_date, $Send_Subject);
    $Pattern = '/%date_tomorrow%/i';
    $the_date = date($date_format, strtotime("tomorrow"));
    $DB_MsgBodyHTML = preg_replace($Pattern, $the_date, $DB_MsgBodyHTML);
    $DB_MsgBodyText = preg_replace($Pattern, $the_date, $DB_MsgBodyText);
    $Send_Subject = preg_replace($Pattern, $the_date, $Send_Subject);
    $Pattern = '/%next_monday%/i';
    $the_date = date($date_format, strtotime("next monday"));
    $DB_MsgBodyHTML = preg_replace($Pattern, $the_date, $DB_MsgBodyHTML);
    $DB_MsgBodyText = preg_replace($Pattern, $the_date, $DB_MsgBodyText);
    $Send_Subject = preg_replace($Pattern, $the_date, $Send_Subject);
    $Pattern = '/%next_tuesday%/i';
    $the_date = date($date_format, strtotime("next tuesday"));
    $DB_MsgBodyHTML = preg_replace($Pattern, $the_date, $DB_MsgBodyHTML);
    $DB_MsgBodyText = preg_replace($Pattern, $the_date, $DB_MsgBodyText);
    $Send_Subject = preg_replace($Pattern, $the_date, $Send_Subject);
    $Pattern = '/%next_wednesday%/i';
    $the_date = date($date_format, strtotime("next wednesday"));
    $DB_MsgBodyHTML = preg_replace($Pattern, $the_date, $DB_MsgBodyHTML);
    $DB_MsgBodyText = preg_replace($Pattern, $the_date, $DB_MsgBodyText);
    $Send_Subject = preg_replace($Pattern, $the_date, $Send_Subject);
    $Pattern = '/%next_thursday%/i';
    $the_date = date($date_format, strtotime("next thursday"));
    $DB_MsgBodyHTML = preg_replace($Pattern, $the_date, $DB_MsgBodyHTML);
    $DB_MsgBodyText = preg_replace($Pattern, $the_date, $DB_MsgBodyText);
    $Send_Subject = preg_replace($Pattern, $the_date, $Send_Subject);
    $Pattern = '/%next_friday%/i';
    $the_date = date($date_format, strtotime("next friday"));
    $DB_MsgBodyHTML = preg_replace($Pattern, $the_date, $DB_MsgBodyHTML);
    $DB_MsgBodyText = preg_replace($Pattern, $the_date, $DB_MsgBodyText);
    $Send_Subject = preg_replace($Pattern, $the_date, $Send_Subject);
    $Pattern = '/%next_saturday%/i';
    $the_date = date($date_format, strtotime("next saturday"));
    $DB_MsgBodyHTML = preg_replace($Pattern, $the_date, $DB_MsgBodyHTML);
    $DB_MsgBodyText = preg_replace($Pattern, $the_date, $DB_MsgBodyText);
    $Send_Subject = preg_replace($Pattern, $the_date, $Send_Subject);
    $Pattern = '/%next_sunday%/i';
    $the_date = date($date_format, strtotime("next sunday"));
    $DB_MsgBodyHTML = preg_replace($Pattern, $the_date, $DB_MsgBodyHTML);
    $DB_MsgBodyText = preg_replace($Pattern, $the_date, $DB_MsgBodyText);
    $Send_Subject = preg_replace($Pattern, $the_date, $Send_Subject);
    # -------------------------
    # Custom fields
    $infrespcustomfields = $table_prefix . 'InfResp_customfields';
    $query = "SELECT * FROM " . $infrespcustomfields . " WHERE user_attached = '{$DB_SubscriberID}' LIMIT 1";
    $result = mysql_query($query, $DB_LinkID) or die("Invalid query: " . mysql_error());
    if (mysql_num_rows($result) > 0) {
        $data = mysql_fetch_assoc($result);
        foreach ($data as $name => $value) {
            $Pattern = "/%cf_{$name}%/i";
            $DB_MsgBodyHTML = preg_replace($Pattern, $data[$name], $DB_MsgBodyHTML);
            $DB_MsgBodyText = preg_replace($Pattern, $data[$name], $DB_MsgBodyText);
            $Send_Subject = preg_replace($Pattern, $data[$name], $Send_Subject);
        }
    }
    $message['BodyText'] = $DB_MsgBodyText;
    $message['BodyHTML'] = $DB_MsgBodyHTML;
    $message['Subject'] = $Send_Subject;
    return $message;
}