Title: Harry Potter Character Selection v2.0

Author: John Briggs

Description:
This modification will provide an option to select a Harry Potter Character image in your member control panel.
This modification will display your selected Harry Potter Character image in your profile, control panel and threads.

Copyright:  2006 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.

Author Note:
You downloaded this hack from XMBGarage.com, the #1 source for XMB related downloads.
Please visit http://www.xmbgarage.com/ for support.

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

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

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

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

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

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

loadtemplates(

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

loadtemplates(
'member_profile_hpchar',

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

                $langfileselect = createLangFileSelect($SETTINGS['langfile']);

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

                // Harry Potter Character Selection Mod Begin
                $hps = array();
                $hps[] = '<option value="">'.$lang['hpcharnone'].'</option>';
                $dp = opendir(ROOT.'images/hpchar');
                while ($file = readdir($dp)) {
                    if ($file != '.' AND $file != '..' AND $file != 'index.html') {
                        $hpcharname = $file;
                        $hpcharname = str_replace(array('.gif','.jpg','.png','_'), array('','','',' '), $hpcharname);
                        if ($memberinfo['hpchar'] == $file) {
                            $hps[] = '<option value="'.$file.'" selected="selected">'.$hpcharname.'</option>';
                        } else {
                            $hps[] = '<option value="'.$file.'">'.$hpcharname.'</option>';
                        }
                    }
                }
                closedir($dp);
                natcasesort($hps);
                $hpcharselect = '<select name="hpchar" onchange="document.getElementById(\'hpcharimg\').src = (this.options[this.selectedIndex].value != \'\') ? \'images/hpchar/\'+this.options[this.selectedIndex].value : \'./images/pixel.gif\';" />'.implode("\n", $hps).'</select>';
                $hpcharimg  = '<img src="'.ROOT.'images/pixel.gif" id="hpcharimg" alt="" />';
                if ($memberinfo['hpchar'] != '') {
                    $hpcharimg = '<img src="'.ROOT.'images/hpchar/'.$memberinfo['hpchar'].'" alt="'.str_replace(array('.gif','.jpg','.png','_'), array('','','',' '), $memberinfo['hpchar']).'" id="hpcharimg" />';
                }
                // Harry Potter Character Selection Mod End

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

                $sig = postedVar('sig', 'javascript', ($SETTINGS['sightml']=='off'), TRUE, TRUE);

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

                // Harry Potter Character Selection Mod Begin
                $hpchar = postedVar('hpchar', 'javascript', TRUE, TRUE, TRUE);
                // Harry Potter Character Selection Mod End

===================
Find Code (2 instances):
===================

) VALUES ('$username',

=========================
Replace Code With (2 instances):
=========================

, hpchar) VALUES ('$username',

=================================
Find Code At End Of Both Query Statements:
=================================

)");

===========================
Replace Code With (Both Instances):
===========================

, '$hpchar')");

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

                if ($memberinfo['customstatus'] != '') {
                    $showtitle = $rank['title'];
                    $customstatus = '<br />'.censor($memberinfo['customstatus']);
                } else {
                    $showtitle = $rank['title'];
                    $customstatus = '';
                }

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

                // Harry Potter Character Selection Mod Begin
                $hpcharblock = '';
                if ($memberinfo['hpchar'] != '') {
                    $hpcharname = $memberinfo['hpchar'];
                    $hpcharname = str_replace('.gif', '', $hpcharname);
                    $hpcharname = str_replace('_', ' ', $hpcharname);
                    if (file_exists(ROOT.'images/hpchar/'.$memberinfo['hpchar'])) {
                        $hpcharimg = '<img src="./images/hpchar/'.$memberinfo['hpchar'].'" alt="'.$hpcharname.'" title="'.$hpcharname.'" border="0" /><br />'.$hpcharname;
                        $memberinfo['hpchar'] = $hpcharimg;
                        eval('$hpcharblock = "'.template('member_profile_hpchar').'";');
                    }
                }
                // Harry Potter Character Selection Mod End

=======================================================================================================================================
=======
Step 3:
=======

