09 Temporary Demotion For Testing

Started by Mindless, July 25, 2012, 11:51:19 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

BamBam0077

"When Darkness Shadows Your Doubts, Deep Within Us Is Our Key, Not Success But Everything" ~ Anonymous

Mindless

So define the variable, nothing difficult about that eh

$usrclass = '';

Alternatively you could always think that the U-232 dev have covered all that shit and more in U-232 v3 and reference from github files which would answer 90 % of questions asked, its all there for public access.

denede

works fine, but in accounts lower than mod, or whatever, keeps saying
Notice: Undefined variable: usrclass

rushed

thank you very much mindless works perfectly :)

Mindless

Credits to Retro

Code (php) Select
ALTER TABLE `users` ADD `override_class` TINYINT( 3 ) UNSIGNED DEFAULT '255' NOT NULL AFTER `class`;

open include/bittorrent.php and find

Code (php) Select
$row['ip'] = $ip;
$GLOBALS["CURUSER"] = $row;


and change to

Code (php) Select
$row['ip'] = $ip;
if ($row['override_class'] < $row['class']) $row['class'] = $row['override_class']; // Override class and save in GLOBAL array below.
$GLOBALS["CURUSER"] = $row;



find

Code (php) Select
if ($TBDEV['msg_alert'] && isset($unread) && !empty($unread))
{


above it add

Code (php) Select
if ($CURUSER['override_class'] != 255 && $CURUSER) // Second condition needed so that this box isn't displayed for non members/logged out members.
{
$htmlout .= "<p><table border='0' cellspacing='0' cellpadding='10' bgcolor='green'><tr><td style='padding: 10px; background: green'><b><a href='{$TBDEV['baseurl']}/restoreclass.php'><font color='white'>{$lang['gl_tempdemotion']}</font></a></b></td></tr></table></p>";
}


find

Code (php) Select
$StatusBar = '';

add above it

Code (php) Select
if ($CURUSER['override_class'] != 255)
$usrclass = "&nbsp;<b>(".get_user_class_name($CURUSER['class']).")</b>&nbsp;";
else
if($CURUSER['class'] >= UC_MODERATOR)
$usrclass = "&nbsp;<a href='{$TBDEV['baseurl']}/setclass.php'><b>(".get_user_class_name($CURUSER['class']).")</b></a>&nbsp;";


find a few lines down

Code (php) Select
<div style='float:left;color:black;'>{$lang['gl_msg_welcome']}, <a href='userdetails.php?id={$CURUSER['id']}'>{$CURUSER['username']}</a>

and add

Code (php) Select
".$usrclass."

open lang\en\lang_global.php and add

Code (php) Select
'gl_tempdemotion' => "You are running under a lower class. Click here to restore.",

create a new file called setclass.php add this to it and upload to root

Code (php) Select
<?php
require_once "include/bittorrent.php";
require_once 
"include/user_functions.php";
require_once 
"include/html_functions.php";
require_once 
"include/bbcode_functions.php";

dbconn(false);

loggedinorreturn();
$lang array_mergeload_language('global'), load_language('set_class') );


if (
$CURUSER['class'] < UC_MODERATOR) die(); // No acces to below this rank
if ($CURUSER['override_class'] != 255) die(); // No access to an overridden user class either - just in case
if (isset($_GET["action"]) && $_GET["action"] == "editclass") { 
// Process the querystring - No security checks are done as a temporary class higher
// than the actual class mean absoluetly nothing.
 
 
$newclass $_GET['class'];
 
mysql_query("UPDATE users SET override_class = " sqlesc($newclass) . " WHERE id = ".sqlesc($CURUSER['id'])); // Set temporary class
 
header("Location: /userdetails.php?id=" $CURUSER['id']);
 die();
}
// HTML Code to allow changes to current class

$HTMLOUT ='';
$HTMLOUT .="<br />
<font size='4'><b>
{$lang['set_class_allow']}</b></font>
<br /><br />
<form method='get' action='
{$TBDEV['baseurl']}/setclass.php'>
<input type='hidden' name='action' value='editclass' />
<input type='hidden' name='returnto' value='userdetails.php?id="
.(int)$CURUSER['id']."' />
<table width='150' border='2' cellspacing='5' cellpadding='5'>
<tr>
<td>Class</td>
<td align='left'>
<select name='class'>"
;
 
$maxclass $CURUSER['class'] - 1;
for ($i 0$i <= $maxclass; ++$i)
if (trim(get_user_class_name($i)) != ""
$HTMLOUT .="<option value='$i.  "'>" get_user_class_name($i) . "</option>\n";
$HTMLOUT .="</select></td></tr>
<tr><td colspan='3' align='center'><input type='submit' class='btn' value='
{$lang['set_class_ok']}' /></td></tr>
</table>
</form>
<br />"
;

 print 
stdhead("{$lang['set_class_temp']}") . $HTMLOUT stdfoot();

?>


create a new language file called lang_set_class.php and upload to your language folder

Code (php) Select
<?php

$lang 
= array (
 
'set_class_temp' => "Temporary Demotion",
'set_class_ok' => "Ok!",
'set_class_allow' => "Allows you to change your user class on the fly.",
'set_class_class' => "Class"

);
?>


create a new file called restoreclass.php and upload to root

Code (php) Select
<?php
require_once("include/bittorrent.php");
require_once (
"include/user_functions.php");
dbconn(false);
loggedinorreturn();

mysql_query("UPDATE users SET override_class='255' WHERE id = ".sqlesc($CURUSER['id']));
header("Location: {$TBDEV['baseurl']}/index.php");
die();

?>