2007-10-10 21:32:46 +00:00
|
|
|
require "/var/www/perl/include";
|
2007-10-10 09:44:51 +00:00
|
|
|
|
2007-10-10 18:51:01 +00:00
|
|
|
#get tags from database and fill $page with xml
|
2007-10-10 09:01:16 +00:00
|
|
|
sub fill_tagcloud {
|
2007-10-10 18:51:01 +00:00
|
|
|
#connect to db
|
2007-10-10 15:14:05 +00:00
|
|
|
$dbh = DBI->connect("DBI:mysql:$database:$dbhost", $dbuser, $dbpass);
|
2007-10-10 18:51:01 +00:00
|
|
|
|
|
|
|
#prepare query
|
2007-10-10 09:01:16 +00:00
|
|
|
my $sth = $dbh->prepare(qq{select text, count from tagcloud });
|
2007-10-10 18:51:01 +00:00
|
|
|
|
|
|
|
#execute it
|
2007-10-10 09:01:16 +00:00
|
|
|
$sth->execute();
|
2007-10-10 18:51:01 +00:00
|
|
|
|
|
|
|
#get every returned value
|
2007-10-10 09:01:16 +00:00
|
|
|
while (my ($text, $count) = $sth->fetchrow_array())
|
|
|
|
{
|
2007-10-10 18:51:01 +00:00
|
|
|
#push the new value to the $page->tagcloud array
|
|
|
|
push @{ $page->{tagcloud}->{tag} }, { text => [$text], count => [$count] };
|
2007-10-10 09:01:16 +00:00
|
|
|
}
|
2007-10-10 18:51:01 +00:00
|
|
|
|
|
|
|
#finish query
|
2007-10-10 09:01:16 +00:00
|
|
|
$sth->finish();
|
2007-10-10 18:51:01 +00:00
|
|
|
|
|
|
|
#close db
|
2007-10-10 09:01:16 +00:00
|
|
|
$dbh->disconnect();
|
|
|
|
}
|
2007-10-10 16:05:54 +00:00
|
|
|
|
2007-10-10 18:51:01 +00:00
|
|
|
#return a username from passed session id
|
2007-10-10 16:05:54 +00:00
|
|
|
sub get_username_from_sid {
|
2007-10-10 18:51:01 +00:00
|
|
|
#get parameters
|
2007-10-10 16:05:54 +00:00
|
|
|
my ($sid) = @_;
|
2007-10-10 18:51:01 +00:00
|
|
|
|
|
|
|
#connect to db
|
2007-10-10 16:05:54 +00:00
|
|
|
$dbh = DBI->connect("DBI:mysql:$database:$dbhost", $dbuser, $dbpass);
|
2007-10-10 18:51:01 +00:00
|
|
|
|
|
|
|
#prepare query
|
2007-10-10 16:05:54 +00:00
|
|
|
my $sth = $dbh->prepare(qq{select username from users where sid = '$sid'});
|
2007-10-10 18:51:01 +00:00
|
|
|
|
|
|
|
#execute it
|
2007-10-10 16:05:54 +00:00
|
|
|
$sth->execute();
|
2007-10-10 18:51:01 +00:00
|
|
|
|
|
|
|
#save the resulting username
|
2007-10-10 16:05:54 +00:00
|
|
|
my ($username) = $sth->fetchrow_array();
|
2007-10-10 18:51:01 +00:00
|
|
|
|
|
|
|
#finish query
|
2007-10-10 16:05:54 +00:00
|
|
|
$sth->finish();
|
2007-10-10 18:51:01 +00:00
|
|
|
|
|
|
|
#close db
|
2007-10-10 16:05:54 +00:00
|
|
|
$dbh->disconnect();
|
2007-10-10 18:51:01 +00:00
|
|
|
|
|
|
|
#return username
|
2007-10-10 16:05:54 +00:00
|
|
|
return $username;
|
|
|
|
}
|