diff --git a/trunk/account.pl b/trunk/account.pl index cee165f..8b53f1b 100644 --- a/trunk/account.pl +++ b/trunk/account.pl @@ -98,8 +98,4 @@ else $page->{'message'}->{'text'} = "error_202c"; } -#print xml http header along with session cookie -print $session->header(-type=>'text/xml', -charset=>'UTF-8'); - -#print xml -print XMLout($page, KeyAttr => {}, XMLDecl => $XMLDecl, RootName => 'page', AttrIndent => '1'); +print output_page(); diff --git a/trunk/download.pl b/trunk/download.pl index 287607b..69cf23a 100644 --- a/trunk/download.pl +++ b/trunk/download.pl @@ -68,11 +68,7 @@ if($query->param('id')) $page->{'message'}->{'type'} = "error"; $page->{'message'}->{'text'} = "error_202c"; - #print xml http header along with session cookie - print $session->header(-type=>'text/xml', -charset=>'UTF-8'); - - #print xml - print XMLout($page, KeyAttr => {}, XMLDecl => $XMLDecl, RootName => 'page'); + print output_page(); } } else @@ -84,9 +80,5 @@ else $page->{'message'}->{'type'} = "error"; $page->{'message'}->{'text'} = "error_202c"; - #print xml http header along with session cookie - print $session->header(-type=>'text/xml', -charset=>'UTF-8'); - - #print xml - print XMLout($page, KeyAttr => {}, XMLDecl => $XMLDecl, RootName => 'page'); + print output_page(); } diff --git a/trunk/functions.pl b/trunk/functions.pl index 65f5cb8..04ca69f 100644 --- a/trunk/functions.pl +++ b/trunk/functions.pl @@ -132,3 +132,50 @@ sub urlencode $url =~ s/([^A-Za-z0-9_\$\-.+!*'()])/sprintf("%%%02X", ord($1))/eg; return $url; } + +sub output_page +{ + if($query->http('USER_AGENT') =~ m{(Firefox/[2-3]|MSIE [6-7]|yolanda-upload)}) + { + #print xml + return $session->header( + -type=>'text/xml', + -charset=>'UTF-8' + ), + XMLout( + $page, + KeyAttr => {}, + XMLDecl => $XMLDecl, + RootName => 'page', + AttrIndent => '1' + ); + } + else + { + use XML::LibXSLT; + use XML::LibXML; + + my $parser = XML::LibXML->new(); + my $xslt = XML::LibXSLT->new(); + + my $stylesheet = $xslt->parse_stylesheet($parser->parse_file("$root/xsl/xhtml.xsl")); + + return $session->header( + -type=>'text/xml', + -charset=>'UTF-8' + ), + $stylesheet->output_string( + $stylesheet->transform( + $parser->parse_string( + XMLout( + $page, + KeyAttr => {}, + XMLDecl => $XMLDecl, + RootName => 'page', + AttrIndent => '1' + ) + ) + ) + ); + } +} diff --git a/trunk/index.pl b/trunk/index.pl index 0b9126c..e205d66 100644 --- a/trunk/index.pl +++ b/trunk/index.pl @@ -3,7 +3,7 @@ require "functions.pl"; #create or resume session CGI::Session->name($session_name); $query = new CGI; -my $session = new CGI::Session; +$session = new CGI::Session; @userinfo = get_userinfo_from_sid($session->id); @@ -41,11 +41,4 @@ while (my ($text, $count) = $sth->fetchrow_array()) #finish query $sth->finish() or die $dbh->errstr; -#close db -$dbh->disconnect() or die $dbh->errstr; - -#print xml http header along with session cookie -print $session->header(-type=>'text/xml', -charset=>'UTF-8'); - -#print xml -print XMLout($page, KeyAttr => {}, XMLDecl => $XMLDecl, RootName => 'page', AttrIndent => '1'); +print output_page(); diff --git a/trunk/login.pl b/trunk/login.pl index 2eb097d..f2b7208 100644 --- a/trunk/login.pl +++ b/trunk/login.pl @@ -26,10 +26,7 @@ if($query->param('action')) $page->{'message'}->{'type'} = "error"; $page->{'message'}->{'text'} = "error_already_logged_in"; - #print xml http header along with session cookie - print $session->header(-type=>'text/xml', -charset=>'UTF-8'); - - print XMLout($page, KeyAttr => {}, XMLDecl => $XMLDecl, RootName => 'page', AttrIndent => '1'); + print output_page(); } #if login is requested elsif($query->param('action') eq "login") @@ -54,10 +51,7 @@ if($query->param('action')) $page->{'message'}->{'type'} = "error"; $page->{'message'}->{'text'} = "error_username_password_do_not_match"; - #print xml http header along with session cookie - print $session->header(-type=>'text/xml', -charset=>'UTF-8'); - - print XMLout($page, KeyAttr => {}, XMLDecl => $XMLDecl, RootName => 'page', AttrIndent => '1'); + print output_page(); } } @@ -135,10 +129,7 @@ if($query->param('action')) #if not, print login form $page->{'loginform'}->{'action'} = 'openid'; - #print xml http header along with session cookie - print $session->header(-type=>'text/xml', -charset=>'UTF-8'); - - print XMLout($page, KeyAttr => {}, XMLDecl => $XMLDecl, RootName => 'page', AttrIndent => '1'); + print output_page(); } } else @@ -147,10 +138,7 @@ if($query->param('action')) $page->{'message'}->{'type'} = "error"; $page->{'message'}->{'text'} = "error_202c"; - #print xml http header along with session cookie - print $session->header(-type=>'text/xml', -charset=>'UTF-8'); - - print XMLout($page, KeyAttr => {}, XMLDecl => $XMLDecl, RootName => 'page', AttrIndent => '1'); + print output_page(); } } #check if user is logged in @@ -159,18 +147,12 @@ elsif($userinfo->{'username'}) $page->{'message'}->{'type'} = "error"; $page->{'message'}->{'text'} = "error_already_logged_in"; - #print xml http header along with session cookie - print $session->header(-type=>'text/xml', -charset=>'UTF-8'); - - print XMLout($page, KeyAttr => {}, XMLDecl => $XMLDecl, RootName => 'page', AttrIndent => '1'); + print output_page(); } else { #if not, print login form $page->{'loginform'} = ['']; - #print xml http header along with session cookie - print $session->header(-type=>'text/xml', -charset=>'UTF-8'); - - print XMLout($page, KeyAttr => {}, XMLDecl => $XMLDecl, RootName => 'page', AttrIndent => '1'); + print output_page(); } diff --git a/trunk/register.pl b/trunk/register.pl index 718f357..e95d3ea 100644 --- a/trunk/register.pl +++ b/trunk/register.pl @@ -15,10 +15,7 @@ if($username) $page->{'message'}->{'type'} = "error"; $page->{'message'}->{'text'} = "error_already_registered"; - #print xml http header along with session cookie - print $session->header(-type=>'text/xml', -charset=>'UTF-8'); - - print XMLout($page, KeyAttr => {}, XMLDecl => $XMLDecl, RootName => 'page', AttrIndent => '1'); + print output_page(); } #if username and password are passed put them into the database elsif($query->param('user') and $query->param('pass') and $query->param('pass_repeat')) @@ -37,10 +34,7 @@ elsif($query->param('user') and $query->param('pass') and $query->param('pass_re $page->{'message'}->{'type'} = "error"; $page->{'message'}->{'text'} = "error_passwords_do_not_match"; - #print xml http header along with session cookie - print $session->header(-type=>'text/xml', -charset=>'UTF-8'); - - print XMLout($page, KeyAttr => {}, XMLDecl => $XMLDecl, RootName => 'page', AttrIndent => '1'); + print output_page(); } } elsif(not $query->param('user') and ($query->param('pass') or $query->param('pass_repeat'))) @@ -49,10 +43,7 @@ elsif(not $query->param('user') and ($query->param('pass') or $query->param('pas $page->{'message'}->{'type'} = "error"; $page->{'message'}->{'text'} = "error_insert_username"; - #print xml http header along with session cookie - print $session->header(-type=>'text/xml', -charset=>'UTF-8'); - - print XMLout($page, KeyAttr => {}, XMLDecl => $XMLDecl, RootName => 'page', AttrIndent => '1'); + print output_page(); } elsif(not $query->param('pass') and ($query->param('user') or $query->param('pass_repeat'))) { @@ -60,10 +51,7 @@ elsif(not $query->param('pass') and ($query->param('user') or $query->param('pas $page->{'message'}->{'type'} = "error"; $page->{'message'}->{'text'} = "error_insert_password"; - #print xml http header along with session cookie - print $session->header(-type=>'text/xml', -charset=>'UTF-8'); - - print XMLout($page, KeyAttr => {}, XMLDecl => $XMLDecl, RootName => 'page', AttrIndent => '1'); + print output_page(); } elsif(not $query->param('pass_repeat') and ($query->param('user') or $query->param('pass'))) { @@ -71,17 +59,11 @@ elsif(not $query->param('pass_repeat') and ($query->param('user') or $query->par $page->{'message'}->{'type'} = "error"; $page->{'message'}->{'text'} = "error_repeat_password"; - #print xml http header along with session cookie - print $session->header(-type=>'text/xml', -charset=>'UTF-8'); - - print XMLout($page, KeyAttr => {}, XMLDecl => $XMLDecl, RootName => 'page', AttrIndent => '1'); + print output_page(); } else { $page->{'registerform'} = ['']; - #print xml http header along with session cookie - print $session->header(-type=>'text/xml', -charset=>'UTF-8'); - - print XMLout($page, KeyAttr => {}, XMLDecl => $XMLDecl, RootName => 'page', AttrIndent => '1'); + print output_page(); } diff --git a/trunk/search.pl b/trunk/search.pl index 844bbd1..fd93b21 100644 --- a/trunk/search.pl +++ b/trunk/search.pl @@ -103,8 +103,4 @@ else $page->{'message'}->{'text'} = "error_202c"; } -#print xml http header along with session cookie -print $session->header(-type=>'text/xml', -charset=>'UTF-8'); - -#print xml -print XMLout($page, KeyAttr => {}, XMLDecl => $XMLDecl, RootName => 'page', AttrIndent => '1'); +print output_page(); diff --git a/trunk/upload.pl b/trunk/upload.pl index 2d5c2ba..a636ab6 100644 --- a/trunk/upload.pl +++ b/trunk/upload.pl @@ -89,7 +89,4 @@ else $page->{'message'}->{'text'} = "error_202c"; } -#print xml http header along with session cookie -print $session->header(-type=>'text/xml', -charset=>'UTF-8'); - -print XMLout($page, KeyAttr => {}, XMLDecl => $XMLDecl, RootName => 'page', AttrIndent => '1'); +print output_page(); diff --git a/trunk/uploader.pl b/trunk/uploader.pl index 0e93def..e075de4 100644 --- a/trunk/uploader.pl +++ b/trunk/uploader.pl @@ -54,8 +54,5 @@ else $page->{'message'}->{'type'} = "error"; $page->{'message'}->{'text'} = "error_202c"; } -#print xml http header along with session cookie -print $session->header(-type=>'text/xml', -charset=>'UTF-8'); -#print xml -print XMLout($page, KeyAttr => {}, XMLDecl => $XMLDecl, RootName => 'page', AttrIndent => '1'); +print output_page(); diff --git a/trunk/video.pl b/trunk/video.pl index fd2eb88..8078579 100644 --- a/trunk/video.pl +++ b/trunk/video.pl @@ -226,8 +226,4 @@ else $page->{'message'}->{'text'} = "error_202c"; } -#print xml http header along with session cookie -print $session->header(-type=>'text/xml', -charset=>'UTF-8'); - -#print xml -print XMLout($page, KeyAttr => {}, XMLDecl => $XMLDecl, RootName => 'page', AttrIndent => '1'); +print output_page(); diff --git a/trunk/xsl/xhtml/frontpage.xsl b/trunk/xsl/xhtml/frontpage.xsl index d6020ad..781d0a4 100644 --- a/trunk/xsl/xhtml/frontpage.xsl +++ b/trunk/xsl/xhtml/frontpage.xsl @@ -64,4 +64,4 @@ - \ No newline at end of file +