============================================================================================================================
Modification Title: Ranking System

Version: 1.0

Author: nfpunk, GuldanWarlock, John Briggs and WormHole

Updated By: GuldanWarlock, John Briggs and WormHole

Description: This modification will add a Ranking System that keeps track of wins and losses. It is editable by Staff or members, your choice.

Compatibility: XMB 1.9.5 SP1

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 v3. 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:
=======
====================================
Go To Administration Panel --> Insert Raw SQL
====================================

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

============================================================================================================================
=======
Step 2:
=======
=======================
Edit File: lang/English.lang.php
=======================
========================
Add To End Of File Above  ?>
========================

// Ranking System Mod Begin
$lang['ranking'] = 'Rankings';
$lang['ranking_settings'] = 'Ranking Settings';
$lang['ranking_status'] = 'Ranking Status';
$lang['ranking_enabled'] = 'Enabled';
$lang['ranking_disabled'] = 'Disabled';
$lang['ranking_name'] = 'Ranking Name';
$lang['ranking_winname'] = 'Win Name';
$lang['ranking_losename'] = 'Loss Name';
$lang['ranking_increment'] = 'Increment';
$lang['ranking_edit'] = 'Input user status and/or usernames that are allowed to edit rankings.';
$lang['ranking_updatesuccessful'] = 'Ranking Settings Updated Successfully!';
$lang['ranking_editdeny'] = 'Sorry! You are not allowed to edit the user\'s ';
$lang['ranking_editallow'] = 'You have successfully edited the user\'s ';
$lang['ranking_commanote'] = '<strong>Note:</strong> Place a comma after every entry.';
$lang['ranking_noeditown'] = "Sorry! You are now allowed to edit your own *TITLE*.";
// Ranking System Mod End

============================================================================================================================
=======
Step 3:
=======
=============
Edit header.php
=============
==========
Find Code:
==========

,'ranks'

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

,'ranking_settings','ranks'

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

    &raquo;&nbsp;<a href="cp2.php?action=restrictions"><?php echo $lang['cprestricted']?></a><br />

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

    <!-- Ranking System Mod Begin -->
    &raquo;&nbsp;<a href="ranking.php?action=settings"><?php echo $lang['ranking']?></a><br />
    <!-- Ranking System Mod End -->

============================================================================================================================
=======
Step 5:
=======
=================
Edit File: member.php
=================
==========
Find Code:
==========

loadtemplates(

============
Replace with:
============

loadtemplates(
'member_profile_ranking',

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

$db->query("INSERT INTO $table_members (

==============================
Add To Line Just BEFORE  ) VALUES
==============================

, wins, losses

==============================
Add To End Of Line Just BEFORE  )");
==============================

, '0', '0'

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

        $memberinfo = $db->fetch_array($db->query("SELECT * FROM $table_members WHERE username='$member'"));

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

        $rankquery = $db->query("SELECT * FROM $table_ranking_settings");
        $rankingsettings = $db->fetch_array($rankquery);
        $db->free_result($rankquery);

======
Find:
======

            if (strpos($memberinfo['site'], 'http') === false) {
                $memberinfo['site'] = "http://$memberinfo[site]";
            }

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

            // Ranking System Mod Begin
            $rankingblock = '';
            if ($rankingsettings['rstatus'] == 'on') {
                eval('$rankingblock = "'.template('member_profile_ranking').'";');
            }
            // Ranking System Mod End

============================================================================================================================
=======
Step 6:
=======
===================
Edit File: viewthread.php
===================
==========
Find Code:
==========

    while ($post = $db->fetch_array($querypost)) {

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

    // Ranking System Mod Begin
    $rankquery = $db->query("SELECT * FROM $table_ranking_settings");
    $rankingsettings = $db->fetch_array($rankquery);
    $db->free_result($rankquery);
    // Ranking System Mod End

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

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

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

            // Ranking System Mod Begin
            $rankhtml = '';
            if ($rankingsettings['rstatus'] != 'off') {
                $rankhtml = '<br /><br /><div align="left">'.$rankingsettings['ranktitle'].'<br />'.$rankingsettings['wintitle'].': '.$post['wins'].' - '.$rankingsettings['losetitle'].': '.$post['losses'].'<br />';
                $rankhtml .= '<a href="ranking.php?action=win&amp;member='.$encodename.'&amp;tid='.$tid.'&amp;pid='.$post['pid'].'">'.$rankingsettings['wintitle'].'</a> | <a href="ranking.php?action=lose&amp;member='.$encodename.'&amp;tid='.$tid.'&amp;pid='.$post['pid'].'">'.$rankingsettings['losetitle'].'</a></div>';
            }
            // Ranking System Mod End

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

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

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

            // Ranking System Mod Begin
            $rankhtml = '';
            // Ranking System Mod End

============================================================================================================================
=======
Step 7:
=======
===============================
Go To Administration Panel --> Templates
===============================
===========================
Create New Template: ranking_edit
===========================
=========================
Paste Code and Submit Changes:
=========================

<div align="center"><font class="mediumtxt">$lang[ranking_editallow]$rsettings[ranktitle].</font></div>

============================================================================================================================
=======
Step 8:
=======
===============================
Go To Administration Panel --> Templates
===============================
===========================
Create New Template: ranking_deny
===========================
=========================
Paste Code and Submit Changes:
=========================

<div align="center"><font class="mediumtxt">$lang[ranking_editdeny]$rsettings[ranktitle].</font></div>

============================================================================================================================
=======
Step 9:
=======
===============================
Go To Administration Panel --> Templates
===============================
===================================
Create New Template: member_profile_ranking
===================================
=========================
Paste Code and Submit Changes:
=========================

<tr class="tablerow">
<td bgcolor="$THEME[altbg1]" width="22%">$rankingsettings[ranktitle]</td>
<td bgcolor="$THEME[altbg2]">$rankingsettings[wintitle]: $memberinfo[wins] - $rankingsettings[losetitle]: $memberinfo[losses]</td>
</tr>

============================================================================================================================
========
Step 10:
========
===============================
Go To Administration Panel --> Templates
===============================
Edit Template-> member_profile
===============================
==========
Find Code:
==========

<tr>
<td bgcolor="$altbg1" class="tablerow">$lang[textregistered]</td>
<td bgcolor="$altbg2" class="tablerow">$memberinfo[regdate] ($ppd $lang[textmesperday])</td>
</tr>

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

$rankingblock

============================================================================================================================
=======
Step 11:
=======
===============================
Go To Administration Panel --> Templates
===============================
========================
Edit Template: viewthread_post
========================
==========
Find Code:
==========

$mood

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

$rankhtml

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

Upload all edited files, and upload ranking.php from the "Contents" folder to your forum directory

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