============================================================================================================================
Modification Name: Broken Avatar Removal Tool

Version: 1.0

Author: GuldantheWarlock (GuldantheWarlock@xmbgarage.com)

Last Updated: November 10, 2010

Description: This modification will allow members to create their own custom theme to be displayed in their profile.

Supported Version: XMB 1.9.5 SP1

License Note: This modification is released under the GPL License v3. A copy is provided 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:
=======
===============
Edit File" tools.php
===============
==========
Find Code:
==========

    case 'repairtables':
        $start = true;
        @set_time_limit(180);
        $tables = $db->fetch_tables($dbname);
        $q = array();
        foreach ($tables as $key=>$val) {
            if ($start) {
                dump_query($db->query('REPAIR TABLE `'.$val.'`'));
                $start = false;
            } else {
                dump_query($db->query('REPAIR TABLE `'.$val.'`'), false);
            }
        }
        break;
        
==========
Add Above:
==========

    // Broken Avatar Removal Tool Mod Begin
    case 'removebrokenavatars':
        $clearusers = array();
        $query = $db->query("SELECT username, avatar FROM $table_members WHERE avatar != ''");
        while($ava = $db->fetch_array($query)) {
            if (@getimagesize($ava['avatar']) === false) {
                $clearusers[] = $ava['username'];
            }
        }
        $db->free_result($query);

        $message = $lang['rba_nobroken'];
        if (count($clearusers) > 0) {
            $message = str_replace('{X}', count($clearusers), $lang['rba_success']);
            $db->query("UPDATE $table_members SET avatar = '' WHERE username IN('".implode("', '", $clearusers)."')");
        }

        echo '<tr bgcolor="'.$altbg2.'" class="ctrtablerow"><td>'.$message.'</td></tr>';
    // Broken Avatar Removal Tool Mod End
        
============================================================================================================================
=======
Step 2:
=======
=======================
Edit File: lang/English.lang.php
=======================
========================
Add To End Of File Before  ?>
========================

// Broken Avatar Removal Tool Mod Begin
$lang['rba_txtlink'] = 'Remove Broken Avatars';
$lang['rba_confirm'] = 'NOTICE: This tool will go through and check all your users avatars and remove any that are broken. This may take a while to run, especially if you have a lot of members. Do you want to continue?';
$lang['rba_success'] = 'Tool Completed - Cleared {X} broken avatars!';
$lang['rba_nobroken'] = 'Tool Completed - No broken avatars found!';
// Broken Avatar Removal Tool Mod End

============================================================================================================================
=======
Step 3:
=======
===========================
Edit File: include/admin.user.inc.php
===========================
==========
Find Code:
==========

    &raquo;&nbsp;<a href="cp.php?action=members"><?php echo $lang['textmembers']?></a><br />

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

    <!-- Broken Avatar Removal Tool Mod Begin -->
    &raquo;&nbsp;<a href="javascript:confirmAction('<?php echo $lang['rba_confirm']?>', 'tools.php?action=removebrokenavatars');"><?php echo $lang['rba_txtlink']?></a><br />
    <!-- Broken Avatar Removal Tool Mod End -->

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