============================================================================================================================
Modification Name: Advanced Debug System

Version: 1.0

Author: Adam Clarke

Minor 1.9.3 Update by: GuldantheWarlock (GuldantheWarlock@xmbgarage.com)
Minor 1.9.5 Update by: WormHole (XMB Garage)

Last Updated: May 22, 2011

Description:
This modification will allow you to enable DEBUG mode via the administration panel.
This modification will also allow you specify which statuses can see the debug messages.

Supported Version: XMB 1.9.5 SP1

Notes: This modificatioin is released under the GPL. You should have recieved a copy of it with this software package.

Please backup your files before installing this modification.
Neither XMBGarage nor the author can be held  responsible if your board stops functioning properly due to you installing this modification.
============================================================================================================================
=======
Step 1:
=======
====================================
Go To Administration Panel --> Insert Raw SQL
====================================
===============================
Paste The Following Code and Hit Submit
===============================

ALTER TABLE `$table_settings` ADD `debugstatus` int(1) NOT NULL default '0';

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

// Advanced Debug System Mod Begin
$lang['admin_debug_settings'] = 'Debug Settings';
$lang['textdebugstatus'] = 'Enable Debugging For:';
$lang['textdebug1'] = 'Admins';
$lang['textdebug2'] = 'All Staff';
$lang['textdebug3'] = 'All Members';
$lang['textdebug4'] = 'Everyone';
// Advanced Debug System Mod End

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

if ($action == "settings") {
    if (!isset($_POST['settingsubmit'])) {
    
===============
Add Code Below:
===============

        // Advanced Debug System Mod Begin
        $debugchecked[0] = $debugchecked[1] = $debugchecked[2] = $debugchecked[3] = $debugchecked[4] = false;
        if ($SETTINGS['debugstatus'] == '1') {
            $debugchecked[1] = true;
        } elseif ($SETTINGS['debugstatus'] == '2') {
            $debugchecked[2] = true;
        } elseif ($SETTINGS['debugstatus'] == '3') {
            $debugchecked[3] = true;
        } elseif ($SETTINGS['debugstatus'] == '4') {
            $debugchecked[4] = true;
        } else {
            $debugchecked[0] = true;
        }
        // Advanced Debug System Mod End

==========
Find Code:
==========
        
        <tr class="category">
        <td colspan="2"><strong><font color="<?php echo $cattext?>">&raquo;&nbsp;<?php echo $lang['admin_main_settings1']?></font></strong></td>
        </tr>
        
================
Replace Code With:
================

        <tr class="category">
        <td colspan="2"><strong><font color="<?php echo $cattext?>">&raquo;&nbsp;<?php echo $lang['admin_debug_settings']?></font></strong></td>
        </tr>
        <?php
        printsetting3($lang['textdebugstatus'], 'debugstatusnew', array($lang['textoff'], $lang['textdebug1'], $lang['textdebug2'], $lang['textdebug3'], $lang['textdebug4']), array('0', '1', '2', '3', '4'), $debugchecked, false);
        ?>
        <tr>
        <td class="tablerow" bgcolor="<?php echo $altbg2?>" colspan="2">&nbsp;</td>
        </tr>
        <tr>
        <td bgcolor="<?php echo $altbg1?>" colspan="2" class="category"><strong><font color="<?php echo $cattext?>">&raquo;&nbsp;<?php echo $lang['admin_main_settings1']?></font></strong></td>
        </tr>
        
==========
Find Code:
==========

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

, debugstatus='$debugstatusnew'

============================================================================================================================
=======
Step 4:
=======
=================
Edit File: header.php
=================
==================
Find Code and Delete:
==================

    // Debug-mode
    /*
    / To turn on DEBUG mode (you can then see ALL queries done at the bottom of each screen (except buddy-list & u2u)
    / just uncomment this variable. These queries are ONLY visible to the user currently loading that page
    / and ONLY visible to Super Administrators
    /
    / SECURITY NOTICE: DO NOT COMMENT OUT UNLESS YOU KNOW WHAT YOU'RE DOING!
    */
    define('DEBUG', false);
    // define('DEBUG', true);
    //
    /*
    / Comment first line and uncomment second line to use debug mode (1.9+ only). Only one define can be
    / active as define is immutable once set.
    */

==================
Find Code and Delete:
==================

if (DEBUG) {
    error_reporting(E_ALL | E_STRICT | E_DEPRECATED);
}

=============================
Find Code and Delete (on 2 occasions):
=============================

.(DEBUG === true ? ' (Debug)' : '')

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

// Get the required language file
    
===============
Add Code Above:
===============

// Advanced Debug System Mod Begin
if ((X_ADMIN && $SETTINGS['debugstatus'] == '1') || (X_STAFF && $SETTINGS['debugstatus'] == '2') || (X_MEMBER && $SETTINGS['debugstatus'] == '3') || $SETTINGS['debugstatus'] == '4') {
    error_reporting(E_ALL | E_STRICT | E_DEPRECATED);
    define('DEBUG', true);
} else {
    define('DEBUG', false);
}
// Advanced Debug System Mod End

============================================================================================================================
=======
Step 5:
=======
==================
Edit File: functions.php:
==================
=======================
Find Code (On 3 Occasions):
=======================

X_SADMIN && DEBUG

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

DEBUG

============================================================================================================================
=======
Step 6:
=======
============================================================
If MySQL is not your database driver, please edit the appropriate file in the db folder.
============================================================
==================
Edit File: db/mysql.php
==================
==========
Find Code:
==========

if (defined('X_SADMIN') && X_SADMIN && defined('DEBUG') && DEBUG)

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

if (defined('DEBUG') && DEBUG)

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

if ((defined('X_SADMIN') && X_SADMIN && defined('DEBUG') && DEBUG) || (!defined('X_MEMBER') && !defined('X_GUEST'))) {

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

if (defined('DEBUG') && DEBUG) {

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

return 'MySQL has encountered an unknown error. To find out the exact problem, please set the DEBUG flag to true in header.php.';

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

return 'MySQL has encountered an unknown error. To find out the exact problem, please set the DEBUG option in the Administration Panel.';

============================================================================================================================
Enjoy