=================
Edit File: memcp.php
=================

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

        $langfileselect = createLangFileSelect($member['langfile']);

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

        // Harry Potter Character Selection Mod Begin
        $hps = array();
        $hps[] = '<option value="">'.$lang['hpcharnone'].'</option>';
        $dp = opendir(ROOT.'images/hpchar');
        while ($file = readdir($dp)) {
            if ($file != '.' AND $file != '..' AND $file != 'index.html') {
                $hpcharname = $file;
                $hpcharname = str_replace(array('.gif','.jpg','.png','_'), array('','','',' '), $hpcharname);
                if ($member['hpchar'] == $file) {
                    $hps[] = '<option value="'.$file.'" selected="selected">'.$hpcharname.'</option>';
                } else {
                    $hps[] = '<option value="'.$file.'">'.$hpcharname.'</option>';
                }
            }
        }
        closedir($dp);
        natcasesort($hps);
        $hpcharselect = '<select name="newhpchar" onchange="document.getElementById(\'hpcharimg\').src = (this.options[this.selectedIndex].value != \'\') ? \'images/hpchar/\'+this.options[this.selectedIndex].value : \'./images/pixel.gif\';" />'.implode("\n", $hps).'</select>';
        $hpcharimg  = '<img src="'.ROOT.'images/pixel.gif" id="hpcharimg" alt="" />';
        if ($member['hpchar'] != '') {
            $hpcharimg = '<img src="'.ROOT.'images/hpchar/'.$member['hpchar'].'" alt="'.str_replace(array('.gif','.jpg','.png','_'), array('','','',' '), $member['hpchar']).'" id="hpcharimg" />';
        }
        // Harry Potter Character Selection Mod End

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

        $sig = isset($_POST['newsig']) ? checkInput($_POST['newsig'], '', $SETTINGS['sightml'], '', false) : '';

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

        // Harry Potter Character Selection Mod Begin
        $newhpchar = formVar('newhpchar');
        $hpchar = $newhpchar ? checkInput($newhpchar, 'no', 'yes', 'javascript', false) : '';
        // Harry Potter Character Selection Mod End

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

        $sig = addslashes($sig);

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

        // Harry Potter Character Selection Mod Begin
        $hpchar = addslashes($hpchar);
        // Harry Potter Character Selection Mod End

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

