Skip to content

Commit

Permalink
aseclev is now gone.
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianAker committed Oct 22, 2000
1 parent 3c09fd6 commit fd05846
Show file tree
Hide file tree
Showing 31 changed files with 183 additions and 195 deletions.
42 changes: 14 additions & 28 deletions Slash/Apache/User/User.pm
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ sub getUser {

$uid = $constants->{anonymous_coward_uid} unless defined $uid;

if (!isAnon($uid) && ($user = $slashdb->getUser($uid))) { # getUserInstance($uid, $r->uri))) {
if (!isAnon($uid) && ($user = $slashdb->getUser($uid))) { # getUserInstance($uid, $r->uri))) {}
my $timezones = $slashdb->getCodes('tzcodes');
$user->{offset} = $timezones->{ $user->{tzcode} };

Expand All @@ -191,30 +191,6 @@ sub getUser {
setCookie('anon', $user->{anon_id}, 1);
}

if ($form->{op} eq 'adminlogin') {
my $sid;
($user->{aseclev}, $sid) =
$slashdb->setAdminInfo($form->{aaid}, $form->{apasswd});
if ($user->{aseclev}) {
$user->{aid} = $form->{aaid};
setCookie('session', $sid);
$user->{is_admin} = 1;
} else {
undef $user->{aid};
}

} elsif ($cookies->{session} && length($cookies->{session}->value) > 3) {
(@{$user}{qw[aid aseclev asection url]}) =
$slashdb->getAdminInfo(
$cookies->{session}->value,
$constants->{admin_timeout}
);
$user->{is_admin} = $user->{aid} ne '';

} else {
$user->{aid} = '';
$user->{aseclev} = 0;
}

my @defaults = (
['mode', 'thread'], qw[
Expand All @@ -235,9 +211,6 @@ sub getUser {
}
}

$user->{seclev} = $user->{aseclev}
if $user->{aseclev} > $user->{seclev};

if ($user->{commentlimit} > $constants->{breaking}
&& $user->{mode} ne 'archive') {
$user->{commentlimit} = int($constants->{breaking} / 2);
Expand All @@ -255,6 +228,19 @@ sub getUser {
$user->{extid} = testExStr($user->{extid}) if $user->{extid};
$user->{points} = 0 unless $user->{willing}; # No points if you dont want 'em

if ($form->{op} eq 'adminlogin') {
if(my $sid = $slashdb->getAuthorAuthenticate($form->{aaid}, $form->{apasswd}, $user)) {
setCookie('session', $sid);
}
} elsif ($cookies->{session} && length($cookies->{session}->value) > 3) {
my $value = $slashdb->getAuthorInfo(
$cookies->{session}->value,
$constants->{admin_timeout},
$user
);
print STDERR "VALUE $value \n";
}

return $user;
}

Expand Down
62 changes: 31 additions & 31 deletions Slash/DB/MySQL/MySQL.pm
Original file line number Diff line number Diff line change
Expand Up @@ -436,8 +436,8 @@ sub getDiscussions {
########################################################
# Handles admin logins (checks the sessions table for a cookie that
# matches). Called by getSlash
sub getAdminInfo {
my($self, $session, $admin_timeout) = @_;
sub getAuthorInfo {
my($self, $session, $admin_timeout, $user) = @_;

$self->sqlDo("DELETE from sessions WHERE now() > DATE_ADD(lasttime, INTERVAL $admin_timeout MINUTE)");

Expand All @@ -448,15 +448,21 @@ sub getAdminInfo {
);

unless ($aid) {
return('', 0, '', '');
return(0);
} else {
$self->sqlDo("DELETE from sessions WHERE aid = '$aid' AND session != " .
$self->{_dbh}->quote($session)
);
$self->sqlUpdate('sessions', {-lasttime => 'now()'},
'session=' . $self->{_dbh}->quote($session)
);
return($aid, $seclev, $section, $url);
$user->{aid} = $aid;
$user->{seclev} = $seclev;
$user->{asection} = $section;
$user->{url} = $url;
$user->{is_admin} = 1;

return($seclev);
}
}

Expand Down Expand Up @@ -493,26 +499,30 @@ sub setSectionExtra {

########################################################
# Initial Administrator Login.
sub setAdminInfo {
my($self, $aid, $pwd) = @_;
sub getAuthorAuthenticate {
my($self, $aid, $pwd, $user) = @_;

my $db_aid = $self->{_dbh}->quote($aid);
if (my($seclev) = $self->sqlSelect('seclev', 'authors',
'aid=' . $self->{_dbh}->quote($aid) .
"aid=$db_aid" .
' AND pwd=' . $self->{_dbh}->quote($pwd) ) ) {
$user->{seclev} = $seclev;
$user->{aid} = $aid;
$user->{is_admin} = 1;

my($title) = $self->sqlSelect('lasttitle', 'sessions',
'aid=' . $self->{_dbh}->quote($aid)
"aid=$db_aid"
);

$self->sqlDo('DELETE FROM sessions WHERE aid=' . $self->{_dbh}->quote($aid) );
$self->sqlDo("DELETE FROM sessions WHERE aid=$db_aid");

my $sid = $self->generatesession($aid);
$self->sqlInsert('sessions', { session => $sid, aid => $aid,
$self->sqlInsert('sessions', { session => $sid, -aid => $db_aid,
-logintime => 'now()', -lasttime => 'now()',
lasttitle => $title }
);
return($seclev, $sid);

return($sid);
} else {
return(0);
}
Expand Down Expand Up @@ -652,8 +662,8 @@ sub deleteUser {
my($self, $uid) = @_;
$self->setUser($uid, {
bio => '',
nickname => '<deleted user>',
matchname => '<deleted user>',
nickname => 'deleted user',
matchname => 'deleted user',
realname => '',
realemail => '',
fakeemail => '',
Expand Down Expand Up @@ -845,12 +855,12 @@ sub getACTz {
sub getVars {
my($self, @invars) = @_;

my @vars;
my @values;
for (@invars) {
push @vars, $self->sqlSelect('value', 'vars', "name='$_'");
push @values, $self->sqlSelect('value', 'vars', "name='$_'");
}

return @vars;
return @values;
}


Expand Down Expand Up @@ -1965,7 +1975,7 @@ sub setCommentCleanup {
($val > 0 ? " < $constants->{comment_maxscore}" : "");

$strsql .= " AND lastmod<>$user->{uid}"
unless $user->{aseclev} > 99 && $constants->{authors_unlimited};
unless $user->{seclev} > 99 && $constants->{authors_unlimited};

if ($val ne "+0" && $self->sqlDo($strsql)) {
$self->setModeratorLog($cid, $sid, $user->{uid}, $modreason, $val);
Expand Down Expand Up @@ -2000,7 +2010,7 @@ sub setCommentCleanup {
"users_comments",
{ -points=>$user->{points} },
"uid=$user->{uid}"
); # unless ($user->{aseclev} > 99 && $comments->{authors_unlimited});
);
return 1;
}
return;
Expand Down Expand Up @@ -2095,7 +2105,7 @@ sub getStories {

$where .= "AND displaystatus=0 " unless $form->{section};

$where .= "AND time < now() "; # unless $user->{aseclev};
$where .= "AND time < now() ";
$where .= "AND (displaystatus>=0 AND '$SECT->{section}'=section) " if $form->{section};

$form->{issue} =~ s/[^0-9]//g; # Kludging around a screwed up URL somewhere
Expand Down Expand Up @@ -2787,18 +2797,8 @@ sub getNewStory {

########################################################
sub getVar {
my($self, $name) = @_;
my $db_name = $self->{_dbh}->quote($name);
my $sql = "SELECT value FROM vars WHERE name=$db_name";
my $var = $self->{_dbh}->selectrow_array($sql);

return $var;
}

########################################################
sub getVarRef {
my $varref = _genericGet('vars', 'name', @_);
return $varref;
my $answer = _genericGet('vars', 'name', @_);
return $answer;
}

########################################################
Expand Down
16 changes: 8 additions & 8 deletions Slash/Slash.pm
Original file line number Diff line number Diff line change
Expand Up @@ -193,12 +193,12 @@ sub selectSection {
return;
}

my $aseclev = getCurrentUser('aseclev');
my $seclev = getCurrentUser('seclev');
my $sectionbank = $slashdb->getSections();
my %sections = map {
($_, $sectionbank->{$_}{title})
} grep {
!($sectionbank->{$_}{isolate} && $aseclev < 500)
!($sectionbank->{$_}{isolate} && $seclev < 500)
} keys %$sectionbank;

createSelect($label, \%sections, $default, $return);
Expand Down Expand Up @@ -622,7 +622,7 @@ sub currentAdminUsers {

return slashDisplay('currentAdminUsers', {
ids => $aids,
can_edit_admins => $user->{aseclev} > 10000,
can_edit_admins => $user->{seclev} > 10000,
}, 1);
}

Expand Down Expand Up @@ -727,7 +727,7 @@ sub header {
);
$params{-status} = $status if $status;
$params{-pragma} = 'no-cache'
unless $user->{aseclev} || $ENV{SCRIPT_NAME} =~ /comments/;
unless $user->{seclev} || $ENV{SCRIPT_NAME} =~ /comments/;

print CGI::header(%params);
}
Expand Down Expand Up @@ -1190,7 +1190,7 @@ sub printComments {
}

slashDisplay('printCommentsComments', {
can_moderate => (($user->{aseclev} || $user->{points}) && !$user->{is_anon}),
can_moderate => (($user->{seclev} || $user->{points}) && !$user->{is_anon}),
comment => $comment,
comments => $comments,
'next' => $next,
Expand Down Expand Up @@ -1233,7 +1233,7 @@ sub moderatorCommentLog {
my $slashdb = getCurrentDB();
my $constants = getCurrentStatic();

my $aseclev = getCurrentUser('aseclev');
my $seclev = getCurrentUser('seclev');
my $comments = $slashdb->getModeratorCommentLog($sid, $cid);
my(@reasonHist, $reasonTotal);

Expand All @@ -1243,7 +1243,7 @@ sub moderatorCommentLog {
}

slashDisplay('moderatorCommentLog', {
mod_admin => getCurrentUser('aseclev') > 1000,
mod_admin => getCurrentUser('seclev') > 1000,
comments => $comments,
reasonTotal => $reasonTotal,
reasonHist => \@reasonHist,
Expand Down Expand Up @@ -1498,7 +1498,7 @@ sub dispComment {
my $can_mod = ! $user->{is_anon} &&
(( $user->{willing} && $user->{points} > 0 &&
$comment->{uid} != $user->{uid} && $comment->{lastmod} != $user->{uid}
) || ($user->{aseclev} > 99 && $constants->{authors_unlimited}));
) || ($user->{seclev} > 99 && $constants->{authors_unlimited}));

slashDisplay('dispComment', {
%$comment,
Expand Down
6 changes: 3 additions & 3 deletions plugins/PollBooth/pollBooth.pl
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ sub main {
header(getData('title'), $form->{section});
if ($user->{aseclev} > 99 && $op eq 'edit') {
if ($user->{seclev} > 99 && $op eq 'edit') {
editpoll($form->{qid});
} elsif ($user->{aseclev} > 99 && $op eq 'save') {
} elsif ($user->{seclev} > 99 && $op eq 'save') {
savepoll();
} elsif (! defined $form->{qid}) {
Expand Down Expand Up @@ -178,7 +178,7 @@ sub listpolls {
slashDisplay('pollBooth-listpolls', {
questions => $questions,
startat => $min + @$questions,
admin => getCurrentUser('aseclev') >= 100,
admin => getCurrentUser('seclev') >= 100,
title => "$sitename Polls",
width => '99%'
});
Expand Down
4 changes: 2 additions & 2 deletions plugins/Sections/sections.pl
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ sub main {
my $form = getCurrentForm();

my $op = $form->{op};
my $seclev = $user->{aseclev};
my $seclev = $user->{seclev};

header(getData('head'), 'admin');

Expand Down Expand Up @@ -142,7 +142,7 @@ sub editSection {

slashDisplay('sections-editSection', {
section => $section,
seclev => $user->{aseclev},
seclev => $user->{seclev},
this_section => $this_section,
qid => $qid,
isolate => $isolate,
Expand Down
2 changes: 1 addition & 1 deletion plugins/Submit/submit.pl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ sub main {
my($section, $op, $aid) = (
$form->{section}, $form->{op}, $user->{aid}
);
$user->{submit_admin} = 1 if $user->{aseclev} >= 100;
$user->{submit_admin} = 1 if $user->{seclev} >= 100;

$form->{del} ||= 0;
$form->{op} ||= '';
Expand Down
Loading

0 comments on commit fd05846

Please sign in to comment.