$text = nl2br(htmlspecialchars($text));
        }
    }
    if ($FUD_OPT_1 & 6144) {
        char_fix($text);
    }
    if ($FUD_OPT_1 & 8192 && !$msg_smiley_disabled) {
        $text = smiley_to_post($text);
    }
    $text_s = htmlspecialchars($text_s);
    char_fix($text_s);
    $spell = $spell_check_button && isset($_POST['spell']);
    if ($spell && strlen($text)) {
        $text = check_data_spell($text, 'body', $usr->pspell_lang);
    }
    fud_wordwrap($text);
    $subj = $spell && !$no_spell_subject && $text_s ? check_data_spell($text_s, 'subject', $usr->pspell_lang) : $text_s;
    $signature = $FUD_OPT_1 & 32768 && $usr->sig && $msg_show_sig ? '<p><u>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</u><br />' . $usr->sig . '' : '';
    $apply_spell_changes = $spell ? '<input type="submit" class="button" name="btn_spell" value="Apply Spelling Changes">&nbsp;' : '';
    $preview_message = '<div align="center"><table border="0" cellspacing="1" cellpadding="2" class="PreviewTable">
<tr><th colspan=2>Post Preview</th></tr>
<tr><td class="RowStyleA"><font class="MsgSubText">' . $subj . '</font></td></tr>
<tr><td class="RowStyleA"><font class="MsgBodyText">' . $text . $signature . '</font></td></tr>
<tr><td align="left" class="RowStyleB">' . $apply_spell_changes . '<input type="submit" class="button" name="btn_submit" value="Send" tabindex="5" onClick="javascript: document.post_form.btn_action.value=\'send\';">&nbsp;<input type="submit" tabindex="4" class="button" value="Preview Message" name="preview">&nbsp;' . $spell_check_button . '<input type="submit" class="button" name="btn_draft" value="Save Draft" onClick="javascript: document.post_form.btn_action.value=\'draft\';"></td></tr>
</table></div><br />';
} else {
    $preview_message = '';
}
$post_error = is_post_error() ? '<h4 align="center"><font class="ErrorText">You have an error</font></h4>' : '';
$to_err = get_err('msg_to_list');
$msg_subect_err = get_err('msg_subject');
 $uent->bday = fmt_year($_POST['b_year']) . str_pad((int) $_POST['b_month'], 2, '0', STR_PAD_LEFT) . str_pad((int) $_POST['b_day'], 2, '0', STR_PAD_LEFT);
 $uent->sig = apply_custom_replace($uent->sig);
 if ($FUD_OPT_1 & 131072) {
     $uent->sig = tags_to_html($uent->sig, $FUD_OPT_1 & 524288);
 } else {
     if ($FUD_OPT_1 & 65536) {
         $uent->sig = nl2br(htmlspecialchars($uent->sig));
     }
 }
 if ($FUD_OPT_1 & 196608) {
     char_fix($uent->sig);
 }
 if ($FUD_OPT_1 & 262144) {
     $uent->sig = smiley_to_post($uent->sig);
 }
 fud_wordwrap($uent->sig);
 if ($uent->bio) {
     $uent->bio = htmlspecialchars($uent->bio);
     char_fix($uent->bio);
 }
 if (!$uent->icq && !($uent->users_opt & 4)) {
     $uent->users_opt |= 4;
 }
 /* Restore avatar values to their previous values */
 $uent->avatar = $old_avatar;
 $uent->avatar_loc = $old_avatar_loc;
 $old_opt = $uent->users_opt & (4194304 | 16777216 | 8388608);
 $uent->users_opt |= 4194304 | 16777216 | 8388608;
 /* prevent non-confirmed users from playing with avatars, yes we are that cruel */
 if ($FUD_OPT_1 & 28 && _uid) {
     if ($_POST['avatar_type'] == 'b') {
    if ($m[1] == md5($GLOBALS['WWW_ROOT'])) {
        q("UPDATE " . sql_p . "msg SET mlist_msg_id='" . addslashes($emsg->msg_id) . "' WHERE id=" . intval($m[2]) . " AND mlist_msg_id IS NULL");
        if (db_affected()) {
            exit;
        }
    }
}
$msg_post->body = apply_custom_replace($emsg->body);
if (!($mlist->mlist_opt & 16)) {
    if ($frm->forum_opt & 16) {
        $msg_post->body = tags_to_html($msg_post->body, 0);
    } else {
        $msg_post->body = nl2br($msg_post->body);
    }
}
fud_wordwrap($msg_post->body);
$msg_post->subject = htmlspecialchars(apply_custom_replace($emsg->subject));
if (!strlen($msg_post->subject)) {
    mlist_error_log("Blank Subject", $emsg->raw_msg);
}
if (!$emsg->from_email || !$emsg->from_name) {
    $msg_post->poster_id = 0;
} else {
    $msg_post->poster_id = match_user_to_post($emsg->from_email, $emsg->from_name, $mlist->mlist_opt & 64, $emsg->user_id);
}
$msg_post->ip_addr = $emsg->ip;
$msg_post->mlist_msg_id = addslashes($emsg->msg_id);
$msg_post->attach_cnt = 0;
$msg_post->poll_id = 0;
$msg_post->msg_opt = 2;
$msg_post->post_stamp = !empty($emsg->headers['date']) ? strtotime($emsg->headers['date']) : 0;