Mod Title: Registration Notification By Username v1.0

Mod Author: John Briggs

Mod Description:
This mod will replace the redundant notification tool that contacts all super admins on new reg notifications.
This mod will provide a new tool in admin panel to choose what username(s) you want new registration notices sent to.
This mod will provide the option of assigning single or multiple usernames for notification.

Supported Version: XMB 1.9.5 Nexus

Installation Note: Before adding this mod to your forum, you should back up all files related to this mod.

License Note: This mod is released under the GPL License.

Author Note:
For security purposes, Please Check: http://www.xmbxtreme.com for the latest version of this mod.
Downloading this mod from other sites could cause malicious code to enter into your XMB Forum software.
As such, XMBXtreme.com will not offer support for mod's not offered in our mod forum.

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

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

Upload provided file named "SQL.txt" & click "Submit Changes" button.

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

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

==========
Find Code:
==========

       $lang['spell_checker'] .= $spell_off_reason;

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

        // New Reg Notification By Username Mod Begin
        $SETTINGS['usernamenotify'] = stripslashes($SETTINGS['usernamenotify']);
        // New Reg Notification By Username Mod End

==========
Find Code:
==========

        printsetting3($lang['notifyonreg'], 'notifyonregnew', array($lang['textoff'], $lang['viau2u'], $lang['viaemail']), array('off', 'u2u', 'email'), $notifycheck, false);

==================
Replace Code With:
==================

        printsetting3($lang['notifyonreg'], 'notifyonregnew', array($lang['textoff'], $lang['viau2u'], $lang['viaemail']), array('off', 'u2u', 'email'), $notifycheck, false);
        ?>
        <!-- New Reg Notification By Username Mod Begin -->
        <tr>
        <td class="tablerow" bgcolor="<?php echo $altbg1?>" valign="top"><?php echo $lang['notify']?></td>
        <td class="tablerow" bgcolor="<?php echo $altbg2?>"><textarea rows="5" name="usernamenotifynew" cols="50"><?php echo $SETTINGS['usernamenotify']?></textarea></td>
        </tr>
        <!-- New Reg Notification By Username Mod End -->
        <?php

==========
Find Code:
==========

       $spellchecknew = ($spellchecknew == 'on' && defined('PSPELL_FAST')) ? 'on' : 'off';

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

        // New Reg Notification By Username Mod Begin
        $usernamenotifynew = addslashes($usernamenotifynew);
        // New Reg Notification By Username Mod End

==========
Find Code:
==========

