Mailer New Mainfile Edits

From MontegoScriptsWiki
Jump to: navigation, search

Home>Mailer>New Installation>Core File Edits>mainfile.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.

This edit is what brings the TegoNuke™ Mailer into operation. Without the first change listed here, the Mailer is never called into action. The required edits follow.

Open File

Open the following script off your *nuke web root:

mainfile.php

Ensure Mailer Helper Function is Loaded

If you cannot find the below code, than you are behind on your patch levels. See Alternate Edits section down below for other possible versions of this.

FIND CODE:

@require_once(INCLUDE_PATH.'db/db.php');
@require_once(INCLUDE_PATH.'includes/sql_layer.php');
@require_once(INCLUDE_PATH.'includes/ipban.php');
if (file_exists(INCLUDE_PATH.'includes/custom_files/custom_mainfile.php')) {
    @include_once(INCLUDE_PATH.'includes/custom_files/custom_mainfile.php');
}

AFTER THE ABOVE ADD THESE LINES:

/**
 * TegoNuke(tm) Mailer
 */
include_once(INCLUDE_PATH . 'includes/tegonuke/mailer/mailer.php');
 
/*
 * NOTE: NukeSentinel and NSN Groups MUST come after as both use the PHP mail() function for their operations.
 * Actually, any script that could send an email out must be loaded AFTER TegoNuke(tm) Mailer.
 *
 * end of TegoNuke(tm) Mailer add
 */

Modify validate_mail Function Code

FIND THIS CODE BLOCK:

function validate_mail($email) {
  if(strlen($email) < 7 || !preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/", $email)) {
     //include_once("header.php");
     OpenTable();
     echo _ERRORINVEMAIL;
     CloseTable();
     //include_once("footer.php");
  }
  else {
     return $email;
  }
}

REPLACE WITH (OR IF YOU DO NOT HAVE THE ABOVE FUNCTION IN mailfile.php, THEN ADD):

function validate_mail($email) {
    if(strlen($email) < 7 || !preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/", $email)) {
// These next 3 lines have been commented out by Raven on 1/14/2007.
// Reason being, this function should only validate the email and return to the calling script.
// The calling script should handle the validation results.
//        OpenTable();
//        echo _ERRORINVEMAIL;
//        CloseTable();
        return false;
    } else {
        return $email;
    }
}

Modify paid() Function

FIND THIS CODE WITHIN FUNCTION paid():

mail($row['user_email'], $subject, $body, "From: $from\nX-Mailer: PHP/" . phpversion());

REPLACE WITH:

/*
 * TegoNuke(tm) Mailer
 */
$mailsuccess = false;
if (TNML_IS_ACTIVE) {
    $to = array(array($row['user_email'], $row['username']));
    $mailsuccess = tnml_fMailer($to, $subject, $body, $adminmail, $sitename);
} else {
    $mailsuccess = mail($row['user_email'], $subject, $body, "From: $from\r\nX-Mailer: PHP/" . phpversion());
}
//mail($row['user_email'], $subject, $body, "From: $from\nX-Mailer: PHP/" . phpversion());
/*
 * end of TegoNuke(tm) Mailer add
 */

Modify ads() Function

Do not be concerned if your version of PHP-Nuke does not have this function. This goes with the Advertising module which came in later nukes and RavenNuke™ with version 2.30.00.

FIND THIS CODE WITHIN FUNCTION ads():

mail($to, $subject, $message, 'From: '."$from\n".'X-Mailer: PHP/'.phpversion());

REPLACE WITH:

/*
 * TegoNuke(tm) Mailer
 */
$mailsuccess = false;
if (TNML_IS_ACTIVE) {
    $to2 = array(array($c_email, $c_contact));
    $mailsuccess = tnml_fMailer($to2, $subject, $body, $adminmail, $sitename);
} else {
    $mailsuccess = mail($to, $subject, $message, 'From: '."$from\r\n".'X-Mailer: PHP/'.phpversion());
}
//mail($to, $subject, $message, 'From: '."$from\n".'X-Mailer: PHP/'.phpversion());
/*
 * end of TegoNuke(tm) Mailer add
 */

This concludes the edits for this script.

Alternate Edits

If your set of includes in mainfile.php are anything other than the above or the below then you may need to post your code block in the forums and we'll do our best to help you sort it out.

IF YOU HAVE THIS:

