Title: User Rank Icons

Author: John Briggs

Copyright:  2009 John Briggs. All rights reserved.

Description:
This modification will provide a user rank icon image to display next to usernames within your forum.
This modification will provide a user rank icon image to display in Who's Online on index.
This modification will provide a user rank icon image to display in Who's Online today.
This modification will provide a user rank icon image to display in the Who's Doing What Online area.
This modification will provide a user rank icon image to display in threads.
This modification will provide a user rank icon image to display in member control panel.
This modification will provide a user rank icon image to display in in member list.
This modification will provide a user rank icon image to display in member profiles.

Compatability: XMB 1.9.11

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.

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

====================
Edit File: index.php
====================

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

        for($mnum=0; $mnum<$show_total; $mnum++) {
            $pre = $suff = '';

            $online = $member[$mnum];

            $pre = '<span class="status_'.str_replace(' ', '_', $online['status']).'">';
            $suff = '</span>';

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

        for($mnum=0; $mnum<$show_total; $mnum++) {
            $pre = $suff = $ricon = '';

            $online = $member[$mnum];

            $pre = '<span class="status_'.str_replace(' ', '_', $online['status']).'">';
            $suff = '</span>';
            $ricon = '<img src="./images/ricons/online'.str_replace(' ', '', $online['status']).'.gif" border="0" alt="'.$online['status'].'" />';

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

            $memtally[] = '<a href="member.php?action=viewpro&amp;member='.recodeOut($online['username']).'">'.$pre.''.$online['username'].''.$suff.'</a>';

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

            $memtally[] = $ricon.'<a href="member.php?action=viewpro&amp;member='.recodeOut($online['username']).'">'.$pre.''.$online['username'].''.$suff.'</a>';

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

            $pre = $suff = '';
            $x = 0;
            while($memberstoday = $db->fetch_array($query)) {
                if ($x <= $onlinetodaycount) {
                    $pre = '<span class="status_'.str_replace(' ', '_', $memberstoday['status']).'">';
                    $suff = '</span>';
                    $todaymembers[] = '<a href="member.php?action=viewpro&amp;member='.recodeOut($memberstoday['username']).'">'.$pre.''.$memberstoday['username'].''.$suff.'</a>';
                    $x++;
                } else {
                    continue;
                }
            }

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

            $pre = $suff = $ricon = '';
            $x = 0;
            while($memberstoday = $db->fetch_array($query)) {
                if ($x <= $onlinetodaycount) {
                    $pre = '<span class="status_'.str_replace(' ', '_', $memberstoday['status']).'">';
                    $suff = '</span>';
                    $ricon = '<img src="./images/ricons/online'.str_replace(' ', '', $memberstoday['status']).'.gif" border="0" alt="'.$memberstoday['status'].'" />';
                    $todaymembers[] = $ricon.'<a href="member.php?action=viewpro&amp;member='.recodeOut($memberstoday['username']).'">'.$pre.''.$memberstoday['username'].''.$suff.'</a>';
                    $x++;
                } else {
                    continue;
                }
            }

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

===================
Edit File: misc.php
===================

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

        // UNION Syntax Reminder: "Use of ORDER BY for individual SELECT statements implies nothing about the order in which the rows appear."
        $sql = "SELECT username, 1 AS sort_col, MAX(ip) AS ip, MAX(`time`) as `time`, MAX(location) AS location, MAX(invisible) AS invisible "
             . "FROM ".X_PREFIX."whosonline $where GROUP BY username, sort_col "
             . "UNION ALL "
             . "SELECT username, 2 AS sort_col, ip, `time`, location, invisible "
             . "FROM ".X_PREFIX."whosonline WHERE username = 'xguest123' "
             . "ORDER BY sort_col, username, `time` DESC "
             . "LIMIT {$mpage['start']}, $tpp";
        $query = $db->query($sql);

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

        // UNION Syntax Reminder: "Use of ORDER BY for individual SELECT statements implies nothing about the order in which the rows appear."
        $sql = "SELECT w.username, 1 AS sort_col, MAX(ip) AS ip, MAX(`time`) as `time`, "
             . "MAX(w.location) AS location, MAX(w.invisible) AS invisible, MAX(status) AS status "
             . "FROM ".X_PREFIX."whosonline AS w "
             . "LEFT JOIN ".X_PREFIX."members AS m USING (username) $where "
             . "GROUP BY w.username, sort_col "
             . "UNION ALL "
             . "SELECT username, 2 AS sort_col, ip, `time`, location, invisible, 'Guest' AS status "
             . "FROM ".X_PREFIX."whosonline WHERE username = 'xguest123' "
             . "ORDER BY sort_col, username, `time` DESC "
             . "LIMIT {$mpage['start']}, $tpp";
        $query = $db->query($sql);

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

        $onlineusers = '';
        while($online = $db->fetch_array($query)) {
            $array = url_to_text($online['location']);
            $onlinetime = gmdate ($timecode, $online['time'] + ($timeoffset * 3600) + ($addtime * 3600));
            $username = str_replace('xguest123', $lang['textguest1'], $online['username']);

            $online['location'] = shortenString($array['text'], 80, X_SHORTEN_SOFT|X_SHORTEN_HARD, '...');
            if (X_STAFF) {
                $online['location'] = '<a href="'.$array['url'].'">'.shortenString($array['text'], 80, X_SHORTEN_SOFT|X_SHORTEN_HARD, '...').'</a>';
                $online['location'] = stripslashes($online['location']);
            }

            if ($online['invisible'] == 1 && (X_ADMIN || $online['username'] == $xmbuser)) {
                $hidden = ' ('.$lang['hidden'].')';
            } else {
                $hidden = '';
            }

            if (X_SADMIN && $online['username'] != 'xguest123' && $online['username'] != $lang['textguest1']) {
                $online['username'] = '<a href="member.php?action=viewpro&amp;member='.recodeOut($online['username']).'">'.$username.'</a>'.$hidden;
            } else {
                $online['username'] = $username;
            }

            if (X_ADMIN) {
                eval('$onlineusers .= "'.template('misc_online_row_admin').'";');
            } else {
                $online['invisible'] = '';
                $online['ip'] = '';
                eval('$onlineusers .= "'.template('misc_online_row').'";');
            }
        }
        $db->free_result($query);

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

        $onlineusers = '';
        while($online = $db->fetch_array($query)) {
            $array = url_to_text($online['location']);
            $onlinetime = gmdate ($timecode, $online['time'] + ($timeoffset * 3600) + ($addtime * 3600));
            $username = str_replace('xguest123', '<span class="status_Member">'.$lang['textguest1'].'</span>', $online['username']);

            $online['location'] = shortenString($array['text'], 80, X_SHORTEN_SOFT|X_SHORTEN_HARD, '...');
            if (X_STAFF) {
                $online['location'] = '<a href="'.$array['url'].'">'.shortenString($array['text'], 80, X_SHORTEN_SOFT|X_SHORTEN_HARD, '...').'</a>';
                $online['location'] = stripslashes($online['location']);
            }

            if ($online['invisible'] == 1 && (X_ADMIN || $online['username'] == $xmbuser)) {
                $hidden = ' ('.$lang['hidden'].')';
            } else {
                $hidden = '';
            }

            $pre = $suff = $ricon = '';
            $pre = '<span class="status_'.str_replace(' ', '_', $online['status']).'">';
            $suff = '</span>';

            if ($online['username'] != 'xguest123' && $online['username'] != $lang['textguest1']) {
                $ricon = '<img src="./images/ricons/online'.str_replace(' ', '', $online['status']).'.gif" border="0" alt="'.$online['status'].'" />';
            } else {
                $ricon = '<img src="./images/ricons/onlineGuest.gif" alt="'.$lang['textguest1'].'" border="0" />';
            }

            if (X_SADMIN && $online['username'] != 'xguest123' && $online['username'] != $lang['textguest1']) {
                $online['username'] = $ricon.'<a href="member.php?action=viewpro&amp;member='.recodeOut($online['username']).'">'.$pre.''.$username.''.$suff.'</a>'.$hidden;
            } else {
                $online['username'] = $ricon.''.$pre.''.$username.''.$suff;
            }

            if (X_ADMIN) {
                eval('$onlineusers .= "'.template('misc_online_row_admin').'";');
            } else {
                $online['invisible'] = '';
                $online['ip'] = '';
                eval('$onlineusers .= "'.template('misc_online_row').'";');
            }
        }
        $db->free_result($query);


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

        $where = "WHERE username != 'xguest123'";
        if (!X_ADMIN) {
            $where .= " AND (invisible='0' OR username='$xmbuser')";
        }

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

        $where = "WHERE w.username != 'xguest123'";
        if (!X_ADMIN) {
            $where .= " AND (w.invisible='0' OR w.username='$xmbuser')";
        }

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

    case 'onlinetoday':
        if ($SETTINGS['whosonlinestatus'] == 'off' || $SETTINGS['onlinetoday_status'] == 'off') {
            header('HTTP/1.0 403 Forbidden');
            eval('echo "'.template('header').'";');
            eval('echo "'.template('misc_feature_notavailable').'";');
            end_time();
            eval('echo "'.template('footer').'";');
            exit();
        }

        $datecut = $onlinetime - (3600 * 24);
        if (X_ADMIN) {
            $query = $db->query("SELECT username, status FROM ".X_PREFIX."members WHERE lastvisit >= '$datecut' ORDER BY username ASC");
        } else {
            $query = $db->query("SELECT username, status FROM ".X_PREFIX."members WHERE lastvisit >= '$datecut' AND invisible != '1' ORDER BY username ASC");
        }

        $todaymembersnum = 0;
        $todaymembers = array();
        $pre = $suff = '';
        while($memberstoday = $db->fetch_array($query)) {
            $pre = '<span class="status_'.str_replace(' ', '_', $memberstoday['status']).'">';
            $suff = '</span>';
            $todaymembers[] = '<a href="member.php?action=viewpro&amp;member='.recodeOut($memberstoday['username']).'">'.$pre.''.$memberstoday['username'].''.$suff. '</a>';
            ++$todaymembersnum;
        }
        $todaymembers = implode(', ', $todaymembers);
        $db->free_result($query);

        if ($todaymembersnum == 1) {
            $memontoday = $todaymembersnum.$lang['textmembertoday'];
        } else {
            $memontoday = $todaymembersnum.$lang['textmemberstoday'];
        }
        eval('$misc = "'.template('misc_online_today').'";');
        break;

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

    case 'onlinetoday':
        if ($SETTINGS['whosonlinestatus'] == 'off' || $SETTINGS['onlinetoday_status'] == 'off') {
            header('HTTP/1.0 403 Forbidden');
            eval('echo "'.template('header').'";');
            eval('echo "'.template('misc_feature_notavailable').'";');
            end_time();
            eval('echo "'.template('footer').'";');
            exit();
        }

        $datecut = $onlinetime - (3600 * 24);
        if (X_ADMIN) {
            $query = $db->query("SELECT username, status FROM ".X_PREFIX."members WHERE lastvisit >= '$datecut' ORDER BY username ASC");
        } else {
            $query = $db->query("SELECT username, status FROM ".X_PREFIX."members WHERE lastvisit >= '$datecut' AND invisible != '1' ORDER BY username ASC");
        }

        $todaymembersnum = 0;
        $todaymembers = array();
        $pre = $suff = $ricon = '';
        while($memberstoday = $db->fetch_array($query)) {
            $pre = '<span class="status_'.str_replace(' ', '_', $memberstoday['status']).'">';
            $suff = '</span>';
            $ricon = '<img src="./images/ricons/online'.str_replace(' ', '', $memberstoday['status']).'.gif" border="0" alt="'.$memberstoday['status'].'" />';
            $todaymembers[] = $ricon.'<a href="member.php?action=viewpro&amp;member='.recodeOut($memberstoday['username']).'">'.$pre.''.$memberstoday['username'].''.$suff. '</a>';
            ++$todaymembersnum;
        }
        $todaymembers = implode(', ', $todaymembers);
        $db->free_result($query);

        if ($todaymembersnum == 1) {
            $memontoday = $todaymembersnum.$lang['textmembertoday'];
        } else {
            $memontoday = $todaymembersnum.$lang['textmemberstoday'];
        }
        eval('$misc = "'.template('misc_online_today').'";');
        break;

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

                if ($member['location'] != '') {
                    $member['location'] = censor($member['location']);
                } else {
                    $member['location'] = '';
                }

                $memurl = recodeOut($member['username']);
                if ($order == 'status') {
                    if ($oldst != $member['status']) {
                        $oldst = $member['status'];
                        $seperator_text = (trim($member['status']) == '' ? $lang['onlineother'] : $member['status']);
                        eval('$members .= "'.template('misc_mlist_separator').'";');
                    }
                }

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

                if ($member['location'] != '') {
                    $member['location'] = censor($member['location']);
                } else {
                    $member['location'] = '';
                }

                $memurl = recodeOut($member['username']);
                if ($order == 'status') {
                    if ($oldst != $member['status']) {
                        $oldst = $member['status'];
                        $seperator_text = (trim($member['status']) == '' ? $lang['onlineother'] : $member['status']);
                        eval('$members .= "'.template('misc_mlist_separator').'";');
                    }
                }

                $pre = $suff = $ricon = '';
                $pre = '<span class="status_'.str_replace(' ', '_', $member['status']).'">';
                $suff = '</span>';
                $ricon = '<img src="./images/ricons/online'.str_replace(' ', '', $member['status']).'.gif" border="0" alt="'.$member['status'].'" />';

                $member["username"] = $ricon.'<a href="member.php?action=viewpro&amp;member='.recodeOut($member['username']).'">'.$pre.''.$member['username'].''.$suff.'</a>';

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

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

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

        $daysreg = ($onlinetime - $memberinfo['regdate']) / (24*3600);
        if ($daysreg > 1) {
            $ppd = $memberinfo['postnum'] / $daysreg;
            $ppd = round($ppd, 2);
        } else {
            $ppd = $memberinfo['postnum'];
        }

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

        $pre = $suff = $ricon = '';
        $pre = '<span class="status_'.str_replace(' ', '_', $memberinfo['status']).'">';
        $suff = '</span>';
        $ricon = '<img src="./images/ricons/online'.str_replace(' ', '', $memberinfo['status']).'.gif" border="0" alt="'.$memberinfo['status'].'" />';

        $memberinfousername = $ricon.''.$pre.''.$memberinfo['username'].''.$suff;

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

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

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

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

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

    $pre = $suff = $ricon = '';
    $pre = '<span class="status_'.str_replace(' ', '_', $member['status']).'">';
    $suff = '</span>';
    $ricon = '<img src="./images/ricons/online'.str_replace(' ', '', $member['status']).'.gif" border="0" alt="'.$member['status'].'" />';

    $member['username'] = $ricon.''.$pre.''.$member['username'].''.$suff;

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

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

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

            $encodename = recodeOut($post['author']);
            $profilelink = "<a href=\"./member.php?action=viewpro&amp;member=$encodename\">{$post['author']}</a>";

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

            $pre = $suff = $ricon = '';
            $pre = '<span class="status_'.str_replace(' ', '_', $post['status']).'">';
            $suff = '</span>';
            $ricon = '<img src="./images/ricons/online'.str_replace(' ', '', $post['status']).'.gif" border="0" alt="'.$post['status'].'" />';
            $encodename = recodeOut($post['author']);
            $profilelink = $ricon.'<a href="member.php?action=viewpro&amp;member='.$encodename.'">'.$pre.''.$post['author'].''.$suff.'</a>';

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

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

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

<font class="mediumtxt"><strong>$profilelink</strong></font>

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

<font class="mediumtxt">$profilelink</font>

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

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

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

<td bgcolor="$altbg1" colspan="2" class="mediumtxt">
$lang[key]<strong><u><em>$lang[superadmin]</em></u></strong> - <strong><u>$lang[textsendadmin]</u></strong> - <em><strong>$lang[textsendsupermodification]</strong></em> - <strong>$lang[textsendmodification]</strong> - $lang[textsendall]$hidden
</td>

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

<td bgcolor="$altbg1" colspan="2" class="mediumtxt">
$lang[key]
<img src="./images/ricons/onlineSuperAdministrator.gif" alt="" border="0" /><font class="status_Super_Administrator">$lang[superadmin]</font> -
<img src="./images/ricons/onlineAdministrator.gif" alt="" border="0" /><font class="status_Administrator">$lang[textsendadmin]</font> -
<img src="./images/ricons/onlineSuperModerator.gif" alt="" border="0" /><font class="status_Super_Moderator">$lang[textsendsupermodification]</font> -
<img src="./images/ricons/onlineModerator.gif" alt="" border="0" /><font class="status_Moderator">$lang[textsendmodification]</font> -
<img src="./images/ricons/onlineMember.gif" alt="" border="0" /><font class="status_Member">$lang[textsendall]$hidden</font>
</td>

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

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

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

<tr class="tablerow">
<td bgcolor="$altbg1" width="22%">$lang[textusername]</td>
<td bgcolor="$altbg2">{$memberinfo['username']}$memberlinks</td>
</tr>

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

<tr class="tablerow">
<td bgcolor="$altbg1" width="22%">$lang[textusername]</td>
<td bgcolor="$altbg2">$memberinfousername$memberlinks</td>
</tr>

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

Now upload the provided folder "ricons" to your folder "images" in root of your forum.

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