Hack Name: Email Notification Of New Posts v1.1

Authors: WormHole & GuldantheWarlock

Original Code by: John Briggs 

Last Updated: 01/07/08

Description:
This modification will send an email notification to the Administrator email address when new threads and replies are posted.
The feature can be turned on or off via the Admin Panel.

Supported Version: XMB 1.9.8 SP2. Do Not Use On Any Other Version Of XMB.

Notes:

This hack is released under the GPL. You should have recieved a copy of it with this hack.

Please backup your files before installing this mod. Neither XMB Garage nor the author can be held 
responsible if your board stops functioning properly due to you installing this hack.

=======================================================================================================

=======
Step 1:
=======

===================================
Go To Admin Panel -> Insert Raw SQL
===================================

========================================
Paste the following code and hit submit:
========================================

ALTER TABLE `$table_settings` ADD `postemailcheck` varchar(3) NOT NULL default 'on';

=======================================================================================================

=======
Step 2:
=======

=================================
Edit File: lang/English.lang.php:
=================================

========================
Add To End Of File Above ?>:
========================

// Email Notification Of New Posts Mod Begin
$lang['postnotifystatus'] = "Notify Admin Of All Posts:";
$lang['postnotifyrcode'] = '$lang[postnotifysubject] = "$username has replied to ";';
$lang['postnotifymcode'] = '$lang["postnotifymessage"] = "$username has posted a new reply to: $threadname\n\n$username posted:\n\n$lang[textsubject] $subject\n\n$lang[textmessage]\n$message\n\n$threadurl";';
$lang['postnotifynsubject'] = "New Thread at $bbname";
$lang['postnotifyntmcode'] = '$lang["postnotifyntmessage"] = "$username has posted a new thread - $subject\n\n$lang[textmessage]\n$message\n\n$threadurl";';
// Email Notification Of New Posts Mod End

=======================================================================================================

=======
Step 3:
=======

==================
Edit File: cp.php:
==================

=====
Find:
=====

        $echeckon = $echeckoff = '';
        settingHTML('emailcheck', $echeckon, $echeckoff);
        
==========
Add Below:
==========
        
        // Email Notification Of New Posts Mod Begin
        $postemailcheckon = $postemailcheckoff = '';
        settingHTML('postemailcheck', $postemailcheckon, $postemailcheckoff;
        // Email Notification Of New Posts Mod End
        
=====
Find:
=====

        printsetting2($lang['pruneusers'], 'pruneusersnew', ((int)$SETTINGS['pruneusers']), 3);
        
==========
Add Below:
==========

        // Email Notification Of New Posts Mod Begin
        printsetting1($lang['postnotifystatus'], 'postemailchecknew', $postemailcheckon, $postemailcheckoff);
        // Email Notification Of New Posts Mod End

=====
Find:
=====

        $smileyinsertnew = formOnOff('smileyinsertnew');

==========
Add Below:
==========

        // Email Notification Of New Posts Mod Begin
        $postemailchecknew = formOnOff('postemailchecknew');
        // Email Notification Of New Posts Mod End
        
=====
Find:
=====

            onlinetoday_status='$onlinetoday_statusnew'
        
===============================
Replace With:
===============================

            onlinetoday_status='$onlinetoday_statusnew',
            postemailcheck='$postemailchecknew'

=======================================================================================================

=======
Step 4:
=======

====================
Edit File: post.php:
====================

=====
Find:
=====

        $db->query("INSERT INTO ".X_PREFIX."posts (fid, tid, author, message, subject, dateline, icon, usesig, useip, bbcodeoff, smileyoff) VALUES ($fid, $tid, '$username', '$message', '$subject', ".$db->time($thatime).", '$posticon', '$usesig', '$onlineip', '$bbcodeoff', '$smileyoff')");
        $pid = $db->insert_id();
            
==========
Add Above:
==========

        // Email Notification Of New Posts Begin
        if ($SETTINGS['postemailcheck'] == "on") {
            $message = stripslashes($message);
            $threadurl = $boardurl."viewthread.php?tid=$tid";
            $subject = (phpversion() < 5) ? html_entity_decode(stripslashes($subject), ENT_QUOTES) : htmlspecialchars_decode(stripslashes($subject), ENT_QUOTES);
            eval($lang['postnotifyntmcode']);
            altMail($adminemail, $lang['postnotifynsubject'], $lang['postnotifyntmessage'], "From: $bbname <$adminemail>");
        }   
        // Email Notification Of New Posts End

=====================
Find:
=====================

            $db->query("INSERT INTO ".X_PREFIX."posts (fid, tid, author, message, subject, dateline, icon, usesig, useip, bbcodeoff, smileyoff) VALUES ($fid, $tid, '$username', '$message', '$subject', ".$db->time(time()).", '$posticon', '$usesig', '$onlineip', '$bbcodeoff', '$smileyoff')");
            $pid = $db->insert_id();

==========
Add Below:
==========

            // Email Notification Of New Posts Begin
            if ($SETTINGS['postemailcheck'] == "on") {
                $message = stripslashes($message);
                $threadurl = $boardurl."viewthread.php?tid=$tid";
                $subject    = (phpversion() < 5) ? html_entity_decode(stripslashes($subject), ENT_QUOTES) : htmlspecialchars_decode(stripslashes($subject), ENT_QUOTES);
                $threadname = (phpversion() < 5) ? html_entity_decode(stripslashes($thread['subject']), ENT_QUOTES) : htmlspecialchars_decode(stripslashes($thread['subject']), ENT_QUOTES);
                eval($lang['postnotifymcode']);
                eval($lang['postnotifyrcode']);
                altMail($adminemail, $lang['postnotifysubject'].$threadname, $lang['postnotifymessage'], "From: $bbname <$adminemail>");
            }
            // Email Notification Of New Posts End
        
=======================================================================================================

Upload all Edited files and Enjoy!