Mailer New Newsletter Edits

From MontegoScriptsWiki
Jump to: navigation, search

Home>Mailer>New Installation>Core File Edits>admin/modules/newsletter.php

Given the vast number of *nuke-based forks and versions across all of these, we cannot possibly provide updates to all of them. In fact, the bulk of the updates will be based upon PHP-Nuke 7.6 just like the instructions for new installations. However, where possible, a few RavenNukeā„¢ specific notes will be added as helpful hints along the way.

RavenNukeā„¢ installations of version 2.30.00 and greater can ignore these instructions as the PHP-Nuke Newsletter module was replaced by the more functional HTML Newsletter module which already has this embedded and the older code should still work.

Open File

Open the following script:

admin/modules/newsletter.php

Replace newsletter_send() Function

FIND THIS CODE BLOCK (The Entire Function):

function newsletter_send($title, $content) {
    global $user_prefix, $sitename, $db, $nukeurl, $adminmail, $admin_file;
    $send_html_messages = "yes";
    $from = $adminmail;
    $subject = "[$sitename Newsletter]: " . stripslashes($title) . "";
    $content = stripslashes($content);
    $content = "$sitename " . _NEWSLETTER . "\n\n\n$content\n\n- $sitename " . _STAFF . "\n\n\n\n\n\n" . _NLUNSUBSCRIBE . "";
    $result = $db->sql_query("SELECT user_email from " . $user_prefix . "_users where newsletter='1'");
    while ($row = $db->sql_fetchrow($result)) {
        $user_email = $row['user_email'];
        $xheaders = "From: " . $sitename . " <" . $adminmail . ">\n";
        $xheaders .= "X-Sender: <" . $adminmail . ">\n";
        $xheaders .= "X-Mailer: PHP\n"; // mailer
        $xheaders .= "X-Priority: 6\n"; // Urgent message!
        if ($send_html_messages == "yes") {
                $xheaders .= "Content-Type: text/html; charset=iso-8859-1\n"; // Mime type
        }
        mail("$user_email","$subject","$content",$xheaders);
    }
    Header("Location: ".$admin_file.".php?op=newsletter_sent");
}

REPLACE WITH:

/*
 * TegoNuke(tm) Mailer
 */
function newsletter_send($title, $content) {
    global $user_prefix, $sitename, $db, $nukeurl, $adminmail, $admin_file;
    $send_html_messages = "yes";
    $from = $adminmail;
    $subject = "[$sitename Newsletter]: " . stripslashes($title) . "";
    $content = stripslashes($content);
    $content = "$sitename " . _NEWSLETTER . "\n\n\n$content\n\n- $sitename " . _STAFF . "\n\n\n\n\n\n" . _NLUNSUBSCRIBE . "";
    $xheaders = "From: $sitename <$adminmail>\r\n";
    $xheaders .= "X-Sender: <" . $adminmail . ">\r\n";
    $xheaders .= "X-Mailer: PHP\r\n"; // mailer
    $xheaders .= "X-Priority: 3\r\n"; // Change the 3 to 6 to make it "Urgent"
    if ($send_html_messages == "yes") {
        $encode = 1;
        $xheaders .= "Content-Type: text/html; charset=iso-8859-1\n"; // Mime type
    } else {
        $encode = 0;
        $xheaders .= "Content-Type: text/plain; charset=iso-8859-1\n"; // Mime type
    }
    $tnml_asTo = array();
    $result = $db->sql_query("SELECT user_email, username from " . $user_prefix . "_users where newsletter='1'");
    while ($row = $db->sql_fetchrow($result)) {
        $tnml_asTo[] = array($row['user_email'], $row['username']);
    }
    $mailsuccess = false;
    if (TNML_IS_ACTIVE) {
        $params = array('html' => $encode, 'batch' => 1);
        $mailsuccess = tnml_fMailer($tnml_asTo, $subject, $content, $adminmail, $sitename, $params);
    } else {
        foreach($tnml_asTo as $to) {
            $to2 = $to[1] . ' <' . $to[0] . '>';
            $mailsuccess = mail($to2, $subject, $content, $xheaders);
        }
    }
    Header("Location: ".$admin_file.".php?op=newsletter_sent");
}
/*
 * end of TegoNuke(tm) Mailer replace function
 */

Replace massmail() Function

FIND THIS CODE BLOCK (The Entire Function):

function massmail_send($title, $content) {
    global $user_prefix, $sitename, $db, $nukeurl, $adminmail, $admin_file;
    $send_html_messages = "yes";
    $from = $adminmail;
    $subject = "[$sitename]: $title";
    $content = stripslashes($content);
    $content = "" . _FROM . ": $sitename\n\n\n\n$content\n\n\n\n- $sitename " . _STAFF . "\n\n\n\n" . _MASSEMAILMSG . "";
    $result = $db->sql_query("SELECT user_email from " . $user_prefix . "_users where user_id != '1'");
    while ($row = $db->sql_fetchrow($result)) {
    $user_email = $row['user_email'];
        $xheaders = "From: " . $sitename . " <" . $adminmail . ">\n";
        $xheaders .= "X-Sender: <" . $adminmail . ">\n";
        $xheaders .= "X-Mailer: PHP\n"; // mailer
        $xheaders .= "X-Priority: 6\n"; // Urgent message!
        if ($send_html_messages == "yes") {
                $xheaders .= "Content-Type: text/html; charset=iso-8859-1\n"; // Mime type
        }
        mail("$user_email","$subject","$content",$xheaders);
    }
    Header("Location: ".$admin_file.".php?op=massmail_sent");
}

REPLACE WITH:

/*
 * TegoNuke(tm) Mailer
 */
function massmail_send($title, $content) {
    global $user_prefix, $sitename, $db, $nukeurl, $adminmail, $admin_file;
    $send_html_messages = "yes";
    $from = $adminmail;
    $subject = "[$sitename]: $title";
    $content = stripslashes($content);
    $content = "" . _FROM . ": $sitename\n\n\n\n$content\n\n\n\n- $sitename " . _STAFF . "\n\n\n\n" . _MASSEMAILMSG . "";
    $xheaders = "From: " . $sitename . " <" . $adminmail . ">\n";
    $xheaders .= "X-Sender: <" . $adminmail . ">\n";
    $xheaders .= "X-Mailer: PHP\n"; // mailer
    $xheaders .= "X-Priority: 6\n"; // Urgent message!
    if ($send_html_messages == "yes") {
        $encode = 1;
        $xheaders .= "Content-Type: text/html; charset=iso-8859-1\n"; // Mime type
    } else {
        $encode = 0;
        $xheaders .= "Content-Type: text/plain; charset=iso-8859-1\n"; // Mime type
    }
    $tnml_asTo = array();
    $result = $db->sql_query("SELECT user_email, username from " . $user_prefix . "_users where user_id != '1'");
    while ($row = $db->sql_fetchrow($result)) {
        $tnml_asTo[] = array($row['user_email'], $row['username']);
    }
    $mailsuccess = false;
    if (TNML_IS_ACTIVE) {
        $params = array('html' => $encode, 'batch' => 1);
        $mailsuccess = tnml_fMailer($tnml_asTo, $subject, $content, $adminmail, $sitename, $params);
    } else {
        foreach($tnml_asTo as $to) {
            $to2 = $to[1] . ' <' . $to[0] . '>';
            $mailsuccess = mail($to2, $subject, $content, $xheaders);
        }
    }
    Header("Location: ".$admin_file.".php?op=massmail_sent");
}
/*
 * end of TegoNuke(tm) Mailer replace function
 */
Personal tools