board admmember cgi


#!/usr/bin/perl
#------------------------------------------------------------------------------
# UltraThreads
# Copyright (c) 2000 Kelvin Wu
#
# 2001.02
#------------------------------------------------------------------------------

use strict;

# Imports
use CGI::Carp qw(fatalsToBrowser);

BEGIN{ ($0 =~ m,(.*)/[^/]+,) && unshift (@INC, "$1"); ($0 =~ m,(.*)\\[^\\]+,) && unshift (@INC, "$1"); }

use DBI;
use UTConfig;
use UTLanguage;
use UTMain;
use UTCGI;

#---------- --------------------------------------------------------------------

# Get user
connectDb();
my $user = authUser();

# Check if forum is closed
printMessage("$lng{'forumClosedLb'}", "$lng{'forumClosed'}")
if $cfg{'forumClosed'} && !$user->{'admin'};

# Get CGI parameters
my $cgi = new UTCGI;
my $page = $cgi->param('pg') || 1;
my $boardId = int($cgi->param('id'));
$boardId or paramError($lng{'errBrdIdMiss'});
my $usersPP = 20;

# Get board data
my $query = "SELECT * FROM ut_boards WHERE id = $boardId AND active = 1";
my $sth = query($query);
my $board = $sth->fetchrow_hashref();
$board or entryError($lng{'errBrdNotFnd'});
$sth->finish;

# Check if board is private
entryError($lng{'errBrdNotPrv'}) if !$board->{'private'};

# Check if user can see board
boardVisible($user, $board, undef, undef, 0) or entryError($lng{'errBrdNotFnd'});

# Print header
my @buttons = ();
printCpHeader($user, $lng{'forumAdmMember'});
# Total members
$query = "
SELECT COUNT(*)
FROM ut_members, ut_users
WHERE ut_users.id = ut_members.userId
AND ut_members.boardId = $boardId";
$sth = query($query);
my ($userNum) = $sth->fetchrow_array();
$sth->finish;
my $pageNum = int($userNum / $usersPP) + ($userNum % $usersPP != 0);

# Get board members
my $limit = $usersPP;
my $offset = ($page - 1) * $limit;
$query = "
SELECT id, userName, email, hideEmail, regTime, admin, moderator, superMod, postNum, score
FROM ut_members, ut_users
WHERE ut_users.id = ut_members.userId
AND ut_members.boardId = $boardId
ORDER BY regTime DESC
LIMIT $offset, $limit";
$sth = query($query);
my $members = $sth->fetchall_arrayref({});
$sth->finish;

# Print bar
my @bar = ();
my $imgAlign = getBrowserAttr('middleImgAlign');
my $navBar =
"» $cfg{'forumName'} » " .
"Board Admin » " .
"$lng{'forumAdmMember'}";
printBar($user, $navBar, "", \@bar, 1);

# Print member list header
print
tableStart($user),
"\n",
"$lng{'memsName'}\n";

print
"$lng{'memsPm'}\n"
if $cfg{'pm'};

print
"$lng{'memsEmail'}\n",
"$lng{'memsRegDate'}\n",
"$lng{'memsStatus'}\n",
"$lng{'memsPosts'}\n",
"$lng{'topicDel'}\n",
"\n\n";

# Print member list
my $rowColor = $cfg{'lightCellColor2'};
for my $member (@$members) {
my $userId = $member->{'id'};
my $emailAddress = $member->{'email'};
my $regDate = formatDate($member->{'regTime'});

print
"",
"$member->{'userName'}",
"\n";

print
" urlEncode("$member->{'userName'}"),
"\" target=_blank>$lng{
",
"\n"
if $cfg{'pm'};

print
"$emailAddress"
if ((!$member->{'hideEmail'}) and ($emailAddress ne ""));

my $status;
if ($member->{'admin'}) {
$status = $cfg{'rankLevelA'};
}
elsif ($member->{'moderator'}) {
$status = $cfg{'rankLevelM'};
}
elsif ($member->{'postNum'} >= 0 and $member->{'postNum'} <= $cfg{'rankLevel1'} ) {
$status = "";
}
elsif ($member->{'postNum'} > $cfg{'rankLevel1'} and $member->{'postNum'} <= $cfg{'rankLevel2'} ) {
$status = "";
}
elsif ($member->{'postNum'} > $cfg{'rankLevel2'} and $member->{'postNum'} <= $cfg{'rankLevel3'} ) {
$status = "";
}
elsif ($member->{'postNum'} > $cfg{'rankLevel3'} and $member->{'postNum'} <= $cfg{'rankLevel4'} ) {
$status = "";
}
elsif ($member->{'postNum'} > $cfg{'rankLevel4'}) {
$status = "";
}

print
" $regDate\n",
"$status\n",
"$member->{'postNum'}\n",
"$lng{'topicDel'}\n",
"\n\n";

if ($rowColor eq $cfg{'lightCellColor2'}) {
$rowColor = $cfg{'lightCellColor'};
}
else {
$rowColor = $cfg{'lightCellColor2'};
}
}

print
tableEnd($user);

# Print page bar
if ($pageNum > 1) {
my $prevPage = $page - 1;
my $nextPage = $page + 1;
my @pageBar = (
"board_info.cgi?pg=$prevPage&id=$boardId", "pagePrevS", $page == 1 ? 0 : 1
);

# First, set how many pages we have on the left and the right.
my ($lower, $upper);
my $left = $page;
my $right = int($userNum/$limit) - $page;

# Then work out what page number we can go above and below.
($left > int($cfg{'maxBoardPages'}/2))
? ($lower = $left - int($cfg{'maxBoardPages'}/2))
: ($lower = 1);
($right > int($cfg{'maxBoardPages'}/2))
? ($upper = $page + int($cfg{'maxBoardPages'}/2))
: ($upper = int($userNum/$limit) + 1);

# Finally, adjust those page numbers if we are near an endpoint.
(int($cfg{'maxBoardPages'}/2) - $page >= 0) and
($upper = $upper + (int($cfg{'maxBoardPages'}/2) + 1 - $page));
($page > ($userNum/$limit - int($cfg{'maxBoardPages'}/2))) and
($lower = $lower - ($page - int($userNum/$limit - int($cfg{'maxBoardPages'}/2)) - 1));

for (my $i = 1 ; $i <= int($userNum/$limit) + 1; $i++) {
if ($i < $lower) { $i = $lower - 1; next; }
last if ($i > $upper);
push @pageBar, "board_info.cgi?pg=$i&id=$boardId", $i, $i == $page ? 0 : 1;
last if (($i * $limit) >= $userNum);
}

push @pageBar, "board_info.cgi?pg=$nextPage&id=$boardId", "pageNextS", $page == $pageNum ? 0 : 1;

printBar($user, "", "", \@pageBar);
}

print "
";
# Print search form
print
tableStart($user, "add member"),
"
\n",
"\n",
"
Name is  ",
"",
"\n",
"\n",
"\n",
"
\n";
print
tableEnd($user);
# Print popup box if new PM comes

print
"\n"
if (!$user->{'defaultUser'} && $user->{'pmNew'} && $user->{'pmPopup'} && $cfg{'pm'});

# Print footer
printFooter();


Wyszukiwarka

Podobne podstrony:
board?mmember x cgi
wwwboard cgi board=DHTML&id=5
wwwboard cgi board=dhtml
wwwboard cgi board=DHTML&id=4
wwwboard cgi board=dhtml&send=1
wwwboard cgi board=DHTML&id=6
wwwboard cgi board=DHTML&id=7
wwwmail cgi board=dhtml
Board
demo cgi 850
listart cgi id=3

więcej podobnych podstron