Example #1
0
 function convert_field_name($string)
 {
     $string = str_replace("_", " ", $string);
     if (function_exists('my_ucwords')) {
         return my_ucwords($string, 1);
     } else {
         return ucsmart($string);
     }
 }
Example #2
0
function title_case($title)
{
    $smallwordsarray = array('da', 'de', 'a', 'e', 'o', 'u', 'não', 'do');
    $words = explode(' ', $title);
    foreach ($words as $key => $word) {
        if ($key == 0 or !in_array($word, $smallwordsarray)) {
            $words[$key] = my_ucwords(strtolower($word));
        }
    }
    $newtitle = implode(' ', $words);
    return $newtitle;
}
Example #3
0
function convert_field_name($string)
{
    $string = str_replace("_", " ", $string);
    return my_ucwords($string);
}
Example #4
0
File: index.php Project: cokita/srp
             }
         }
         $componentePrincipal = new $controle(ControleSessao::$params);
         $view = Control::carregarInterface($interface);
         $conteudoComponente = $componentePrincipal->{$action}();
         $params = ControleSessao::$params;
         Componente::inclusaoDependencias($params, $view, $componentePrincipal);
         Componente::inclusaoComponentes($params, $view);
         Componente::inclusaoComponentes($params, $conteudoComponente, $view);
         $view->setVariable("aplicacao", $conteudoComponente->get());
         $conteudo = $conteudoComponente->get();
         $view->touchBlock("Logout");
         verificarControleMenu($controle, $params, $view);
         $view->setVariable("usuario_logado", my_ucwords(mb_strtolower($_SESSION["user_nome"], 'UTF-8')));
         $view->setVariable("centro_custo", my_ucwords(mb_strtolower($_SESSION["centro_custo"], 'UTF-8')));
         $view->setVariable("cargo", my_ucwords(mb_strtolower($_SESSION["cargo"], 'UTF-8')));
         $view->setVariable("data_ultimo_acesso", formatDataWEBComHora($_SESSION["data_ultimo_acesso"], 'UTF-8'));
         $view->setVariable("url", URL);
         $view->setVariable('controle', ControleSessao::$control);
         $view->setVariable("aplicacao", $conteudo);
     } else {
         header("Location: " . URL . "Permissao_404");
     }
 } else {
     $interface = "index.html";
     if (!ControleSessao::$control || ControleSessao::$control == "admin.php") {
         $controle = "ControleLogin";
     } else {
         $controle = "Controle" . ControleSessao::$control;
     }
     if (class_exists($controle)) {
Example #5
0
function createperson($email, $password, $firstname, $middlename, $lastname, $sex, $adr1, $adr2, $streetno, $floor, $adr3, $zip, $city, $country, $languagepref, $tel, $mobil, $email, $birthday, $club, $status1 ='', $status2='', $status3='')
{
	global $db_conn;

	$now_time = time();
	$created = strftime("%Y-%m-%d", $now_time);
	$changed = strftime("%Y-%m-%d", $now_time);
	$rights = 100000;
	$firstname = addslashes($firstname);
	$middlename = addslashes($middlename);
	$lastname = addslashes($lastname);
	$sex = addslashes($sex);
	$adr1 = addslashes($adr1);
	$adr2 = addslashes($adr2);
	$streetno = addslashes($streetno);
	$floor = addslashes($floor);
	$adr3 = addslashes($adr3);
	$zip = addslashes($zip);
	$city = addslashes($city);
	$country = addslashes($country);
	$languagepref = addslashes($languagepref);
	$tel = addslashes($tel);
	$mobil = addslashes($mobil);
	$email = addslashes($email);
	$club = addslashes($club);
	$password = addslashes($password);
	$status1 = addslashes($status1);
	$status2 = addslashes($status2);
	$status3 = addslashes($status3);
	$rights = addslashes($rights);
	$privacy = addslashes($privacy);

// Trim blanks
$firstname = trim($firstname);
$middlename = trim($middlename);
$lastname = trim($lastname);
$sex = trim($sex);
$adr1 = trim($adr1);
$adr2 = trim($adr2);
$streetno = trim($streetno);
$floor = trim($floor);
$adr3 = trim($adr3);
$zip = trim($zip);
$city = trim($city);
$country = trim($country);
$languagepref = trim($languagepref);
$tel = trim($tel);
$mobil = trim($mobil);
$email = trim($email);
$club = trim($club);
$password = trim($password);
$status1 = trim($status1);
$status2 = trim($status2);
$status3 = trim($status3);
$rights = trim($rights);
$privacy = trim($privacy);

$firstname = my_ucwords($firstname, $is_name=true);
$middlename = my_ucwords($middlename, $is_name=true);
$lastname = my_ucwords($lastname, $is_name=true);

if ($country == '')
{
	$country = 'DK';
}

	if ($password == "")
	{
		$password = create_password("$firstname$email");
	}
	$fields = "firstname, middlename, lastname, sex, adr1, adr2, streetno, floor, adr3, zip, city, country, languagepref, tel, mobil, email, birthday, club, password, status1, status2, status3, rights, privacy, ownupdate, created, changed, uid";
	$values = "'$firstname', '$middlename', '$lastname', '$sex', '$adr1', '$adr2', '$streetno', '$floor', '$adr3', '$zip', '$city', '$country', '$languagepref', '$tel', '$mobil', '$email', '$birthday', '$club', '$password', '$status1', '$status2', '$status3', '$rights', '$privacy', '$ownupdate', '$created', '$changed', '$uid'";
	$query = "insert into ff_persons ($fields) values ($values)";
	$query = mac2ibm($query);
    if(!($result = @mysql_query($query, $db_conn)))
    {
	    echo("Error : $errstr\n");
        exit;
    }

	// get puid
	$query = "SELECT LAST_INSERT_ID()";
    if(!($result = @mysql_query($query, $db_conn)))
    {
	    echo("Error : $errstr\n");
        exit;
    }
		if (mysql_num_rows($result)>0)
	{
        $row = mysql_fetch_row($result);
        $uid = doubleval($row[0]);
		return($uid);
	} 
	// end get puid
	
}
function title_case($title, $lc_extra = null, $uc_extra = null, $exact_extra = null)
{
    $title = strtolower($title);
    // words to keep lower case
    $lc_stopwords = array('of', 'a', 'the', 'and', 'an', 'or', 'nor', 'but', 'is', 'if', 'then', 'else', 'when', 'at', 'from', 'by', 'on', 'off', 'for', 'in', 'out', 'over', 'to', 'into', 'with', 'als', 'aneb', 'auf', 'aus', 'av', 'con', 'de', 'del', 'den', 'der', 'des', 'di', 'die', 'ds', 'du', 'e', 'en', 'et', 'fra', 'für', 'ihr', 'il', 'im', 'ist', 'la', 'le', 'les', 'mit', 'na', 'ne', 'o', 'och', 'oder', 'og', 'om', 'per', 'po', 'pour', 'pro', 'son', 'til', 'till', 'um', 'un', 'una', 'una', 'und', 'und', 'unserer', 'vom', 'von', 'voor', 'vor', 'was', 'we', 'wsi', 'y', 'z', 'za');
    if (!is_null($lc_extra) && is_array($lc_extra)) {
        $lc_stopwords = array_merge($lc_stopwords, $lc_extra);
    }
    // words to capitalise
    $uc_stopwords = array('bbc', 'bufvc', 'rsc', 'jfk', 'pa', 'bc', 'ad', 'tv', 'ac', 'dc', 'ii', 'iii', 'iv', 'vi', 'vii', 'viii', 'ix', 'xx');
    if (!is_null($uc_extra) && is_array($uc_extra)) {
        $uc_stopwords = array_merge($uc_stopwords, $uc_extra);
    }
    // special words to handle
    $exact_stopwords = array();
    if (!is_null($exact_extra) && is_array($exact_extra)) {
        $exact_stopwords = array_merge($exact_stopwords, $exact_extra);
    }
    $foundPunctuation = false;
    // flag
    $words = explode(' ', $title);
    foreach ($words as $key => $word) {
        // special case, two words around ellipsis
        $second = '';
        if (preg_match('/([a-z]+\\.\\.\\.)([a-z]+)/', $word, $matches)) {
            $word = $matches[1];
            // first half
            $second = $matches[2];
            // second half
            // handle second half here
            if (in_array($second, $uc_stopwords)) {
                $second = strtoupper($second);
            } else {
                if (array_key_exists($second, $exact_stopwords)) {
                    $second = $exact_stopwords[$second];
                } else {
                    if (!in_array($second, $lc_stopwords)) {
                        $second = my_ucwords($second);
                    }
                }
            }
        }
        // remove trailing punctuation before test
        $string = preg_replace('/[[:punct:]]+$/', '', $word);
        // also remove leading punctuation before exact stopwords test
        $string_no_punct = preg_replace('/^[[:punct:]]+/', '', $string);
        // exact stopwords
        if (array_key_exists($string_no_punct, $exact_stopwords)) {
            $words[$key] = preg_replace('/' . $string_no_punct . '/', $exact_stopwords[$string_no_punct], $word);
        } else {
            if (in_array($string_no_punct, $uc_stopwords)) {
                $words[$key] = strtoupper($word);
            } else {
                if ($foundPunctuation) {
                    $words[$key] = my_ucwords($word);
                    $foundPunctuation = false;
                    // reset flag
                } else {
                    if ($key == 0 or !in_array($string, $lc_stopwords)) {
                        $words[$key] = my_ucwords($word);
                    } else {
                        $words[$key] = $word;
                    }
                }
            }
        }
        // finish handling ellipsis special case
        if ($second != '') {
            $words[$key] = $words[$key] . $second;
            $word = $second;
        }
        // check for trailing punctuation
        if (preg_match('/[[:punct:]]$/', $word)) {
            $foundPunctuation = true;
        }
        // set flag
    }
    $newtitle = implode(' ', $words);
    return $newtitle;
}
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;
}