$db->query("UPDATE ".X_PREFIX."members SET $pwtxt

=======================================
Find Code In-Line At End Of Above Query Statement:
=======================================

 WHERE username='$xmbuser'");

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

, hpchar='$hpchar' WHERE username='$xmbuser'");

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

    if ($member['mood'] != '') {
        $member['mood'] = censor($member['mood']);
        $member['mood'] = postify($member['mood'], 'no', 'no', 'yes', 'no', 'yes', 'no', true, 'yes');
    } else {
        $member['mood'] = '';
    }

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

    // Harry Potter Character Selection Mod Begin
    if ($member['hpchar'] != '') {
        $hpcharname = $member['hpchar'];
        $hpcharname = str_replace('.gif', '', $hpcharname);
        $hpcharname = str_replace('_', ' ', $hpcharname);
        if (file_exists(ROOT.'images/hpchar/'.$member['hpchar'])) {
            $hpcharimg = '<img src="'.ROOT.'images/hpchar/'.$member['hpchar'].'" alt="'.$hpcharname.'" title="'.$hpcharname.'" border="0" /><br />'.$hpcharname;
            $member['hpchar'] = $hpcharimg;
        }
    }
    // Harry Potter Character Selection Mod End

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

==========================
Edit File: editprofile.php
==========================

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

    $langfileselect = createLangFileSelect($member['langfile']);

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

    // Harry Potter Character Selection Mod Begin
    $hps = array();
    $hps[] = '<option value="">'.$lang['hpcharnone'].'</option>';
    $dp = opendir(ROOT.'images/hpchar');
    while ($file = readdir($dp)) {
        if ($file != '.' AND $file != '..' AND $file != 'index.html') {
            $hpcharname = $file;
            $hpcharname = str_replace(array('.gif','.jpg','.png','_'), array('','','',' '), $hpcharname);
            if ($member['hpchar'] == $file) {
                $hps[] = '<option value="'.$file.'" selected="selected">'.$hpcharname.'</option>';
            } else {
                    $hps[] = '<option value="'.$file.'">'.$hpcharname.'</option>';
            }
        }
    }
    closedir($dp);
    natcasesort($hps);
    $hpcharselect = '<select name="newhpchar" onchange="document.getElementById(\'hpcharimg\').src = (this.options[this.selectedIndex].value != \'\') ? \'images/hpchar/\'+this.options[this.selectedIndex].value : \'./images/pixel.gif\';" />'.implode("\n", $hps).'</select>';
    $hpcharimg  = '<img src="'.ROOT.'images/pixel.gif" id="hpcharimg" alt="" />';
    if ($member['hpchar'] != '') {
        $hpcharimg = '<img src="'.ROOT.'images/hpchar/'.$member['hpchar'].'" alt="'.str_replace(array('.gif','.jpg','.png','_'), array('','','',' '), $member['hpchar']).'" id="hpcharimg" />';
    }
    // Harry Potter Character Selection Mod End

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

    $sig = isset($_POST['newsig']) ? checkInput($_POST['newsig'], '', $SETTINGS['sightml'], '', false) : '';

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

    // Harry Potter Character Selection Mod Begin
    $newhpchar = formVar('newhpchar');
    $hpchar = $newhpchar ? checkInput($newhpchar, 'no', 'yes', 'javascript', false) : '';
    // Harry Potter Character Selection Mod End

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

    $sig = addslashes($sig);

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

    // Harry Potter Character Selection Mod Begin
    $hpchar = addslashes($hpchar);
    // Harry Potter Character Selection Mod End

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

$db->query("UPDATE ".X_PREFIX."members SET email='$email',

==================================================
Find Code In-Line At End Of Above Query Statement:
==================================================

 WHERE username='$user'");

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

, hpchar='$hpchar' WHERE username='$user'");

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

=========================
Edit File: viewthread.php
=========================

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

            if ($post['location'] != '') {
                $post['location'] = censor($post['location']);
                $location = '<br />'.$lang['textlocation'].' '.$post['location'];
            } else {
                $location = '';
            }

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

            // Harry Potter Character Selection Mod Begin
            if ($post['hpchar'] != '') {
                $hpcharname = $post['hpchar'];
                $hpcharname = str_replace(array('.gif','.jpg','.png','_'), array('','','',' '), $hpcharname);
                if (file_exists(ROOT.'images/hpchar/'.$post['hpchar'].'')) {
                    $hpcharimg = '<img src="'.ROOT.'images/hpchar/'.$post['hpchar'].'" alt="'.$hpcharname.'" title="'.$hpcharname.'" border="0" /><br />'.$hpcharname.'<br />';
                    $post['hpchar'] = '<br />'.$lang['hpchar'].' '.$hpcharimg;
                }
            }
            // Harry Potter Character Selection Mod End

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

            $location = '';
            $mood = '';

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

            // Harry Potter Character Selection Mod Begin
            $post['hpchar'] = '';
            // Harry Potter Character Selection Mod End

=======================================================================================================================================
=======
Step 6:
=======

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

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

// Harry Potter Character Selection Mod Begin
$lang['hpchar'] = "Harry Potter Character:";
$lang['hpcharnone'] = "--Select Harry Potter Character--";
// Harry Potter Character Selection Mod End

=======================================================================================================================================
=======
Step 7:
=======

=======================================================
Go To Admin Panel -> Templates -> admintool_editprofile
=======================================================

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

<tr class="tablerow">
<td bgcolor="$altbg1" width="22%">$lang[textlocation]</td>
<td bgcolor="$altbg2"><input type="text" name="newlocation" size="25" value="$member[location]" /></td>
</tr>

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

<tr class="tablerow">
<td bgcolor="$THEME[altbg1]" width="22%">$lang[hpchar]</td>
<td bgcolor="$THEME[altbg2]">$hpcharselect&nbsp;<img id="hpcharimg" src="./images/hpchar/$member[hpchar]" alt="$hpcharname" title="$hpcharname" border="0" /></td>
</tr>

=======================================================================================================================================
=======
Step 8:
=======

==========================================
Go To Admin Panel -> Templates -> member_reg_optional
==========================================

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

<tr class="tablerow">
<td bgcolor="$altbg1" width="22%">$lang[textlocation]</td>
<td bgcolor="$altbg2"><input type="text" name="location" size="25" value="" /></td>
</tr>

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

<tr class="tablerow">
<td bgcolor="$THEME[altbg1]" width="22%">$lang[hpchar]</td>
<td bgcolor="$THEME[altbg2]">$hpcharselect&nbsp;<img id="hpcharimg" src="./images/pixel.gif" alt="$hpcharname" title="$hpcharname" border="0" /></td>
</tr>

=======================================================================================================================================
=======
Step 9:
=======

===============================================
Go To Admin Panel -> Templates -> memcp_profile
===============================================

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

<tr class="tablerow">
<td bgcolor="$altbg1" width="22%">$lang[textlocation]</td>
<td bgcolor="$altbg2"><input type="text" name="newlocation" size="25" value="$member[location]" /></td>
</tr>

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

<tr class="tablerow">
<td bgcolor="$THEME[altbg1]" width="22%">$lang[hpchar]</td>
<td bgcolor="$THEME[altbg2]">$hpcharselect&nbsp;$hpcharimg</td>
</tr>

=======================================================================================================================================
========
Step 10:
========

=================================================
Go To Admin Panel -> Templates -> viewthread_post
=================================================

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

$location

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

$post[hpchar]

=======================================================================================================================================
========
Step 11:
========

======================================
Go To Admin Panel -> Templates -> member_profile
======================================

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

<tr class="tablerow">
<td bgcolor="$altbg1">$lang[textlocation]</td>
<td bgcolor="$altbg2">$memberinfo[location]</td>
</tr>

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

$hpcharblock

=======================================================================================================================================
========
Step 12:
========

===========================================================
Go to admin panel -> templates -> create template name -> member_profile_hpchar
===========================================================

================================
Add Code & Click Submit Changes:
================================

<tr class="tablerow">
<td bgcolor="$THEME[altbg1]" width="22%" valign="top">$lang[hpchar]</td>
<td bgcolor="$THEME[altbg2]">$memberinfo[hpchar]</td>
</tr>

=======================================================================================================================================
========
Step 13:
========

=====================================
Go To Admin Panel -> Templates -> memcp_home
=====================================

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

<td bgcolor="$altbg1" valign="top">&nbsp;</td>
<td bgcolor="$altbg2" valign="top">&nbsp;</td>

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

<td bgcolor="$THEME[altbg1]" valign="top">$lang[hpchar]</td>
<td bgcolor="$THEME[altbg2]" valign="top" align="center">$member[hpchar]</td>

=======================================================================================================================================
========
Step 14:
========

Now upload provided folder named "/hpchar/" to your forum "/images/" directory.

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