habe den code in die staff eingebaut funkt nicht kann aber auch sein das ich es falsch eingebaut habe hier mal der code der staff seite mit dem zusatz code vom levelmod
Code: Alles auswählen
<?php
define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
$userdata = session_pagestart($user_ip, PAGE_STAFF, $session_length);
init_userprefs($userdata);
$page_title = $lang['Staff'];
include('includes/page_header.'.$phpEx);
include('level_mod.'.$phpEx);
$template->set_filenames(array(
'body' => 'staff_body.tpl')
);
// forums
// $sql = "SELECT ug.user_id, f.forum_id, f.forum_name
// FROM " . FORUMS_TABLE . " f, " . AUTH_ACCESS_TABLE . " aa, " . USER_GROUP_TABLE . " ug
// LEFT JOIN " . USER_GROUP_TABLE . " ug2 ON ug2.user_id = " . $userdata['user_id'] . "
// LEFT JOIN " . AUTH_ACCESS_TABLE . " aa2 ON aa2.group_id = ug2.group_id AND aa2.auth_view = " . TRUE . "
// WHERE aa.auth_mod = " . TRUE . "
// AND ug.group_id = aa.group_id
// AND f.forum_id = aa.forum_id
// AND ( f.auth_view <= '.$auth.'
// OR aa2.auth_view = " . TRUE . ")
// GROUP BY ug.user_id, ug2.user_id
// ORDER BY ug.user_id";
$sql = "SELECT ug.user_id, f.forum_id, f.forum_name
FROM ".AUTH_ACCESS_TABLE." aa, ".USER_GROUP_TABLE." ug, ".FORUMS_TABLE." f
WHERE aa.auth_mod = " . TRUE . "
AND ug.group_id = aa.group_id
AND f.forum_id = aa.forum_id";
if ( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, 'Could not query forums.', '', __LINE__, __FILE__, $sql);
}
while( $row = $db->sql_fetchrow($result) )
{
$forum_id = $row['forum_id'];
$staff2[$row['user_id']][$row['forum_id']] = 'ø <a href='.append_sid("viewforum.$phpEx?f=$forum_id").' class=genmed>'.$row['forum_name'].'</a><br />';
}
//main
$sql = "SELECT * FROM ".USERS_TABLE."
WHERE user_level >= 1
ORDER BY user_level = 2, user_level = 3";
if ( !($results = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not obtain user information.', '', __LINE__, __FILE__, $sql);
}
while($staff = $db->sql_fetchrow($results))
{
if ( $staff['user_avatar'] )
{
switch( $staff['user_avatar_type'] )
{
case USER_AVATAR_UPLOAD:
$avatar = ( $board_config['allow_avatar_upload'] ) ? '<img src="' . $board_config['avatar_path'] . '/' . $staff['user_avatar'] . '" border="0" />' : '';
break;
case USER_AVATAR_REMOTE:
$avatar = ( $board_config['allow_avatar_remote'] ) ? '<img src="' . $staff['user_avatar'] . '" width="60" height="40" alt="" border="0" />' : '';
break;
case USER_AVATAR_GALLERY:
$avatar = ( $board_config['allow_avatar_local'] ) ? '<img src="' . $board_config['avatar_gallery_path'] . '/' . $staff['user_avatar'] . '" alt="" border="0" />' : '';
break;
}
}
else
{
$avatar = '';
}
$level = ( $staff['user_level'] == 1 ) ? '<b style="color:#' . $theme['fontcolor3'] . '">'.$lang['Admin'].'</b>' : '';
$level .= ( $staff['user_level'] == 9 ) ? '<b style="color:#' . $theme['fontcolor1'] . '">'.$lang['Junior'].'</b>' : '';
$level .= ( $staff['user_level'] == 3 ) ? '<b style="color:#' . $theme['fontcolor1'] . '">'.$lang['Super'].'</b>' : '';
$level .= ( $staff['user_level'] == 2 ) ? '<b style="color:#' . $theme['fontcolor2'] . '">'.$lang['Mod'].'</b>' : '';
$forums = '';
if ( !empty($staff2[$staff['user_id']]) )
{
asort($staff2[$staff['user_id']]);
$forums = implode(' ',$staff2[$staff['user_id']]);
}
$memberdays = max(1, round( ( time() - $staff['user_regdate'] ) / 86400 ));
$posts_per_day = $staff['user_posts'] / $memberdays;
if ( $staff['user_posts'] != 0 )
{
$total_posts = get_db_stat('postcount');
$percentage = ( $total_posts ) ? min(100, ($staff['user_posts'] / $total_posts) * 100) : 0;
}
else
{
$percentage = 0;
}
$user_id = $staff['user_id'];
$sql = "SELECT post_time, post_id FROM ".POSTS_TABLE." WHERE poster_id = " . $user_id . " ORDER BY post_time DESC LIMIT 1";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Error getting user last post time', '', __LINE__, __FILE__, $post_time_sql);
}
$row = $db->sql_fetchrow($result);
$last_post = ( isset($row['post_time']) ) ? '<a href="'.append_sid("viewtopic.$phpEx?" . POST_POST_URL . "=$row[post_id]#$row[post_id]").'" class=gensmall>'.create_date($board_config['default_dateformat'], $row['post_time'], $board_config['board_timezone']).'</a>' : $lang['None'];
$mailto = ( $board_config['board_email_form'] ) ? append_sid("profile.$phpEx?mode=email&" . POST_USERS_URL .'=' . $staff['user_id']) : 'mailto:' . $staff['user_email'];
$mail = ( $staff['user_email'] ) ? '<a href="' . $mailto . '"><img src="' . $images['icon_email'] . '" alt="' . $lang['Send_email'] . '" title="' . $lang['Send_email'] . '" border="0" /></a>' : '';
$pmto = append_sid("privmsg.$phpEx?mode=post&" . POST_USERS_URL . "=$staff[user_id]");
$pm = '<a href="' . $pmto . '"><img src="' . $images['icon_pm'] . '" alt="' . $lang['Send_private_message'] . '" title="' . $lang['Send_private_message'] . '" border="0" /></a>';
$msn = ( $staff['user_msnm'] ) ? '<a href="mailto: '.$staff['user_msnm'].'"><img src="' . $images['icon_msnm'] . '" alt="' . $lang['MSNM'] . '" title="' . $lang['MSNM'] . '" border="0" /></a>' : '';
$yim = ( $staff['user_yim'] ) ? '<a href="http://edit.yahoo.com/config/send_webmesg?.target=' . $staff['user_yim'] . '&.src=pg"><img src="' . $images['icon_yim'] . '" alt="' . $lang['YIM'] . '" title="' . $lang['YIM'] . '" border="0" /></a>' : '';
$aim = ( $staff['user_aim'] ) ? '<a href="aim:goim?screenname=' . $staff['user_aim'] . '&message=Hello+Are+you+there?"><img src="' . $images['icon_aim'] . '" alt="' . $lang['AIM'] . '" title="' . $lang['AIM'] . '" border="0" /></a>' : '';
$icq = ( $staff['user_icq'] ) ? '<a href="http://wwp.icq.com/scripts/contact.dll?msgto=' . $staff['user_icq'] . '"><img src="' . $images['icon_icq'] . '" alt="' . $lang['ICQ'] . '" title="' . $lang['ICQ'] . '" border="0" /></a>' : '';
$www = ( $staff['user_website'] ) ? '<a href="' . $staff['user_website'] . '" target="_userwww"><img src="' . $images['icon_www'] . '" alt="' . $lang['Visit_website'] . '" title="' . $lang['Visit_website'] . '" border="0" /></a>' : '';
/* Begin HP/MP/EXP Mod
*
* Note: all new variables used created in this mod
* are prefixed with level_ to be sure of not overwriting
* other variables.
*
*/
/* Calculate Level
* A user's level is determined by their total number of posts.
* A nice mathmatical formula is used to translate their post count
* into an intager level.
*
* Note: A user with zero (0) posts is considered level 0, however
* making one (1) post, raises them to level 1.
*
*/
if($postrow[$i]['user_posts'] < 1)
{
$level_level = 0;
}
else
{
$level_level = floor( pow( log10( $postrow[$i]['user_posts'] ), 3 ) ) + 1;
}
/* Determine Hit Points (HP)
*
* Hp is based on user activity.
* Max HP is based on the user's level, and will generally
* be the same for all users of the same level.
*
* A user's current HP is based on the user's posts per day.
* A higher post per day (ppd), the more HP they will have. A
* user with an average PPD (set below) will have 50% of their
* max HP. As a user goes over the average PPD, they will have
* more HP, but the gains will decrease as the user's PPD increases.
* This makes achieving 100% hp difficult, but not impossible.
*
* For users with under the average PPD, they will have HP equal
* to 1/2 the percentage their ppd is of the average.
* ie- a user with 2.5 ppd, and an average ppd of 5 will have
* 25% of their max HP. This is because 2.5 is 50% of 5, and 1/2
* of that, is 25%.
*
* Users who manage to post so far above the average that they have
* more HP than their max will recieve a bonus to their max HP.
*
* Note that users at level 0 will always have 0 / 0 hp.
*
*/
/*
* This value determines the 'average' posts per day.
* The admin may redefine this variable as he wishes.
* Higher values will generally decrease users' HP, and
* lower values will generally increase users' HP.
*
* Note: Do NOT set this value to zero (0).
* This -may- be set to a fractional value (eg, 5.1, 3.1415)
*
*/
$level_avg_ppd = 5;
/*
* this value sets how hard it is to achieve 100%
* hp. The higher you set it, the harder it is to
* get full hp.
*
* to judge how high to set it, a user must have
* posts per day equal to the $level_avg_ppd plus
* the number set below.
*
* This should NOT be zero.
*/
$level_bonus_redux = 5;
/*
* We need to actually calculate the user's posts per day
* because unlike in the profile, it's not done for us.
*
*/
$level_user_ppd = ($postrow[$i]['user_posts'] / max(1, round( ( time() - $postrow[$i]['user_regdate'] ) / 86400 )));
if($level_level < 1)
{
$level_hp = "0 / 0";
$level_hp_percent = 0;
}
else
{
$level_max_hp = floor( (pow( $level_level, (1/4) ) ) * (pow( 10, pow( $level_level+2, (1/3) ) ) ) / (1.5) );
if($level_user_ppd >= $level_avg_ppd)
{
$level_hp_percent = floor( (.5 + (($level_user_ppd - $level_avg_ppd) / ($level_bonus_redux * 2)) ) * 100);
}
else
{
$level_hp_percent = floor( $level_user_ppd / ($level_avg_ppd / 50) );
}
if($level_hp_percent > 100)
{
//Give the user a bonus to max HP for greater than 100% hp.
$level_max_hp += floor( ($level_hp_percent - 100) * pi() );
$level_hp_percent = 100;
}
else
{
$level_hp_percent = max(0, $level_hp_percent);
}
$level_cur_hp = floor($level_max_hp * ($level_hp_percent / 100) );
//Be sure a user has no more than max, and no less than zero hp.
$level_cur_hp = max(0, $level_cur_hp);
$level_cur_hp = min($level_max_hp, $level_cur_hp);
$level_hp = $level_cur_hp . ' / ' . $level_max_hp;
}
/* Determine MP
*
* MP is calculated by how long the user has been around
* and how often they post.
*
* Max MP is based on level, and increases with level
* Each post a user makes costs them mp,
* and a user regenerates mp proportional to how
* many days they have been registered
*
*/
//Number of days the user has been at the forums.
$level_user_days = max(1, round( ( time() - $postrow[$i]['user_regdate'] ) / 86400 ));
/* The mp cost for one post.
* Raising this value will generally decrease the current
* mp for most posters.
* This may be set to a decimal value (eg, 2, 2.1, 3.141596)
* This should NOT be set to 0
*/
$level_post_mp_cost = 2.5;
/* This determines how much mp a user regenerates per day
* Raising this value will generally increase the current
* mp for most posters.
* This may be set to a decimal value (eg, 3, 3.5, 2.71828)
* This should NOT be set to 0
*/
$level_mp_regen_per_day = 4;
if($level_level < 1)
{
$level_mp = '0 / 0';
$level_mp_percent = 0;
}
else
{
$level_max_mp = floor( (pow( $level_level, (1/4) ) ) * (pow( 10, pow( $level_level+2, (1/3) ) ) ) / (pi()) );
$level_mp_cost = $postrow[$i]['user_posts'] * $level_post_mp_cost;
$level_mp_regen = max(1, $level_user_days * $level_mp_regen_per_day);
$level_cur_mp = floor($level_max_mp - $level_mp_cost + $level_mp_regen);
$level_cur_mp = max(0, $level_cur_mp);
$level_cur_mp = min($level_max_mp, $level_cur_mp);
$level_mp = $level_cur_mp . ' / ' . $level_max_mp;
$level_mp_percent = floor($level_cur_mp / $level_max_mp * 100 );
}
/* Determine EXP percentage
*
* Experience is determined by how far the user is away
* from the next level. This is expressed as a percentage.
*
* Note, a user of level 0 has 100% experience. Making one post
* will put them at level 1. Also, a user that is shown to have 100%
* experience, will go up a level on their next post.
*
*/
if($level_level == 0)
{
$level_exp = "0 / 0";
$level_exp_percent = 100;
}
else
{
$level_posts_for_next = floor( pow( 10, pow( $level_level, (1/3) ) ) );
$level_posts_for_this = max(1, floor( pow( 10, pow( ($level_level - 1), (1/3) ) ) ) );
$level_exp = ($postrow[$i]['user_posts'] - $level_posts_for_this) . " / " . ($level_posts_for_next - $level_posts_for_this);
$level_exp_percent = floor( ( ($postrow[$i]['user_posts'] - $level_posts_for_this) / max( 1, ($level_posts_for_next - $level_posts_for_this ) ) ) * 100);
}
/* END HP/MP/EXP MOD */
$sql = "SELECT * FROM " . RANKS_TABLE . " ORDER BY rank_special, rank_min";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Could not obtain ranks information.", '', __LINE__, __FILE__, $sql);
}
$ranksrow = array();
while ( $row = $db->sql_fetchrow($result) )
{
$ranksrow[] = $row;
}
$db->sql_freeresult($result);
$rank = '';
$rank_image = '';
if ( $staff['user_rank'] )
{
for($j = 0; $j < count($ranksrow); $j++)
{
if ( $staff['user_rank'] == $ranksrow[$j]['rank_id'] && $ranksrow[$j]['rank_special'] )
{
$rank = $ranksrow[$j]['rank_title'];
$rank_image = ( $ranksrow[$j]['rank_image'] ) ? '<img src="' . $ranksrow[$j]['rank_image'] . '" alt="' . $rank . '" title="' . $rank . '" border="0" /><br />' : '';
}
}
}
else
{
for($j = 0; $j < count($ranksrow); $j++)
{
if ( $staff['user_posts'] >= $ranksrow[$j]['rank_min'] && !$ranksrow[$j]['rank_special'] )
{
$rank = $ranksrow[$j]['rank_title'];
$rank_image = ( $ranksrow[$j]['rank_image'] ) ? '<img src="' . $ranksrow[$j]['rank_image'] . '" alt="' . $rank . '" title="' . $rank . '" border="0" /><br />' : '';
}
}
}
$template->assign_block_vars('staff', array(
'AVATAR' => $avatar,
'RANK' => $rank,
'RANK_IMAGE' => $rank_image,
'U_NAME' => append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=$staff[user_id]"),
'NAME' => $staff[username],
'LEVEL' => $level,
'FORUMS' => $forums,
'JOINED' => create_date($board_config['default_dateformat'], $staff['user_regdate'], $board_config['board_timezone']),
'PERIOD' => sprintf($lang['Period'], $memberdays),
'POSTS' => $staff['user_posts'],
'POST_DAY' => sprintf($lang['User_post_day_stats'], $posts_per_day),
'POST_PERCENT' => sprintf($lang['User_post_pct_stats'], $percentage),
'LAST_POST' => $last_post,
'MAIL' => $mail,
'PM' => $pm,
'MSN' => $msn,
'YIM' => $yim,
'AIM' => $aim,
'ICQ' => $icq,
'WWW' => $www,
/* BEGIN LEVEL MOD */
"POSTER_HP" => $level_hp,
"POSTER_HP_WIDTH" => $level_hp_percent,
"POSTER_HP_EMPTY" => ( 100 - $level_hp_percent ),
"POSTER_MP" => $level_mp,
"POSTER_MP_WIDTH" => $level_mp_percent,
"POSTER_MP_EMPTY" => ( 100 - $level_mp_percent ),
"POSTER_EXP" => $level_exp,
"POSTER_EXP_WIDTH" => $level_exp_percent,
"POSTER_EXP_EMPTY" => ( 100 - $level_exp_percent ),
"POSTER_LEVEL" => $level_level,
/* END LEVEL MOD */
)
);
}
$template->assign_vars(array(
'L_AVATAR' => $lang['Avatar'],
'L_USERNAME' => $lang['Username'],
'L_FORUMS' => $lang['Forums'],
'L_POSTS' => $lang['Posts'],
'L_JOINED' => $lang['Joined'],
'L_EMAIL' => $lang['Email'],
'L_PM' => $lang['Private_Message'],
'L_MESSENGER' => $lang['Messenger'],
'L_WWW' => $lang['Website'])
);
$template->pparse('body');
include('includes/page_tail.'.$phpEx);
?>