Skip to content

Commit

Permalink
Minor fixies
Browse files Browse the repository at this point in the history
  • Loading branch information
pudge committed Aug 6, 2001
1 parent 65acac7 commit 2cf1369
Show file tree
Hide file tree
Showing 11 changed files with 165 additions and 168 deletions.
71 changes: 36 additions & 35 deletions Slash/DB/MySQL/MySQL.pm
Expand Up @@ -980,7 +980,7 @@ sub createUser {
# - Cliff
# Initialize the expiry variables...
# ...users start out as registered...
# ...the default email view is to SHOW email address...
# ...the default email view is to SHOW email address...
# (not anymore - Jamie)
my $constants = getCurrentStatic();

Expand All @@ -992,7 +992,7 @@ sub createUser {
'expiry_days' => $constants->{min_expiry_days},
'user_expiry_comm' => $constants->{min_expiry_comm},
'user_expiry_days' => $constants->{min_expiry_days},
# 'emaildisplay' => 2,
# 'emaildisplay' => 2,
});

return $uid;
Expand Down Expand Up @@ -1603,12 +1603,12 @@ sub getSubmissionLast {
}

########################################################
# get the last timestamp user created or
# submitted a formkey
# get the last timestamp user created or
# submitted a formkey
sub getLastTs {
my($self, $formname, $id, $submitted) = @_;

my $tscol = $submitted ? 'submit_ts' : 'ts';
my $tscol = $submitted ? 'submit_ts' : 'ts';
my $where = $self->_whereFormkey($id);
$where .= " AND formname = '$formname'";
$where .= ' AND value = 1' if $submitted;
Expand Down Expand Up @@ -1643,7 +1643,7 @@ sub getUnsetFkCount {

my $formkey_earliest = time() - $constants->{formkey_timeframe};
my $where = $self->_whereFormkey($id);
$where .= " AND formname = '$formname'";
$where .= " AND formname = '$formname'";
$where .= " AND ts >= $formkey_earliest";
$where .= " AND value = 0";

Expand All @@ -1656,7 +1656,7 @@ sub getUnsetFkCount {
"count(*) >= $max_unused",
"formkeys",
$where);

return $unused;

} else {
Expand Down Expand Up @@ -1785,7 +1785,7 @@ sub updateFormkeyVal {
my $speed_limit = $constants->{"${formname}_speed_limit"};
my $maxposts = $constants->{"max_${formname}_allowed"} || 0;

my $min = time() - $speed_limit;
my $min = time() - $speed_limit;
my $where = "idcount < $maxposts ";
$where .= "AND last_ts <= $min ";
$where .= "AND value = 0";
Expand Down Expand Up @@ -1906,10 +1906,10 @@ sub checkMaxPosts {
$where .= " AND formname = '$formname'",
$where .= " HAVING count >= $maxposts";

my ($limit_reached) = $self->sqlSelect(
my($limit_reached) = $self->sqlSelect(
"COUNT(*) AS count",
"formkeys",
$where );
$where);

if ($constants->{DEBUG}) {
print STDERR "LIMIT REACHED (times posted) $limit_reached\n";
Expand Down Expand Up @@ -2077,7 +2077,7 @@ sub getNetIDList {

##################################################################
sub getReadOnlyList {
my ($self, $min) = @_;
my($self, $min) = @_;
$min ||= 0;
my $max = $min + 100;

Expand All @@ -2104,8 +2104,9 @@ sub getAbuses {
};

$self->sqlSelectAll("ts,uid,ipid,subnetid,pagename,reason", "abusers WHERE $where->{$key} ORDER by ts DESC");

}

##################################################################
sub getReadOnlyReason {
my($self, $formname, $user) = @_;
Expand Down Expand Up @@ -2852,10 +2853,10 @@ sub getStoriesBySubmitter {
'story_heap' : 'stories';

$limit = 'LIMIT ' . $limit if $limit;
my $answer = $self->sqlSelectAllHashrefArray('sid,title,time',
$story_table,
"submitter='$id'",
"ORDER by time DESC $limit");
my $answer = $self->sqlSelectAllHashrefArray(
'sid,title,time',
$story_table, "submitter='$id'",
"ORDER by time DESC $limit");
return $answer;
}

Expand Down Expand Up @@ -2883,7 +2884,7 @@ sub getStoriesEssentials {
my $columns = 'sid, section, title, time, commentcount, time, hitparade';

my $where = "time < NOW() ";
# Added this to narrow the query a bit more, I need
# Added this to narrow the query a bit more, I need
# see about the impact on this -Brian
$where .= "AND writestatus != 'delete' AND writestatus != 'archived' ";
$where .= "AND displaystatus=0 " unless $form->{section};
Expand Down Expand Up @@ -3184,7 +3185,7 @@ sub createStory {
commentstatus => $story->{commentstatus},
submitter => $story->{submitter} ?
$story->{submitter} : $story->{uid},
writestatus => 'dirty',
writestatus => 'dirty',
};

my $text = {
Expand Down Expand Up @@ -3237,7 +3238,7 @@ sub updateStory {
section => $form->{section},
displaystatus => $form->{displaystatus},
commentstatus => $form->{commentstatus},
writestatus => $form->{writestatus},
writestatus => $form->{writestatus},
}, 'sid=' . $self->sqlQuote($form->{sid}));
}

Expand All @@ -3250,7 +3251,7 @@ sub updateStory {
section => $form->{section},
displaystatus => $form->{displaystatus},
commentstatus => $form->{commentstatus},
writestauts => $form->{writestauts},
writestatus => $form->{writestatus},
}, 'sid=' . $self->sqlQuote($form->{sid}));

$self->sqlUpdate('story_text', {
Expand Down Expand Up @@ -3938,15 +3939,15 @@ sub setUser {
for (@param) {
if ($_->[0] eq "acl") {
$self->sqlReplace('users_acl', {
uid => $uid,
name => $_->[1]->{name},
value => $_->[1]->{value},
uid => $uid,
name => $_->[1]->{name},
value => $_->[1]->{value},
});
} else {
$self->sqlReplace('users_param', {
uid => $uid,
name => $_->[0],
value => $_->[1],
uid => $uid,
name => $_->[0],
value => $_->[1],
}) if defined $_->[1];
}
}
Expand Down Expand Up @@ -4404,7 +4405,7 @@ F
$story_table.sid = discussions.sid
AND ((displaystatus = 0 and $section_dbi="")
OR ($story_table.section=$section_dbi and displaystatus > -1))
AND time < NOW() $story_table.writestatus != 'delete' AND $story_table.writestatus != 'archived')
AND time < NOW() $story_table.writestatus != 'delete' AND $story_table.writestatus != 'archived')
W
GROUP BY $story_table.sid
ORDER BY time DESC
Expand Down Expand Up @@ -4564,22 +4565,22 @@ sub getRandomSpamArmor {

########################################################
sub sqlShowProcessList {
my($self) = @_;
my($self) = @_;

$self->sqlConnect();
my $proclist = $self->{_dbh}->prepare("SHOW PROCESSLIST");
$self->sqlConnect();
my $proclist = $self->{_dbh}->prepare("SHOW PROCESSLIST");

return $proclist;
return $proclist;
}

########################################################
sub sqlShowStatus {
my($self) = @_;
my($self) = @_;

$self->sqlConnect();
my $status = $self->{_dbh}->prepare("SHOW STATUS");
$self->sqlConnect();
my $status = $self->{_dbh}->prepare("SHOW STATUS");

return $status;
return $status;
}

########################################################
Expand Down
38 changes: 17 additions & 21 deletions Slash/DB/Static/MySQL/MySQL.pm
Expand Up @@ -77,7 +77,6 @@ sub updateCommentTotals {
}
}


########################################################
# For slashd
# "LIMIT 10" chosen arbitrarily, actually could be LIMIT 5 but doesn't
Expand Down Expand Up @@ -106,8 +105,8 @@ sub archiveComments {

$self->sqlDo("update discussions SET type=2 WHERE to_days(now()) - to_days(ts) > $constants->{discussion_archive} AND type = 0 ");
# Optimize later to use heap table -Brian
for($self->sqlSelect('cid', 'comments,discussions', "WHERE to_days(now()) - to_days(date) > $constants->{discussion_archive} AND discussion.id = comments.sid AND discussion.type = 1 AND discussion.pid = 0")) {
$self->deleteComments('',$_);
for ($self->sqlSelect('cid', 'comments,discussions', "WHERE to_days(now()) - to_days(date) > $constants->{discussion_archive} AND discussion.id = comments.sid AND discussion.type = 1 AND discussion.pid = 0")) {
$self->deleteComments('', $_);
}
}

Expand All @@ -120,7 +119,7 @@ sub deleteDaily {
# Now for some random stuff
$self->sqlDo("DELETE from pollvoters");
$self->sqlDo("DELETE from moderatorlog WHERE
to_days(now()) - to_days(ts) > $constants->{archive_delay} ");
to_days(now()) - to_days(ts) > $constants->{archive_delay} ");
$self->sqlDo("DELETE from metamodlog WHERE
to_days(now()) - to_days(ts) > $constants->{archive_delay} ");
# Formkeys
Expand All @@ -140,15 +139,15 @@ sub countDaily {
($returnable{'total'}) = $self->sqlSelect("count(*)", "accesslog",
"to_days(now()) - to_days(ts)=1");

my $c = $self->sqlSelectMany("count(*)","accesslog",
my $c = $self->sqlSelectMany("count(*)", "accesslog",
"to_days(now()) - to_days(ts)=1 GROUP BY host_addr");
$returnable{'unique'} = $c->rows;
$c->finish;

# my($comments) = $self->sqlSelect("count(*)","accesslog",
# my($comments) = $self->sqlSelect("count(*)", "accesslog",
# "to_days(now()) - to_days(ts)=1 AND op='comments'");

$c = $self->sqlSelectMany("dat,count(*)","accesslog",
$c = $self->sqlSelectMany("dat,count(*)", "accesslog",
"to_days(now()) - to_days(ts)=1 AND
(op='index' OR dat='index')
GROUP BY dat");
Expand Down Expand Up @@ -373,7 +372,7 @@ sub tokens2points {
my $cursor = $self->sqlSelectMany('uid,tokens,value as rtbl',
'users_info, users_param',
"tokens >= $constants->{maxtokens}
AND users_param.uid = users_info.uid
AND users_param.uid = users_info.uid
AND name='rtbl' AND value=1");
$self->sqlTransactionStart('LOCK TABLES users READ,
users_info WRITE, users_comments WRITE');
Expand All @@ -399,7 +398,7 @@ sub tokens2points {
$userFields{'-points'} =
($constants->{maxtokens} / $constants->{tokensperpoint})
if ! $rtbl;

$self->setUser($uid, \%userFields);
}

Expand Down Expand Up @@ -554,7 +553,7 @@ sub checkUserExpiry {
# Now grab all UIDs that look to be expired, we explicitly exclude
# authors from this search.
$ret = $self->sqlSelectAll(
'distinct uid',
'distinct uid',
'users_info',
'expiry_days < 0 or expiry_comm < 0'
);
Expand Down Expand Up @@ -584,9 +583,9 @@ sub getMetamodIDs {

# The previous code was shite because I let myself get distracted
# due to a silly logic error. The way to REALLY do this is to wait a
# day LATER than the life of a discussion. This way, YOU KNOW that
# no further M2 records will show up in the database after
# reconciliation.
# day LATER than the life of a discussion. This way, YOU KNOW that
# no further M2 records will show up in the database after
# reconciliation.
#
# Cliff == B4K4!
#
Expand All @@ -595,8 +594,8 @@ sub getMetamodIDs {
# - Cliff 7/12/01
my $num_days = $constants->{archive_delay} + 1;
my $list = $self->sqlSelectAllHashrefArray(
'metamodlog.id as id, mmid', 'metamodlog,moderatorlog',
"TO_DAYS(CURDATE())-TO_DAYS(metamodlog.ts) >= $num_days AND
'metamodlog.id as id, mmid', 'metamodlog,moderatorlog',
"TO_DAYS(CURDATE())-TO_DAYS(metamodlog.ts) >= $num_days AND
flag=10 AND moderatorlog.id=metamodlog.mmid",
"order by id LIMIT $constants->{m2_batchsize}"
);
Expand All @@ -614,15 +613,14 @@ sub getMetaModerations {
my($self, $mmid) = @_;

my $ret = $self->sqlSelectAllHashrefArray(
'*','metamodlog', "mmid=$mmid"
'*', 'metamodlog', "mmid=$mmid"
);

return $ret;
}


########################################################
# For moderation scripts.
# For moderation scripts.
#
#
sub updateMMFlag {
Expand All @@ -634,7 +632,7 @@ sub updateMMFlag {
}

########################################################
# For moderation scripts.
# For moderation scripts.
#
#
sub clearM2Flag {
Expand All @@ -661,7 +659,6 @@ sub getStoriesWithFlag {
return $returnable;
}


########################################################
# For tasks/spamarmor.pl
#
Expand Down Expand Up @@ -736,7 +733,6 @@ sub deleteStoryAll {
$self->sqlDo("DELETE from comment_text where sid=$db_sid");
}


1;

__END__
Expand Down
2 changes: 1 addition & 1 deletion plugins/Search/search.pl
Expand Up @@ -181,7 +181,7 @@ sub userSearch {
}

slashDisplay('usersearch', {
users => $users,
users => $users,
back => $back,
forward => $forward,
args => _buildargs($form),
Expand Down
6 changes: 2 additions & 4 deletions plugins/Search/templates/usersearch;search;default
Expand Up @@ -14,10 +14,8 @@ __template__
[% USE Slash %]
[% IF users %]
[% FOREACH user=users %]
[% IF user.3 %]
[% user.3 %]
[% END %]
<A HREF="[% constants.rootdir %]/users.pl?nick=[% FILTER fixparam; user.1; END %]">[% FILTER strip_literal; user.1; END %]</A> &nbsp;
[% user.3 IF user.3 %]
<A HREF="[% constants.rootdir %]/users.pl?nick=[% FILTER fixparam; user.1; END %]">[% FILTER strip_literal; user.1; END %]</A> &nbsp;
[% IF user.0 %]
([% user.2 %]) email: <A HREF="mailto:[% FILTER fixparam; user.0; END %]">[% FILTER strip_literal; user.0; END %]</A> <BR>
[% ELSE %]
Expand Down

0 comments on commit 2cf1369

Please sign in to comment.