============================================================================================================================
Modification: Name: Account Activation via Email

Version: 1.0

Author: GuldantheWarlock (GuldantheWarlock@xmbgarage.com)

Description:
This modification will require that all members activate their account before they are allowed to make any posts.
Upon registration, an email will be sent to the address they provide with a link to the activation area.
All registered members will already be activated (i.e. all members existing upon installation of this modification will automatically be activated).
If a member loses the email and isn't activated, they have the option to send a new email.
This new version includes and on/off switch in the Administration Panel under Settings.

Supported Version: XMB 1.9.5 SP1

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

License Note: This modification is released under the GPL License v3. A copy is provided with this software package.

Author Note:
You downloaded this modification from XMBGarage.com, the #1 source for XMB related downloads.
Please visit http://www.xmbgarage.com/ for support.
============================================================================================================================
=======
Step 1:
=======
====================================
Go To Administration Panel --> Insert Raw SQL
====================================
==================================
Add The Following Code and Submit Changes:
==================================

ALTER TABLE `$table_members` ADD `activated` SET('yes','no') NOT NULL default 'no';
ALTER TABLE `$table_members` ADD `activate_password` VARCHAR(32) default '';
ALTER TABLE `$table_settings` ADD `account_activation` SET('on','off') NOT NULL default 'on';
UPDATE `$table_members` SET activated='yes';

============================================================================================================================
=======
Step 2:
=======
==============
Edit File: cp.php
==============
==========
Find Code:
==========

        $reportposton = $reportpostoff = '';
        if ($SETTINGS['reportpost'] == "on") {
            $reportposton = $selHTML;
        } else {
            $reportpostoff = $selHTML;
        }
        
===============
Add Code Below:
===============

        // Account Activation Via Email Mod Begin
        $accountactivationon = $accountactivationoff = '';
        switch ($SETTINGS['account_activation']) {
            case 'on':
                $accountactivationon = $selHTML;
                break;
            default:
                $accountactivationoff = $selHTML;
                break;
        }
        // Account Activation Via Email Mod End
        
==========
Find Code:
==========

        printsetting1($lang['reportpoststatus'], 'reportpostnew', $reportposton, $reportpostoff);
        
==========
Add Below:
==========

        // Account Activation Via Email Mod Begin
        printsetting1($lang['activate_status'], 'accountactivationnew', $accountactivationon, $accountactivationoff);
        // Account Activation Via Email Mod End

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

        $resetSigNew = ($resetSigNew == 'on') ? 'on' : 'off';

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

        // Account Activation Via Email Mod Begin
        $accountactivationnew = ($accountactivationnew == 'on') ? 'on' : 'off';
        // Account Activation Via Email Mod End

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

        $db->query("UPDATE $table_settings SET
        
==========================
Add To End Of Line BEFORE  ");
==========================

, account_activation='$accountactivationnew'

============================================================================================================================
=======
Step 3:
=======
================
Edit File: index.php
================
==========
Find Code:
==========

    eval('$ticker  = "'.template('index_ticker').'";');
}

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

// Check if users account is activated
$activated = '';
if (X_MEMBER && $SETTINGS['account_activation'] == 'on' && $self['activated'] == 'no') {
    $activated = error(str_replace('*USER*', rawurlencode($self['username']), $lang['howtoactivate']), false, '', '', false, false, true, false);
}

