2007-10-11 16:25:56 +00:00
|
|
|
#!/usr/bin/perl
|
2007-10-11 17:06:08 +00:00
|
|
|
require "include.pl";
|
2007-10-10 21:48:12 +00:00
|
|
|
|
|
|
|
#get tags from database and fill $page with xml
|
2007-10-11 17:26:39 +00:00
|
|
|
sub fill_tagcloud
|
|
|
|
{
|
2007-10-10 21:48:12 +00:00
|
|
|
#connect to db
|
2007-10-11 10:00:38 +00:00
|
|
|
my $dbh = DBI->connect("DBI:mysql:$database:$dbhost", $dbuser, $dbpass) or die $dbh->errstr;
|
2007-10-10 21:48:12 +00:00
|
|
|
|
|
|
|
#prepare query
|
2007-10-11 10:00:38 +00:00
|
|
|
my $sth = $dbh->prepare(qq{select text, count from tagcloud }) or die $dbh->errstr;
|
2007-10-10 21:48:12 +00:00
|
|
|
|
|
|
|
#execute it
|
2007-10-11 10:00:38 +00:00
|
|
|
$sth->execute() or die $dbh->errstr;
|
2007-10-10 21:48:12 +00:00
|
|
|
|
|
|
|
#get every returned value
|
|
|
|
while (my ($text, $count) = $sth->fetchrow_array())
|
|
|
|
{
|
|
|
|
#push the new value to the $page->tagcloud array
|
|
|
|
push @{ $page->{tagcloud}->{tag} }, { text => [$text], count => [$count] };
|
|
|
|
}
|
|
|
|
|
|
|
|
#finish query
|
2007-10-11 10:00:38 +00:00
|
|
|
$sth->finish() or die $dbh->errstr;
|
2007-10-10 21:48:12 +00:00
|
|
|
|
|
|
|
#close db
|
2007-10-11 10:00:38 +00:00
|
|
|
$dbh->disconnect() or die $dbh->errstr;
|
2007-10-10 21:48:12 +00:00
|
|
|
}
|
|
|
|
|
2007-10-29 15:00:40 +00:00
|
|
|
sub get_userinfo_from_sid
|
2007-10-11 17:26:39 +00:00
|
|
|
{
|
2007-10-10 21:48:12 +00:00
|
|
|
#get parameters
|
|
|
|
my ($sid) = @_;
|
|
|
|
|
|
|
|
#connect to db
|
2007-10-11 10:00:38 +00:00
|
|
|
my $dbh = DBI->connect("DBI:mysql:$database:$dbhost", $dbuser, $dbpass) or die $dbh->errstr;
|
2007-10-10 21:48:12 +00:00
|
|
|
|
|
|
|
#prepare query
|
2007-10-29 15:00:40 +00:00
|
|
|
my $sth = $dbh->prepare(qq{select id, username, locale, pagesize, cortado from users where sid = ?}) or die $dbh->errstr;
|
2007-10-10 21:48:12 +00:00
|
|
|
|
|
|
|
#execute it
|
2007-10-12 00:34:32 +00:00
|
|
|
$sth->execute($sid) or die $dbh->errstr;
|
2007-10-10 21:48:12 +00:00
|
|
|
|
|
|
|
#save the resulting username
|
2007-10-29 15:00:40 +00:00
|
|
|
($userinfo->{'id'}, $userinfo->{'username'}, $userinfo->{'locale'}, $userinfo->{'pagesize'}, $userinfo->{'cortado'}) = $sth->fetchrow_array();
|
2007-10-10 21:48:12 +00:00
|
|
|
|
|
|
|
#finish query
|
2007-10-11 10:00:38 +00:00
|
|
|
$sth->finish() or die $dbh->errstr;
|
2007-10-10 21:48:12 +00:00
|
|
|
|
|
|
|
#close db
|
2007-10-11 10:00:38 +00:00
|
|
|
$dbh->disconnect() or die $dbh->errstr;
|
2007-10-10 21:48:12 +00:00
|
|
|
|
2007-10-11 10:00:38 +00:00
|
|
|
#return
|
2007-10-29 15:00:40 +00:00
|
|
|
return @userinfo;
|
2007-10-10 21:48:12 +00:00
|
|
|
}
|
2007-10-11 10:57:52 +00:00
|
|
|
|
2007-10-29 15:00:40 +00:00
|
|
|
sub get_page_array
|
2007-10-11 17:26:39 +00:00
|
|
|
{
|
2007-10-11 10:57:52 +00:00
|
|
|
#get parameters
|
2007-10-29 15:00:40 +00:00
|
|
|
my (@userinfo) = @_;
|
2007-10-11 10:57:52 +00:00
|
|
|
|
2007-10-29 15:00:40 +00:00
|
|
|
$page->{'username'} = $userinfo->{'username'};
|
|
|
|
#if user is logged in, use his locale setting
|
|
|
|
if($userinfo->{'locale'})
|
|
|
|
{
|
|
|
|
$page->{'locale'} = $userinfo->{'locale'};
|
|
|
|
}
|
|
|
|
#else get the locale from the http server variable
|
|
|
|
else
|
|
|
|
{
|
|
|
|
($page->{'locale'}) = $query->http('HTTP_ACCEPT_LANGUAGE') =~ /^([^,]+),.*$/;
|
|
|
|
}
|
|
|
|
$page->{stylesheet} = $stylesheet;
|
|
|
|
$page->{'xmlns:dc'} = $xmlns_dc;
|
|
|
|
$page->{'xmlns:cc'} = $xmlns_cc;
|
|
|
|
$page->{'xmlns:rdf'} = $xmlns_rdf;
|
2007-10-11 10:57:52 +00:00
|
|
|
}
|