=======================================================================================================================================
Name: Auto Mood Icons Insert v1.0

Author: John Briggs

Updated for 1.9.8 by: WormHole @ XMB Garage

Based On: Auto Smilie Insert By Adam Clarke

Description:
This modification will add the ability to automatically insert mood icons from the mood icons directory.
This modification requires the mood icons modification to be installed.

Copyright:  2009 John Briggs. All rights reserved.

Compatability: XMB 1.9.8 SP3

Install 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. 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:
=======
===============
Edit File: cp2.php
===============
==========
Find Code:
==========

        <tr bgcolor="<?php echo $THEME[altbg1]?>" class="tablerow">
        <td><?php echo $lang['moodiconnew']?></td>
        <td colspan="2"><input type="text" name="newurl3" value="" /></td>
        </tr>

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

        <!-- Auto Mood Icons Insert Mod Begin -->
        <tr class="ctrtablerow">
        <td bgcolor="<?php echo $THEME[altbg1]?>"><input type="checkbox" name="autoinsertmoodicons" value="1" /></td>
        <td bgcolor="<?php echo $THEME[altbg1]?>" colspan="3"><?php echo $lang['autoinsertmoodicons']?> <?php echo $lang['moodiconspath']?></td>
        </tr>
        <!-- Auto Mood Icons Insert Mod End -->

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

        if (isset($newurl3) && $newurl3 != '') {
            if ($db->result($db->query("SELECT count(id) FROM ".X_PREFIX."smilies WHERE url = '$newurl3' AND type = 'moodicon'"), 0) > 0) {
                error($lang['moodiconexists'], false, '</td></tr></table></td></tr></table><br />');
            }
            $query = $db->query("INSERT INTO ".X_PREFIX."smilies (type, code, url, id) VALUES ('moodicon', '', '$newurl3', '')");
        }

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

        // Auto Mood Icons Insert Mod Begin
        if (isset($autoinsertmoodicons) && $autoinsertmoodicons == 1) {
            $moodicons_count = $newmoodicons_count = 0;
            // Load all existing mood icons to ensure we don't insert a duplicate.
            $moodicon_url = array();
            $newmoodicons = array();
            $query = $db->query("SELECT * FROM ".X_PREFIX."smilies WHERE type = 'moodicon'");
            while ($picon = $db->fetch_array($query)) {
                $moodicon_url[] = $picon['url'];
            }
            $db->free_result($query);

            $dir = opendir(ROOT.'images/moodicons/');
            while ($picon = readdir($dir)) {
                if ($picon != '.' && $picon != '..' && (strpos($picon, '.gif') || strpos($picon, '.jpg') || strpos($picon, '.bmp') || strpos($picon, '.png'))) {
                    $newmoodicon_url = $picon;
                    $newmoodicon_url = str_replace(' ', '%20', $newmoodicon_url);
                    if (!in_array($newmoodicon_url, $moodicon_url)) {
                        $newmoodicons[] = $newmoodicon_url;
                        $newmoodicons_count++;
                    }
                    $moodicons_count++;
                }
            }
            closedir($dir);
            
            reset($newmoodicons);
            sort($newmoodicons);
            
            foreach($newmoodicons as $mood_icon) {
                $query = $db->query("INSERT INTO ".X_PREFIX."smilies (type, code, url, id) VALUES ('moodicon', '', '$mood_icon', '')");
            }
            
            echo '<tr bgcolor="'.$THEME['altbg2'].'" class="ctrtablerow"><td>'.$newmoodicons_count.' / '.$moodicons_count.' '.$lang['moodiconsadded'].'</td></tr>';
        }
        // Auto Mood Icons Insert Mod End

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

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

// Auto Mood Icons Insert Mod Begin
$lang['autoinsertmoodicons'] = "Insert all mood icons from smilies directory";
$lang['moodiconsadded'] = "Mood Icons Have Been Added.";
$lang['moodiconspath'] = "(images/moodicons)?";
// Auto Mood Icons Insert Mod End

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