============================================================================================================================
=======
Step 4:
=======
=================
Edit File: member.php
=================
==========
Find Code:
==========

) VALUES ('', '$username'

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

, activated, activate_password) VALUES ('', '$username'

=======================
On The Same Line Find Code:
=======================

");

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

, 'no', '$activate_password'");

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

$db->query("INSERT INTO $table_members

===============
Add Code Above:
===============

        // Account Activation Via Email Mod Begin
        if ($SETTINGS['account_activation'] == 'on') {
            $activate_password = md5(uniqid(mt_rand()));
            altMail($email, $lang['activate_mailsub'], str_replace(array('*BOARDNAME*', '*FULL_URL*', '*USER*', '*CODE*'), array($SETTINGS['bbname'], $full_url, $username, $activate_password), $lang['activate_mailmess']), 'From: '.$SETTINGS['bbname'].' <'.$SETTINGS['adminemail'].'>');
        }
        // Account Activation Via Email Mod End

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

"<center><span class=\"mediumtxt \">$lang[regged]</span></center>";

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

"<center><span class=\"mediumtxt \">$lang[regged]<br />$activatemsg</span></center>";

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

        echo ($emailcheck == "on") ?

===============
Add Code Above:
===============

        // Account Activation Via Email Mod Begin
        $activatemsg = ($SETTINGS['account_activation'] == 'on') ? $lang['activate_message'] : '';
        // Account Activation Via Email Mod End

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

} else {
    error($lang['textnoaction']);
}

===============
Add Code Above:
===============

// Account Activation Via Email Mod Begin
} elseif ($action == 'activate') {
    if (!X_MEMBER || $self['activated'] == 'yes') {
        error($lang['textnoaction']);
    } else {
        if (!$activate_password || empty($activate_password)) {
            eval('echo "'.template('header').'";');
            
            if ($SETTINGS['account_activation'] == 'on') {
                $activate_password2 = md5(uniqid(mt_rand()));

                altMail($self['email'], $lang['activate_mailsub'], str_replace(array('*BOARDNAME*', '*FULL_URL*', '*USER*', '*CODE*'), array($SETTINGS['bbname'], $full_url, $self['username'], $activate_password2), $lang['activate_mailmess']), 'From: '.$SETTINGS['bbname'].' <'.$SETTINGS['adminemail'].'>');
                $db->query("UPDATE $table_members SET activate_password='$activate_password2' WHERE username='$self[username]'");

                echo "<center><span class=\"mediumtxt \">$lang[activate_message]</span></center>";
                redirect('index.php', 2, X_REDIRECT_JS);
            } else {
                echo "<center><span class=\"mediumtxt \">$lang[activate_featureoff]</span></center>";
                redirect('index.php', 2, X_REDIRECT_JS);
            }
        } else {
            eval('echo "'.template('header').'";');
            if ($activate_password == $self['activate_password']) {
                $db->query("UPDATE $table_members SET activated='yes' WHERE username='$self[username]'");
                echo "<center><span class=\"mediumtxt \">$lang[account_activated]</span></center>";
                redirect('index.php', 2);
            } else {
                error($lang['invalidactivecode']);
            }
        }
    }
// Account Activation Via Email Mod End

============================================================================================================================
=======
Step 5:
=======
===============
Edit File: post.php
===============
==========
Find Code:
==========

if ( $action == "newthread") {

===============
Add Code Above:
===============

// Account Activation Via Email Mod Begin
// Check if user's account is activated
if ($SETTINGS['account_activation'] == 'on' && $self['activated'] == 'no') {
    error($lang['inactivated_account']);
}
// Account Activation Via Email Mod End

============================================================================================================================
=======
Step 6:
=======
==============
Edit File: u2u.php
==============
==========
Find Code:
==========

        $msgto = isset($msgto) ? $msgto : '';

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

        // Account Activation Via Email Mod Begin
        if ($SETTINGS['account_activation'] == 'on' && $self['activated'] == 'no') {
            error($lang['inactivenou2u'], false, $u2uheader, $u2ufooter, false, true, false, false);
        }
        // Account Activation Via Email Mod End

============================================================================================================================
=======
Step 7:
=======
=======================
Edit File: lang/English.lang.php
=======================
=========================
Add To End Of File ABOVE  ?>
=========================

// Account Activation Via Email Mod Begin
$lang['inactivated_account'] = "Account not activated! You must activate your account before you can post.";
$lang['howtoactivate'] = "Your account is not activated! To activate your account, <a href=\"./member.php?action=activate&amp;member=*USER*\"><strong>click here</strong></a> if you have not received the activation email";
$lang['activate_account'] = "Activate Account";
$lang['activate_message'] = "An Activation email has been sent to the email address on file.";
$lang['activate_mailsub'] = "Activate your account at $bbname";
$lang['activate_mailmess'] = "To activate your account at *BOARDNAME*, click this link *FULL_URL*member.php?action=activate&amp;member=*USER*&activate_password=*CODE*";
$lang['activate_status'] = "Account Activation via E-Mail Status:";
$lang['activate_featureoff'] = "This feature is currently disabled.";
$lang['account_activated'] = "Thank you! Your account has been activated. You may now post and send U2Us.";
$lang['invalidactivecode'] = "Invalid Activation Code! If you copied the link, please make sure you got the entire link from your email. If you need the email to be sent again, please <a href=\"./member.php?action=activate\">click here</a>.";
$lang['inactivenou2u'] = "You Must Activate your account before being allowed to send U2U messages!";
// Account Activation Via Email Mod End

============================================================================================================================
=======
Step 8:
=======
===============================
Go To Administration Panel --> Templates
===============================
================
Edit Template: index
================
==========
Find Code:
==========

$ticker

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

$activated

============================================================================================================================
Enjoy!