# Splitted: SQLExtras.pl
#
-if (&IsParam("useStrict")) { use strict; }
+use strict;
+
+use vars qw($dbh $who);
+use vars qw(%param);
###
# Usage: &CmdFactInfo($faqtoid, $query);
return;
}
- my $i = 0;
- my %factinfo;
- my @factinfo = &getFactInfo($faqtoid,"*");
- foreach ( &dbGetColInfo("factoids") ) {
- $factinfo{$_} = $factinfo[$i] || '';
- $i++;
- }
+ my %factinfo = &sqlSelectRowHash("factoids", "*",
+ { factoid_key => $faqtoid }
+ );
# factoid does not exist.
- if (scalar @factinfo <= 1) {
+ if (scalar (keys %factinfo) <= 1) {
&performReply("there's no such factoid as \002$faqtoid\002");
return;
}
if ($time) {
if (time() - $time > 60*60*24*7) {
my $days = int( (time() - $time)/60/60/24 );
- $string .= " at \037". scalar(localtime $time). "\037" .
+ $string .= " at \037". scalar(gmtime $time). "\037" .
" ($days days)";
} else {
$string .= " ".&Time2String(time() - $time)." ago";
}
# modified:
-# if ($factinfo{'modified_by'}) {
-# $string = "last modified";
-#
-# my $time = $factinfo{'modified_time'};
-# if ($time) {
-# if (time() - $time > 60*60*24*7) {
-# $string .= " at \037". scalar(localtime $time). "\037";
-# } else {
-# $string .= " ".&Time2String(time() - $time)." ago";
-# }
-# }
-#
-# my @x;
-# foreach (split ",", $factinfo{'modified_by'}) {
-# /\!/;
-# push(@x, $`);
-# }
-# $string .= "by ".&IJoin(@x);
-#
-# $i++;
-# push(@array,$string);
-# }
+ # disabled for the time being... it's misleading/useless info.
+ if (0 && $factinfo{'modified_by'}) {
+ $string = "last modified";
+
+ my $time = $factinfo{'modified_time'};
+ if ($time) {
+ if (time() - $time > 60*60*24*7) {
+ $string .= " at \037". scalar(gmtime $time). "\037";
+ } else {
+ $string .= " ".&Time2String(time() - $time)." ago ";
+ }
+ }
+
+ $string .= " by ".(split ",", $factinfo{'modified_by'})[0];
+
+ push(@array,$string);
+ }
# requested:
if ($factinfo{'requested_by'}) {
$string .= "\002". $requested_count. "\002 ".
&fixPlural("time", $requested_count);
}
- }
- $string .= ", " if ($string ne "");
+ my $requested_by = $factinfo{'requested_by'};
+ $requested_by =~ /\!/;
+ $string .= ", last by $`";
- my $requested_by = $factinfo{'requested_by'};
- $requested_by =~ /\!/;
- $string .= "last by $`";
-
- my $requested_time = $factinfo{'requested_time'};
- if ($requested_time) {
- if (time() - $requested_time > 60*60*24*7) {
- $string .= " at \037". scalar(localtime $requested_time). "\037";
- } else {
- $string .= ", ".&Time2String(time() - $requested_time)." ago";
+ my $requested_time = $factinfo{'requested_time'};
+ if ($requested_time) {
+ if (time() - $requested_time > 60*60*24*7) {
+ $string .= " at \037". scalar(localtime $requested_time). "\037";
+ } else {
+ $string .= ", ".&Time2String(time() - $requested_time)." ago";
+ }
}
+ } else {
+ $string = "has not been requested yet";
}
- push(@array,$string);
+ push(@array, $string);
}
# locked:
for (@list) {
my $factoid = $_;
my $val = &getFactInfo($factoid, "factoid_value");
- if ($val =~ /^<REPLY> see( also)? (.*?)\.?$/i) {
+ if ($val =~ /^<REPLY> ?see( also)? (.*?)\.?$/i) {
my $redirf = lc $2;
my $redir = &getFactInfo($redirf, "factoid_value");
next if (defined $redir);
} elsif ($type =~ /^(2|too)long$/i) {
my @list;
+ my $query;
# factoid_key.
$query = "SELECT factoid_key FROM factoids WHERE length(factoid_key) >= $param{'maxKeySize'}";
while (my @row = $sth->fetchrow_array) {
push(@list,$row[0]);
}
+ $sth->finish;
# factoid_value.
- my $query = "SELECT factoid_key,factoid_value FROM factoids WHERE length(factoid_value) >= $param{'maxDataSize'}";
+ $query = "SELECT factoid_key,factoid_value FROM factoids WHERE length(factoid_value) >= $param{'maxDataSize'}";
$sth = $dbh->prepare($query);
$sth->execute;
while (my @row = $sth->fetchrow_array) {
push(@list,sprintf("\002%s\002 - %s", length($row[1]), $row[0]));
}
+ $sth->finish;
if (scalar @list == 0) {
return "good. no factoids exceed length.";