if (defined('FORUM_ADMIN')) {
   @require_once("../../../config.php");
   @require_once("../../../db/db.php");
   @require_once("../../../includes/sql_layer.php");
   if (file_exists("../../../includes/custom_files/custom_mainfile.php")) { @include_once("../../../includes/custom_files/custom_mainfile.php"); }
   @require_once("../../../includes/ipban.php");
   if (defined('NUKE_HEADER') && file_exists("../../../includes/custom_files/custom_head.php")) { @include_once("../../../includes/custom_files/custom_head.php"); }
   if (defined('NUKE_HEADER') && file_exists("../../../includes/custom_files/custom_header.php")) { @include_once("../../../includes/custom_files/custom_header.php"); }
} elseif (defined('INSIDE_MOD')) {
   @require_once("../../config.php");
   @require_once("../../db/db.php");
   @require_once("../../includes/sql_layer.php");
   if (file_exists("../../includes/custom_files/custom_mainfile.php")) { @include_once("../../includes/custom_files/custom_mainfile.php"); }
   @require_once("../../includes/ipban.php");
   if (defined('NUKE_HEADER') && file_exists("../../includes/custom_files/custom_head.php")) { @include_once("../../includes/custom_files/custom_head.php"); }
   if (defined('NUKE_HEADER') && file_exists("../../includes/custom_files/custom_header.php")) { @include_once("../../includes/custom_files/custom_header.php"); }
} else {
   @require_once("config.php");
   @require_once("db/db.php");
   @require_once("includes/sql_layer.php");
   if (file_exists("includes/custom_files/custom_mainfile.php")) { @include_once("includes/custom_files/custom_mainfile.php"); }
   @require_once("includes/ipban.php");
   if (defined('NUKE_HEADER') && file_exists("includes/custom_files/custom_head.php")) { @include_once("includes/custom_files/custom_head.php"); }
   if (defined('NUKE_HEADER') && file_exists("includes/custom_files/custom_header.php")) { @include_once("includes/custom_files/custom_header.php"); }
}

REPLACE WITH:

if (defined('FORUM_ADMIN')) {
   if (!defined('INCLUDE_PATH')) define('INCLUDE_PATH', '../../../');
   @require_once("../../../config.php");
   @require_once("../../../db/db.php");
   @require_once("../../../includes/sql_layer.php");
   if (file_exists("../../../includes/custom_files/custom_mainfile.php")) { @include_once("../../../includes/custom_files/custom_mainfile.php"); }
   @require_once("../../../includes/ipban.php");
   if (defined('NUKE_HEADER') && file_exists("../../../includes/custom_files/custom_head.php")) { @include_once("../../../includes/custom_files/custom_head.php"); }
   if (defined('NUKE_HEADER') && file_exists("../../../includes/custom_files/custom_header.php")) { @include_once("../../../includes/custom_files/custom_header.php"); }
} elseif (defined('INSIDE_MOD')) {
   if (!defined('INCLUDE_PATH')) define('INCLUDE_PATH', '../../');
   @require_once("../../config.php");
   @require_once("../../db/db.php");
   @require_once("../../includes/sql_layer.php");
   if (file_exists("../../includes/custom_files/custom_mainfile.php")) { @include_once("../../includes/custom_files/custom_mainfile.php"); }
   @require_once("../../includes/ipban.php");
   if (defined('NUKE_HEADER') && file_exists("../../includes/custom_files/custom_head.php")) { @include_once("../../includes/custom_files/custom_head.php"); }
   if (defined('NUKE_HEADER') && file_exists("../../includes/custom_files/custom_header.php")) { @include_once("../../includes/custom_files/custom_header.php"); }
} else {
   if (!defined('INCLUDE_PATH')) define('INCLUDE_PATH', './');
   @require_once("config.php");
   @require_once("db/db.php");
   @require_once("includes/sql_layer.php");
   if (file_exists("includes/custom_files/custom_mainfile.php")) { @include_once("includes/custom_files/custom_mainfile.php"); }
   @require_once("includes/ipban.php");
   if (defined('NUKE_HEADER') && file_exists("includes/custom_files/custom_head.php")) { @include_once("includes/custom_files/custom_head.php"); }
   if (defined('NUKE_HEADER') && file_exists("includes/custom_files/custom_header.php")) { @include_once("includes/custom_files/custom_header.php"); }
}
Personal tools