--------------------------------------------------
Member level for PHP-Fusion v6
--------------------------------------------------
Version: 1.7
Author: PahaW
Email: paha@khspu.ru
Date: Sep 29, 2006
--------------------------------------------------
Released under the terms & conditions of v2 of the
GNU General Public License. For details refer to
the included gpl.txt file or visit http://gnu.org
--------------------------------------------------
PHP-Fusion Copyright (C) 2002 - 2005 Nick Jones
--------------------------------------------------

This module for addition of a level to the user, and changes.

Included files:
  administration\forums.php
  administration\members.php 
  administration\updateuser.php 
  forum\viewthread.php
  locale\You language\admin\forums.php
  locale\You language\admin\members.php
  sql.sql

Support at http://www.khspu.ru/~Board or http://fusion.byweb.ru

--------------------------------------------------
Installation:
--------------------------------------------------
Difficulty: Easy
BackUp you files and base.

Copy the files to the appropriate directories, and replace all files.

SQL:
Create base:

To copy in the root catalogue (sql.php).
In an address line of a browser enter here it:
http://you_site/sql.php
If there will be a text of green color all is normal if red that look a mistake.

PHP:
open file administration\forums.php:

find line:
---
} elseif ($action == "delete" && $t == "forum") {
	if (dbcount("(*)", "posts", "forum_id='$forum_id'") == 0) {
		$data = dbarray(dbquery("SELECT * FROM ".$db_prefix."forums WHERE forum_id='$forum_id'"));
		$result = dbquery("UPDATE ".$db_prefix."forums SET forum_order=forum_order-1 WHERE forum_cat='".$data['forum_cat']."' AND forum_order>'".$data['forum_order']."'");
		$result = dbquery("DELETE FROM ".$db_prefix."forums WHERE forum_id='$forum_id'");
		redirect(FUSION_SELF.$aidlink."&status=delf1");
	} else {
		redirect(FUSION_SELF.$aidlink."&status=delf2");
	}
} else {

replace line:
---
} elseif ($action == "delete" && $t == "forum") {
	if (dbcount("(*)", "posts", "forum_id='$forum_id'") == 0) {
		$data = dbarray(dbquery("SELECT * FROM ".$db_prefix."forums WHERE forum_id='$forum_id'"));
		$result = dbquery("UPDATE ".$db_prefix."forums SET forum_order=forum_order-1 WHERE forum_cat='".$data['forum_cat']."' AND forum_order>'".$data['forum_order']."'");
		$result = dbquery("DELETE FROM ".$db_prefix."forums WHERE forum_id='$forum_id'");
		redirect(FUSION_SELF.$aidlink."&status=delf1");
	} else {
		redirect(FUSION_SELF.$aidlink."&status=delf2");
	}
///////////////////
} elseif (isset($_POST['add_tname'])&&($mpost!="")&&($mlevel!="")){
       $mlevel = trim(eregi_replace(" +", " ", $mlevel));
       $forum_level = dbrows(dbquery("SELECT * FROM ".$db_prefix."forum_nmember"))+1;
       $result = dbquery("INSERT INTO ".$db_prefix."forum_nmember (forum_mpost, forum_mlevel, forum_level) VALUES ('{$mpost}', '{$mlevel}', '{$forum_level}')");
       $mlevel = "";
       $mpost = "";
       $lev_action = FUSION_SELF.$aidlink."&amp;status=add_member_level";
       redirect(FUSION_SELF);
} elseif (isset($_POST['save_tname'])&&($mpost!="")&&($mlevel!="")){
         $result = dbquery("UPDATE ".$db_prefix."forum_nmember SET forum_mpost='{$mpost}', forum_mlevel='{$mlevel}' WHERE forum_lev_id='{$_GET['forum_lev_id']}'");
         if (!$result){echo "11";}
         $mlevel = "";
         $mpost = "";
         $lev_action = FUSION_SELF.$aidlink."&amp;status=save_member_level";
         redirect(FUSION_SELF);
} elseif (isset($_POST['delete_tname'])){
         $result = dbquery("DELETE FROM ".$db_prefix."forum_nmember WHERE forum_lev_id='{$_GET['forum_lev_id']}'");
         if (!$result){echo "11";}
         $mlevel = "";
         $mpost = "";
         $lev_action = FUSION_SELF.$aidlink."&amp;status=delete_member_level";
         redirect(FUSION_SELF);
///////////////////
} else {


find line:
---
	if ($action == "edit") {
		if ($t == "cat") {
			$result = dbquery("SELECT * FROM ".$db_prefix."forums WHERE forum_id='$forum_id'");
			$data = dbarray($result);
			$cat_name = $data['forum_name'];
			$cat_title = $locale['420'];
			$cat_action = FUSION_SELF.$aidlink."&amp;action=edit&amp;forum_id=".$data['forum_id']."&amp;t=cat";
			$forum_title = $locale['421'];
			$forum_action = FUSION_SELF.$aidlink;
		} elseif ($t == "forum") {
			$result = dbquery("SELECT * FROM ".$db_prefix."forums WHERE forum_id='$forum_id'");
			$data = dbarray($result);
			$forum_name = $data['forum_name'];
			$forum_description = $data['forum_description'];
			$forum_cat = $data['forum_cat'];
			$forum_access = $data['forum_access'];
			$forum_posting = $data['forum_posting'];
			$forum_title = $locale['422'];
			$forum_action = FUSION_SELF.$aidlink."&amp;action=edit&amp;forum_id=".$data['forum_id']."&amp;t=forum";
			$cat_title = $locale['423'];
			$cat_action = FUSION_SELF.$aidlink;
		}
	} else {
		$cat_name = "";
		$cat_order = "";
		$cat_title = $locale['423'];
		$cat_action = FUSION_SELF.$aidlink;
		$forum_name = "";
		$forum_description = "";
		$forum_cat = "";
		$forum_order = "";
		$forum_access = "";
		$forum_posting = "";
		$forum_title = $locale['421'];
		$forum_action = FUSION_SELF.$aidlink;
	}
//////////////////////////////////////////


replace line:
---
	if ($action == "edit") {
		if ($t == "cat") {
			$result = dbquery("SELECT * FROM ".$db_prefix."forums WHERE forum_id='$forum_id'");
			$data = dbarray($result);
			$cat_name = $data['forum_name'];
			$cat_title = $locale['420'];
			$cat_action = FUSION_SELF.$aidlink."&amp;action=edit&amp;forum_id=".$data['forum_id']."&amp;t=cat";
			$forum_title = $locale['421'];
			$forum_action = FUSION_SELF.$aidlink;
		} elseif ($t == "forum") {
			$result = dbquery("SELECT * FROM ".$db_prefix."forums WHERE forum_id='$forum_id'");
			$data = dbarray($result);
			$forum_name = $data['forum_name'];
			$forum_description = $data['forum_description'];
			$forum_cat = $data['forum_cat'];
			$forum_access = $data['forum_access'];
			$forum_posting = $data['forum_posting'];
			$forum_title = $locale['422'];
			$forum_action = FUSION_SELF.$aidlink."&amp;action=edit&amp;forum_id=".$data['forum_id']."&amp;t=forum";
			$cat_title = $locale['423'];
			$cat_action = FUSION_SELF.$aidlink;
		}
        } elseif (($action == "edit_tname")&&($t == "nmember")){
	        $forum_lev_id = $_GET['forum_lev_id'];
                if ($forum_lev_id > 0){
                    $data = dbarray(dbquery("SELECT * FROM ".$db_prefix."forum_nmember WHERE forum_lev_id='{$forum_lev_id}'"));
                    $mpost = $data['forum_mpost'];
                    $mlevel = $data['forum_mlevel'];
                    $lev_action = FUSION_SELF.$aidlink."&amp;action=save_tname&amp;forum_lev_id={$forum_lev_id}&amp;t=nmember";
                 } else {
                    redirect(FUSION_SELF.$aidlink);
                 }
		$cat_name = "";
		$cat_order = "";
		$cat_title = $locale['423'];
		$cat_action = FUSION_SELF.$aidlink;
		$forum_name = "";
		$forum_description = "";
		$forum_cat = "";
		$forum_order = "";
		$forum_access = "";
		$forum_posting = "";
		$forum_title = $locale['421'];
		$forum_action = FUSION_SELF.$aidlink;
	} else {
		$cat_name = "";
		$cat_order = "";
		$cat_title = $locale['423'];
		$cat_action = FUSION_SELF.$aidlink;
		$forum_name = "";
		$forum_description = "";
		$forum_cat = "";
		$forum_order = "";
		$forum_access = "";
		$forum_posting = "";
		$forum_title = $locale['421'];
		$forum_action = FUSION_SELF.$aidlink;
	}
//////////////////////////////////////////


find line:
---
	if ($t != "forum") {
		opentable($cat_title);
		echo "<form name='addcat' method='post' action='$cat_action'>
<table align='center' cellpadding='0' cellspacing='0' width='300'>



Above add:
---
		opentable($locale['ml494']);
echo "<SCRIPT LANGUAGE=\"JavaScript\">
<!-- 
function menu(){
var URL = document.addlm.level.options[document.addlm.level.selectedIndex].value;
top.location.href = URL; target = '_self';
}
// -->
</SCRIPT>";
echo "<form method='post' action='$lev_action' name='addlm'>
<table align='center' border='0' cellpadding='0' cellspacing='0' width='500' class='border'>
<tr><td>".$locale['ml500']." ".$locale['ml501']."</td><td>";
echo "
<select name='level' onchange=\"menu()\" class='font'>
<option value='".FUSION_SELF.$aidlink."'> --- </option>";
$query=dbquery("SELECT * FROM ".$db_prefix."forum_nmember");
      while($data=dbarray($query)) {
            echo "<option value='".FUSION_SELF.$aidlink."&amp;action=edit_tname&amp;forum_lev_id=".$data['forum_lev_id']."&amp;t=nmember' target='_self'";
            if (isset($forum_lev_id)&&($forum_lev_id==$data['forum_lev_id'])){
                echo "selected>";
            } else {
                echo ">";
            }
            echo $locale['ml495']." ".$data['forum_level']." ".$locale['ml496']."</option>";
      }
echo "</select>";
echo "</td></tr>
<tr><td class='tbl2' colspan='2' align='center'><b>".$locale['ml495']." ";
if ($forum_lev_id > 0) echo $forum_lev_id;
echo " ".$locale['ml496']."</b></td></tr>
<tr><td>&nbsp;</td></tr>
<tr><td class='tbl1' style='white-space:nowrap'><b>".$locale['ml495']." ".$locale['ml497']."</b></td>
    <td class='tbl1'><input type='text' name='mpost' value='$mpost' class='textbox' style='width:230px;'></td>
</tr>
<tr><td class='tbl1' style='white-space:nowrap'><b>".$locale['ml495']." ".$locale['ml498']."</b></td>
    <td class='tbl1'><input type='text' name='mlevel' value='$mlevel' class='textbox' style='width:230px;'></td>
</tr>
<tr>
<tr><td class='tbl2' colspan='2'>&nbsp;</td></tr>
<td align='center' colspan='2' class='tbl'>";
if ($action == "edit_tname"){
   echo "<input type='submit' name='save_tname' value='".$locale['ml502']."' class='button'>&nbsp;";
   echo "<input type='submit' name='delete_tname' value='".$locale['ml503']."' class='button'>";
} else {
   echo " <input type='submit' name='add_tname' value='".$locale['ml499']."' class='button'></td>";
}
echo "</tr>
</table>
</form>\n";
		closetable();
	tablebreak();
///////////////////////////////////////////


open file locale\You Language\admin\forum.php
befor ?> add:
---
// Mlevel Forums
$locale['ml494'] = "Personal status";
$locale['ml495'] = "Level";
$locale['ml496'] = "detail";
$locale['ml497'] = "mark message";
$locale['ml498'] = "name";
$locale['ml499'] = "Add";
$locale['ml500'] = "Select";
$locale['ml501'] = "level";
$locale['ml502'] = "Save";
$locale['ml503'] = "Delete";



close file.

open file administration\members.php
find line: 
---
$username = trim(eregi_replace(" +", " ", $_POST['username']));

after add:
---
if ($_POST['mlevel'] == "") {
    $mlevel = "none";
} else {
    $mlevel = trim(eregi_replace(" +", " ", $_POST['mlevel']));
    if (!preg_match("/^[-0-9A-Z_@\s]+$/i", $mlevel)) $error .= $locale['452']."<br>\n";
}
find line:
---
$result = dbquery("INSERT INTO ".$db_prefix."users (user_name, user_password, user_email, user_hide_email, user_location, user_birthdate, user_aim, user_icq, user_msn, user_yahoo, user_web, user_theme, user_offset, user_avatar, user_sig, user_posts, user_joined, user_lastvisit, user_ip, user_rights, user_groups, user_level, user_status) VALUES ('$username', '$mlevel', md5('$password1'), '$email', '$hide_email', '', '0000-00-00', '', '', '', '', '', 'Default', '0', '', '', '0', '".time()."', '0', '".USER_IP."', '', '', '101', '0')");

replace:
---
$result = dbquery("INSERT INTO ".$db_prefix."users (user_name, user_mlevel, user_password, user_email, user_hide_email, user_location, user_birthdate, user_aim, user_icq, user_msn, user_yahoo, user_web, user_theme, user_offset, user_avatar, user_sig, user_posts, user_joined, user_lastvisit, user_ip, user_rights, user_groups, user_level, user_status) VALUES ('$username', '$mlevel', md5('$password1'), '$email', '$hide_email', '', '0000-00-00', '', '', '', '', '', 'Default', '0', '', '', '0', '".time()."', '0', '".USER_IP."', '', '', '101', '0')");

find line:
---
<tr>
<td class='tbl'>".$locale['u001']."<span style='color:#ff0000'>*</span></td>
<td class='tbl'><input type='text' name='username' maxlength='30' class='textbox' style='width:200px;'></td>
</tr>


after add:
---
<tr>
<td class='tbl'>".$locale['ml482']."</b></td>
<td class='tbl'><input type='text' name='mlevel' value='' maxlength='30' class='textbox' style='width:200px;'></td>
</tr>

find line:
---
<tr>
<td class='tbl'>".$locale['u001']."<font color='red'>*&nbsp;</font></td>
<td class='tbl'><input type='text' name='user_name' value='".$data['user_name']."' maxlength='30' class='textbox' style='width:200px;'></td>
</tr>


after add:
---
<tr>
<td class='tbl'>".$locale['ml482']."</b></td>
<td class='tbl'><input type='text' name='mlevel' value='".$data['user_mlevel']."' maxlength='30' class='textbox' style='width:200px;'></td>
</tr>

close file


open file locale\You Language\admin\members.php
before ?> add:

---
$locale['ml482'] = "Level member:";


close file.

open file administration\updateuser.php
find line:
---
$user_name = trim(eregi_replace(" +", " ", $_POST['user_name']));

after add:
---
$mlevel = trim(eregi_replace(" +", " ", $_POST['mlevel']));

find line:
---
if (!preg_match("/^[-0-9A-Z_@\s]+$/i", $user_name)) $error .= $locale['452']."<br>\n";


after add:
---
if ($_POST['mlevel'] == "") $mlevel = "none";


find line:
---
$result = dbquery("UPDATE ".$db_prefix."users SET user_name='$user_name',".$newpass."user_email='".$_POST['user_email']."', user_hide_email='$user_hide_email', user_location='$user_location', user_birthdate='$user_birthdate', user_aim='$user_aim', user_icq='$user_icq', user_msn='$user_msn', user_yahoo='$user_yahoo', user_web='$user_web', user_theme='$user_theme', user_offset='$user_offset', ".$set_avatar."user_sig='$user_sig' WHERE user_id='$user_id'");

replace:
---
$result = dbquery("UPDATE ".$db_prefix."users SET user_name='$user_name', user_mlevel='$mlevel',".$newpass."user_email='".$_POST['user_email']."', user_hide_email='$user_hide_email', user_location='$user_location', user_birthdate='$user_birthdate', user_aim='$user_aim', user_icq='$user_icq', user_msn='$user_msn', user_yahoo='$user_yahoo', user_web='$user_web', user_theme='$user_theme', user_offset='$user_offset', ".$set_avatar."user_sig='$user_sig' WHERE user_id='$user_id'");

close file.

open file forum\viewthread.php

find line:
---
<a href='../profile.php?lookup=".$data['user_id']."'>".$data['user_name']."</a><br>


replace:
---
<a href='../profile.php?lookup=".$data['user_id']."'>".$data['user_name']."</a><br>";

find line:
---
<span class='alt'>".($is_mod ? $locale['userf1'] : getuserlevel($data['user_level']))."</span><br><br>\n";

replace:
---
if (($data['user_level'] >= "102") && ($data['user_mlevel']=="")){
   echo "<span class='alt'>".getuserlevel($data['user_level'])."</span><br><br>\n";
} elseif ($data['user_mlevel']!="none"){
        echo "<span class='alt'>".$data['user_mlevel']."</span><br><br>\n";
} else {
   $query = dbquery("SELECT * FROM ".$db_prefix."forum_nmember");
   while ($data2 = dbarray($query)){
         if ($data['user_posts'] < $data2['forum_mpost']){
            echo "<span class='alt'>".$data2['forum_mlevel']."</span><br><br>\n";
            break;
         }
   }
}

close file.

open css  file you theme and inthe end add:

select.font {
             border: 1px solid #e1e1e1;
  	     color : #555;
 	     background-color : #fff;
             font: 11px Verdana;
            }

url admin
http://localhost/fusion/administration/members.php
We choose the user
"Level member:"
add level(nik)
http://localhost/fusion/administration/forums.php
We go to the address of viewthread.php
Below a name will be level(nik) user.
That's all :)