Modification Title: Personal Photo v1.0

Modification Author: John Briggs

Last Updated: 04/01/09

Modification Description:
This modification provides an option to add a personal photo in your profile similiar to how avatars work.
This modification provides a height and width size control in admin panel settings.
This modification provides an on/off control in admin panel settings.

Supported Version: XMB 1.9.8 SP3

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. You should have received a copy with this software package.

Author Note:
For security purposes, Please Check: http://www.xmbgarage.com for the latest version of this modification.
Downloading this modification from other sites could cause malicious code to enter into your XMB Forum software.
As such, xmbgarage.com will not offer support for modifications not offered at our website.

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

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

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

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

=============
Edit File: cp.php
=============

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

        $avchecked[0] = $avchecked[1] = $avchecked[2] = false;
        if (!empty($avatarlist)) {
            $avchecked[1] = true;
        } else if (!empty($avataroff)) {
            $avchecked[2] = true;
        } else {
            $avchecked[0] = true;
        }

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

        // Personal Photo Mod Begin
        $photo_on = $photo_off = '';
        switch ($SETTINGS['photostatus']) {
            case 'on':
                $photo_on = $selHTML;
                break;
            default:
                $photo_off = $selHTML;
                break;
        }
        // Personal Photo Mod End

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

        $lang['spell_checker'] .= $spell_off_reason;

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

        // Personal Photo Mod Begin
        $max_photo_sizes = explode('x', $SETTINGS['max_photo_size']);
        // Personal Photo Mod End

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

        printsetting2($lang['pruneusers'], 'pruneusersnew', ((int)$SETTINGS['pruneusers']), 3);
        ?>

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

        <!-- Personal Photo Mod Begin -->
        <tr>
        <td class="tablerow" bgcolor="<?php echo $THEME['altbg2']?>" colspan="2">&nbsp;</td>
        </tr>
        <tr>
        <td bgcolor="<?php echo $THEME['altbg1']?>" colspan="2" class="category"><strong><font color="<?php echo $THEME[cattext]?>">&raquo;&nbsp;<?php echo $lang['photo_main_settings']?></font></strong></td>
        </tr>
        <?php
        printsetting1($lang['photostatus'], 'photostatusnew', $photo_on, $photo_off);
        printsetting2($lang['max_photo_size_w'], "max_photo_size_w_new", $max_photo_sizes[0], 4);
        printsetting2($lang['max_photo_size_h'], "max_photo_size_h_new", $max_photo_sizes[1], 4);
        ?>
        <!-- Personal Photo Mod End -->

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

        $spellchecknew = ($_POST['spellchecknew'] == 'on' && defined('PSPELL_FAST')) ? 'on' : 'off';

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

        // Personal Photo Mod Begin
        $max_photo_size_w_new = formInt('$max_photo_size_w_new');
        $max_photo_size_h_new = formInt('$max_photo_size_h_new');
        $photostatusnew = formOnOff('photostatusnew');
        // Personal Photo Mod End

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

        $db->query("UPDATE ".X_PREFIX."settings SET

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

        $db->query("UPDATE ".X_PREFIX."settings SET
            photostatus='$photostatusnew',
            max_photo_size='${max_photo_size_w_new}x${max_photo_size_h_new}',

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

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

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

loadtemplates(

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

loadtemplates(
'admintool_editprofile',
'memcp_profile_photourl',

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

    $lang['searchusermsg'] = str_replace('*USER*', $user, $lang['searchusermsg']);

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

    // Personal Photo Mod Begin
    $photobox = '';
    if ($SETTINGS['photostatus'] == 'on') {
        eval('$photobox = "'.template('memcp_profile_photourl').'";');
    }
    // Personal Photo Mod End

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

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

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

    // Personal Photo Mod Begin
    $newphoto = isset($newphoto) ? ereg_replace(' ', '%20', $newphoto) : ''; // Problem with spaces in photo url
    $photo = $newphoto ? checkInput($newphoto, '', '', 'javascript', false) : '';
    // Personal Photo Mod End

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

    $sig = addslashes($sig);

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

    // Personal Photo Mod Begin
    $photo = addslashes($photo);
    // Personal Photo Mod End

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

    $max_size = explode('x', $SETTINGS['max_avatar_size']);
    if ($max_size[0] > 0 && $max_size[1] > 0 && ini_get('allow_url_fopen')) {
        $size = @getimagesize($_POST['newavatar']);
        if ($size === false) {
            $avatar = '';
        } else if (($size[0] > $max_size[0] && $max_size[0] > 0) || ($size[1] > $max_size[1] && $max_size[1] > 0) && !X_SADMIN) {
            error($lang['avatar_too_big'] . $SETTINGS['max_avatar_size'] . 'px', false);
        }
    }

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

    // Personal Photo Mod Begin
    $photosize = @getimagesize($photo);
    $max_photosize = explode('x', $SETTINGS['max_photo_size']);
    if ($photosize === false && ($max_photosize['0'] > 0 && $max_photosize['1'] > 0)) {
        $photo = '';
    } elseif (($max_photosize['0'] > 0 && $max_photosize['1'] > 0) && ($photosize['0'] > $max_photosize['0'] || $photosize['1'] > $max_photosize['1']) && !X_SADMIN) {
        error($lang['photo_too_big'] . $SETTINGS['max_photo_size'] . 'px', false);
    }
    // Personal Photo 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:
==================

, photo='$newphoto' WHERE username='$user'");

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

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

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

loadtemplates(

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

loadtemplates(
'memcp_subscriptions_row',
'memcp_profile_photourl',

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

            eval('$avatar = "'.template('memcp_profile_avatarlist').'";');
            closedir($dir1);
        }

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

        // Personal Photo Mod Begin
        $photobox = '';
        if ($SETTINGS['photostatus'] == 'on') {
            eval('$photobox = "'.template('memcp_profile_photourl').'";');
        }
        // Personal Photo Mod End

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

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

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

        // Personal Photo Mod Begin
        $newphoto = isset($newphoto) ? ereg_replace(' ', '%20', $newphoto) : ''; // Problem with spaces in photo url
        $photo = $newphoto ? checkInput($newphoto, '', '', 'javascript', false) : '';
        // Personal Photo Mod End

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

        $sig = addslashes($sig);

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

        // Personal Photo Mod Begin
        $photo = addslashes($photo);
        // Personal Photo Mod End

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

                error($lang['avatar_too_big'] . $SETTINGS['max_avatar_size'] . 'px', false);
            }
        }

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

        // Personal Photo Mod Begin
        $photosize = @getimagesize($photo);
        $max_photosize = explode('x', $SETTINGS['max_photo_size']);
        if ($photosize === false && ($max_photosize['0'] > 0 && $max_photosize['1'] > 0)) {
            $photo = '';
        } elseif (($max_photosize['0'] > 0 && $max_photosize['1'] > 0) && ($photosize['0'] > $max_photosize['0'] || $photosize['1'] > $max_photosize['1']) && !X_SADMIN) {
            error($lang['photo_too_big'] . $SETTINGS['max_photo_size'] . 'px', false);
        }
        // Personal Photo Mod End

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

$db->query("UPDATE $table_members SET $pwtxt

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

 WHERE username='$xmbuser'");

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

, photo='$newphoto' 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:
===============

    // Personal Photo Mod Begin
    if (!empty($member['photo'])) {
        $member['photo'] = '<img src="'.$member['photo'].'" alt="'.$lang['photoalt'].'" title="'.$lang['photoalt'].'" border="0" />';
    } else {
        $member['photo'] = '';
    }
    // Personal Photo Mod End

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

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

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

loadtemplates(

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

loadtemplates(
'misc_feature_notavailable',
'member_reg_photourl',
'member_profile_photo',

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

                if ($SETTINGS['sightml'] == 'on') {
                    $htmlis = $lang['texton'];
                } else {
                    $htmlis = $lang['textoff'];
                }

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

                // Personal Photo Mod Begin
                $photobox = '';
                if ($SETTINGS['photostatus'] == 'on') {
                    eval('$photobox = "'.template('member_reg_photourl').'";');
                }
                // Personal Photo Mod End

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

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

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

                // Personal Photo Mod Begin
                $photo = postedVar('photo', 'javascript', TRUE, TRUE, TRUE);
                // Personal Photo Mod End

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

                $max_size = explode('x', $SETTINGS['max_avatar_size']);
                if ($max_size[0] > 0 && $max_size[1] > 0 && ini_get('allow_url_fopen')) {
                    $size = @getimagesize($_POST['avatar']);
                    if ($size === false ) {
                        $avatar = '';
                    } else if (($size[0] > $max_size[0] && $max_size[0] > 0) || ($size[1] > $max_size[1] && $max_size[1] > 0)) {
                        error($lang['avatar_too_big'] . $SETTINGS['max_avatar_size'] . 'px');
                    }
                }

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

                // Personal Photo Mod Begin
                $photosize = @getimagesize($photo);
                $max_photosize = explode('x', $SETTINGS['max_photo_size']);
                if ($photosize === false && ($max_photosize[0] > 0 && $max_photosize[1] > 0)) {
                    $photo = '';
                } elseif (($max_photosize[0] > 0 && $max_photosize[1] > 0) && ($photosize['0'] > $max_photosize['0'] || $photosize['1'] > $max_photosize['1']) && !X_SADMIN) {
                    error($lang['photo_too_big'] . $SETTINGS['max_photo_size'] . 'px');
                }
                // Personal Photo Mod End

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

$db->query("INSERT INTO ".X_PREFIX."members (uid,

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

) VALUES ('$username'

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

, photo) VALUES ('$username'

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

)");

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

, '$photo')");

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

                if ($memberinfo['avatar'] != '') {
                    $memberinfo['avatar'] = '<img src="'.$memberinfo['avatar'].'" alt="'.$lang['altavatar'].'" border="0" />';
                }

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

                // Personal Photo Mod Begin
                $memberinfo['photo'] = trim($memberinfo['photo']);
                $photoblock = '';
                if (!empty($memberinfo['photo'])) {
                    $memberinfo['photo'] = '<img src="'.$memberinfo['photo'].'" alt="'.$lang['photoalt'].'" title="'.$lang['photoalt'].'" border="0" />';
                    eval('$photoblock = "'.template('member_profile_photo').'";');
                }
                // Personal Photo Mod End

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

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

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

// Personal Photo Mod Begin
$lang['photoalt'] = "Personal Photo";
$lang['phototext'] = "Personal Photo:";
$lang['photostatus'] = "Personal Photo Status:";
$lang['photo_main_settings'] = "Personal Photo Settings";
$lang['max_photo_size_w'] = "The maximum personal photo Width (in pixels):";
$lang['max_photo_size_h'] = "The maximum personal photo Height (in pixels):";
$lang['photo_too_big'] = "Your personal photo is too big! The maximum allowed personal photo size on this board is: ";
// Personal Photo Mod End

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

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

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

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

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

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

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

<tr class="tablerow">
<td bgcolor="$THEME[altbg1]" valign="top" wifth="22%">$lang[phototext]</a></td>
<td bgcolor="$THEME[altbg2]" valign="top">$memberinfo[photo]</td>
</tr>

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

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

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

<tr class="tablerow">
<td bgcolor="$THEME[altbg1]" width="22%">$lang[phototext]</td>
<td bgcolor="$THEME[altbg2]"><input type="text" name="newphoto" size="25" value="$member[photo]" /></td>
</tr>

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

=====================================
Go to admin panel -> templates -> member_profile
=====================================

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

<tr class="tablerow">
<td bgcolor="$altbg1" valign="top">$lang[textstatus]<br /><a href="$sitelink" target="_blank">$memberinfo[avatar]</a></td>
<td bgcolor="$altbg2">$showtitle$customstatus<br />$stars<br /><br />$rank[avatarrank]</td>
</tr>

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

$photoblock

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

====================================
Go to admin panel -> templates -> memcp_profile
====================================

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

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

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

$photobox

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

========================================
Go to admin panel -> templates -> admintool_editprofile
========================================

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

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

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

$photobox

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

====================================
Go to admin panel -> templates -> memcp_home
====================================

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

<td bgcolor="$altbg1" valign="top">$lang[textcusstatus]</td>
<td bgcolor="$altbg2" valign="top">$member[customstatus]</td>
<td bgcolor="$altbg1" valign="top">&nbsp;</td>
<td bgcolor="$altbg2" valign="top">&nbsp;</td>

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

<td bgcolor="$altbg1" valign="top">$lang[textcusstatus]</td>
<td bgcolor="$altbg2" valign="top">$member[customstatus]</td>
<td bgcolor="$THEME[altbg1]" valign="top">$lang[phototext]</td>
<td bgcolor="$THEME[altbg2]" align="center">$member[photo]</td>

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

=========================================
Go to admin panel -> templates -> member_reg_optional
=========================================

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

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

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

$photobox

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