$db->query("UPDATE $table_settings SET langfile='$langfilenew'

====================================
Find Code At End Of Above Statement:
====================================

");

==================
Replace Code With:
==================

, usernamenotify='$usernamenotifynew'");

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

=====================
Edit File: member.php
=====================

==========
Find Code:
==========

        if ($SETTINGS['notifyonreg'] != "off") {
            if ($SETTINGS['notifyonreg'] == 'u2u') {
                $mailquery = $db->query("SELECT username FROM $table_members WHERE status='Super Administrator'");
                while ($admin = $db->fetch_array($mailquery)) {
                    $db->query("INSERT INTO $table_u2u ( u2uid, msgto, msgfrom, type, owner, folder, subject, message, dateline, readstatus, sentstatus ) VALUES ('', '$admin[username]', '".addslashes($bbname)."', 'incoming', '$admin[username]', 'Inbox', '$lang[textnewmember]', '$lang[textnewmember2]', '" . time() . "', 'no', 'yes')");
                }
            } else {
                $headers[] = "From: $bbname <$adminemail>";
                $headers[] = "X-Sender: <$adminemail>";
                $headers[] = 'X-Mailer: PHP';
                $headers[] = 'X-AntiAbuse: Board servername - '.$bbname;
                $headers[] = 'X-AntiAbuse: Username - '.$xmbuser;
                $headers[] = 'X-Priority: 2';
                $headers[] = "Return-Path: <$adminemail>";
                $headers[] = 'Content-Type: text/plain; charset=ASCII';
                $headers = implode("\r\n", $headers);

                $mailquery = $db->query("SELECT email FROM $table_members WHERE status = 'Super Administrator'");
                while ($notify = $db->fetch_array($mailquery)) {
                    mail($notify['email'], $lang['textnewmember'], $lang['textnewmember2'], $headers);
                }
            }
        }

==================
Replace Code With:
==================

        // New Reg Notification By Username Mod Begin
        if ($SETTINGS['notifyonreg'] != 'off') {
            if ($SETTINGS['notifyonreg'] == 'u2u') {
                if (!empty($SETTINGS['usernamenotify'])) {
                    $member = explode(",", $SETTINGS['usernamenotify']);
                    for ($i=0; $i < count($member); $i++) {
                        $member[$i] = trim($member[$i]);
                        $mailquery = $db->query("SELECT * FROM $table_members WHERE username='$member[$i]'");
                        while ($admin = $db->fetch_array($mailquery)) {
                            $usernameurl = "<a href=\"member.php?action=viewpro&amp;member=".rawurlencode($username)."\" target=\"_blank\"><strong>$username</strong></a>";
                            $db->query("INSERT INTO $table_u2u (u2uid, msgto, msgfrom, type, owner, folder, subject, message, dateline, readstatus, sentstatus) VALUES ('', '$admin[username]', '$admin[username]', 'incoming', '$admin[username]', 'Inbox', '$lang[newmember] ".addslashes($bbname)."', '$lang[newmember2]\n\n$usernameurl', '" . time() . "', 'no', 'yes')");
                        }
                    }
                }
            } else {
                if ($SETTINGS['notifyonreg'] == 'email') {
                    if (!empty($SETTINGS['usernamenotify'])) {
                        $member = explode(",", $SETTINGS['usernamenotify']);
                        for ($i=0; $i < count($member); $i++) {
                            $member[$i] = trim($member[$i]);
                            $headers[] = "From: $bbname <$adminemail>";
                            $headers[] = "X-Sender: <$adminemail>";
                            $headers[] = 'X-Mailer: PHP';
                            $headers[] = 'X-AntiAbuse: Board servername - '.$bbname;
                            $headers[] = 'X-AntiAbuse: Username - '.$xmbuser;
                            $headers[] = 'X-Priority: 2';
                            $headers[] = "Return-Path: <$adminemail>";
                            $headers[] = 'Content-Type: text/plain; charset=ASCII';
                            $headers = implode("\r\n", $headers);
                            $mailquery = $db->query("SELECT * FROM $table_members WHERE username='$member[$i]'");
                            while ($notify = $db->fetch_array($mailquery)) {
                                $username = str_replace(' ', '%20', $username);
                                $usernameurl = $SETTINGS['boardurl'] . "member.php?action=viewpro&member=$username";
                                mail("$notify[username]<$notify[email]>", $lang['newmember'].' '.$bbname, $lang['newmember2']." \n\n".$usernameurl, $headers);
                            }
                        }
                    }
                }
            }
        }
        // New Reg Notification By Username Mod End

=======================================================================================================================
=======
Step 5:
=======

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

==========
Find Code:
==========

$lang['notifyonreg'] = 'Notify (Super-)Administrator on new registrations';

==================
Replace Code With:
==================

// New Reg Notification By Username Mod Begin
$lang['notifyonreg'] = 'Member Registration Notification Status:';
// New Reg Notification By Username Mod End

===============
Add Code To End Of File:
===============

// New Reg Notification By Username Mod Begin
$lang['newmember'] = "New member signed up at ";
$lang['newmember2'] = "This is an automatic email. To disable this option you must turn it to OFF in Settings Panel.\n\n The following new member has signed up:";
$lang['notify'] = "Email/U2U Notification List:<br /><small>Put the username(s) you want to receive Email/U2U notifications here. Separate names with commas (i.e. 'Person 1, Person 2'). Names are also case sensitive.</small>";
// New Reg Notification By Username Mod End

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