From 3cae15be7660e19a323de9068ba6baefa2f451bc Mon Sep 17 00:00:00 2001 From: josch Date: Wed, 10 Oct 2007 09:01:16 +0000 Subject: [PATCH] initial version git-svn-id: http://yolanda.mister-muffin.de/svn@6 7eef14d0-6ed0-489d-bf55-20463b2d70db --- trunk/functions.pl | 12 ++++++++++++ trunk/include.pl | 4 ++++ trunk/index.pl | 25 +++++++++++++++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 trunk/functions.pl create mode 100644 trunk/include.pl create mode 100644 trunk/index.pl diff --git a/trunk/functions.pl b/trunk/functions.pl new file mode 100644 index 0000000..e697f79 --- /dev/null +++ b/trunk/functions.pl @@ -0,0 +1,12 @@ +sub fill_tagcloud { + my $sth = $dbh->prepare(qq{select text, count from tagcloud }); + $sth->execute(); + while (my ($text, $count) = $sth->fetchrow_array()) + { + push @{ $page->{tagcloud}->{tag} }, { text => [$text], count => [$count] }; + } + $sth->finish(); + $dbh->disconnect(); +} + +1; diff --git a/trunk/include.pl b/trunk/include.pl new file mode 100644 index 0000000..69c6ccd --- /dev/null +++ b/trunk/include.pl @@ -0,0 +1,4 @@ +use CGI::Session; +use DBI; +use XML::Simple qw(:strict); +$dbh = DBI->connect('DBI:mysql:gnutube:localhost', 'root', ''); diff --git a/trunk/index.pl b/trunk/index.pl new file mode 100644 index 0000000..f0fb12e --- /dev/null +++ b/trunk/index.pl @@ -0,0 +1,25 @@ +#!/usr/bin/perl +require "/var/www/perl/include.pl"; +require "/var/www/perl/functions.pl"; + +#create or resume session +CGI::Session->name("SID"); +my $session = new CGI::Session; + +#store session param +$session->param('auth', 'true'); + +#read xml +$page = XMLin('/var/www/perl/index.xml', ForceArray => 1, KeyAttr => {} ); + +#fill tags +$page->{sid} = [$session->id]; +$page->{loggedin} = [$session->param('auth')]; + +fill_tagcloud; + +#print xml http header along with session cookie +print $session->header(-type=>'text/xml'); + +#print xml +print XMLout($page, KeyAttr => {}, XMLDecl => '', RootName => 'page');